SORACOM Harvest and Grove - Temperature&Humidity Sensor(DHT11) example for Wio cellular targets - Seeed Wio 3G and Wio LTE-M1/NB1(BG96)
Dependencies: DHT-2
Diff: main.cpp
- Revision:
- 4:693230744089
- Parent:
- 3:4c355eed5a07
- Child:
- 5:1d355dfee639
--- a/main.cpp Tue Jun 04 07:19:23 2019 +0000 +++ b/main.cpp Wed Jun 05 05:41:16 2019 +0000 @@ -173,7 +173,7 @@ */ int n = 0; int val = 1; - int *echo_string = &val; + // int *echo_string = &val; char recv_buf[4]; sock.set_timeout(15000); @@ -219,7 +219,14 @@ n = sock.recv((void*) recv_buf, sizeof(recv_buf)); #else //UDP + char echo_string[]={'\0'}; + sprintf(echo_string, "{\"count\" : %d}", val); + retcode = sock.sendto(sock_addr, (void*)echo_string, sizeof(echo_string)); + //retcode = sock.sendto(sock_addr, ("{\"count\":%d}", *echo_string) , sizeof(echo_string)); + print_function("%s\n", echo_string); + /* retcode = sock.sendto(sock_addr, (void*) echo_string, sizeof(echo_string)); + */ if (retcode < 0) { print_function("UDPSocket.sendto() fails, code: %d\n", retcode); return -1;