This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
在Zstack 2.5.1a中,Coordinator节点使用AF_DataRequest发送一组十六进制数据uint8 theMessageData[128] = {0x02, 0x03, 0x10, 0x00, 0x35, 0x00, 0xF2, 0x00};
使用EndDevice接收,但收到的数据只有{02 03 10},请问为什么会出现这样的问题?如何解决?
主要代码如下:
//按键按下事件,自定义 if ( events & X1_KEY_EVT ) { GenericApp_SendTheMessage(); //发送Hello World HalUARTWrite(0, "The Key is down\n", sizeof("The Key is down\n")); HalLedSet(HAL_LED_1, HAL_LED_MODE_TOGGLE); return (events ^ X1_KEY_EVT); } static void GenericApp_SendTheMessage( void ) { // char theMessageData[] = "Hello World!\n"; uint8 theMessageData[128] = {0x02, 0x03, 0x10, 0x00, 0x35, 0x00, 0xF2, 0x00}; AF_DataRequest( &GenericApp_DstAddr, &GenericApp_epDesc, GENERICAPP_CLUSTERID, (byte)osal_strlen( theMessageData ) + 1, (byte *)&theMessageData, &GenericApp_TransID, AF_DISCV_ROUTE, AF_DEFAULT_RADIUS ); } //终端节点接收 static void GenericApp_MessageMSGCB( afIncomingMSGPacket_t *pkt ) { uint8 buffer[20]; switch ( pkt->clusterId ) { case GENERICAPP_CLUSTERID: osal_memcpy(buffer, pkt->cmd.Data, osal_strlen((char *)pkt->cmd.Data)); HalUARTWrite(0, buffer, osal_strlen((char *)pkt->cmd.Data)); break; } }
你theMessageData中間帶了0x00所以被osal_strlen給截了、你試試直接把theMessageData長度帶下去給AF_DataRequest應該就可以發送出去