![](/media/cache/group/arm_mbed.PNG.50x50_q85.png)
LED Demo for Tech Con 2014
Dependencies: EthernetInterface PololuLedStripx mbed-rtos mbed nanoservice_client_1_12_X
Fork of LPC1768_LWM2M_Client by
Diff: main.cpp
- Revision:
- 14:25430e88728f
- Parent:
- 11:3e5ac016a106
- Child:
- 15:2f2b3eaa51a6
--- a/main.cpp Sat Oct 04 04:58:32 2014 +0000 +++ b/main.cpp Sat Oct 04 05:12:45 2014 +0000 @@ -1,13 +1,12 @@ #include "mbed.h" -#include "WiflyInterface.h" +#include "EthernetInterface.h" #include "nsdl_support.h" #include "dbg.h" - // Include resources #include "light.h" +#include "IAP.h" #include "PololuLedStrip.h" - -PololuLedStrip ledStrip(D2); +PololuLedStrip ledStrip(P0_4); //#define LED_COUNT 60 #define LED_COUNT 120 rgb_color colors[LED_COUNT]; @@ -26,13 +25,36 @@ #define MASK "255.255.255.0" #define GW "10.0.0.1" +extern "C" void mbed_mac_address(char *mac) +{ + static char buf[64] = {0}; + IAP iap; + int32_t *block = iap.read_serial(); + uint32_t serial_number[5] = {0}; + + memset(buf, 0, sizeof(buf)); + serial_number[0] = *(block); + serial_number[1] = *(block+1); + // we only want bottom 16 bits of word1 (MAC bits 32-47) + // and bit 9 forced to 1, bit 8 forced to 0 + // Locally administered MAC, reduced conflicts + // http://en.wikipedia.org/wiki/MAC_address + //serial_number[0] |= 0x00000200; + //serial_number[0] &= 0x0000FEFF; + memcpy(mac, (uint8_t*) &serial_number[0], 6); + mac[0] |= 0x02; + mac[0] &= 0xFE; + mac[5] |= 0x02; + mac[5] &= 0xFE; + + // snprintf(buf, 16, "%4X%08X", serial_number[0], serial_number[1]); +} // NSP configuration /* Change this IP address to that of your NanoService Platform installation */ //static const char* NSP_ADDRESS = "217.140.101.20"; /* public mbed demo server */ -static const char* NSP_ADDRESS = "54.228.25.31"; //leshan sandbox -//static const char* NSP_ADDRESS = "23.99.99.252"; // barista.cloudapp.net +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] = "LED-booth-"; @@ -42,9 +64,7 @@ // **************************************************************************** // Ethernet initialization -//EthernetInterface eth; -WiflyInterface eth(D1, D0, D5, LED1, "demo", "ARMDEMO1", WPA); - +EthernetInterface eth; static void ethernet_init() { /* Initialize network */ @@ -56,7 +76,7 @@ eth.init(IP, MASK, GW); NSDL_DEBUG("eth.init\r\n"); #endif - if(eth.connect() == 0) + if(eth.connect(30000) == 0) pc.printf("Connect OK\n\r"); NSDL_DEBUG("IP Address:%s ", eth.getIPAddress());