Exclusive code for server communication

Dependencies:   mbed-rtos mbed

Fork of test_thread by GR_Peach_Abhinav_Rahul

Revision:
1:0ceb20b56f7f
Parent:
0:adb256c0dfa9
Child:
2:52ecf89221d3
--- a/main.cpp	Sat Dec 03 07:25:30 2016 +0000
+++ b/main.cpp	Mon Jan 09 10:53:01 2017 +0000
@@ -1,24 +1,52 @@
 #include "mbed.h"
 #include "rtos.h"
+#include <string>
  
 DigitalOut led1(LED1);
 DigitalOut led2(LED2);
+std::string data;
+char read_data;
+uint8_t wifi_ack;
+Serial pc(USBTX, USBRX);
+//Serial Wifi(P2_14,P2_15);
+Serial Wifi(P5_0, P5_1);
+bool i = true;
+bool j = false;
+char MSB;
+char LSB;
  
-void led2_thread(void const *args) {
-    int i=0;
-    while (i<4) {
-        led2 = !led2;
-        Thread::wait(1000);
-        i++;
+void reader_thread(void const *args) {
+    while (true) {
+        if(Wifi.readable()){
+            while(Wifi.readable()){
+                read_data = Wifi.getc();
+                pc.putc(read_data);
+            }
+        }
+        Wifi.puts("\n");
+        pc.puts("\n");
     }
 }
+void send_to_device(string command){
+    
+ 
+    }
  
 int main() {
     led1 = 1;
     led2 = 1;
     uint8_t data[3] = {0x47, 0x32, 0xA7};
-    Thread thread(led2_thread);
-    
+    Wifi.puts("AT");
+    Wifi.puts("AT+RST");
+    wait(2);
+    Wifi.puts("AT+CWMODE=3");
+    wait_ms(100);
+    Wifi.puts("AT+CWJAP=\"Username\"+\"Password\"");
+    Wifi.puts("AT+CIPMUX=1");
+    Thread thread(reader_thread);
+    Wifi.puts("AT+CIPSTART=0,\"TCP\",\"localhost/peach/index.php?device_token=jabv5su2&device_id=gr_peach1&command4u=Sent_Something\",80");
+    Wifi.puts("AT+CIPSEND=0,30");
+    Wifi.puts("GET localhost/peach/index.php?device_token=jabv5su2&device_id=gr_peach1&command4u=Sent_Something HTTP/1.1" );
     while (true) {
         led1 = !led1;
         Thread::wait(500);