Skip to main content
Associate II
January 19, 2024
Solved

STM32WB5MM-DK, connecting to Tuya gateway with zigbee, part 2

  • January 19, 2024
  • 4 replies
  • 9248 views

Hello,

I have still connection problem to Tuya gateway. Simple OnOff application can connect to Tuya gateway, but when I try to connect STM32WB5MM-DK as a temperature sensor, connection fails.

Connection to Tuya gateway succeeds with STM32WB5MM-DK example OnOff_Server_Coordinator and On/Off button comes visible on SmartLife app. But with temperature sensor application connection won't work. The application things that it has succeed to connect, but nothing comes visible in SmartLife app. Little display shows "Join ok". According to Wireshark logs, temperature sensor won't reply to gateway's read attributes request where it wants to read basic attributes:

Command: Read Attributes (0x00)
Attribute: Manufacturer Name (0x0004)
Attribute: ZCL Version (0x0000)
Attribute: Application Version (0x0001)
Attribute: Model Identifier (0x0005)
Attribute: Power Source (0x0007)
Attribute: Unknown (0xfffe)

OnOff application responds for that, but not quite like should. Anyway connection succeed.

Connection shoud go according to that specification:

【Zigbee Popular Science Series】 - 3 Network Access Process - Tuya Developer Forum (tuyaos.com)

I attached three Wireshark log; WB5MM_OnOff__Server_Coord, WB5MM_TempMeas_Server_Coord and Nedis_capture. In both Server_Coord applications, I changed starttype --> join and also channel change to WPAN_2400MHZ.

I'am not shure is that the reason why connection fail, but this is at least first difference. 

This topic has been closed for replies.
Best answer by Ouadi

Hello,

The join process works fine also with Temperature application according to the logs and Wireshark capture, From WB device side, I don't observe any issue which may disturb the join, no leave request is sent after the association.

For me the investigation should be directed on the Tuya side to know why the SmartLife app does not display the device after a successful join.

Kind regards,

Ouadi

4 replies

eskomjAuthor
Associate II
January 21, 2024

It looks like handling of basic attribute request hapens in that portion of code:

IPC_CLUSTER_REQ_CALLBACK_FUNC(ZbZclReadReq, MSG_M4TOM0_ZCL_READ_REQ, ZbZclReadReqT, ZbZclReadRspT);

-->

#define IPC_CLUSTER_REQ_CALLBACK_FUNC(name, cmd_id, req_type, rsp_type)

.....

Whole message handling is based on that define construction. Now I am  wandering how I can modify the code so, that I get better loggin. The code  is in zigbee_core_wb.c which is read only. I think, it's not meant to be changed.

ST Technical Moderator
January 24, 2024

Hello @eskomj,

From the logs I observe that the device leave the network just after the join, and it may be explained by the fact that the device does not implement the attributes required by the coordinator.

In fact, Zigbee_TempMeas_Server_Coord and OnOff_Server_Coordinator does not handle the listed attributes as the Manufacturer Name, Stack Version ,Model Identifier.., these applications are developed in order to demonstrate the use of ZigBee network and to help designers to build their specific Zigbee applications based on STM32WB series.

Therefore, you have to modify the application according to Tuya Gateway specification so that your device is supported.

To implement these attributes, you can use following APIs : ZbZclBasicServerConfigDefaults and ZbZclBasicWriteDirect.

You can refer to this post which describes the steps to follow.

Kind regards,

Ouadi

eskomjAuthor
Associate II
January 27, 2024

Thank you Ouadi! I got basic cluster working according to the instructions. But connecting to the Tuya network won't work yet. Now it looks like the application won't send TC link key request, which is point 12 in Tuya guide (link above). Such attention also, that instead of setting basic cluster before creating any ZCL endpoints I had to do it after endpoint creation. That is also said in post . When I tried to add ZbZclBasicWriteDirect calls before creating end points, writeDirect call returned STATUS_FAILURE. I moved the basic cluster setting after that 

USER CODE BEGIN CONFIG_ENDPOINT 

in the function APP_ZIGBEE_ConfigEndpoints()

then it worked. Now the problem seems to be that the application won't send TC link key request  I attached latest Wireshark capture. For comparison, Nedis capture can be found in ealier post above. It shoud look like that (from filtered Wireshark capture from Nedis device):

191 157.916257 0xbde5 ZigBee 0x0000 84 Request Key
198 158.226943 0x0000 ZigBee 0xbde5 116 Transport Key
200 158.237543 0xbde5 ZigBee 0x0000 91 Verify Key
201 158.242451 0xbde5 ZigBee 0x0000 91 Verify Key
202 158.247377 0xbde5 ZigBee 0x0000 91 Verify Key

 

eskomjAuthor
Associate II
January 27, 2024

I looked more closely the Wireshark capture. First difference compared to Tuya specification, is that the application won't send node descriptor request (point 10). 

It is obvious that ZbZdoNodeDescReq() call still missing. If so, where should it be inserted?

ST Technical Moderator
February 1, 2024

Another point, I noticed that you have configured your device to use a distributed network, which is not correct in your case, Tuya gateway use a centralized network and plays the role of the coordinator ( Trust Center) 

This leads to a conflict in the TC key exchange between your device and coordinator as in a distributed network there is no TC link key exchanged.

I have updated your file with a router configuration.

Please give it a try and keep me informed of the result. Thanks

BR,

Ouadi 

eskomjAuthor
Associate II
February 1, 2024

Hello, 

In both of those versions (3 and 4) startupControl is ZbStartTypeJoin. In original Server_Coord version it was ZbStartTypeForm. Version 4 seems to work same way. The reason why I think device is not connected is that Smartlife app won't find my end device. As I stated ealier OnOff server works and Smartlife app finds it as OnOff light switch and it also works.

Esko

Associate III
September 28, 2024

Hi Esko, 

I have found this topic because I am standing at the same point rn: I could connect my On/Off project to Tuya/Smartlife, but with any other functionality I cannot achieve this. The MCU however thinks it joined the network.

Could you solve this problem and could you share your solution?

I assume an alternative would be to use somethin else than Tuya, maybe Zigbee2mqtt with HA, since it seems that this is a Tuya/Smartlife issue?

Associate III
April 18, 2024

Hi,

I read your comments and I wonder what is the ioc file should be to use Zigbee server/client model. Is there specific pins that I have to use Zigbee on STM32WB5MMG processor? Or it is working internally connected, so we do not need to set up any pins to use zigbee. My intension is send/receive between two Zigbee network using STM32WB5MMG processors. I am not sure how to set the ioc file from STM32CubeIDE tool.

 

thanks in advance,