diff --git a/inos/Smart-Watch/Smart-Watch.ino b/inos/Smart-Watch/Smart-Watch.ino index 70e5399..83b723b 100644 --- a/inos/Smart-Watch/Smart-Watch.ino +++ b/inos/Smart-Watch/Smart-Watch.ino @@ -9,7 +9,7 @@ #define TFT_DC D7 #define TFT_RST D9 -unsigned long SEC=40; +unsigned long SEC=0; unsigned long MIN=0; unsigned long HOUR=0; @@ -24,8 +24,10 @@ Arduino_DataBus *bus = new Arduino_HWSPI(TFT_DC, -1); Arduino_GFX *gfx = new Arduino_ST7789(bus, TFT_RST, 0, true, 240, 240, 0, 0); #define SERVICE_UUID "791cadd7-de87-49f9-8986-94b7ae11940b" -#define CHAR_TEST_UUID "3e4eac5b-eaa2-4e0c-a705-dcac4f606e01" + +#define CHAR_MESSAGE_UUID "3e4eac5b-eaa2-4e0c-a705-dcac4f606e01" #define CHAR_TIME_UUID "3e4eac5b-eaa2-4e0c-a705-dcac4f606e02" +#define CHAR_DATE_UUID "3e4eac5b-eaa2-4e0c-a705-dcac4f606e03" #define deviceName "ESP32-Watch" @@ -37,7 +39,15 @@ class CharacteristicCallbacks: public BLECharacteristicCallbacks { //Time characteristic check if (pCharacteristic->getUUID().equals(BLEUUID(CHAR_TIME_UUID))) { - Serial.print("Uhrzeit empfangen: "); + Serial.print("Time Recived: "); + Serial.println(value); + } + if (pCharacteristic->getUUID().equals(BLEUUID(CHAR_DATE_UUID))) { + Serial.print("Date Recived: "); + Serial.println(value); + } + if (pCharacteristic->getUUID().equals(BLEUUID(CHAR_MESSAGE_UUID))) { + Serial.print("Message Recived: "); Serial.println(value); } } @@ -102,23 +112,33 @@ void initDevice(){ BLEService *pService = pServer->createService(SERVICE_UUID); BLESecurity *pSecurity = new BLESecurity(); - pSecurity->setAuthenticationMode(ESP_LE_AUTH_BOND); // Bonding erlauben + pSecurity->setAuthenticationMode(ESP_LE_AUTH_BOND); pSecurity->setCapability(ESP_IO_CAP_NONE); pSecurity->setInitEncryptionKey(ESP_BLE_ENC_KEY_MASK | ESP_BLE_ID_KEY_MASK); - //Test characteristic - BLECharacteristic *pCharacteristic = pService->createCharacteristic( - CHAR_TEST_UUID, - BLECharacteristic::PROPERTY_READ); - pCharacteristic->setValue("Hello World"); + //Message + BLECharacteristic *pCharacteristicMessage = pService->createCharacteristic( + CHAR_MESSAGE_UUID, + BLECharacteristic::PROPERTY_READ | + BLECharacteristic::PROPERTY_WRITE); + pCharacteristicMessage->setCallbacks(new CharacteristicCallbacks()); + pCharacteristicMessage->setValue("Hello World"); //Time - BLECharacteristic *pCharacteristicTime = pService->createCharacteristic(CHAR_TIME_UUID, + BLECharacteristic *pCharacteristicTime = pService->createCharacteristic( + CHAR_TIME_UUID, BLECharacteristic::PROPERTY_READ | BLECharacteristic::PROPERTY_WRITE); pCharacteristicTime->setCallbacks(new CharacteristicCallbacks()); pCharacteristicTime->setValue("TIME"); + BLECharacteristic *pCharacteristicDate = pService->createCharacteristic( + CHAR_DATE_UUID, + BLECharacteristic::PROPERTY_READ | + BLECharacteristic::PROPERTY_WRITE); + pCharacteristicDate->setCallbacks(new CharacteristicCallbacks()); + pCharacteristicDate->setValue("Date"); + pService->start(); // BLEAdvertising *pAdvertising = pServer->getAdvertising(); // this still is working for backward compatibility BLEAdvertising *pAdvertising = BLEDevice::getAdvertising();