Is it possible to set more than one service ? #1898
Replies: 15 comments
-
Posted at 2016-12-19 by @gfwilliams
The above works for me - I think it's because you were trying to send a string inside an array as the temperature. It should really have errored though - I'm not sure why it didn't |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-12-19 by @MaBecker only see 0x1809, no 0x180F , which application did you use to check this ? Can I use a second puck to check this ?
|
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-12-19 by @MaBecker Found it all in the documents ....
looks like the eBeacon and BlueFruit have problems with reading ... |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-12-19 by @gfwilliams I use the
|
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-12-19 by @MaBecker During testing with iPhone and iPad I realized that switching BLE YES Attachments: |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-12-19 by @gfwilliams I imagine some other apps will just cache the BLE services and don't cope well with them changing. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-12-20 by ChristianW Actually I believe that iOS is doing the caching here. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-12-21 by Fabio978 Nice idea! It's working for me but i get wrong temperature value (143.85°C instead of 18°C from the console). |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-12-21 by dklinkman @fabio978 I get something similar. I believe it's because toFixed() returns a string and the temperature value is supposed to be 16 bit floating point number. The characters in the string that end up being read as a sint16 and converted to floating point for display just happen to represent 143.85. I tried just rounding the temperature down to an integer but that doesn't work at all. The battery works fine because it's being read as a byte, with a valid range of 0 to 100. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-12-22 by Fabio978 I think the problem is that temperature must be specified in 11073-20601 16-bit FLOAT-Type format, but i couldn't find how to do that. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-12-30 by dklinkman I was able to figure this out eventually. Can't believe how much google searching and code searching. Bluetooth specs are specific but not much help to the uninformed. Bottom line is that the value sent to the characteristic needs to be a signed 16 bit integer supplied as a mantissa with an 'implied' decimal exponent of -2. All along I was trying to fit a float16 or a half-precision float or a 4 bit exponent float variant into a sint16 and it just doesn't work. Duh. This works:
Be sure to disconnect from the puck and then connect using nRF Connect or whatever and look for the Health Thermometer service. The temperature now reads correctly as 18.75'C. If reading the value using another puck you just need to divide by 100 (or multiply by 10^-2). Of course this simple example doesn't update the temperature value over time. NRF.updateServices in some sort of a timed loop would do that. Writing a string to the characteristic does work (doesn't fail) and if you read back the data and interpet it as a string that will work too. But the spec for the characteristic is sint16. Tools like nRF Connect expect to see an sint16 vs an array of chacters which is why it appeared to display an incorrect value. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-01-02 by Fabio978 Great find @dklinkman! I will try this tonight! |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-01-02 by Fabio978 @dklinkman your code works very well! Thank you! |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-01-06 by @MaBecker are you planing functions to convert to the the different value formats for Characteristics ? |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-01-06 by @gfwilliams Afraid not - you can do a lot of value conversion using ArrayBuffers though.
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2016-12-19 by @MaBecker
Was thinking of having more than one service set with
NRF.setService
.eBeacon or Bluefruit only display the service 0x1809
Any hints ?
Beta Was this translation helpful? Give feedback.
All reactions