Adjusting BLE communication
This commit is contained in:
parent
703a3e0c38
commit
359eb64f30
8
src/lightingFirmware/esp32_test0/.theia/launch.json
Normal file
8
src/lightingFirmware/esp32_test0/.theia/launch.json
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
// Use IntelliSense to learn about possible attributes.
|
||||||
|
// Hover to view descriptions of existing attributes.
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
|
||||||
|
]
|
||||||
|
}
|
||||||
@ -27,7 +27,7 @@ BLECharacteristic* pCharacteristic = NULL;
|
|||||||
bool deviceConnected = false;
|
bool deviceConnected = false;
|
||||||
bool oldDeviceConnected = false;
|
bool oldDeviceConnected = false;
|
||||||
uint32_t value = 0;
|
uint32_t value = 0;
|
||||||
String btmessage;
|
uint32_t btmessage;
|
||||||
|
|
||||||
// See the following for generating UUIDs:
|
// See the following for generating UUIDs:
|
||||||
// https://www.uuidgenerator.net/
|
// https://www.uuidgenerator.net/
|
||||||
@ -288,7 +288,7 @@ void setup() {
|
|||||||
pAdvertising->setScanResponse(false);
|
pAdvertising->setScanResponse(false);
|
||||||
pAdvertising->setMinPreferred(0x0); // set value to 0x00 to not advertise this parameter
|
pAdvertising->setMinPreferred(0x0); // set value to 0x00 to not advertise this parameter
|
||||||
BLEDevice::startAdvertising();
|
BLEDevice::startAdvertising();
|
||||||
Serial.println("Waiting a client connection to notify...");
|
Serial.println("\nWaiting a client connection to notify...");
|
||||||
|
|
||||||
pinMode(INTERRUPT_PIN, INPUT_PULLUP);
|
pinMode(INTERRUPT_PIN, INPUT_PULLUP);
|
||||||
attachInterrupt(digitalPinToInterrupt(INTERRUPT_PIN), isr, RISING);
|
attachInterrupt(digitalPinToInterrupt(INTERRUPT_PIN), isr, RISING);
|
||||||
@ -305,7 +305,8 @@ void loop() {
|
|||||||
|
|
||||||
// notify changed value
|
// notify changed value
|
||||||
if (deviceConnected) {
|
if (deviceConnected) {
|
||||||
btmessage = pCharacteristic->getValue().c_str();
|
btmessage = pCharacteristic->getData();
|
||||||
|
// Serial.print(btmessage);
|
||||||
mode = btmessage.toInt();
|
mode = btmessage.toInt();
|
||||||
}
|
}
|
||||||
// disconnecting
|
// disconnecting
|
||||||
@ -331,6 +332,7 @@ void loop() {
|
|||||||
button1.pressed = false; // Reset button status to FALSE
|
button1.pressed = false; // Reset button status to FALSE
|
||||||
};
|
};
|
||||||
if (modeOld != mode){
|
if (modeOld != mode){
|
||||||
|
Serial.printf("\nCurrently received data is %p", btmessage);
|
||||||
Serial.printf("\nChanging Lighting Preset to Preset %d", mode);
|
Serial.printf("\nChanging Lighting Preset to Preset %d", mode);
|
||||||
}
|
}
|
||||||
// Wait until the packet is finished being sent before proceeding.
|
// Wait until the packet is finished being sent before proceeding.
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user