Send Value from Input Number Box to Write Characteristic

Ask, and ye shall receive.
DonPancoe
Posts: 25
Joined: 06:53, 20 Nov 2014
Location: Philadelphia, PA, USA
Contact:

Send Value from Input Number Box to Write Characteristic

Postby DonPancoe » 04:24, 01 Nov 2015

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">

Fredrik
Site Admin
Posts: 196
Joined: 15:00, 18 Nov 2013

Re: Send Value from Input Number Box to Write Characteristic

Postby Fredrik » 10:32, 02 Nov 2015

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)])

DonPancoe
Posts: 25
Joined: 06:53, 20 Nov 2014
Location: Philadelphia, PA, USA
Contact:

Re: Send Value from Input Number Box to Write Characteristic

Postby DonPancoe » 04:11, 05 Nov 2015

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.


Return to “Questions and answers”

Who is online

Users browsing this forum: No registered users and 5 guests