Receiving/decoding more than 1 byte with ble_advert and known_services? #7897
-
|
Is it possible? Am I just tripping? I know there are other ways of doing this, but I've gone down a rabbit hole and this is where I'm stuck. I want to advertise my current step count. I wrote a simple little boot app: I also have/had this in my config.json: There are a few problems. With the boot code how it is, I only get the first byte of the array (the low byte). If I remove the entry from advertised_services and restart EspruinoHub, then I don't get anything unless I enable "mqtt_advertise_service_data". If I uncomment method 1 and comment method 2 (with the entry in advertised_services), I get a mqtt messages like this: And on the status page: The actual step count is 274. 274 & 255 = 18, so it's still only seeing the first byte. I don't know what else to try, I'd like to avoid using manufacturer data for this if I can. I can see in /lib/attributes.js, the "decodeAttribute" function: Which explains why I'm only getting the first byte when I have an entry in advertised_services, but I imagine there has to be a way to send values larger than 255, right?! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 6 replies
-
|
I think I did mention in the last post you made was that using BTHome might be way easier for you, and it should handle this case pretty well? As far as I remember with EspruinoHub it attempts to decode services it knows about, which are in https://github.com/espruino/EspruinoHub/blob/master/lib/attributes.js#L51 But it doesn't know
It looks like |
Beta Was this translation helpful? Give feedback.
Glad you got it working!
For BTHome the apps themselves don't have HRM broadcast built in, but it's pretty easy to use the app to add it. The
BTHomeapp provides a functionBangle.btHome: https://github.com/espruino/BangleApps/blob/master/apps/bthome/boot.js#L18-L24So you can just add the following to some boot code to make it advertise the current step count: