-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for Qingping Cleargrass CGD1 #23
Comments
Surprise, an update to Android 14 re-enabled It looks like the app writes |
Got some updates (sorry for spamming). I tried to snoop the BT communication with the Qingping+ app (com.cleargrass.app.air) and this app seems to be less verbose than Xiaomo Home when talking to the clock. I tried to replay the data being written on the The data I wrote was Capture file: qingping-app.pcapng.gz |
Thanks for looking into this! I actually have the same clock, and I tried to figure out the synchronization. I recognized like you that the app writes the time in the same format as for the BT Clock Lite, but I didn't try the data packet the app sent before the time, and without this packet the clock didn't synchronize. With the results of your investigation, I looked again at the communication between the Qingping+ app and my clock. In my situation, the first command the app sends to the clock is
When I send my command and then the same time synchronization command as for the BT Clock Lite, the time synchronizes, like in your case. It looks like it sends the same 18-byte command each time before sending the time synchronization command. This is progress! When I send your command and then the time synchronization command, the time doesn't synchronize. So this seems like some device-specific key you first need to send to the device before being able to synchronize the time.
|
Great finding with the common So I began to sniff Qingping+ app's traffic over internet and guess what: the key is found in the response for
Obtaining this programmatically is another challenge, as it seems there's a dynamic header named Probably there's a similar way to get this key from the Xiaomi Home app (or using Xiaomi-cloud-tokens-extractor), but at a first glance I couldn't find the key anywhere else. |
I found a solution. We can set up our own key. I removed the alarm clock from the Qingping+ app and added it again while sniffing the BLE traffic. The app sent this sequence of commands to the 0001 characteristic:
The next time I opened the app, it didn't send the first command. So, it looks like the command beginning with I implemented this logic in a test script to write a new key to the alarm clock:
Then another test scripts takes a key from the user and:
This successfully synchronizes the time. So I'm confident that I can now add support for the CGD1. I'll add a command to set a new key, as well as an option to provide the necessary key for synchronizing the time. I noticed though that the time is off one hour. This is probably a bug related to the time zone or daylight savings time. I'll investigate this further. |
Well... this is surprising. I was expecting this to be some sort of burned-in key or a key negotiated during the pairing process. I tested on my side and I can confirm that writing Here (Romania) the time is off by two hours with your script. I suppose the app writes the timezone on the device and every timestamp after that it's treated as local time, because if I send a UTC timestamp, the time appears correctly on the clock. |
Still investigating the time discrepancy. After the time synchronization command, the Qingping+ app sends the following commands to the 0010 characteristic:
Are these the same for you? |
I think you mean on the 0001 characteristic, right? If yes, I'm seeing this write operations on it after time syncing:
I tried with your values, but either I'm doing something wrong or it doesn't seem to change anything. |
Sorry, I meant 0001 yes. Ok, I'm not sure what the difference between your 14 and my 0a is (20 vs. 10 in decimal), or whether it is relevant at all. Those commands don't seem to be necessary anyway to set the time. |
It's on
There's only two bytes different, I think edit: I'm so stupid, it's so obvious. So the value at offset 6 is a tenth of an hour. If you want to add two hours, you set HEX |
The thing is, I'm in Brussels timezone (GMT+1), not Portugal timezone (GMT). I haven't seen the Qingping+ app writing to the 000b characteristic in my case. |
Try to change the timezone in your phone settings and reinstall the app, that's how I triggered writing on |
If you go with writing on
and this is how I turn on all the alarms:
If might want to get the current settings, and you do this by writing |
Hi, thank you for all the hard work. Is there any update on this? |
Thank you for your project, I started something similar in the past but without ever finalizing it.
This is the clock I'm talking about: https://www.amazon.com/Bluetooth-Temperature-Ringtones-Adjustable-Backlight/dp/B08NX6BM6X
These are the services and characteristics of the clock:
It looks like the service UUID and characteristic UUID matches the ones on BT Clock Lite, although I'm not sure if
00000001-0000-1000-8000-00805f9b34fb
is also the characteristic for the time on CGD1, too. I tried to force it to be recognizable in bluetooth-clocks by modifying the code indevices/qingping.py
, to the point where the script connected and even wrote data successfully on the device's00000001-0000-1000-8000-00805f9b34fb
characteristic, but nothing happens on the clock (apart from the Bluetooth symbol flashing, as a result of the connection).I suppose that communication with the clock is encrypted with the BLE key or the token I'm getting by using Xiaomi-cloud-tokens-extractor:
but I'm not sure what the encryption algorithm could be.
Have you looked into this product yet? I'm waiting to root my spare Redmi phone (I have to wait for a few days to be able to unlock the bootloader) so I can btsnoop the official app, but if you got any other hint until then, I could try it to see if I get any result.
The text was updated successfully, but these errors were encountered: