Prototype for 4-byte BLE communication

This commit is contained in:
Tempest 2024-11-04 21:14:20 +07:00
parent 703a3e0c38
commit b2e0851c77
2 changed files with 11 additions and 6 deletions

View File

@ -70,8 +70,8 @@ void setup() {
void loop() {
// notify changed value
if (deviceConnected) {
btmessage = pCharacteristic->getValue().c_str();
mode = btmessage;
btmessage = pCharacteristic->getData();
mode = btmessage;
}
// disconnecting
if (!deviceConnected && oldDeviceConnected) {

View File

@ -255,6 +255,7 @@ void dmxSetup() {
void setup() {
Serial.begin(115200);
delay(2000);
Serial.print("\nIf you receive this message, ESP32 module has finished setting up Serial Interface for communication.");
// Create the BLE Device
BLEDevice::init("Pupilometer LED Billboard");
@ -288,11 +289,10 @@ void setup() {
pAdvertising->setScanResponse(false);
pAdvertising->setMinPreferred(0x0); // set value to 0x00 to not advertise this parameter
BLEDevice::startAdvertising();
Serial.println("Waiting a client connection to notify...");
Serial.println("\nWaiting a client connection to notify...");
pinMode(INTERRUPT_PIN, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(INTERRUPT_PIN), isr, RISING);
delay(2000);
dmxSetup();
const dmx_port_t dmx_num = DMX_NUM_1;
Serial.println("Welcome to Pupilometer LED Billboard!");
@ -305,8 +305,13 @@ void loop() {
// notify changed value
if (deviceConnected) {
btmessage = pCharacteristic->getValue().c_str();
mode = btmessage.toInt();
Serial.printf("\nI received the following string: %s",String(pCharacteristic->getValue()));
Serial.printf("\nI received the following bytes: ");
uint8_t* btMessage = pCharacteristic->getData();
for (int i = 0; i < sizeof(btMessage); i++){
Serial.printf("%d ",btMessage[i]);
};
delay(100);
}
// disconnecting
if (!deviceConnected && oldDeviceConnected) {