rfWsnNodeExtFlashOadClient Example
Example Summary
The WSN Node example illustrates how to create a Wireless Sensor Network Node device which sends packets to a concentrator. This example is meant to be used together with the WSN Concentrator example to form a one- to-many network where the nodes send messages to the concentrator.
This examples showcases the use of several Tasks, Semaphores and Events to get sensor updates and send packets with acknowledgement from the concentrator. For the radio layer, this example uses the EasyLink API which provides an easy-to-use API for the most frequently used radio operations.
Refer to EasyLink API for more information on the EasyLink API.
Peripherals Exercised
Board_PIN_LED0- Toggled when the a packet is sentBoard_ADCCHANNEL_A0- Used to measure the Analog Light Sensor by the SCE taskBoard_PIN_BUTTON0- Selects fast report or slow report mode. In slow report mode the sensor data is sent every 5s or as fast as every 1s if there is a significant change in the ADC reading. in fast reporting mode the sensor data is sent every 1s regardless of the change in ADC value. The default is slow reporting mode.
Resources & Jumper Settings
If you’re using an IDE (such as CCS or IAR), please refer to Board.html in your project directory for resources used and board-specific jumper settings. Otherwise, you can find Board.html in the directory <SDK_INSTALL_DIR>/source/ti/boards/<BOARD>.
Example Usage
- Run the example. On another board run the WSN Concentrator example. This node should show up on the LCD of the Concentrator.
The example also support Over The Air Update (OAD), where new FW can be loaded over OAD. The must be an OAD Server, which is included in the concentrator, and an OAD client which is included in the sensor.
Generating the required binary images for OAD
For generating the images the following tools are required:
CCSv7https://processors.wiki.ti.com/index.php/Download_CCSsimplelink_cc13x0_sdk_1_31_00_xxhttps://www.ti.com/tool/simplelink-cc13x0-sdkPython 2.7Python intelhex-2.1Python crcmod-1.7
Note: When building examples for the CC1350STK Board *The bim_extflash_cc1350lp project must be built with CC1350STK defined. This can be done by adding CC1350STK to the predefined symbols.
- Or you can use the prebuild CC1350STK files already generated for you located here.
<SDK_DIR>\examples\rtos\CC1350STK\easylink\hexfiles\offChipOad\ccs - The following instructions will be based upon the CC1310_LAUNCHXL board. The same instructions apply to the CC1350STK board, only file names and directories will have applicable changes.
The prebuilt BIM binary is generated from the BLE SDK projects:
- CCS:
<SDK_DIR>\examples\rtos\CC1350_LAUNCHXL\blestack\util\bim_extflash\tirtos\ccs - IAR:
<SDK_DIR>\examples\rtos\CC1350_LAUNCHXL\blestack\util\bim_extflash\tirtos\iar
The python intelhex merge utility is used to combine the BIM and App into one hex file that can be downloaded with SmartRF Studio:
cd <SDK_DIR>/examples/rtos/CC1310_LAUNCHXL/easylink/hexfiles/offChipOad
python /usr/bin/hexmerge.py -o rfWsnNodeExtFlashOadClient_CC1310_LAUNCHXL_all_v1.hex "--overlap=error" rfWsnNodeExtFlashOadClient_CC1310_LAUNCHXL_app_v1.hex bim_extflash_cc1350lp_bim.hex
Note: Select the relevant int_flash/ext_flash files.
An OAD image can then be created from the application image with the oad_image_tool_13x0.py:
python ../../../../../../tools/easylink/oad_image_tool_13x0.py -v 0x[major version:minor version] -i app rfWsnNodeOad_CC1310LP_app.hex -ob rfWsnNodeExtFlashOadClient_CC1310_LAUNCHXL_app_v1.bin -m 0x1000
Where major version (XX) and minor version (YY) must be of the format 0xXXYY, for example 2.3 would be 0x0203.
Using the OAD example
To be safe the external flash of the Concentrator and the Node should be wiped before running the example. To do this, program both LP boards with erase_extflash_cc13x0lp.hex. The program will flash the LED’s while erasing and once finished the LED’s will stop flashing. Allow the application to run until the external flash has been erased and the LED’s stop flashing.
The wipe flash FW can be found in below location and should be downloaded with Uniflash programmer: <SDK_DIR>/hexfiles/offChipOad/ccs/erase_extflash_cc13x0lp.hex
Using Uniflash, load the appropriate file(s) onto the CC13x0_LAUNCHXL board.
- CC13x0_LAUNCXL A - load the concentrator image `
\examples\rtos\CC1310_LAUNCHXL\easylink\hexfiles\oad\rfWsnConcentratorOadServer_CC1310_LAUNCHXL.hex - CC13x0_LAUNCXL B - load the node application image
<SDK_DIR>\examples\rtos\CC1310_LAUNCHXL\easylink\hexfiles\oad\rfWsnNodeExtFlashOadClient_CC1310_LAUNCHXL_all_v1.hex
Connect CC13x0_LAUNCHXL A (concentrator) and CC13x0_LAUNCHXL B (node) to the USB of a PC.
The Concentrator will display the below on the UART terminal:
Nodes Value SW RSSI
0x0b 0887 0 -080
0xdb 1036 0 -079
0x91 0940 0 -079
*Action: Update available FW
Info: Available FW unknown
cmd:
he Nodes will display the following once the 1st sensor reading has been sent (after 10s of booting):
Node ID: 0x95
Node ADC Reading: 0012
The node OAD image can be loaded into the external flash of the Concentrator over the UART with the oad_write_bin.py script. The action must first be selected using BTN-2. Press BTN-2 until the Action is set to Update available FW, then Press BTN-1 and Press BTN-2 to execute the action.
When “Available FW” is selected and BTN-2 is pressed the terminal will display:
Waiting for Node FW update...
The image is loaded into the external flash using the UART. Therefore, the UART terminal must first be closed to free the com port. After the com port is free, run the python script:
python ../../../../../../tools/easylink/oad/oad_write_bin.py /dev/ttyS28 <SDK_DIR>\examples\rtos\CC1310_LAUNCHXL\easylink\hexfiles\oad\rfWsnNodeExtFlashOadClient_CC1310_LAUNCHXL_app_v2.bin
After the download the UART terminal can be re-opened and the “Available FW” will be updated to reflect the new FW.
The current FW version running on the node can be requested using the Send FW Ver Req action. This is done by pressing BTN-1 until Action is selected. Then press BTN-2 until the Action is set to Update available FW, The Press BTN-1 until intended device is selected. Press BTN-2 to execute the action.
The next time the node sends data it will respond and the FW version will be displayed:
Nodes Value SW RSSI
0x0b 0887 0 -080
0xdb 1036 0 -079
*0x91 0940 0 -079
Action: Update available FW
Info: Node 0x91 FW v1.0
The FW running on the nodes can now be updated to the available fw on the concentrator. The Action must first be selected using BTN-1. The Press BTN-2 until the Action is set to Update node FW, and Press BTN-1 until the intended device is selected. Press BTN-2 to execute the action.
The next time the node sends data it will respond and the FW update request and start requesting OAD blocks, which will be displayed:
Nodes Value SW RSSI
0x0b 0887 0 -080
0xdb 1036 0 -079
*0x91 0940 0 -079
Action: Update available FW
Info: OAD Block 14 of 1089
Once the OAD has completed the node will reset (if not you may need to do a manual reset).
After resetting the node will be shown on the concentrator with a new node ID. A FW version request can be performed to verify that the OAD has completed successfully and FW version 2 is running:
Nodes Value SW RSSI
0x0b 0887 0 -080
0xdb 1036 0 -079
*0xe2 0940 0 -079
Action: Update available FW
Info: Node 0xe2 FW v2.0
Building an OAD hex firmware image in hex format
The following steps talk through how to use CCS or IAR to create an OAD hex file which can be used to create the OAD biniaries as described in previous sections
Building the hex file in CCS
- Import the CCS project into CCS(for more information consult the Examples Users Guide in the proprietary-rf documentation)
- Exclude the ccfg.c file from the project.
- Enable hex file conversion in Project->Properties Arm Hex Utility
- Set memory width to 8 in General options
- Set output format to intel hex.
- Make a code change, for testing this can just be updating the nodeFwVersion string in NodeTask.c
- build
- copy hex from the projects Debug dir to the bin folder
Building the hex file in IAR
- Create a new IAR workspace
- Create a new Empty IAR project and save it as rfWsnNodeOad
- Select Project -> “Add Project Connection” and add C:\ti\simplelink_cc13x0_sdk_1_xx_xx_xx\examples\rtos\CC1310_LAUNCHXL\easylink\rfWsn
NodeOadClient\tirtos\iar\rfWsn NodeOadClient.ipcf - Remove the ccfg.c file from the project.
- Enable hex file conversion in Project->Option Arm Hex Output Converter
- Check “Generate additional output”
- Set output format to Intel Extended hex.
- Make a code change, for testing this can just be updating the nodeFwVersion string in NodeTask.c
- build
- copy hex from the projects Debug dir to the bin folder
Building the hex file in CCS the GCC Compiler
- Import the GCC project into CCS (for more information consult the Examples Users Guide in the proprietary-rf documentation)
- Exclude the ccfg.c file from the project.
- Enable hex file conversion in Project->GNU Objcopy Utility
- In Edit flags add the following:
-O ihex --remove-section .vtable --remove-section .dmaSpi0RxControlTableEntry --remove-section .dmaSpi0TxControlTableEntry --remove-section .dmaSpi1RxControlTableEntry --remove-section .dmaSpi1TxControlTableEntry --gap-fill 0xff - Make a code change, for testing this can just be updating the nodeFwVersion string in NodeTask.c
- Build
- copy hex from the projects Debug dir to the bin folder
Application Design Details
This examples consists of two tasks, one application task and one radio protocol task. It also consists of a Sensor Controller Engine (SCE) Task which samples the ADC.
On initialization the CM3 application sets the minimum report interval and the minimum change value which is used by the SCE task to wake up the CM3. The ADC task on the SCE checks the ADC value once per second. If the ADC value has changed by the minimum change amount since the last time it notified the CM3, it wakes it up again. If the change is less than the masked value, then it does not wake up the CM3 unless the minimum report interval time has expired.
The NodeTask waits to be woken up by the SCE. When it wakes up it toggles
Board_PIN_LED1and sends the new ADC value to the NodeRadioTask.The NodeRadioTask handles the radio protocol. This sets up the EasyLink API and uses it to send new ADC values to the concentrator. After each sent packet it waits for an ACK packet back. If it does not get one, then it retries three times. If it did not receive an ACK by then, then it gives up.
RadioProtocol.h can also be used to change the PHY settings to be either the default IEEE 802.15.4g 50kbit, Long Range Mode or custom settings. In the case of custom settings, the smartrf_settings.c file is used. This can be changed either by exporting from Smart RF Studio or directly in the file.
Note for IAR users: When using the CC1310DK, the TI XDS110v3 USB Emulator must be selected. For the CC1310_LAUNCHXL, select TI XDS110 Emulator. In both cases, select the cJTAG interface.
References
- For more information on the EasyLink API and usage refer to SimpleLink-EasyLink.