I'm a bit new to the BLE environment, my code works just fine, buy I can't manage to get some sort of response,
I'll show you the code, and I'll tell you more about my objective
WriteReadCharacteristic.prototype.onWriteRequest = function(data, offset, withoutResponse, callback) {
const output = Buffer.from(data, 'hex');
let payload = "";
if (hasJsonStructure(String(output))) {
payload = JSON.parse(String(output));
}
wifi.scan((error, networks) => {
if (error) {
console.log(error);
} else {
exec('sudo iwlist scan && echo '+ password);
console.log(payload.ssid);
networks.forEach(network =>{
if(payload.ssid === network.ssid){
console.log("Success, wifi found")
}
else {
console.log("Failed, not found")
let data = new Buffer(31);
data.writeUInt32LE(this.RESULT_UNLIKELY_ERROR);
callback(data);
}
});
}
});
callback(this.RESULT_SUCCESS);
};
I'm using two npm depedencies : Bleno, and Node-wifi
When my code runs, my devices shows up, and I can send data to it via nRF Connect (Android App)
As you can see, I have a condition, if true, it returns a success message ...
But when it fails, I'd like to send back a message to the sender device (In my case, a phone)
edit : Don't mind the exec + sudo line, that's a temporary fix for a specific problem I face with my Rpi