void SampleApp_SendPointToPointMessage( void )
{
//uint8 *abc ;
//abc= *pBuf++; //How to deal with this pointer, or how to deal with the following parameters
//uint16 data=10;
//uint16 j = 0;
rtgItem_t rt;
NLME_GetRequest(nwkRoutingTable,0,&rt);
char msg[100] = {0};
uint16 i = 0x2040;
//i=NLME_GetRequest(nwkNumRoutingTableEntries ,j,&data);
i=NLME_GetShortAddr();
sprintf(msg, "number:%x\n", i ); //The \nASCII code of the newline symbol is 10, which is actually output as A. Because the ASCII code value of A is 1
HalUARTWrite( 0, msg,osal_strlen("number:%x\n"));
//sprintf(msg, "ssssss:%x\n", i );
//HalUARTWrite( 0, msg, 9);
}
As shown in the above code, in this case, the newline character is output as an ASCII value, which cannot achieve the desired output effect. The following code is in Zstack:
modify it as follows to achieve the desired output and wrap:
void SampleApp_SendPointToPointMessage( void )
{
//uint8 *abc ;
//abc= *pBuf++; //How to deal with this pointer, or how to deal with the following parameters
//uint16 data=10;
//uint16 j = 0;
rtgItem_t rt;
NLME_GetRequest(nwkRoutingTable,0,&rt);
char msg[100] = {0};
uint16 i = 0x2040;
//i=NLME_GetRequest(nwkNumRoutingTableEntries ,j,&data);
i=NLME_GetShortAddr();
sprintf(msg, "number:%x\n", i );
HalUARTWrite( 0, msg,osal_strlen("number:%x\n"));
HalUARTWrite( 0, "\n",1);
//sprintf(msg, "ssssss:%x\n", i );
//HalUARTWrite( 0, msg, 9);
}
PS: In addition, be familiar with the knowledge points:
The character length in the HalUARTWrite function does not include \0, nor does the strlen function, and the sizeof function needs to add 1 (length). The length of the string output function must be well controlled, otherwise unexpected errors will occur.