Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: fsl_phy_mcr20a fsl_smac mbed-rtos mbed
Fork of mcr20_wireless_uart by
Diff: NSDL/nsdl_run.cpp
- Revision:
- 2:3e7685cfb2a7
- Child:
- 3:a38ad504a18c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/NSDL/nsdl_run.cpp Thu Mar 05 15:47:08 2015 +0000 @@ -0,0 +1,111 @@ +#include "mbed.h" +#include "nsdl_support.h" +#include "nsdl_dbg.h" + +#include "node_cfg.h" + +#include "rgb.h" +#include "battery.h" +#include "light.h" +#include "HVAC.h" +#include "door.h" +#include "pressure.h" +#include "temperature.h" +#include "moisture.h" +#include "hcho.h" +#include "UVsensor.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(); + +} +