sending value established - needs formating

This commit is contained in:
vanarebane 2025-02-28 09:31:55 +02:00
parent 638ad3535c
commit 17ce0505c0
2 changed files with 26 additions and 5 deletions

View File

@ -262,13 +262,16 @@
$('#profileconfig_send').on('click', async event => {
let msg = $('#profile_message')
// cmd = "SWN|"+$('[name="ssid"]').val()+"|"+$('[name="wifipass"]').val()
// elem = $(event.target)
// elem.addClass('processing')
cmd = "SWN"
elem = $(event.target)
elem.addClass('processing')
// msg.html("Sending config to SmartKnob")
msg.html("Sending config to SmartKnob")
// let value = stringToBuffer("CMD|"+cmd)
let value = sk.stringToBuffer("CMD|"+cmd)
let res = await sk.sendWrite(cmd, value);
// try{
// console.log('Sending command: '+cmd+'...');
// await serviceCharacteristic.writeValue(value);

View File

@ -216,6 +216,24 @@ const SmartKnob = class {
}
}
async sendWrite(cmd, value){
let msg = $('#profile_message')
try{
console.log('Sending command: '+cmd+'...');
await this.serviceCharacteristics[0].writeValue(value);
msg.html("Sending done, waiting back")
elem.removeClass('processing')
console.log('> Command sent: '+cmd);
}
catch(error){
msg.html("Sending error: "+error)
console.log('> Command BT error: '+error);
this.isDisconnected(message_tryagain, "error")
}
}
// handleCombinedNotifications(event) {