Heckie75 / govee-h5075-thermo-hygrometer

MIT License
10 stars 2 forks source link

Device data receiving format #1

Closed am-i-abdullah closed 5 months ago

am-i-abdullah commented 5 months ago

Hey there, I hope you are doing well, and sorry for disturbing you. Can you please share me the documentation of GVH5075 or the format in which you are writing data to the device for reading past recorded data? I'll be very thankful to you.

Regards

Heckie75 commented 5 months ago

@am-i-abdullah Pls. take a look at https://github.com/Heckie75/govee-h5075-thermo-hygrometer/blob/main/API.md

On Linux systems you can try these commands 1:1 using the shell tool gatttool.

am-i-abdullah commented 5 months ago

Hey thanks a lot, actually I'm using windows and developing an application in flutter (dart). Can you please let me know about these handles? as I can't see these in the Characteristics UUIDs. image

Heckie75 commented 5 months ago

@am-i-abdullah Then take a look at https://github.com/Heckie75/govee-h5075-thermo-hygrometer/blob/main/govee-h5075.py line 127ff. There is a static variable called _COMMANDS which is a json object.

The uuids are:

    _COMMANDS = {
        "NAME": {
            "UUID": "00002a00-0000-1000-8000-00805f9b34fb",
        },
        "FIRMWARE": {
            "UUID": "494e5445-4c4c-495f-524f-434b535f2011",
            "SEQUENCE": [0xaa, 0x0e] + [0] * 17 + [0xa4]
        },
        "HARDWARE": {
            "UUID": "494e5445-4c4c-495f-524f-434b535f2011",
            "SEQUENCE": [0xaa, 0x0d] + [0] * 17 + [0xa7]
        },
        "DATA_CONTROL": {
            "UUID": "494e5445-4c4c-495f-524f-434b535f2012",
            "SEQUENCE": [0x33, 0x01]
        },
        "DATA": {
            "UUID": "494e5445-4c4c-495f-524f-434b535f2013"
        }
    }
am-i-abdullah commented 5 months ago

yeah, I've seen these. Can you explain me what do you mean by the sequence here?

Heckie75 commented 5 months ago

@am-i-abdullah The sequence is the payload that is sent, e.g.:

        "FIRMWARE": {
            "UUID": "494e5445-4c4c-495f-524f-434b535f2011",
            "SEQUENCE": [0xaa, 0x0e] + [0] * 17 + [0xa4]
        },

is this command:

char-write-req 0x11 aa0e0000000000000000000000000000000000a4

Of course the handle 0x11 is related to the uuid 494e5445-4c4c-495f-524f-434b535f2011.

am-i-abdullah commented 5 months ago

Thanks, can I get GVH5075's official documentation? as I'm receiving these values for a month :) after writing at uuid: 494e5445-4c4c-495f-524f-434b535f2012 I/flutter ( 7482): [238, 1, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 234] I/flutter ( 7482): ee105000000000000000ea

does it indicate some error?

am-i-abdullah commented 5 months ago

always same responses:

image

Heckie75 commented 5 months ago

Maybe check the request again. Keep in mind that the thermometer does not keep recorded data if batteries have been removed in the meantime ;-)

am-i-abdullah commented 5 months ago

can you please confirm that we've to write at DATA_CONTROL UUID and then read the data from DATA UUID?

        "DATA_CONTROL": {
            "UUID": "494e5445-4c4c-495f-524f-434b535f2012",
            "SEQUENCE": [0x33, 0x01]
        },
        "DATA": {
            "UUID": "494e5445-4c4c-495f-524f-434b535f2013"
        }
Heckie75 commented 5 months ago

Yes, this is correct as you can see in the example:

[A4:C1:38:68:41:23][LE]> char-write-req 0x15 3301001500020000000000000000000000000035
                                             |   |   |   |                         + Byte 20: checksum XORed all bytes from 1 to byte 19 
                                             |   |   |   + Byte 7 - 19: static zeros
                                             |   |   + Byte 5 - 6 (2 bytes): minutes back in the past when to end
                                             |   + Byte 3 - 4 (2 bytes): minutes back in the past when to start
                                             ^ Byte 1 - 2: Command 0x3301

Notification handle = 0x0015 value: 33 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 32
                                    |                                                        + Byte 20: checksum XORed all bytes from 1 to byte 19 
                                    ^ Byte 1 - 2: notification on handle 0x15 that request was successful and data transfer will start
Characteristic value was written successfully

Notification handle = 0x0019 value: 00 15 03 71 e7 03 75 cf 03 71 e7 03 75 cf 03 71 e6 03 75 ce
                                    |     + Byte 3 - 5, 6 - 8, 9 - 11, 12 - 14, 15 - 17, 18 - 20 (6 records each 3 bytes): encoded temperature and humidity (see 'decode temperature and humitity') 
                                    + Byte 1 - 2: minute back of first record, here now - 21m

Notification handle = 0x0019 value: 00 0f 03 75 cf 03 75 cf 03 75 ce 03 75 cf 03 75 ce 03 75 cf
Notification handle = 0x0019 value: 00 09 03 75 cf 03 75 cf 03 75 d1 03 75 d0 03 75 d0 03 75 cf
Notification handle = 0x0019 value: 00 03 03 75 cf 03 75 cf 03 75 ce ff ff ff ff ff ff ff ff ff

Notification handle = 0x0015 value: ee 01 00 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 eb
                                    |     |                                                  + Byte 20: checksum XORed all bytes from 1 to byte 19 
                                    |     + Byte 3 - 4: Number of messages (notifications) sent
                                    + Byte 1 - 2: notification on handle 0x15 that data transfer has finished

Steps are:

  1. Send request with payload on handle 494e5445-4c4c-495f-524f-434b535f2012
  2. Get response on handle 494e5445-4c4c-495f-524f-434b535f2012 instantly
  3. Get a couple of data notifications on handle 494e5445-4c4c-495f-524f-434b535f2013
  4. Get finally a notification on 494e5445-4c4c-495f-524f-434b535f2012 that ends data transmission
am-i-abdullah commented 5 months ago

Thanks a lot, should I delete or close this issue?