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:
- 3:4c355eed5a07
- Parent:
- 0:fb5e1789de47
- Child:
- 4:693230744089
diff -r cf787cebee82 -r 4c355eed5a07 main.cpp --- a/main.cpp Mon May 20 06:11:03 2019 +0000 +++ b/main.cpp Tue Jun 04 07:19:23 2019 +0000 @@ -165,9 +165,15 @@ #endif return -1; } - +/* +int val = 123; // 普通の変数 +int* ptr = &val; // ポインタ(pointer) +int& ref = val; // 参照(reference) +const int cval = 45; // 定数(constant) +*/ int n = 0; - const char *echo_string = "TEST"; + int val = 1; + int *echo_string = &val; char recv_buf[4]; sock.set_timeout(15000); @@ -212,7 +218,7 @@ n = sock.recv((void*) recv_buf, sizeof(recv_buf)); #else - +//UDP retcode = sock.sendto(sock_addr, (void*) echo_string, sizeof(echo_string)); if (retcode < 0) { print_function("UDPSocket.sendto() fails, code: %d\n", retcode); @@ -223,6 +229,14 @@ n = sock.recvfrom(&sock_addr, (void*) recv_buf, sizeof(recv_buf)); #endif + + /* + virtual nsapi_size_or_error_t sendto ( const char * host, + uint16_t port, + const void * data, + nsapi_size_t size + ) + */ #endif sock.close(); @@ -235,9 +249,11 @@ return -1; } +DigitalIn pushButton(D20); + int main() { - print_function("\n\nmbed-os-example-cellular\n"); + print_function("\n\nmbed-os-example-cellular_temp\n"); print_function("\n\nBuilt: %s, %s\n", __DATE__, __TIME__); #ifdef MBED_CONF_NSAPI_DEFAULT_CELLULAR_PLMN print_function("\n\n[MAIN], plmn: %s\n", (MBED_CONF_NSAPI_DEFAULT_CELLULAR_PLMN ? MBED_CONF_NSAPI_DEFAULT_CELLULAR_PLMN : "NULL")); @@ -264,9 +280,18 @@ nsapi_error_t retcode = NSAPI_ERROR_NO_CONNECTION; /* Attempt to connect to a cellular network */ - if (do_connect() == NSAPI_ERROR_OK) { + if (do_connect() == NSAPI_ERROR_OK) { retcode = test_send_recv(); - } + }/* + if (do_connect() == NSAPI_ERROR_OK) { + for(int count = 1; count < 100; count = count + 1) { + if(pushButton == 1) { + + retcode = test_send_recv(); + + } + } + }*/ if (iface->disconnect() != NSAPI_ERROR_OK) { print_function("\n\n disconnect failed.\n\n"); @@ -282,7 +307,8 @@ trace_close(); #else dot_thread.terminate(); -#endif // #if MBED_CONF_MBED_TRACE_ENABLE +#endif + return 0; }