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.
Fork of test_thread_reneproj by
main.cpp
- Committer:
- RahulSitaram
- Date:
- 2017-02-05
- Revision:
- 6:850122a18e82
- Parent:
- 5:bdabacd90f75
File content as of revision 6:850122a18e82:
#include "mbed.h"
#include "rtos.h"
#include <string>
#include <iostream>
DigitalOut led1(LED1);
DigitalOut led2(LED2);
std::string data;
string command;
uint8_t wifi_ack;
char read_data;
Serial pc(USBTX, USBRX);
//Serial Wifi(P2_14,P2_15);
Serial Wifi(P5_0, P5_1);
bool i = true;
bool j = false;
int k = 1;
char MSB;
char LSB;
void reader_thread(void const *args) {
while (true) {
Wifi.printf("GET reneproj.esy.es/");
Wifi.printf("peach/index.php?device_token=jabv5su2&device");
Wifi.printf("_id=gr_peach1&command4u=00 HTTP/1.1\r\n");
}
}
void read_from_wifi(){
if(Wifi.readable()){
while(Wifi.readable()){
read_data = Wifi.getc();
pc.putc(read_data);
}
}
}
void setup_esp8266(){
Wifi.baud(9600);
pc.baud(9600);
Wifi.puts("AT\r\n");
wait(8);
Wifi.puts("AT+RST\r\n");
wait(8);
Wifi.puts("AT+CWMODE=3\r\n");
wait(8);
Wifi.puts("AT+CWJAP=\"Googol\",\"sudopass\"\r\n");
wait(8);
Wifi.puts("AT+CIPMUX=1\r\n");
wait(8);
Wifi.printf("AT+CIPSTART=0,\"TCP\",\"reneproj.esy.es\"");
wait(4);
Wifi.printf(",80\r\n");
wait(8);
Wifi.puts("AT+CIPSEND=0,30\r\n");
wait(8);
Thread thread(reader_thread);
}
void send_command(){
pc.printf("sending command");
Wifi.printf("AT+RST\r");
Wifi.printf("\n");
Wifi.printf("\r");
Wifi.printf("\n");
wait_ms(7000);
Wifi.printf("AT+CIPSTART=\"TCP\",\"184.106.153.149\",80\r");
Wifi.printf("\n");
wait_ms(7000);
Wifi.printf("AT+CIPSEND=51\r");
Wifi.printf("\n");
wait_ms(2000);
Wifi.printf("GET /update?api_key=ECSZCMRZJF1ZQDNY&field1=");
Wifi.printf("%d",k);
Wifi.printf("\n");
Wifi.printf("\n");
Wifi.printf("\n");
Wifi.printf("\n");
Wifi.printf("\n");
Wifi.printf("\r");
wait_ms(7000);
k++;
}
int main() {
Wifi.attach(&read_from_wifi);
// setup_esp8266();
while (true) {
send_command();
wait_ms(7000);
}
}
