The MCR20A Wireless UART application functions as an wireless UART bridge between two (one-to-one) or several (one to many) boards. The application can be used with both a TERM, or with software that is capable of opening a serial port and writing to or reading from it. The characters sent or received are not necessarily ASCII printable characters.

Dependencies:   fsl_phy_mcr20a fsl_smac mbed-rtos mbed

Fork of mcr20_wireless_uart by Freescale

By default, the application uses broadcast addresses for OTA communication. This way, the application can be directly downloaded and run without any user intervention. The following use case assumes no changes have been done to the project.

  • Two (or more) MCR20A platforms (plugged into the FRDM-K64F Freescale Freedom Development platform) have to be connected to the PC using the mini/micro-USB cables.
  • The code must be downloaded on the platforms via CMSIS-DAP (or other means).
  • After that, two or more TERM applications must be opened, and the serial ports must be configured with the same baud rate as the one in the project (default baud rate is 115200). Other necessary serial configurations are 8 bit, no parity, and 1 stop bit.
  • To start the setup, each platform must be reset, and one of the (user) push buttons found on the MCR20A platform must be pressed. The user can press any of the non-reset buttons on the FRDM-K64F Freescale Freedom Development platform as well. *This initiates the state machine of the application so user can start.

Documentation

SMAC Demo Applications User Guide

Committer:
sam_grove
Date:
Thu Mar 05 16:37:54 2015 +0000
Revision:
3:a38ad504a18c
Parent:
2:3e7685cfb2a7
Delete multi use functions and update mbed library - exporters for IAR now working again

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sam_grove 2:3e7685cfb2a7 1 #include "mbed.h"
sam_grove 2:3e7685cfb2a7 2 #include "nsdl_support.h"
sam_grove 2:3e7685cfb2a7 3 #include "nsdl_dbg.h"
sam_grove 2:3e7685cfb2a7 4
sam_grove 2:3e7685cfb2a7 5 #include "node_cfg.h"
sam_grove 2:3e7685cfb2a7 6
sam_grove 2:3e7685cfb2a7 7 #include "rgb.h"
sam_grove 2:3e7685cfb2a7 8 #include "battery.h"
sam_grove 2:3e7685cfb2a7 9
sam_grove 2:3e7685cfb2a7 10
sam_grove 2:3e7685cfb2a7 11 // ****************************************************************************
sam_grove 2:3e7685cfb2a7 12 // Configuration section
sam_grove 2:3e7685cfb2a7 13
sam_grove 2:3e7685cfb2a7 14 // NSP configuration
sam_grove 2:3e7685cfb2a7 15 /* Change this IP address to that of your NanoService Platform installation */
sam_grove 2:3e7685cfb2a7 16 uint8_t NSP_address_bytes[] = NSP_IP_ADDRESS;
sam_grove 2:3e7685cfb2a7 17
sam_grove 2:3e7685cfb2a7 18 uint8_t endpoint_name[24] = NODE_NAME;
sam_grove 2:3e7685cfb2a7 19 uint8_t ep_type[] = ENDPOINT_TYPE;
sam_grove 2:3e7685cfb2a7 20 uint8_t lifetime_ptr[] = LIFE_TIME;
sam_grove 2:3e7685cfb2a7 21
sam_grove 2:3e7685cfb2a7 22 // ****************************************************************************
sam_grove 2:3e7685cfb2a7 23 // Resource creation
sam_grove 2:3e7685cfb2a7 24
sam_grove 2:3e7685cfb2a7 25 static int create_resources()
sam_grove 2:3e7685cfb2a7 26 {
sam_grove 2:3e7685cfb2a7 27 sn_nsdl_resource_info_s *resource_ptr = NULL;
sam_grove 2:3e7685cfb2a7 28 sn_nsdl_ep_parameters_s *endpoint_ptr = NULL;
sam_grove 2:3e7685cfb2a7 29
sam_grove 2:3e7685cfb2a7 30 NSDL_DEBUG("Creating resources");
sam_grove 2:3e7685cfb2a7 31
sam_grove 2:3e7685cfb2a7 32 /* Create resources */
sam_grove 2:3e7685cfb2a7 33 resource_ptr = (sn_nsdl_resource_info_s*)nsdl_alloc(sizeof(sn_nsdl_resource_info_s));
sam_grove 2:3e7685cfb2a7 34 if(!resource_ptr)
sam_grove 2:3e7685cfb2a7 35 return 0;
sam_grove 2:3e7685cfb2a7 36 memset(resource_ptr, 0, sizeof(sn_nsdl_resource_info_s));
sam_grove 2:3e7685cfb2a7 37
sam_grove 2:3e7685cfb2a7 38 resource_ptr->resource_parameters_ptr = (sn_nsdl_resource_parameters_s*)nsdl_alloc(sizeof(sn_nsdl_resource_parameters_s));
sam_grove 2:3e7685cfb2a7 39 if(!resource_ptr->resource_parameters_ptr)
sam_grove 2:3e7685cfb2a7 40 {
sam_grove 2:3e7685cfb2a7 41 nsdl_free(resource_ptr);
sam_grove 2:3e7685cfb2a7 42 return 0;
sam_grove 2:3e7685cfb2a7 43 }
sam_grove 2:3e7685cfb2a7 44 memset(resource_ptr->resource_parameters_ptr, 0, sizeof(sn_nsdl_resource_parameters_s));
sam_grove 2:3e7685cfb2a7 45
sam_grove 2:3e7685cfb2a7 46 // Static resources
sam_grove 2:3e7685cfb2a7 47 nsdl_create_static_resource(resource_ptr, sizeof("dev/mfg")-1, (uint8_t*) "dev/mfg", 0, 0, (uint8_t*) "ARM mbed", sizeof("ARM mbed")-1);
sam_grove 2:3e7685cfb2a7 48 nsdl_create_static_resource(resource_ptr, sizeof("dev/mdl")-1, (uint8_t*) "dev/mdl", 0, 0, (uint8_t*) "6LoWPAN node", sizeof("6LoWPAN node")-1);
sam_grove 2:3e7685cfb2a7 49
sam_grove 2:3e7685cfb2a7 50 // Dynamic resources
sam_grove 2:3e7685cfb2a7 51 #if NODE_HOME
sam_grove 2:3e7685cfb2a7 52 create_light_resource(resource_ptr);
sam_grove 2:3e7685cfb2a7 53 create_HVAC_resource(resource_ptr);
sam_grove 2:3e7685cfb2a7 54 create_door_resource(resource_ptr);
sam_grove 2:3e7685cfb2a7 55 #endif
sam_grove 2:3e7685cfb2a7 56
sam_grove 2:3e7685cfb2a7 57 #if NODE_SENSOR_STATION
sam_grove 2:3e7685cfb2a7 58 create_pressure_resource(resource_ptr);
sam_grove 2:3e7685cfb2a7 59 create_temperature_resource(resource_ptr);
sam_grove 2:3e7685cfb2a7 60 create_moisture_resource(resource_ptr);
sam_grove 2:3e7685cfb2a7 61 create_hcho_resource(resource_ptr);
sam_grove 2:3e7685cfb2a7 62 create_UVsensor_resource(resource_ptr);
sam_grove 2:3e7685cfb2a7 63 #endif
sam_grove 2:3e7685cfb2a7 64
sam_grove 2:3e7685cfb2a7 65 #if NODE_CONTROLLER
sam_grove 2:3e7685cfb2a7 66 create_rgbled_resource(resource_ptr);
sam_grove 2:3e7685cfb2a7 67 #endif
sam_grove 2:3e7685cfb2a7 68
sam_grove 2:3e7685cfb2a7 69 #if BATTERY
sam_grove 2:3e7685cfb2a7 70 create_battery_resource(resource_ptr);
sam_grove 2:3e7685cfb2a7 71 #endif
sam_grove 2:3e7685cfb2a7 72
sam_grove 2:3e7685cfb2a7 73
sam_grove 2:3e7685cfb2a7 74 /* Register with NSP */
sam_grove 2:3e7685cfb2a7 75 endpoint_ptr = nsdl_init_register_endpoint(endpoint_ptr, (uint8_t*)endpoint_name, ep_type, lifetime_ptr);
sam_grove 2:3e7685cfb2a7 76 if(sn_nsdl_register_endpoint(endpoint_ptr) != 0)
sam_grove 2:3e7685cfb2a7 77 printf("NSP registering failed\r\n");
sam_grove 2:3e7685cfb2a7 78 else
sam_grove 2:3e7685cfb2a7 79 printf("NSP registering OK\r\n");
sam_grove 2:3e7685cfb2a7 80 nsdl_clean_register_endpoint(&endpoint_ptr);
sam_grove 2:3e7685cfb2a7 81
sam_grove 2:3e7685cfb2a7 82 nsdl_free(resource_ptr->resource_parameters_ptr);
sam_grove 2:3e7685cfb2a7 83 nsdl_free(resource_ptr);
sam_grove 2:3e7685cfb2a7 84 return 1;
sam_grove 2:3e7685cfb2a7 85 }
sam_grove 2:3e7685cfb2a7 86
sam_grove 2:3e7685cfb2a7 87 // ****************************************************************************
sam_grove 2:3e7685cfb2a7 88 // Program entry point
sam_grove 2:3e7685cfb2a7 89 // this modified to startup as an option in the Wi-Go demo
sam_grove 2:3e7685cfb2a7 90
sam_grove 2:3e7685cfb2a7 91 void nsdl_run()
sam_grove 2:3e7685cfb2a7 92 {
sam_grove 2:3e7685cfb2a7 93
sam_grove 2:3e7685cfb2a7 94 NSDL_DEBUG("ARM NSP Init\r\n");
sam_grove 2:3e7685cfb2a7 95
sam_grove 2:3e7685cfb2a7 96 // Initialize NSDL stack
sam_grove 2:3e7685cfb2a7 97 nsdl_init();
sam_grove 2:3e7685cfb2a7 98
sam_grove 2:3e7685cfb2a7 99 // Create NSDL resources
sam_grove 2:3e7685cfb2a7 100 create_resources();
sam_grove 2:3e7685cfb2a7 101
sam_grove 2:3e7685cfb2a7 102 }
sam_grove 2:3e7685cfb2a7 103