This document shows a brief demonstration on executing wireless messenger application using NXP Bluetooth FRDM-KW40Z wireless development board.
To proceed further the below are the prerequisites:
1. The freedom hardware board i.e FRDM-KW40Z-2 No’s as shipped in a box
2. IAR Tool to compile/build the example of wireless messenger project
Steps involved:
1) Cloning a project: run the Project Cloner application
(ConnSw\tools\project_cloner\project_cloner.exe)
2) Building the Binaries using IAR
3) Executing the project using generated binaries
Step -1: Cloning a project
Navigate to the below path
“C:\Freescale\KW40Z_Connectivity_Software_1.0.1\ConnSw\tools\project_cloner”
And run the project cloner application
Now we need to select the path for “codebase path” as shown below
We need to select “C:\Freescale\KW40Z_Connectivity_Software_1.0.1\ConnSw” as its path
Next select the example of wireless messenger application to be cloned (Clone example app), and the desired configuration (Clone Configuration).
Under cloned app name provide name of your choice i have given it as “smac_wireless_messenger-cloned” and other options as shown below:
And select the destination folder where the project needs to be saved
I am saving this project under a folder “C:\Users\brao\Desktop\cloned conn project”
After cloning you can see the data logging of cloning process
You can see the cloned project in folder
“C:\Users\brao\Desktop\cloned conn project\smac_wireless_messenger-cloned”
Step-2: Building the Binaries using IAR
Open IAR
Open the cloned IAR workspace “smac_wireless_messenger-cloned.eww” from below location
“C:\Users\brao\Desktop\cloned conn project\smac_wireless_messenger-cloned”
The project window looks like as shown below:
The KSDK platform libraries are RTOS dependent, so appropriate libraries must be built for the selected RTOS. For any connectivity application, the following Kinetis SDK libraries must be built with the IAR Embedded Workbench for ARM in order to enable the complete board support and RTOS kernel support:
Select the KSDK platform (bare-metal) library project and Build the KSDK platform library project.
It builds with zero error
Next Select the “smac_wireless_messenger-cloned” project and build it as did earlier It builds with zero error and an executable *.bin is generated
Step-3 Executing the wireless messenger using the generated binaries
We need two FRDM-KW40Z boards to execute this project. The binaries are located in the below folder:
“C:\Users\brao\Desktop\cloned conn project\smac_wireless_messenger -cloned\debug”
We can see inside the “Wireless_MessengerMenus.c” the uart baud rate has been set to 115200
Serial_SetBaudRate (mAppSer, gUARTBaudRate115200_c); //Set 115200 as default baud
You can browse for the other api’s and code flow inside the “Wireless_MessengerMenus.c” file as shown below:
If any changes to be made as per your requirement you have to do it here and rebuild again to get the exe file
Now connect both the boards when connected we can see it in explorer as shown
Now copy the generated “smac_wireless_messenger-cloned.bin” file from debug folder and paste it into both the DAPLink foders as shown below:
And to the other board
Now open the Putty hyperterminal with below settings
You can see both the boards in device manager listed under ports (COM & LPT)
COM53 board-1 settings:
COM54 board-2 settings:
After opening putty terminal press reset button on both the boards you will see below message on both terminal
After flashing the board, the device is in idle mode (all 4 LEDs flashing).
Press enter to start on both boards you will see wireless messenger short cuts as shown below
Given in the above figure:
pressing ‘q’ will increase the channel number. When it reaches 26 the channel number will be set to 11.
pressing ‘w’ will decrease the channel number. If previous channel number is 11, the next channel will be 26
pressing ‘a’ and ‘s’ is similar to ‘q’ and ‘w’ but for setting the output power. The limits for this option are [0x03, 0x0F].
pressing ‘z’ will increase the number of retransmissions in case of a channel busy scenario. Keep in mind that a number greater than 0 for this option will enable automatic CCA before TX option.
pressing ‘x’ will decrease the number of retransmission in case of a channel busy status. If the number of retransmissions is decremented to 0, the feature will be disabled.
pressing ‘r’ will increment the number of retries in case of a No Ack situation. If the number of retries is greater than 0, the automatic ACK mechanism is enabled. This mechanism is bypassed in case of a broadcast transmission.
pressing ‘t’ will decrement the number of retries in case of a No Ack situation. If the number of retries reaches 0, the automatic ACK mechanism is disabled.
Configuration Menu
By pressing ‘1’ you will be entered in configuration menu
The configuration menu is shown below . There are three options available:• Configure Short Pan ID: this option will allow the user to set the source/destination PAN address. The user must enter four hexadecimal digits resembling a 16-bit address. The value entered is case-insensitive. For example, to set a broadcast address for the PAN ID, the user can type both “0xFFFF” or “0xffff”.
• Configure Short Src ID: this option will allow the user to set the short address of the node. The option is similar to the one presented above.
• Configure Short Dst ID: this option will allow the user to set the destination address of the packets that will be sent from the console menu. The feature is similar to the Configure Short Pan ID option.
Security IV and key configuration
Press ‘p’ to go back to main menu and press ‘3’ to enter into Security IV and key configuration menu
This configuration menu appears only if the application is built with gSmacUseSecurity_c set to 1. This feature allows the user to configure the initial vector and encryption key. For two devices to communicate properly, security must be enabled on both of them and the initial vector and the key must be identical.
Wireless Messenger console menu
The console menu is used for sending and receiving messages. Outside this menu, the MKW40Z will not receive any packets OTA. Also, in this menu all configuration options are disabled.
In the console menu, the user can see packets intended for his MKW40Z platform or broadcast packets. Also when the user types a message and hits [ENTER] the application will include the message into a packet payload and send it using the addressing information configured previously. The application will notify the user about the status of the packet by writing a status message to the serial port. The status can be either a “Packet Sent” message or an error message in case the retry or retransmission mechanism is enabled and sending failed after the retry/retransmission counter reaches the configured value. For example if the CCA Fail Retries is set to two and the algorithm finds the channel idle after a second attempt, the user will receive a “Packet Sent” message in the TERM. If the channel is busy after a second retry the user will receive a “Packet Sending Failed. Reason. Channel Busy!” notification.
To return to the main menu the user must press the escape key ([Esc]).
Press 2 and enter into messenger menu on both the boards and start chat:
The Video output execution is shown in below video:
Happy Executing the wireless messenger application on KW40Z (wireless MCU)...