SWRA648 May 2019 CC1352P , CC1352R , CC1354P10 , CC1354R10 , CC2642R , CC2642R-Q1 , CC2652P , CC2652R , CC2652R7 , CC2652RB , CC2652RSIP
According to Section 2, in the tree structure the grandpa node is always a central device. The child nodes are always peripheral role devices. But the father node needs to be both. When in the connection to the grandpa node, it is peripheral role, and when in the connection to the child nodes, it is a central role. This peripheral role to central role changing behavior can be used to identify the father node. If the node’s role is changed after the GAP link establishment event, for example, from peripheral to the central, then the node can be identified as a father in the network. The sample code is shown in below:
// Update the role type when the lnk established
uint8_t role = ((gapEstLinkReqEvent_t*) pMsg)->connRole;
static uint8_t last_role;
// Judge the role change
if ( ( (role == GAP_PROFILE_CENTRAL) && (last_role == GAP_PROFILE_PERIPHERAL) )
|| ( (role == GAP_PROFILE_PERIPHERAL) && (last_role == GAP_PROFILE_CENTRAL) ) )
my_role = GAP_PROFILE_MULTIROLE;
else
my_role = role;
// Save the last role state
last_role = role