Skip to content

Instantly share code, notes, and snippets.

@mgulsoy
Created November 29, 2019 09:37
Show Gist options
  • Save mgulsoy/d1ae8f7dbce68ddd9aa3df8e8af07cdd to your computer and use it in GitHub Desktop.
Save mgulsoy/d1ae8f7dbce68ddd9aa3df8e8af07cdd to your computer and use it in GitHub Desktop.
Gatt Server Setup Fonksiyonu
void setup() {
...
...
BLEDevice::init("BizimBLE"); //cihazın görünen adı
pServer = BLEDevice::createServer();
pServer->setCallbacks(new BaglantiCallback());
//Hizmet oluştur
pBatteryService = pServer->createService(BatteryServiceUUID);
pDengeService = pServer->createService(SensorServiceUUID);
//karakteristik özellikleri oluştur
pBatteryLevelCharx = pBatteryService->createCharacteristic(
BatteryLevelCharacteristicUUID,
BLECharacteristic::PROPERTY_READ);
pSensorValueCharx = pSensorService->createCharacteristic(
SensorCharacteristicUUID,
BLECharacteristic::PROPERTY_READ | BLECharacteristic::PROPERTY_NOTIFY);
//Tanımlayıcıyı ayarla
BatteryLevelDescriptor.setValue("Percentage 0 - 100");
//ve ekle
pBatteryLevelCharx->addDescriptor(&BatteryLevelDescriptor); // 2901
pSensorValueCharx->addDescriptor(&ble2902); //Notifications descriptor -- new BLE2902()
//Hizmetleri başlat
pBatteryService->start();
pSensorService->start();
//Sunucunun duyuru yapmasını sağla
pServer->getAdvertising()->start();
...
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment