diff --git a/hexgen.py b/hexgen.py new file mode 100644 index 0000000..50e10a3 --- /dev/null +++ b/hexgen.py @@ -0,0 +1,9 @@ +import random +import json + +unique_numbers = random.sample(range(0x0001, 0xFFFF), 100) + +hexnum = [hex(n) for n in unique_numbers] + +with open("./hexnum.json", "w") as f: + json.dump(hexnum, f, indent=4) diff --git a/hexnum.json b/hexnum.json new file mode 100644 index 0000000..e2489fd --- /dev/null +++ b/hexnum.json @@ -0,0 +1,101 @@ +[ + "-0x4d43", + "-0xb331", + "-0x3c4b", + "-0x6ecf", + "-0xa7fa", + "-0x375f", + "-0x6e40", + "-0x2eef", + "0x30d0", + "0xbb7e", + "0xc937", + "0xd799", + "0x13bc", + "0x3d0b", + "0x5124", + "0x1495", + "0xc571", + "0x46a4", + "0x11e6", + "0xc24", + "0xf639", + "0xabde", + "0xc460", + "0xd15d", + "0x3f13", + "0xb224", + "0x5202", + "0x4fe0", + "0x2c29", + "0x8e09", + "0x931d", + "0x988b", + "0x80c6", + "0xc64b", + "0x2a49", + "0xaa5b", + "0x27bd", + "0x815b", + "0xe9b5", + "0x97ef", + "0xa3c", + "0x8a3c", + "0x5ee6", + "0x4943", + "0x26a6", + "0x7a4d", + "0xd85c", + "0x516e", + "0xb47", + "0xfc42", + "0xf6d0", + "0x6704", + "0xcdb0", + "0xb393", + "0x6948", + "0x6099", + "0x719e", + "0xe77c", + "0xa292", + "0xc275", + "0x4218", + "0xd8d0", + "0x894e", + "0xedb5", + "0x643a", + "0xa658", + "0x60e1", + "0x8cc4", + "0xd0db", + "0x32d1", + "0x2118", + "0x1efd", + "0x9187", + "0xf140", + "0x11a9", + "0x835f", + "0xb94a", + "0xff02", + "0x31af", + "0x37df", + "0xa3e2", + "0x6c31", + "0x9854", + "0xbf59", + "0x3ea0", + "0x1a45", + "0xf52", + "0xbbb5", + "0x381c", + "0x5484", + "0x6fcf", + "0xd7a0", + "0xaaee", + "0xeab", + "0xa367", + "0x70e1", + "0x8996", + "0x774f", + "0x659f" +] diff --git a/inos/Smart-Watch/Smart-Watch.ino b/inos/Smart-Watch/Smart-Watch.ino index bbfb509..5ca0fc4 100644 --- a/inos/Smart-Watch/Smart-Watch.ino +++ b/inos/Smart-Watch/Smart-Watch.ino @@ -17,7 +17,7 @@ unsigned long HOUR=0; unsigned long DAY=0; unsigned long MONTH=0; -unsigned long YEAR=20; +unsigned long YEAR=2026; String message = ""; @@ -30,22 +30,22 @@ bool timeChanged = false; 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" +const uint16_t SERVICE_TD_UUID = 0x4d43; -#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" +const uint16_t CHAR_MESSAGE_UUID = 0xb331; +const uint16_t CHAR_TIME_UUID = 0x3c4b; +const uint16_t CHAR_DATE_UUID = 0x6ecf; -#define SERVICE_NOTIFICATION_UUID "791cadd7-de87-49f9-8986-94b7ae11941b" +const uint16_t SERVICE_NOTIFICATION_UUID = 0xa7fa; -#define CHAR_NOTIF_APP_UUID "9ff3d4a9-2082-424d-bf34-8dfaf752ff90" -#define CHAR_NOTIF_TITLE_UUID "9ff3d4a9-2082-424d-bf34-8dfaf752ff91" -#define CHAR_NOTIF_TEXT_UUID "9ff3d4a9-2082-424d-bf34-8dfaf752ff92" +const uint16_t CHAR_NOTIF_APP_UUID = 0x375f; +const uint16_t CHAR_NOTIF_TITLE_UUID = 0x6e40; +const uint16_t CHAR_NOTIF_TEXT_UUID = 0x2eef; #define deviceName "ESP32-Watch" -class CharacteristicCallbacksService: public BLECharacteristicCallbacks { +class CharacteristicCallbacksServiceTD: public BLECharacteristicCallbacks { void onWrite(BLECharacteristic *pCharacteristic) override { String value = pCharacteristic->getValue(); @@ -84,7 +84,6 @@ class CharacteristicCallbacksNotification: public BLECharacteristicCallbacks { if (pCharacteristic->getUUID().equals(BLEUUID(CHAR_NOTIF_APP_UUID))) { Serial.print("Notification App: "); Serial.println(value); - message = value; } if (pCharacteristic->getUUID().equals(BLEUUID(CHAR_NOTIF_TITLE_UUID))) { @@ -160,7 +159,8 @@ void initDevice(){ BLEServer *pServer = BLEDevice::createServer(); pServer->setCallbacks(new MyServerCallbacks()); - BLEService *pService = pServer->createService(SERVICE_UUID); + BLEService *pServiceNotif = pServer->createService(SERVICE_NOTIFICATION_UUID); + BLEService *pServiceTD = pServer->createService(SERVICE_TD_UUID); BLESecurity *pSecurity = new BLESecurity(); pSecurity->setAuthenticationMode(ESP_LE_AUTH_BOND); @@ -168,55 +168,56 @@ void initDevice(){ pSecurity->setInitEncryptionKey(ESP_BLE_ENC_KEY_MASK | ESP_BLE_ID_KEY_MASK); //---------------ServiceNotificationChar--------------------------------- - BLECharacteristic *pCharacteristicApp = pService->createCharacteristic( + BLECharacteristic *pCharacteristicApp = pServiceNotif->createCharacteristic( CHAR_NOTIF_APP_UUID, BLECharacteristic::PROPERTY_READ | BLECharacteristic::PROPERTY_WRITE); - pCharacteristicApp->setCallbacks(new CharacteristicCallbacksService()); - pCharacteristicApp->setValue("Hello World"); + pCharacteristicApp->setCallbacks(new CharacteristicCallbacksNotification()); + pCharacteristicApp->setValue("App"); - BLECharacteristic *pCharacteristicTitle = pService->createCharacteristic( + BLECharacteristic *pCharacteristicTitle = pServiceNotif->createCharacteristic( CHAR_NOTIF_TITLE_UUID, BLECharacteristic::PROPERTY_READ | BLECharacteristic::PROPERTY_WRITE); - pCharacteristicTitle->setCallbacks(new CharacteristicCallbacksService()); - pCharacteristicTitle->setValue("Hello World"); + pCharacteristicTitle->setCallbacks(new CharacteristicCallbacksNotification()); + pCharacteristicTitle->setValue("Title"); - BLECharacteristic *pCharacteristicText = pService->createCharacteristic( + BLECharacteristic *pCharacteristicText = pServiceNotif->createCharacteristic( CHAR_NOTIF_TEXT_UUID, BLECharacteristic::PROPERTY_READ | BLECharacteristic::PROPERTY_WRITE); - pCharacteristicText->setCallbacks(new CharacteristicCallbacksService()); - pCharacteristicText->setValue("Hello World"); + pCharacteristicText->setCallbacks(new CharacteristicCallbacksNotification()); + pCharacteristicText->setValue("Text"); //---------------ServiceChar-------------------------- - BLECharacteristic *pCharacteristicMessage = pService->createCharacteristic( + BLECharacteristic *pCharacteristicMessage = pServiceTD->createCharacteristic( CHAR_MESSAGE_UUID, BLECharacteristic::PROPERTY_READ | BLECharacteristic::PROPERTY_WRITE); - pCharacteristicMessage->setCallbacks(new CharacteristicCallbacksService()); + pCharacteristicMessage->setCallbacks(new CharacteristicCallbacksServiceTD()); pCharacteristicMessage->setValue("Hello World"); //Time - BLECharacteristic *pCharacteristicTime = pService->createCharacteristic( + BLECharacteristic *pCharacteristicTime = pServiceTD->createCharacteristic( CHAR_TIME_UUID, BLECharacteristic::PROPERTY_READ | BLECharacteristic::PROPERTY_WRITE); - pCharacteristicTime->setCallbacks(new CharacteristicCallbacksService()); + pCharacteristicTime->setCallbacks(new CharacteristicCallbacksServiceTD()); pCharacteristicTime->setValue("TIME"); - BLECharacteristic *pCharacteristicDate = pService->createCharacteristic( + BLECharacteristic *pCharacteristicDate = pServiceTD->createCharacteristic( CHAR_DATE_UUID, BLECharacteristic::PROPERTY_READ | BLECharacteristic::PROPERTY_WRITE); - pCharacteristicDate->setCallbacks(new CharacteristicCallbacksService()); + pCharacteristicDate->setCallbacks(new CharacteristicCallbacksServiceTD()); pCharacteristicDate->setValue("Date"); - pService->start(); + pServiceTD->start(); + Serial.println(ESP.getFreeHeap()); + pServiceNotif->start(); Serial.println(ESP.getFreeHeap()); BLEAdvertising *pAdvertising = BLEDevice::getAdvertising(); - pAdvertising->addServiceUUID(SERVICE_UUID); pAdvertising->setScanResponse(true); pAdvertising->setMinPreferred(0x12); BLEDevice::startAdvertising();