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 mbed-rtos mbed
Fork of Ethernet_K64F by
Diff: main.cpp
- Revision:
- 0:9eca947a9efa
- Child:
- 1:8c684ad7d00e
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Thu May 19 06:52:59 2016 +0000
@@ -0,0 +1,68 @@
+#include "mbed.h"
+#include "EthernetInterface.h"
+
+char* Public_Key = "ro9WnDLy63t4xp5n18vm";
+char* Private_Key = "jkKr0obAEnS0MgJRNa92";
+char* ServerIP = "data.sparkfun.com";
+
+Serial pc(USBTX, USBRX);
+
+EthernetInterface ethernet;
+
+int main()
+{
+ pc.baud(115200);
+ pc.printf("Start\r\n");
+ int a=100;
+ while(1)
+ {
+ int ret = ethernet.init();
+ if (!ret)
+ {
+ pc.printf("Initialized, MAC: %s\r\n", ethernet.getMACAddress());
+ ret = ethernet.connect();
+ if (!ret)
+ {
+ pc.printf("IP: %s, MASK: %s, GW: %s\r\n",
+ ethernet.getIPAddress(), ethernet.getNetworkMask(), ethernet.getGateway());
+ }
+ else
+ {
+ pc.printf("Error ethernet.connect() - ret = %d\r\n", ret);
+ exit(0);
+ }
+ }
+ else
+ {
+ pc.printf("Error ethernet.init() - ret = %d\r\n", ret);
+ exit(0);
+ }
+ TCPSocketConnection sock;
+ char buffer[300];
+ int ret_t;
+ char http_cmd[256];
+ while(1)
+ {
+
+ sock.connect(ServerIP, 80);
+ if(sock.is_connected())
+ printf("Socket Connected\n\r");
+ else
+ printf("Socket NoT Connected\n\r");
+ //sprintf(http_cmd,"GET /input/%s?private_key=%s&a=%2d HTTP/1.0\n\n",Public_Key,Private_Key,a);
+ sprintf(http_cmd,"GET /input/%s?private_key=%s&a=%2d HTTP/1.0\n\n",Public_Key,Private_Key,a);
+ pc.printf("Running - %s\r\n",http_cmd);
+ sock.send_all(http_cmd, sizeof(http_cmd)-1);
+
+ ret_t = sock.receive(buffer, sizeof(buffer)-1);
+ buffer[ret_t] = '\0';
+ pc.printf("Received %d chars from server:\n%s\r\n", ret_t, buffer);
+ sock.close();
+ a=a+1;
+ wait(5);
+ }
+
+ }
+
+
+ }
