NanoService Device Library Hello World Ported to K64F
Dependencies: EthernetInterface mbed-rtos mbed nsdl_lib
Fork of NSDL_HelloWorld by
Revision 9:16f54efbb5fe, committed 2016-02-29
- Comitter:
- romedius
- Date:
- Mon Feb 29 05:09:16 2016 +0000
- Parent:
- 8:cdf868ccae03
- Child:
- 10:1875353284c1
- Commit message:
- Port for K64f
Changed in this revision
--- a/Beep.lib Mon Aug 04 17:00:58 2014 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -http://mbed.org/users/shimniok/code/Beep/#3eb39e374fc3
--- a/C12832_lcd.lib Mon Aug 04 17:00:58 2014 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -https://mbed.org/users/dreschpe/code/C12832_lcd/#8f86576007d6
--- a/EthernetInterface.lib Mon Aug 04 17:00:58 2014 +0000 +++ b/EthernetInterface.lib Mon Feb 29 05:09:16 2016 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/EthernetInterface/#f69b81aa9eb1 +http://mbed.org/users/mbed_official/code/EthernetInterface/#4d7bff17a592
--- a/LM75B.lib Mon Aug 04 17:00:58 2014 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -https://mbed.org/users/chris/code/LM75B/#6a70c9303bbe
--- a/MMA7660.lib Mon Aug 04 17:00:58 2014 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -https://mbed.org/users/Sissors/code/MMA7660/#36a163511e34
--- a/main.cpp Mon Aug 04 17:00:58 2014 +0000 +++ b/main.cpp Mon Feb 29 05:09:16 2016 +0000 @@ -1,6 +1,6 @@ #include "mbed.h" #include "EthernetInterface.h" -#include "C12832_lcd.h" +//#include "C12832_lcd.h" #include "nsdl_support.h" #include "dbg.h" // Include various resources @@ -9,7 +9,7 @@ #include "gps.h" #include "relay.h" -static C12832_LCD lcd; +// static C12832_LCD lcd; Serial pc(USBTX, USBRX); // tx, rx // **************************************************************************** @@ -26,9 +26,10 @@ // NSP configuration /* Change this IP address to that of your NanoService Platform installation */ -static const char* NSP_ADDRESS = "217.140.101.20"; /* demo NSP, web interface at http://nanoservice-demo.mbed.org */ +//static const char* NSP_ADDRESS = "217.140.101.20"; /* demo NSP, web interface at http://nanoservice-demo.mbed.org */ +static const char* NSP_ADDRESS = "192.168.0.38"; /* demo NSP, web interface at http://nanoservice-demo.mbed.org */ static const int NSP_PORT = 5683; -char endpoint_name[16] = "mbed-"; +char endpoint_name[16] = "mbed-clientCoAP"; uint8_t ep_type[] = {"mbed_device"}; uint8_t lifetime_ptr[] = {"1200"}; @@ -39,7 +40,6 @@ static void ethernet_init() { - char mbed_uid[33]; // for creating unique name for the board /* Initialize network */ #ifdef DHCP @@ -51,12 +51,8 @@ if(eth.connect(30000) == 0) pc.printf("Connect OK\n\r"); - mbed_interface_uid(mbed_uid); - mbed_uid[32] = '\0'; - strncat(endpoint_name, mbed_uid + 27, 15 - strlen(endpoint_name)); - - lcd.locate(0,11); - lcd.printf("IP:%s", eth.getIPAddress()); + //lcd.locate(0,11); + //lcd.printf("IP:%s", eth.getIPAddress()); NSDL_DEBUG("IP Address:%s ", eth.getIPAddress()); } @@ -77,8 +73,8 @@ NSDL_DEBUG("name: %s", endpoint_name); NSDL_DEBUG("NSP=%s - port %d\n", NSP_ADDRESS, NSP_PORT); - lcd.locate(0,22); - lcd.printf("EP name:%s\n", endpoint_name); + //lcd.locate(0,22); + //lcd.printf("EP name:%s\n", endpoint_name); } // **************************************************************************** @@ -133,9 +129,16 @@ int main() { - lcd.cls(); - lcd.locate(0,0); - lcd.printf("mbed NanoService demo"); + + pc.printf("Starting\r\n"); + for(int i=15; i > 0; i--){ + pc.printf("Starting in %d Seconds\r\n", i); + wait(1.0); + } + + //lcd.cls(); + //lcd.locate(0,0); + //lcd.printf("mbed NanoService demo"); NSDL_DEBUG("mbed NanoService Example App 0.1\n"); // Initialize Ethernet interface first
--- a/mbed-rtos.lib Mon Aug 04 17:00:58 2014 +0000 +++ b/mbed-rtos.lib Mon Feb 29 05:09:16 2016 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/mbed-rtos/#34e80e862021 +http://mbed.org/users/mbed_official/code/mbed-rtos/#b4c5542476ba
--- a/mbed.bld Mon Aug 04 17:00:58 2014 +0000 +++ b/mbed.bld Mon Feb 29 05:09:16 2016 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/mbed/builds/6213f644d804 \ No newline at end of file +http://mbed.org/users/mbed_official/code/mbed/builds/252557024ec3 \ No newline at end of file
--- a/nsdl_lib.lib Mon Aug 04 17:00:58 2014 +0000 +++ b/nsdl_lib.lib Mon Feb 29 05:09:16 2016 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/teams/Sensinode/code/nsdl_lib/#388450b1e776 +http://developer.mbed.org/teams/Sensinode/code/nsdl_lib/#8a47d4c71067
--- a/resources/light.cpp Mon Aug 04 17:00:58 2014 +0000 +++ b/resources/light.cpp Mon Feb 29 05:09:16 2016 +0000 @@ -7,9 +7,9 @@ #define LIGHT_RES_ID "lt/0/dim" extern Serial pc; -//PwmOut led1(LED1); -static PwmOut led2(LED2); -static PwmOut led3(LED3); +static DigitalOut led1(LED1); +static DigitalOut led2(LED2); +static DigitalOut led3(LED3); //PwmOut led4(LED4); /* Only GET and PUT method allowed */ @@ -43,8 +43,8 @@ led_dimm = led_dimm/100; //led1.write(led_dimm); - led2.write(led_dimm); - led3.write(led_dimm); + //led2.write(led_dimm); + //led3.write(led_dimm); //led4.write(led_dimm); coap_res_ptr = sn_coap_build_response(received_coap_ptr, COAP_MSG_CODE_RESPONSE_CHANGED);
--- a/resources/relay.cpp Mon Aug 04 17:00:58 2014 +0000 +++ b/resources/relay.cpp Mon Feb 29 05:09:16 2016 +0000 @@ -3,12 +3,11 @@ #include "mbed.h" #include "nsdl_support.h" #include "relay.h" -#include "Beep.h" +//#include "Beep.h" #define RELAY_RES_ID "beep/0/on" extern Serial pc; -static Beep buzzer(p26); /* Only GET and PUT method allowed */ static uint8_t relay_resource_cb(sn_coap_hdr_s *received_coap_ptr, sn_nsdl_addr_s *address, sn_proto_info_s * proto) @@ -32,13 +31,13 @@ { if(*(received_coap_ptr->payload_ptr) == '1') { - buzzer.beep(1000,0); + // replace with blink buzzer.beep(1000,0); relay_state = '1'; } else if(*(received_coap_ptr->payload_ptr) == '0') { - buzzer.nobeep(); + // buzzer.nobeep(); relay_state = '0'; } coap_res_ptr = sn_coap_build_response(received_coap_ptr, COAP_MSG_CODE_RESPONSE_CHANGED);
--- a/resources/temperature.cpp Mon Aug 04 17:00:58 2014 +0000 +++ b/resources/temperature.cpp Mon Feb 29 05:09:16 2016 +0000 @@ -2,13 +2,13 @@ #include "mbed.h" #include "rtos.h" -#include "LM75B.h" +// #include "LM75B.h" #include "nsdl_support.h" #include "temperature.h" #define TEMP_RES_ID "sen/temp" -static LM75B tmp(p28,p27); +// static LM75B tmp(p28,p27); /* stored data for observable resource */ static uint8_t obs_number = 0; static uint8_t *obs_token_ptr = NULL; @@ -29,7 +29,7 @@ if((!(time % 10)) && obs_number != 0 && obs_token_ptr != NULL) { obs_number++; - sprintf(temp_val,"%2.2f" ,tmp.read()); + sprintf(temp_val,"%2.2f" ,24.32); if(sn_nsdl_send_observation_notification(obs_token_ptr, obs_token_len, (uint8_t*)temp_val, 5, &obs_number, 1, COAP_MSG_TYPE_NON_CONFIRMABLE, 0) == 0) pc.printf("Observation sending failed\r\n"); else @@ -42,7 +42,7 @@ /* Observable resource */ static uint8_t temp_resource_cb(sn_coap_hdr_s *received_coap_ptr, sn_nsdl_addr_s *address, sn_proto_info_s * proto) { - sprintf(temp_val,"%2.2f" ,tmp.read()); + sprintf(temp_val,"%2.2f" ,42.23); sn_coap_hdr_s *coap_res_ptr = 0; pc.printf("temp callback\r\n");