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: EthernetInterface PololuLedStripx mbed-rtos mbed nanoservice_client_1_12_X
Fork of LPC1768_LWM2M_Client by
Revision 4:71b211dbe14c, committed 2014-09-28
- Comitter:
- michaeljkoster
- Date:
- Sun Sep 28 01:00:23 2014 +0000
- Parent:
- 3:e3aa908cbb51
- Child:
- 5:fcfba34d1aeb
- Commit message:
- MAC address based EP name
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Sun Sep 28 00:09:18 2014 +0000
+++ b/main.cpp Sun Sep 28 01:00:23 2014 +0000
@@ -11,6 +11,8 @@
//#define LED_COUNT 120
rgb_color colors[LED_COUNT];
+extern "C" void mbed_mac_address(char *mac);
+
Serial pc(USBTX, USBRX); // tx, rx
// ****************************************************************************
@@ -31,15 +33,17 @@
static const char* NSP_ADDRESS = "23.99.99.252"; // barista.cloudapp.net
//static const char* NSP_ADDRESS = "192.168.1.200";
static const int NSP_PORT = 5683;
-char endpoint_name[24] = "mbed-LED-booth-1";
+char endpoint_name[24] = "LED-booth-";
uint8_t ep_type[] = {"mbed_device"};
uint8_t lifetime_ptr[] = {"60"};
+char mac[6];
+char macstring[13] ;
+
// ****************************************************************************
// Ethernet initialization
EthernetInterface eth;
-
static void ethernet_init()
{
@@ -71,6 +75,10 @@
nsp.set_address(NSP_ADDRESS, NSP_PORT);
+ mbed_mac_address(mac);
+ sprintf(macstring, "%02X%02X%02X%02X%02X%02X", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
+ strncat(endpoint_name, macstring, 12);
+
NSDL_DEBUG("name: %s", endpoint_name);
NSDL_DEBUG("NSP=%s - port %d\n", NSP_ADDRESS, NSP_PORT);
