Hallo Leute,
ich versuche mit einem NodeMCU-32s einen customize GattServer zum laufen zu bekommen.
Ich konnte einen Service mit 3 Characteristics erstellen und Daten über eine BleClient- Scanner- App ein und herauslesen. Jedoch möchte ich zu jedem Characteristic einen Descriptor hinzufügen.Habe es erstmal mit einem Descriptor zu der Characterisitc "pCharacteristicRX" versucht, jedoch bekomme ich das nicht hin.
Error Message: The error message is "base operand of '->' has non-pointer type 'BLEDescriptor'.
Was muss ich anstelle von nem pointer setzen?
Code:
#include <BLEDevice.h>
#include <BLEUtils.h>
#include <BLEServer.h>
#include <BLE2902.h>
#define SERVICE_UUID "58A329BE-1B1F-4A53-A874-854081499990"
#define CHARACTERISTIC_UUID_TX "C0448006-6CEE-4B41-9E73-D3FB3FF9FD81"
#define CHARACTERISTIC_UUID_RX "c0de0003-feed-f00d-c0ff-eeb3d2dbcce5"
#define CHARACTERISTIC_UUID_PacketCountTX "9308cd72-ac82-11e9-a2a3-2a2ae2dbcce4"
#define DESCRIPTOR_UUID_RX "ec57c662-ac5f-11e9-a2a3-2a2ae2dbcce4"
BLECharacteristic *pCharacteristicRX;
BLECharacteristic *pCharacteristicTX;
BLECharacteristic *pCharacteristicPacketCountTX;
BLEDescriptor pDescriptorRX(DESCRIPTOR_UUID_RX);
bool deviceConnected = false;
class EchoServerCallbacks: public BLEServerCallbacks
{
void onConnect(BLEServer* pServer)
{
deviceConnected = true;
//stop advt?
Serial.println("Connected!");
};
void onDisconnect(BLEServer* pServer)
{
//restart advt?
deviceConnected = false;
Serial.println("Disconnected!");
}
};
void setup()
{
Serial.begin(115200);
Serial.println();
Serial.println("GATT Server Test");
BLEDevice::init("GATT Server Test");
BLEServer *pServer = BLEDevice::createServer();
pServer->setCallbacks(new EchoServerCallbacks());
BLEService *pService = pServer->createService(SERVICE_UUID);
pCharacteristicRX = pService->createCharacteristic(
CHARACTERISTIC_UUID_RX,
BLECharacteristic::PROPERTY_WRITE
);
/******************************** Hier ist was falsch ************************/
pDescriptorRX->setValue("Percentage 0 - 100");
pCharacteristicRX->addDescriptor(pDescriptorRX);
pCharacteristicRX->addDescriptor(new BLE2902());
/******************************************************************************/
pCharacteristicTX = pService->createCharacteristic(
CHARACTERISTIC_UUID_TX,
BLECharacteristic::PROPERTY_READ | BLECharacteristic::PROPERTY_WRITE
);
pCharacteristicPacketCountTX = pService->createCharacteristic(
CHARACTERISTIC_UUID_PacketCountTX,
BLECharacteristic::PROPERTY_WRITE | BLECharacteristic::PROPERTY_READ
);
pService->start();
BLEAdvertising *pAdvertising = pServer->getAdvertising();
pAdvertising->start();
Serial.println("Characteristic defined! Now you can read it in your phone!");
}
void loop()
{
//do stuff
// some delay before running repeatedly
delay(1000);
}
Danke schonmal im Voraus.
Grüßchen
Lesezeichen