Modify the TI SensorDemo routine to get rid of the annoying joystick and buttons!

Source: Internet
Author: User

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.



 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.