Fs_11c14 platform ZigBee point-to-point communication

Source: Internet
Author: User

Author: Zhou Zhiqiang,Hua Qing vision embedded training center lecturer.

To use the fs_11c14 Development Board for point-to-point communication, you need to configure the ZigBee module on the Development Board. Next we will introduce the configuration process.

1. First run the zigbeecfg application. The interface shown is displayed:

Figure 10-1 ZigBee configuration page

In the Device Manager, check and select the serial port we use. Set the baud rate to 115200, the data bit to 8, the check bit to none, and the stop bit to 1 ", after opening the serial port, go to the "zlg page", that is:

Figure 10-2 network configuration page

2. Click "get information" to obtain the relevant configurations of this development board. Set the device type to "terminal device", panid to "0x1000", destination network address to the network address of the Peer Development Board, and send mode to "unicast mode ", the same operation is applied to another Development Board. However, during the operation, we must note that the panid and channel number of the two development boards should be set to the same. In this way, point-to-point configuration is completed in the configuration implementation.

It should be noted that this phenomenon may occur in the experiment: When the serial port is opened and local information is obtained, that is, information cannot be obtained.

Figure 10-3 configuration error

The cause of the above results may be:

(1) because the information of the ZigBee module is also obtained from the serial port, if there are too many operations related to data display in the program or the use of the serial port, this will lead to a time delay. When the time exceeds a certain limit, the configuration information is still not obtained, and the situation is shown.

(2) problems with the ZigBee module itself. This problem can be solved in this way. On the fs_11c14 development platform, there is such a Jumper: jp1. Find this module, use a patch cap to transient the two pins, and then power on and restart the Development Board. After resetting ZigBee, remove the patch line cap and restart the Development Board.

3. In the experiment, we can understand point-to-point communication through data communication. For example:

After completing the network configuration, let's take a look at how the program runs.

Case key_sel:
Switch (menu. Numb)
{
Case 1: // send "Hello ZigBee" data to the other party
Zigbee_putstring ("Hello ZigBee! ");
Printf ("\ r \ nsend Hello ZigBee! ");
Break;

Case 2: // send the "fan on" command to the other party to control the fan on.
Zigbee_putstring ("fan on ");
Printf ("\ r \ nsend Turn On Fan ");
Break;

Case 3: // send the "fan off" command to the other party to control the fan off of the other party
Zigbee_putstring ("fan off ");
Printf ("\ r \ nsend turn off fan ");
Break;

Case 4: // obtain the temperature/humidity information and send the information to the other party. The Development Board of the other party displays the information on the OLED screen.
I = read_temp_hum (temp, hum );
...

Looking at the nature of the phenomenon, let's look at how the above operations are implemented. On the ZigBee module, we only use its data transmission pin, instead of other features of the ZigBee module. The hardware connection is 10-4:

Figure 10-4

The data received by ZigBee on the transfer chip will be converted to the data that is attached to the SPI bus. The following line shows how the transfer process is implemented.

Figure 10-5

In the program, we use the zigbee_putstring () function to send data using Zigbee. Basic implementation:

Void zigbee_putstring (uint8_t * pstr)
{
While (* pstr)
{
Spi752_putchar (1, * pstr); // send a byte each time using channel 1
Pstr ++;
}
}
The use of the spi752_putchar () function illustrates the conversion process between the serial data in the ZigBee module and the data on the SPI bus. After the recipient receives the message, for example, if the "fan on" control message is sent, the information will be received through the following process.
If (uart0_getchar (& rd ))
{
Zigbee_putchar (RD );
}
If (zigbee_getchar (& rd ))
{
Uart0_putchar (RD );
}

After receiving the information, parse the command and perform related operations.
If (BUF [0] = 'F') & (BUF [1] = 'A') // receives the "fan on" command
& (BUF [2] = 'n') & (BUF [3] = '')
& (BUF [4] = 'O') & (BUF [5] = 'n ')
& (BUF [6] = '') & (BUF [7] = ''))
{
Gpiosetvalue (port0, 2, 1); // controls the fan opening
}
Else if (BUF [0] = 'F') & (BUF [1] = 'A') // receives the "fan off" command
& (BUF [2] = 'n') & (BUF [3] = '')
& (BUF [4] = 'O') & (BUF [5] = 'F ')
& (BUF [6] = 'F') & (BUF [7] = ''))
{
Gpiosetvalue (port0, 2, 0); // controls the fan off
}

For embedded and 3G related resources and learning, click: Embedded Development Video Android training 3G training QT Development Video Iot training IoT technology video embedded learning

 

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.