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 ");
});
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;
}