The SensorDemo routine provided by TI is very good. With ZigBee Sensor Monitor, you can also observe the network topology of ZigBee.
However, according to the original SensorDemo, collector, router, and enddevice both have corresponding buttons or joystick to operate in order to establish a network and send data.
1. Add another configuration-RouterEB
Open the SensorDemo Project, find Edit Configurations under the Project menu, and click the New button. The New Configuration dialog box is displayed, as shown in. Click OK:
The configuration of RouterEB is exactly the same as that of CollectorEB.
2. Select the CollectorEB configuration, open the Options option, and add one more compilation option in Defined Symbols: MY_TYPE_COLLECTOR
3. In the sapi. c file's SAPI_Init () function, find the following statement:
AfSetMatch (sapi_epDesc.simpleDesc-> EndPoint, FALSE );
To:
# Ifdef MY_TYPE_COLLECTOR
AfSetMatch (sapi_epDesc.simpleDesc-> EndPoint, TRUE); // FALSE
# Else
AfSetMatch (sapi_epDesc.simpleDesc-> EndPoint, FALSE); // FALSE
# Endif
4. Find the void zb_HandleOsalEvent (uint16 event) function of the DemoCollector. c file)
Modify the code in if (event & ZB_ENTRY_EVENT) to the following:
If (event & ZB_ENTRY_EVENT)
{
// Blind LED 1 to indicate starting/joining a network
HalLedBlink (HAL_LED_1, 0, 50,500 );
HalLedSet (HAL_LED_2, HAL_LED_MODE_OFF );
If (appState = APP_INIT)
{
# Ifdef MY_TYPE_COLLECTOR
LogicalType = ZG_DEVICETYPE_COORDINATOR;
Zb_WriteConfiguration (ZCD_NV_LOGICAL_TYPE, sizeof (uint8), & logicalType );
InitUart (uartRxCB );
# Else
LogicalType = ZG_DEVICETYPE_ROUTER;
Zb_WriteConfiguration (ZCD_NV_LOGICAL_TYPE, sizeof (uint8), & logicalType );
# Endif
}
// Start the device
Zb_StartRequest ();
}
5. In the DemoSensor. c and Democollector. c files, find
If (reportState)
Comment out this line.
In this way, the vro and terminal automatically send a report after successfully binding to the Coordinator.
You can also delete all codes related to reportState in the project.