Yonariel Hernandez
/
Proyecto-Final_copy_petey
kio
source/main-http.cpp
- Committer:
- yonaetworks
- Date:
- 2021-08-05
- Revision:
- 2:4745484bc533
- Parent:
- 1:078a6d9a2ae3
File content as of revision 2:4745484bc533:
#include "select-demo.h" #if DEMO == DEMO_HTTP #include "mbed.h" #include "http_request.h" #include "network-helper.h" #include "mbed_mem_trace.h" #include <iostream> #include <cstring> #include <Thread.h> #include <stdio.h> #include "EthernetInterface.h" //MAHER WAS HERE DigitalOut PUERTA1(PG_9); DigitalOut PUERTA2(PG_14); DigitalOut PUERTA3(PF_15); DigitalOut PUERTA4(PE_13); Serial sim808(PD_5, PD_6,9600); int onetime = 0, i=0, j=0, onedbquery[4]; const int kMaxBufferSize = 100; char buffer[kMaxBufferSize]; string opendoors = "http://192.168.1.10/ws/ws.php?op=micopendoors&telefono="; string closedoors = "http://192.168.1.10/ws/ws.php?op=micclosedoors&telefono="; string registers = "http://192.168.1.10/ws/ws.php?op=create-register&telefono="; char linkdoors[40]= "http://192.168.1.10/ws/ws.php?op=doors"; string linkregister01 = ""; string linkregister02; string linkregister03; string linkregister04; char char_linkregister01[55]; char char_linkregister02[55]; char char_linkregister03[55]; char char_linkregister04[55]; char linkopendoors[100]; char linkclosedoors[100]; char linkregisters[100]; string link_string; string http_response = ""; int len = 0; char telbuf[11]; int mensaje=0; Timer t; void dump_response(HttpResponse* res) { http_response = res->get_body_as_string().c_str(); } string petname = "señormajer" int main() { //-------------------------------------------------------------------- INICIALIZACION DE PINES ------------------------------------------------------------------------------------------- // string linkregister01 = "http://192.168.100.204/post.php?name=SOYMBED&submit=send"; //-------------------------------------------------------------------- INICIALIZACION DE TARJETA DE RED ------------------------------------------------------------------------------------------- NetworkInterface* network = connect_to_default_network_interface(); if (!network) { printf("Cannot connect to the network, see serial output\n"); return 1; } //-------------------------------------------------------------------- CREACION DE PET-------------------------------------------------------------------------------------------------- // Do a GET request to httpbin.org { // By default the body is automatically parsed and stored in a buffer, this is memory heavy. // To receive chunked response, pass in a callback as last parameter to the constructor. HttpRequest* get_req = new HttpRequest(network, HTTP_GET, "http://192.168.100.204:8443/post.php?name=%petname%"); HttpResponse* get_res = get_req->send(); if (!get_res) { printf("HttpRequest failed (error code %d)\n", get_req->get_error()); return 1; } dump_response(get_res); printf("\n----- HTTP GET response -----\n", get_res); delete get_req; } } #endif