Leiaz/python-awox-mesh-light

Questions on protocol

Opened this issue · 7 comments

Hi Leiaz,

Great work! This is working for me for 2 different devices.

I have a few questions you may be able to answer :

  • I'd like to pair/group several devices, do you know how to do it. I guess mesh id and mesh group handle should be used but I didn't work it out yet after messing around.
  • Do you know the purpose of C_LIGHT_MODE ?
    I'm currently using this handle to get device status when I just want to know the state but not do run any command. It does nothing on the light but seems to send several notification messages indicating that it does do something. Do you know a simple way of getting device status ?
  • You recently added firmware upload function. Does that mean you have latest firmware file available ?

I managed to read notification result to get meaningful information.
This is the code to parse the return of decrypt_packet method in notification handle

def parseResult(self, message):
	message = "".join("%02x" % b for b in message)
	result  = {}
	result['debug'] = message
	meshid = int(message[6:8], 16)
	mode = int(message[24:26], 16)

	if mode < 40 and meshid == 0:     # filter some messages that return something else
		result['status'] = mode%2
		modestring = ''
		if mode==1 or mode==5:
			modestring = 'White'
			mode=1
		elif mode==3: 
			modestring = 'Color'
		elif mode==7:
			modestring = 'Transition'
		
		if mode%2 == 1:
			result['mode'] = mode
			result['modestring'] = modestring
			
		result['whitetemperature'] = int(int(message[28:30], 16)*100/127)  # convert to value from 0 to 100
		result['whitebrightness'] = int(int(message[26:28], 16)*100/127)  # convert to value from 0 to 100
		result['color'] = "#" + message[32:38]
		result['colorbrightness'] = int(int(message[30:32], 16)*100/64)  # convert to value from 0 to 100
	return result
Leiaz commented

I'd like to pair/group several devices, do you know how to do it. I guess mesh id and mesh group handle should be used but I didn't work it out yet after messing around.

The data for the C_MESH_GROUP command is :

  • First byte : 1 to add group, 0 to remove group
  • Second an third bytes : I think this is the group's mesh id in little endian order. Third byte is 0x80 because I think group ids are in the form 0x80xx.

So you could try adding the same group number on both devices, and writing a command to them with the 0x80xx group id as destination.

Do you know the purpose of C_LIGHT_MODE ?

Not really. It looks like "light mode" is : 0 for white, 1 for color, 2 for sequence, but the command doesn't actually change the light.

Do you know a simple way of getting device status ?

I haven't really looked into it, but there must be ways to query the status.

You recently added firmware upload function. Does that mean you have latest firmware file available ?

The firmware files are in the Awox Smart Control app apk, which I downloaded from one of those website that let you download free apps without a Google account or phone. Just unpack the apk with something like 7zip, it's in the assets directory or res/raw in previous versions. There are different files for different light hardware versions.

Thanks!
It seems to work for group mesh id. As you mentioned, I added a group 0x8001 to devices and then sent command to this same goup id to any of the device to spread the command.

For status I figured it out. Just need to send a read request to STATUS_CHAR_UUID when connected and status result will come through notification message.

Do you know the purpose of writing byte 1 to STATUS_CHAR_UUID at connection time ? Is it to swith status feedback on for notification subscription ?

C_LIGHT_MODE seems to be some advanced feature as I can see weird messages coming back through notifications.

Leiaz commented

Do you know the purpose of writing byte 1 to STATUS_CHAR_UUID at connection time ? Is it to swith status feedback on for notification subscription ?

It looks like it is turning on some notifications. I don't see any when not doing it.

@Leiaz @guirem do you know the difference between C_MESH_GROUP and C_MESH_ADDRESS?

When calling setMeshId(0x8011) I get a different status message back. But couldn't figure out yet what part of the message is the meshid.

Current parseStatusResult() doesn't look fully correct currently regarding extracting the meshid.

Did a test run with multiple mesh devices on the same credentials. And when asking 1 device the status it looks like I get a messages of multiple devices but couldn't discover yet how to tell from which device.

Ok, found how to extract the mesh_id from the status message. It first byte of the data set and the last byte together

The light mode that comes back is setup as following:
0000
from the right:
1 = on/off
1 = color mode
1 = transition mode
x = not know yet

Ok, found how to extract the mesh_id from the status message. It first byte of the data set and the last byte together

https://github.com/Leiaz/python-awox-mesh-light/pull/23/files#diff-b2fb016cae37842db03967bbc6f5ffea1cbe5e6d15df4482b34ef1d3cf28d208R274