WriteCharacteristics doesn't work through ESP but is working through noble

mrrahul
Posts: 1
Joined: Sat Feb 08, 2020 7:33 pm

WriteCharacteristics doesn't work through ESP but is working through noble

Postby mrrahul » Sat Feb 08, 2020 7:36 pm

I am trying to work on a BLE lock which is currently being operated through a mobile app using the react-native ble plx.

I was trying to make it work through the ESP32 so that it can be controlled remotely. I have prepared the data and is being sent to esp32 through aws iot. data is received but when trying to write to the lock it doesn't respond.

In order to see whether it is something wrong with command or not I installed the noble in my mac and passed the same command through the noble write method and it works and lock responds.

Command is created from a buffer in javascript for noble and this makes lock work

Code: Select all

let buffer = encData.slice(0, 20);
      console.log(i + ": " + buffer.toString("hex"));
      //The buffer value in hex is aa5510f0988fbef125a97eee5e7ae2beeaff79
      foundCharacteristic.write(buffer, true, function(error) {
        console.log("set characteristic value ");
      });
I checked a BLE server using the BLE Scanner app in ios and cloned the same characteristics of the lock and could see the value 0xaa5510f0988fbef125a97eee5e7ae2beeaff79 in the app.

When doing for the ESP, I pass this hex value aa5510f0988fbef125a97eee5e7ae2beeaff79 to aws iot and is received in the ESP32 and then the ble scanning is done and the required service and characteristics are found and are written through the following method using the Ble_Client example.

Code: Select all

String input = "aa5510f0988fbef125a97eee5e7ae2beeaff79"
if (connected) {
    Serial.println("Setting new characteristic value to \"" + input + "\"");

    // Set the characteristic's value to be the array of bytes that is actually a string.
    Serial.println(input.c_str());
    pRemoteCharacteristic->writeValue((uint8_t*)input.c_str(), input.length());
    connected = false;

  }
This never works for me.Am I passing the correct way the value or something missing? I am able to scan and get the services and characteristcs but the write is a failure. Not sure whether some conversion issues or what is going wrong. Please do help me if there is something to be done. I have been trying for so long. Thanks in advance

Who is online

Users browsing this forum: CatNoir, Google [Bot] and 119 guests