SWRA648 May 2019 CC1352P , CC1352R , CC1354P10 , CC1354R10 , CC2642R , CC2642R-Q1 , CC2652P , CC2652R , CC2652R7 , CC2652RB , CC2652RSIP
For top-down write function, the data packet includes the commands and destination node router index, so the grandpa node writes the data to the appointed father node according to the router index. The father node receives the data in GATT message process function, then it decides whether this data is destined for itself or one of its child nodes. If the data is meant for the father node itself, the father node directly executes the data. If the data is meant for a child node, the father node forwards the data to the target child node. Then, the top-down transmission is finished. For more details, see Figure 10 and .
// Noted that newValue[0] is reserved in the example code
// newValue[2] = '0', message to father, no transmit
if (newValue[2] == '0')
{
Display_printf(dispHandle, MR_ROW_my_message, 0, "Get message %s", newValue);
PIN_setOutputValue(ledPinHandle, Board_PIN_RLED, newValue[3] & 0x01);
// set/reset Led
}
//newValue[2] != '0', message to child, transmit to the appointed child
else if ( (newValue[2] - 48) <= (valid_table_sum - 1) )
{
child_index = newValue[2] - 48;
state = multi_role_doSelectConn(child_index);
if (state == false)
Display_printf(dispHandle, MR_ROW_doSelectConn, 0, "doSelectConn fail: %d", child_index);
else
{
multi_role_doGattWriteString(connList[child_index].connHandle, newValue);
// Transmit the data
}
}
For the bottom-up notify, the father node knows the index of the child node that sent the notification, and the grandpa node knows the index of the father node that sent the notification. For the grandpa node to distinguish which child node that originated the notification, the father node adds the index information in the notification data from the child node before the notification is forwarded to the grandpa node. To distinguish whether the notification’s source is the father node or a child node, adding “00” (2 bytes for write data alignment) before the payload data means the notification is from father node. Now, the grandpa node can know where the notification came from. Then, the down-top notification function is finished. For more details, see Figure 11 and .
// Noted that pMsg->data[0] is reserved in the example code
// order number in tree = connHandle
pMsg->data[2] = '0' + pMsg->connHandle;
memcpy(noti.pValue, pMsg->data, SIMPLEPROFILE_CHAR1_LEN);
//Forward the notification
status = GATT_Notification( grandfather_index, ¬i, FALSE );