Increments the value by 1

Dependencies:   mbed-rtos mbed

Fork of test_thread_reneproj by GR_Peach_Abhinav_Rahul

Committer:
RahulSitaram
Date:
Mon Jan 09 17:42:39 2017 +0000
Revision:
3:e8db31793029
Parent:
2:52ecf89221d3
Child:
4:fd0d5e707091
This is the update of the previous version handling some errors

Who changed what in which revision?

UserRevisionLine numberNew contents of line
akverma 0:adb256c0dfa9 1 #include "mbed.h"
akverma 0:adb256c0dfa9 2 #include "rtos.h"
RahulSitaram 1:0ceb20b56f7f 3 #include <string>
akverma 0:adb256c0dfa9 4
akverma 0:adb256c0dfa9 5 DigitalOut led1(LED1);
akverma 0:adb256c0dfa9 6 DigitalOut led2(LED2);
RahulSitaram 1:0ceb20b56f7f 7 std::string data;
RahulSitaram 1:0ceb20b56f7f 8 char read_data;
RahulSitaram 1:0ceb20b56f7f 9 uint8_t wifi_ack;
RahulSitaram 1:0ceb20b56f7f 10 Serial pc(USBTX, USBRX);
RahulSitaram 1:0ceb20b56f7f 11 //Serial Wifi(P2_14,P2_15);
RahulSitaram 1:0ceb20b56f7f 12 Serial Wifi(P5_0, P5_1);
RahulSitaram 1:0ceb20b56f7f 13 bool i = true;
RahulSitaram 1:0ceb20b56f7f 14 bool j = false;
RahulSitaram 1:0ceb20b56f7f 15 char MSB;
RahulSitaram 1:0ceb20b56f7f 16 char LSB;
akverma 0:adb256c0dfa9 17
RahulSitaram 1:0ceb20b56f7f 18 void reader_thread(void const *args) {
RahulSitaram 1:0ceb20b56f7f 19 while (true) {
RahulSitaram 1:0ceb20b56f7f 20 if(Wifi.readable()){
RahulSitaram 1:0ceb20b56f7f 21 while(Wifi.readable()){
RahulSitaram 1:0ceb20b56f7f 22 read_data = Wifi.getc();
RahulSitaram 1:0ceb20b56f7f 23 pc.putc(read_data);
RahulSitaram 1:0ceb20b56f7f 24 }
RahulSitaram 1:0ceb20b56f7f 25 }
akverma 0:adb256c0dfa9 26 }
akverma 0:adb256c0dfa9 27 }
RahulSitaram 1:0ceb20b56f7f 28 void send_to_device(string command){
RahulSitaram 1:0ceb20b56f7f 29
RahulSitaram 1:0ceb20b56f7f 30
RahulSitaram 1:0ceb20b56f7f 31 }
RahulSitaram 2:52ecf89221d3 32 void setup_esp8266(){
RahulSitaram 2:52ecf89221d3 33 Wifi.baud(9600);
RahulSitaram 2:52ecf89221d3 34 pc.baud(9600);
RahulSitaram 2:52ecf89221d3 35 Wifi.puts("AT\r\n");
RahulSitaram 2:52ecf89221d3 36 wait(8);
RahulSitaram 2:52ecf89221d3 37 Wifi.puts("AT+RST\r\n");
RahulSitaram 2:52ecf89221d3 38 wait(8);
RahulSitaram 2:52ecf89221d3 39 Wifi.puts("AT+CWMODE=3\r\n");
RahulSitaram 2:52ecf89221d3 40 wait(8);
RahulSitaram 2:52ecf89221d3 41 Wifi.puts("AT+CWJAP=\"Googol\",\"sudopass\"\r\n");
RahulSitaram 2:52ecf89221d3 42 wait(8);
RahulSitaram 2:52ecf89221d3 43 Wifi.puts("AT+CIPMUX=1\r\n");
RahulSitaram 2:52ecf89221d3 44 wait(8);
RahulSitaram 2:52ecf89221d3 45 Wifi.printf("AT+CIPSTART=0,\"TCP\",\"reneproj.esy.es\"");
RahulSitaram 2:52ecf89221d3 46 wait(4);
RahulSitaram 2:52ecf89221d3 47 Wifi.printf(",80\r\n");
RahulSitaram 2:52ecf89221d3 48 wait(8);
RahulSitaram 2:52ecf89221d3 49 Wifi.puts("AT+CIPSEND=0,30\r\n");
RahulSitaram 2:52ecf89221d3 50 wait(8);
RahulSitaram 3:e8db31793029 51 Wifi.printf("GET reneproj.esy.es/");
RahulSitaram 3:e8db31793029 52 Wifi.printf("peach/index.php?device_token=jabv5su2&device");
RahulSitaram 3:e8db31793029 53 Wifi.printf("_id=gr_peach1&command4u=00 HTTP/1.1\r\n");
RahulSitaram 2:52ecf89221d3 54 wait(8);
RahulSitaram 2:52ecf89221d3 55 }
akverma 0:adb256c0dfa9 56
akverma 0:adb256c0dfa9 57 int main() {
RahulSitaram 2:52ecf89221d3 58 setup_esp8266();
RahulSitaram 2:52ecf89221d3 59 Thread thread(reader_thread);
akverma 0:adb256c0dfa9 60 uint8_t data[3] = {0x47, 0x32, 0xA7};
akverma 0:adb256c0dfa9 61 while (true) {
RahulSitaram 2:52ecf89221d3 62 wait(10);
akverma 0:adb256c0dfa9 63 }
akverma 0:adb256c0dfa9 64 }