Created
November 29, 2019 09:37
-
-
Save mgulsoy/d1ae8f7dbce68ddd9aa3df8e8af07cdd to your computer and use it in GitHub Desktop.
Gatt Server Setup Fonksiyonu
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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