mirror of
https://github.com/scottbez1/smartknob.git
synced 2025-09-26 23:09:27 +08:00
sending value established - needs formating
This commit is contained in:
parent
638ad3535c
commit
17ce0505c0
@ -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);
|
||||
|
@ -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) {
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user