最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

c - ESP32-C3 Super Mini BLE: only the first defined characteristic of the service is visible - Stack Overflow

programmeradmin5浏览0评论

I'm using platform IO for my project. When I define my characteristics, only the first one defined and added to the service will be displayed by nRF. I did the tests by swapping the two features and they both work, but only the first addition to the service is seen.

void setup() 
{
    Serial.begin(115200);
    pinMode(BUTTON_PIN, INPUT);
    Serial.println("START");

    // Initialize BLE device
    BLEDevice::init("ESP32_BLE");

    // Create BLE server
    BLEServer *pServer = BLEDevice::createServer();
    pServer->setCallbacks(new MyServerCallbacks());

    // Create BLE service
    BLEService *pService = pServer->createService(SERVICE_UUID);

    // Create characteristic for receiving data (Write)
    pReceiveCharacteristic = pService->createCharacteristic(RECEIVE_UUID, BLECharacteristic::PROPERTY_WRITE);
    pReceiveCharacteristic->setCallbacks(new MyCallbacks());

    // Create characteristic for button (Notify)
    pButtonCharacteristic = pService->createCharacteristic(BUTTON_UUID,BLECharacteristic::PROPERTY_NOTIFY);

    // Start BLE service
    pService->start();
    BLEAdvertising *pAdvertising = BLEDevice::getAdvertising();
    pAdvertising->addServiceUUID(SERVICE_UUID);
    pAdvertising->start();

    Serial.println("BLE ready, waiting for connections...");
}
发布评论

评论列表(0)

  1. 暂无评论