ported Axeda app. to mbed LPC1114FN28 with WIZ550io

Dependencies:   W5500Interface mbed

Fork of AxedaGo-mbedNXP by Axeda Corp

Files at this revision

API Documentation at this revision

Comitter:
embeddist
Date:
Wed Mar 04 10:33:10 2015 +0000
Parent:
6:1f7647c5691a
Commit message:
ported Axeda app. to mbed LPC1114FN28 with WIZ550io

Changed in this revision

EthernetInterface.lib Show diff for this revision Revisions of this file
W5500Interface.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-rtos.lib Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- a/EthernetInterface.lib	Thu Jun 26 16:58:53 2014 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://mbed.org/users/mbed_official/code/EthernetInterface/#cba86db5ab96
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/W5500Interface.lib	Wed Mar 04 10:33:10 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/teams/EthernetInterfaceW5500-makers/code/W5500Interface/#713b6d2aaefb
--- a/main.cpp	Thu Jun 26 16:58:53 2014 +0000
+++ b/main.cpp	Wed Mar 04 10:33:10 2015 +0000
@@ -1,22 +1,29 @@
 #include "mbed.h"
 #include "EthernetInterface.h"
- 
-EthernetInterface eth;
- 
-AnalogIn pot1(p19);
-AnalogIn pot2(p20);
-TCPSocketConnection sock;
- 
+
+#if defined(TARGET_LPC1114)
+    SPI spi(dp2, dp1, dp6); // mosi, miso, sclk
+    EthernetInterface eth(&spi, dp25, dp26); // spi, cs, reset
+    AnalogIn pot1(dp13);
+#else
+    EthernetInterface eth;
+    AnalogIn pot1(p19);
+    AnalogIn pot2(p20);
+#endif 
+
+#if defined(TARGET_LPC1768)
 DigitalOut led1(LED1);
 DigitalOut led2(LED2);
 DigitalOut led3(LED3);
-DigitalOut led4(LED4);
+DigitalOut led4(LED4); 
+#endif
+
+TCPSocketConnection sock;
  
 int main() 
 {
-    
     char *MODEL = "mbed";
-    char *SERIAL_NUM = "SerialNumber"; 
+    char *SERIAL_NUM = "nlr__embeddist_gmail_com___343881"; 
     float DEADBAND = 0.015;
     
     char* ip;
@@ -27,10 +34,12 @@
     char buffer[buffer_sz];  
     int returnCode = 0;
     
+#if defined(TARGET_LPC1768)    
     led1 = 1;
     led2 = 1;
     led3 = 1;
     led4 = 1;
+#endif
     
     printf("initializing Ethernet\r\n");
     returnCode = eth.init(); //Use DHCP
@@ -38,7 +47,9 @@
     if ( returnCode == 0 )
     {
         printf(" - Ethernet ready\r\n");
+#if defined(TARGET_LPC1768)    
         led1 = returnCode;
+#endif        
     }
     else
     {
@@ -49,10 +60,14 @@
     printf("Ethernet.connecting \r\n");
     returnCode = eth.connect();
     printf(" - connecting returned %d \r\n", returnCode);
+#if defined(TARGET_LPC1768)    
     led2 = returnCode != -1 ? 0: 1;
+#endif    
     printf("Trying to get IP address..\r\n");
     ip = eth.getIPAddress();
+#if defined(TARGET_LPC1768)        
     led3 = strlen(ip)<4 ? 1: 0;
+#endif    
     printf("  -  IP address:%s\r\n", ip);
     
     float oil_level = 0.0;
@@ -63,19 +78,25 @@
     while(1) {
     
         oil_level = pot1.read();
+#if defined(TARGET_LPC1768)            
         oil_level2=pot2.read();
-        
-        if ( abs(oil_level - oldPotVal) < DEADBAND && abs(oil_level2 - oldPotVal2) < DEADBAND)
+#endif        
+        //if ( abs(oil_level - oldPotVal) < DEADBAND && abs(oil_level2 - oldPotVal2) < DEADBAND) //LPC1768
+        if ( abs(oil_level - oldPotVal) < DEADBAND) //LPC1114
         {
             continue;   
         }
         else
         {
-            led4 = 1;
+            //led4 = 1;
             oldPotVal = oil_level;
-            oldPotVal2 = oil_level2;
+#if defined(TARGET_LPC1768)            
+            oldPotVal2 = oil_level2; 
+#endif            
             printf("Sending Value for well1 %.2f\n\r", oil_level);
+#if defined(TARGET_LPC1768)                        
             printf("Sending Value for well2 %.2f\n\r", oil_level2);
+#endif            
             sock.connect("toolbox-connect.axeda.com", 80);
  
             snprintf(http_cmd, http_cmd_sz,  "POST /ammp/data/1/%s!%s HTTP/1.1\r\nContent-Type: application/json\r\nContent-Length: 65\r\n\r\n{\"data\":[{\"di\":{\"oil_level\":%.2f, \"oil_level2\":%.2f}}]}\r\n\r\n", MODEL, SERIAL_NUM, oil_level, oil_level2);
@@ -86,7 +107,7 @@
                 buffer[returnCode] = '\0';
                 printf("Received %d chars from server:\n\r%s\n", returnCode, buffer);
             }
-            led4 = returnCode;
+            //led4 = returnCode;
             sock.close();
         }
  
--- a/mbed-rtos.lib	Thu Jun 26 16:58:53 2014 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://mbed.org/users/mbed_official/code/mbed-rtos/#ee87e782d34f
--- a/mbed.bld	Thu Jun 26 16:58:53 2014 +0000
+++ b/mbed.bld	Wed Mar 04 10:33:10 2015 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/a9913a65894f
\ No newline at end of file
+http://mbed.org/users/mbed_official/code/mbed/builds/9ad691361fac
\ No newline at end of file