pvvx / ATC_MiThermometer

Custom firmware for the Xiaomi Thermometers and Telink Flasher
https://github.com/pvvx/pvvx.github.io/tree/master/ATC_MiThermometer
Other
2.75k stars 196 forks source link

advertisement JSON message is too long (> 256 bytes) #444

Closed bam80 closed 6 months ago

bam80 commented 6 months ago

This probably a 3rd party problem but still I hope we could address it here.

My MQTT client app seems have a restriction of 256 bytes for the message length: https://github.com/RadioShuttle/MQTTPushClient_Android

So I can't parse JSON's in the MQTT messages if they are bigger.

Could we have a setting to exclude some data from the advertisement messages, as temperature in Fahrenheit and such? That would also add to the power-saving, maybe.

pvvx commented 6 months ago

The thermometer uses messages no longer than 31 bytes, including headers. Bluetooth version 4.2 is no longer capable. Bluetooth version 5.0+ can use advertising messages that are several kilobytes long.

bam80 commented 6 months ago

I see, but maybe it transfers the temperature info twice - in Celsius and Fahrenheit?

pvvx commented 6 months ago

No. Only in Celsius.

bam80 commented 6 months ago

Hmm, that means the Fahrenheit temperature is added by Theengs gateway?

I get following MQTT JSON's:


{"name": "ATC_*",
"id": "AA:...",
"rssi": -63,
"brand": "Xiaomi",
"model": "TH Sensor",
"model_id": "LYWSD03MMC/MJWSD05MMC_PVVX",
"type": "THB",
"tempc": 21.73,
"tempf": 71.114,
"hum": 34.24,
"batt": 100,
"volt": 3.074,
"mac": "AA:..."} 
pvvx commented 6 months ago

means the Fahrenheit temperature is added by Theengs gateway?

Yes. The gateway recalculates and adds The thermometer is transmitted with maximum accuracy to two decimal places.

bam80 commented 6 months ago

Do you know if I could have control over the data included in JSON?

Other sample: model_id is pretty long and adds a lot to the message.

bam80 commented 6 months ago

Yes. The gateway recalculates and adds

Do you know where it happens?

I only see it uses tempc: https://github.com/theengs/decoder/blob/development/src/devices/LYWSD03MMC_json.h#L12