time date reciver added
This commit is contained in:
1 parent
c4a8a37d63
commit
8b6875d819
1 file changed
+30
-10
@@ -9,7 +9,7 @@
|
|||||||
#define TFT_DC D7
|
#define TFT_DC D7
|
||||||
#define TFT_RST D9
|
#define TFT_RST D9
|
||||||
|
|
||||||
unsigned long SEC=40;
|
unsigned long SEC=0;
|
||||||
unsigned long MIN=0;
|
unsigned long MIN=0;
|
||||||
unsigned long HOUR=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);
|
Arduino_GFX *gfx = new Arduino_ST7789(bus, TFT_RST, 0, true, 240, 240, 0, 0);
|
||||||
|
|
||||||
#define SERVICE_UUID "791cadd7-de87-49f9-8986-94b7ae11940b"
|
#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_TIME_UUID "3e4eac5b-eaa2-4e0c-a705-dcac4f606e02"
|
||||||
|
#define CHAR_DATE_UUID "3e4eac5b-eaa2-4e0c-a705-dcac4f606e03"
|
||||||
|
|
||||||
#define deviceName "ESP32-Watch"
|
#define deviceName "ESP32-Watch"
|
||||||
|
|
||||||
@@ -37,7 +39,15 @@ class CharacteristicCallbacks: public BLECharacteristicCallbacks {
|
|||||||
|
|
||||||
//Time characteristic check
|
//Time characteristic check
|
||||||
if (pCharacteristic->getUUID().equals(BLEUUID(CHAR_TIME_UUID))) {
|
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);
|
Serial.println(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -102,23 +112,33 @@ void initDevice(){
|
|||||||
BLEService *pService = pServer->createService(SERVICE_UUID);
|
BLEService *pService = pServer->createService(SERVICE_UUID);
|
||||||
|
|
||||||
BLESecurity *pSecurity = new BLESecurity();
|
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->setCapability(ESP_IO_CAP_NONE);
|
||||||
pSecurity->setInitEncryptionKey(ESP_BLE_ENC_KEY_MASK | ESP_BLE_ID_KEY_MASK);
|
pSecurity->setInitEncryptionKey(ESP_BLE_ENC_KEY_MASK | ESP_BLE_ID_KEY_MASK);
|
||||||
|
|
||||||
//Test characteristic
|
//Message
|
||||||
BLECharacteristic *pCharacteristic = pService->createCharacteristic(
|
BLECharacteristic *pCharacteristicMessage = pService->createCharacteristic(
|
||||||
CHAR_TEST_UUID,
|
CHAR_MESSAGE_UUID,
|
||||||
BLECharacteristic::PROPERTY_READ);
|
BLECharacteristic::PROPERTY_READ |
|
||||||
pCharacteristic->setValue("Hello World");
|
BLECharacteristic::PROPERTY_WRITE);
|
||||||
|
pCharacteristicMessage->setCallbacks(new CharacteristicCallbacks());
|
||||||
|
pCharacteristicMessage->setValue("Hello World");
|
||||||
|
|
||||||
//Time
|
//Time
|
||||||
BLECharacteristic *pCharacteristicTime = pService->createCharacteristic(CHAR_TIME_UUID,
|
BLECharacteristic *pCharacteristicTime = pService->createCharacteristic(
|
||||||
|
CHAR_TIME_UUID,
|
||||||
BLECharacteristic::PROPERTY_READ |
|
BLECharacteristic::PROPERTY_READ |
|
||||||
BLECharacteristic::PROPERTY_WRITE);
|
BLECharacteristic::PROPERTY_WRITE);
|
||||||
pCharacteristicTime->setCallbacks(new CharacteristicCallbacks());
|
pCharacteristicTime->setCallbacks(new CharacteristicCallbacks());
|
||||||
pCharacteristicTime->setValue("TIME");
|
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();
|
pService->start();
|
||||||
// BLEAdvertising *pAdvertising = pServer->getAdvertising(); // this still is working for backward compatibility
|
// BLEAdvertising *pAdvertising = pServer->getAdvertising(); // this still is working for backward compatibility
|
||||||
BLEAdvertising *pAdvertising = BLEDevice::getAdvertising();
|
BLEAdvertising *pAdvertising = BLEDevice::getAdvertising();
|
||||||
|
|||||||
Reference in new issue
Block a user