Page 1 of 1

Send Value from Input Number Box to Write Characteristic

Posted: 04:24, 01 Nov 2015
by DonPancoe
This seems like it should be simple, but I can't figure it out after much trial and error (my HTML/JS skills are sketchy at best).

I want to have a number input box in an Evothings app that, upon clicking a SUBMIT button, would write that value to a BLE characteristic on my device. I've got a jQuery knob that can successfully write a range values as well as buttons that can successfully write individual values, but I can't get a number box to send an arbitrarily typed-in number to the device.

Below is some part-HTML, part-pseudo-code of what I am trying to do. Any suggestions would be most appreciated.

Don

Code: Select all

<input type="number" id="ambTemp" min="65" max="81">
<input type="submit" onclick="some code here to send the value 'ambTemp' to the device">

Re: Send Value from Input Number Box to Write Characteristic

Posted: 10:32, 02 Nov 2015
by Fredrik
If your number is to be sent as a single byte, I imagine something like this could work:

Code: Select all

new Uint8Array([Number(document.getElementById('ambTemp').value)])

Re: Send Value from Input Number Box to Write Characteristic

Posted: 04:11, 05 Nov 2015
by DonPancoe
Belated thanks for the reply. I got by with just having up/down buttons, but I will still try your suggestion to be ready for the next time.