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
Revision 3:4c355eed5a07, committed 2019-06-04
- Comitter:
- asagin
- Date:
- Tue Jun 04 07:19:23 2019 +0000
- Parent:
- 2:cf787cebee82
- Child:
- 4:693230744089
- Commit message:
- WIP
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed_app.json | Show annotated file Show diff for this revision Revisions of this file |
--- 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; }
--- a/mbed_app.json Mon May 20 06:11:03 2019 +0000 +++ b/mbed_app.json Tue Jun 04 07:19:23 2019 +0000 @@ -1,13 +1,13 @@ { "config": { - "sock-type": "TCP", + "sock-type": "UDP", "echo-server-hostname": { "help": "Echo server host name.", - "value": "\"echo.mbedcloudtesting.com\"" + "value": "\"harvest.soracom.io\"" }, "echo-server-port": { "help": "Echo server port number.", - "value": 7 + "value": 8514 }, "trace-level": { "help": "Options are TRACE_LEVEL_ERROR,TRACE_LEVEL_WARN,TRACE_LEVEL_INFO,TRACE_LEVEL_DEBUG", @@ -22,7 +22,7 @@ "lwip.ipv4-enabled": true, "lwip.ethernet-enabled": false, "lwip.ppp-enabled": true, - "lwip.tcp-enabled": true, + "lwip.tcp-enabled": false, "platform.stdio-convert-newlines": true, "platform.stdio-baud-rate": 115200, "platform.default-serial-baud-rate": 115200, @@ -36,9 +36,9 @@ }, "WIO_3G": { "target.device_has_remove": ["SERIAL_FC"], - "nsapi.default-cellular-apn": "\"apn\"", - "nsapi.default-cellular-username": "\"username\"", - "nsapi.default-cellular-password": "\"password\"" + "nsapi.default-cellular-apn": "\"soracom.io\"", + "nsapi.default-cellular-username": "\"sora\"", + "nsapi.default-cellular-password": "\"sora\"" }, "WIO_BG96": { "cellular.use-apn-lookup": false, @@ -46,6 +46,8 @@ "nsapi.default-cellular-apn": "\"apn\"", "nsapi.default-cellular-username": "\"username\"", "nsapi.default-cellular-password": "\"password\"" + + } } }