Oops sorry my bad, it's this GATT_Specification_Supplement_v8 the
-1was appended by windows I guess it's stopped using
(1)to indicate duplicate files. I've added screenshots from the specification directly. Do you know why the specification is so difficult to implement, seems like it's raising the barrier of entry for no reason. Specially since they provide basically no information on how to actually implement it. Do you think you have any reference implementations or blogs that can help.
new Uint8Array([battery_status_flags, power_state_flags>>8, power_state_flags&255, battery_level]).buffer
Are you sure this is correct? It seems like you're encoding it in big endian, wouldn't the correct encoding be
new Uint8Array([battery_status_flags, power_state_flags&0xff, power_state_flags>>8, battery_level]).buffer
Well, I can't find the info - googling
GATT_Specification_Supplement_v8-1doesn't return anything, so I can't really confirm if it's right or not, but as far as I can see what you're doing looks good.
However the use of
Uint16Arrayin build_battery_status does look a bit suspect, as that's going to create 6 bytes of data (when I assume that wasn't what was needed).
You might need:
Which would give you 4 bytes (with power_state_flags as little endian 16 bit) - but again I'm not sure what's required so I'm just guessing.