theengs / app

Theengs mobile application to read BLE sensors and push data to an MQTT broker
https://app.theengs.io
GNU General Public License v3.0
38 stars 6 forks source link

No MQTT data with iOS App #91

Closed london89 closed 1 year ago

london89 commented 1 year ago

When I added LYWSD03MMC to iOS app, I can see temperature and humidity, can update it. But in MQTT no data about this. In MQTT i see only topic home/TheengsApp/version with data "v1.3.1"

Steps to reproduce the behavior:

  1. Install app
  2. add LYWSD03MMC
  3. configure mqtt server settings
  4. scan MAC of LYWSD03MMC with debian
  5. Set MAC Address of my LYWSD03MMC into App, from previous scan "root@mdm:/home/london# stdbuf -oL hcitool lescan | grep LYWSD03MMC A4:C1:38:5C:75:B6 LYWSD03MMC"
  6. click Update data in app

Expected behavior I wanna LYWSD03MMC data in MQTT

photo_2023-07-04_20-38-02 (2) photo_2023-07-04_20-38-02 photo_2023-07-04_20-38-00 photo_2023-07-04_20-37-59

iOS App Theengs ver 1.3.1 iPhone 14 Pro iOS ver. 16.5.1

DigiH commented 1 year ago

https://github.com/theengs/decoder/issues/388

😃

DigiH commented 1 year ago

Just repeating it here as well, in case someone else is experiencing this.

Can you make sure you add your LYWSD03MMC's MAC address at the top right three dots menu - Set MAC address.

As iOS does not allow to recognise devices' MAC addresses, but masks them with random uuids, this is required to be able to assign a constant MAC address to each device. Only then can it publish with this MAC address/id to an MQTT broker.

london89 commented 1 year ago

Can you make sure you add your LYWSD03MMC's MAC address at the top right three dots menu - Set MAC addres

of course, you can see it on my screenshot

DigiH commented 1 year ago

What about changing the Broker integration name to something other than Mosquitto. I assume you have the Musquitto broker running, but the name which should go in there is the name of the client connecting to Mosquitto, so should likely be something else.

Or just leave them empty for user name and password, as your 1883 port does not indicate any user/password secure connection

Do you have any other connections to the Mosquitto MQTT broker, or is this your first and only connection to it?

london89 commented 1 year ago

No SSL secure on my MQTT server, so that, port is 1883. But, I use login and password authorisation, and "mosquitto" here is my login for mqtt server. I see in mosquitto logs successful connections from my phone, and I see topic from The ends App with version of app, 1.3.1. (on my screenshots from MQTT Explorer.

1688493468: New client connected from 192.168.1.5:49298 as aa39f781e13948a3961beb4 (p2, c1, k60, u'mosquitto').

But no topics with data from my devices.

london89 commented 1 year ago

Yes, with this login/password I use all my clients. And I see "version topic" from Theengs App, means, Theengs have connect to my server and have permission to write new topics.

DigiH commented 1 year ago

Correct, then I'll need to leave the issue for @1technophile or @emericg, as to why the non-SSL, but user/password authenticated connection to the MQTT broker might not work here.

Myself running 1.3.1 on iOS 16.5.1 as well, but without user/password authentication, everything is published fine.

london89 commented 1 year ago

I don't think, that problem in mqtt authorization, because, in mqtt logs i see, that connection from phone is success and i see topic with application version from Theengs app on my iPhone...

DigiH commented 1 year ago

I wouldn't have thought so either, but the only thing I can think about currently is deleting the MAC address entry again and re-entering it afresh, as this is usually a culprit, when MQTT publishing doesn't work correctly.

Other than that the only real difference between your and my set up is the user/password authentication, other than that we are both running the same App version, iOS version and the Mosquitto broker.

london89 commented 1 year ago

I already try re-enter MAC address with different formats. A4:C1:38:5C:75:B6, A4-C1-38-5C-75-B6, A4C1385C75B6, etc... And already deleting sensors, already reinstall Theengs App. But nothing works :( I think. may be, my method of getting MAC isn't correct? I have only iPhone and debian with BLE adapter, and I get MAC's with "stdbuf -oL hcitool lescan | grep LYWSD03MMC" linux command. What's your way to get LYWSD03MMC's MAC?

DigiH commented 1 year ago

To be honest, I would assume any arbitrary MAC address would actually do, as Theengs App on iOS would not even know which wold be the correct MAC address for any device, so even AA:BB:CC:DD:EE:FF should do. So your entered MAC address does not look wrong in any way, and how you got it.

Obviously, if there are other Theengs projects or OpenMQTTGateway involved, a correct MAC address is always the preferred option.

You could use Theengs Gateway on Debian to check for the actual MAC address, and at the same time also see if publishing to your MQTT broker works fine there.

Theengs Gateway documentation

https://gateway.theengs.io/use/use.html

london89 commented 1 year ago

I tried this, everything is ok. I receive topic's from Theengs Gateway on same MQTT server.

root@mdm:/home/london# python3 -m TheengsGateway -H "XXXX" -u "mosquitto" -p "XXXX"

image

And MAC of LYWSD03MMC is the same

DigiH commented 1 year ago

Actually, one thing I am seeing though is that the message for your LYWSD03MMC is NOT being decoded in the Gateway published message.

With non-decoded messages Theengs App will not publish any messages, so I think this is the issue here.

Which firmware are you running on your LYWSD03MMC that is is not being decoded by Theengs Decoder?

london89 commented 1 year ago

Unforchunatly, I have same result...

photo_2023-07-04_22-07-01 photo_2023-07-04_22-07-00

DigiH commented 1 year ago

Sorry, same result for which different settings?

london89 commented 1 year ago

same result for no login/password on mqtt server. If messages from LYWSD03MMC can't decoded, i think, no temp and hum will be in Theengs App on iOS? But, I have this data in iOS app. Only no mqtt data from this

DigiH commented 1 year ago

I did delete again a previous message talking about alternative firmware for LYWSD03MMC devices, which is usually required for correct decoding with Theengs Decoder, generally being used in Theengs Gateway, OpenMQTTGateway and also Theengs App, with Theengs App also having some legacy decoders implemented which might also decode the stock firmware, but might have an issue with publishing such decodings?!?

Theengs Decoder can currently only decode LYWSD03MMC if the unencrypted ATC or PVVX firmware protocol is being used on these devices

https://decoder.theengs.io/devices/LYWSD03MMC.html

The easiest way to flash the PVVX firmware onto your LYWSD03MMC would be

https://pvvx.github.io/ATC_MiThermometer/TelinkMiFlasher.html

This should then also give you correct decoded messages in Theengs Gateway, which previously above only showed the undecoded raw data as well.

Screenshot 2023-07-04 at 21 20 22
london89 commented 1 year ago

I can't flash this from iOS or non-GUI debian?

DigiH commented 1 year ago

Apologies for all the hoo-haa with this!

You and me both only just got to realise what intricacies Theengs App holds for this special case :(

Me not having a LYWSD03MMC myself here, I don't actually know how you could get the PVVX firmware installed with only iOS and non-GUI Debian.

We will definitely look into this matter more closely and hope to find a solution soon. Please bear with us for a bit.

london89 commented 1 year ago

After flashing LYWSD03MMC from Android phone to ATC firmware - everything is ok. Thank you for your help!

image