This is a full demo that connects to mbed Device Server. It is used with a I2C Grove Color sensor, so it should be compatible on all platforms that support Ethernet.
Dependencies: ColorDetectorV2 EthernetInterface mbed-rtos mbed nsdl
Fork of nespresso_endpoint by
mbed Software Configuration
The default mbed Device Server (NSP or mDS) configuration is used by an instance of the web app (Barista) here: http://barista-test.cloudapp.net:4005.
In main.cpp, find the following lines:
// **************************************************************************** // Configuration section // I2C Settings #define COLOR_SENSOR_SCL I2C_SCL #define COLOR_SENSOR_SDA I2C_SDA // Ethernet configuration /* Define this to enable DHCP, otherwise manual address configuration is used */ #define DHCP /* Manual IP configurations, if DHCP not defined */ #define IP "0.0.0.0" #define MASK "255.255.255.0" #define GW "0.0.0.0" // NSP configuration /* Change this IP address to that of your mbed Device Server installation if you're not using mbed Connector */ static const char* NSP_ADDRESS = "api.connector.mbed.org"; static const int NSP_PORT = 5683; char endpoint_name[] = "nespresso-machine-ethernet"; uint8_t ep_type[] = {"nespresso-endpoint"}; char nsp_domain[] = "56645321f5e24c49908e42f4d71b9ccb"; uint8_t lifetime_ptr[] = {"1200"}; // ****************************************************************************
Edit COLOR_SENSOR_SCL
and COLOR_SENSOR_SDA
to the appropriate I2C pins on your mbed platform.
You should not edit the DHCP/static IP settings if you are not using a static IP address. If you are using a static IP address, provide the appropriate information and remove the following line:
#define DHCP
Change endpoint_name
to uniquely identify your Nespresso endpoint.
If you are using mbed Connector, change the nsp_domain
string to your domain.
If you are using your own installation of mDS, you should change NSP_ADDRESS
to the url of your mDS installation, NSP_PORT
if you're using a non default port on mDS for CoAP, and nsp_domain
to a valid domain on your mDS instance ("domain" is the default mDS domain).
nsdl_support.h@6:9e3f6270fcb0, 2015-05-19 (annotated)
- Committer:
- bridadan
- Date:
- Tue May 19 19:17:41 2015 +0000
- Revision:
- 6:9e3f6270fcb0
- Parent:
- 0:0782597771bc
Fixed update registration issue
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
bridadan | 0:0782597771bc | 1 | // Support functions for the NSDL library |
bridadan | 0:0782597771bc | 2 | |
bridadan | 0:0782597771bc | 3 | #ifndef NSDL_SUPPORT_H |
bridadan | 0:0782597771bc | 4 | #define NSDL_SUPPORT_H |
bridadan | 0:0782597771bc | 5 | |
bridadan | 0:0782597771bc | 6 | #include "mbed.h" |
bridadan | 0:0782597771bc | 7 | #include <stdint.h> |
bridadan | 0:0782597771bc | 8 | #include "sn_nsdl.h" |
bridadan | 0:0782597771bc | 9 | #include "sn_coap_header.h" |
bridadan | 0:0782597771bc | 10 | #include "sn_coap_protocol.h" |
bridadan | 0:0782597771bc | 11 | #include "sn_nsdl_lib.h" |
bridadan | 0:0782597771bc | 12 | |
bridadan | 0:0782597771bc | 13 | typedef uint8_t (*sn_grs_dyn_res_callback_t)(sn_coap_hdr_s *, sn_nsdl_addr_s *, sn_proto_info_s *); |
bridadan | 0:0782597771bc | 14 | |
bridadan | 0:0782597771bc | 15 | extern "C" void *nsdl_alloc(uint16_t size); |
bridadan | 0:0782597771bc | 16 | extern "C" void nsdl_free(void* ptr_to_free); |
bridadan | 0:0782597771bc | 17 | void nsdl_create_static_resource(sn_nsdl_resource_info_s *resource_structure, uint16_t pt_len, uint8_t *pt, uint16_t rpp_len, uint8_t *rpp_ptr, uint8_t *rsc, uint16_t rsc_len); |
bridadan | 0:0782597771bc | 18 | void nsdl_create_dynamic_resource(sn_nsdl_resource_info_s *resource_structure, uint16_t pt_len, uint8_t *pt, uint16_t rpp_len, uint8_t *rpp_ptr, uint8_t is_observable, sn_grs_dyn_res_callback_t callback_ptr, int access_right); |
bridadan | 0:0782597771bc | 19 | sn_nsdl_ep_parameters_s* nsdl_init_register_endpoint(sn_nsdl_ep_parameters_s *endpoint_structure, uint8_t* name, uint8_t* ypename_ptr, uint8_t *lifetime_ptr); |
bridadan | 0:0782597771bc | 20 | void nsdl_clean_register_endpoint(sn_nsdl_ep_parameters_s **endpoint_structure); |
bridadan | 0:0782597771bc | 21 | void nsdl_init(); |
bridadan | 0:0782597771bc | 22 | void nsdl_event_loop_init(); |
bridadan | 0:0782597771bc | 23 | void nsdl_event_loop_run_once(); |
bridadan | 6:9e3f6270fcb0 | 24 | bool register_endpoint(bool init); |
bridadan | 0:0782597771bc | 25 | |
bridadan | 0:0782597771bc | 26 | #endif // NSDL_SUPPORT_H |