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

NSDL/nsdl_run.cpp

Committer:
sam_grove
Date:
2015-03-05
Revision:
3:a38ad504a18c
Parent:
2:3e7685cfb2a7

File content as of revision 3:a38ad504a18c:

#include "mbed.h"
#include "nsdl_support.h"
#include "nsdl_dbg.h"

#include "node_cfg.h"

#include "rgb.h"
#include "battery.h"


// ****************************************************************************
// Configuration section

// NSP configuration
/* Change this IP address to that of your NanoService Platform installation */
uint8_t NSP_address_bytes[] = NSP_IP_ADDRESS;

uint8_t endpoint_name[24] = NODE_NAME; 
uint8_t ep_type[] = ENDPOINT_TYPE;
uint8_t lifetime_ptr[] = LIFE_TIME;  

// ****************************************************************************
// Resource creation

static int create_resources()
{
    sn_nsdl_resource_info_s *resource_ptr = NULL;
    sn_nsdl_ep_parameters_s *endpoint_ptr = NULL;
    
    NSDL_DEBUG("Creating resources");

    /* Create resources */
    resource_ptr = (sn_nsdl_resource_info_s*)nsdl_alloc(sizeof(sn_nsdl_resource_info_s));
    if(!resource_ptr)
        return 0;
    memset(resource_ptr, 0, sizeof(sn_nsdl_resource_info_s));

    resource_ptr->resource_parameters_ptr = (sn_nsdl_resource_parameters_s*)nsdl_alloc(sizeof(sn_nsdl_resource_parameters_s));
    if(!resource_ptr->resource_parameters_ptr)
    {
        nsdl_free(resource_ptr);
        return 0;
    }
    memset(resource_ptr->resource_parameters_ptr, 0, sizeof(sn_nsdl_resource_parameters_s));

    // Static resources
    nsdl_create_static_resource(resource_ptr, sizeof("dev/mfg")-1, (uint8_t*) "dev/mfg", 0, 0,  (uint8_t*) "ARM mbed", sizeof("ARM mbed")-1);
    nsdl_create_static_resource(resource_ptr, sizeof("dev/mdl")-1, (uint8_t*) "dev/mdl", 0, 0,  (uint8_t*) "6LoWPAN node", sizeof("6LoWPAN node")-1);

    // Dynamic resources
#if NODE_HOME
    create_light_resource(resource_ptr); 
    create_HVAC_resource(resource_ptr);
    create_door_resource(resource_ptr);    
#endif
    
#if NODE_SENSOR_STATION    
    create_pressure_resource(resource_ptr); 
    create_temperature_resource(resource_ptr); 
    create_moisture_resource(resource_ptr);
    create_hcho_resource(resource_ptr);
    create_UVsensor_resource(resource_ptr);
#endif   

#if NODE_CONTROLLER
    create_rgbled_resource(resource_ptr); 
#endif

#if BATTERY
    create_battery_resource(resource_ptr); 
#endif


        /* Register with NSP */
    endpoint_ptr = nsdl_init_register_endpoint(endpoint_ptr, (uint8_t*)endpoint_name, ep_type, lifetime_ptr);
    if(sn_nsdl_register_endpoint(endpoint_ptr) != 0)
        printf("NSP registering failed\r\n");
    else
        printf("NSP registering OK\r\n");
    nsdl_clean_register_endpoint(&endpoint_ptr);

    nsdl_free(resource_ptr->resource_parameters_ptr);
    nsdl_free(resource_ptr);
    return 1;
}

// ****************************************************************************
// Program entry point
// this modified to startup as an option in the Wi-Go demo

void nsdl_run()
{

    NSDL_DEBUG("ARM NSP Init\r\n");
    
    // Initialize NSDL stack
    nsdl_init();
     
    // Create NSDL resources
    create_resources();
    
}