BLE-WiFi with BIOSensors
Dependencies: AS7000 BNO055 NNN50_WIFI_API
DELTA NNN50 (Bluetooth LE 4.X & 802.11 b/g/n) with Bio Sensor (HRM, 9DoF motion Sensor) reference design.
Env. Setup step by step.
- Download or build a TCP Server on you host computer
- Please find out the TCP server code or install TCP server application in your host computer.
- Import this sample application and setup these information about AP & TCP Server
- *char* AP_SSID = "SOG";
- *char* AP_PWD = "1122334455667788";
- *char* TCP_SERVER_ADDRESS = "10.0.1.13";
- *int TCP_SERVER_PORT = 1030;
- Compiler your code and download to your mBed device.
- Control your mBed device
- Please use NORDSemi nRF Tool and setup and watch these information: GATT CMD: 0x00 (connect to AP, TCP Server, and create TCP socket), 0x02 disconnection TCP server, close socket, and WiFi sleep), 0xA1 (send sensor data to tcp server from out_buffer[]) and Status will be update by Bluetooth LE adv through manufacturing information
0x00 | 0x02 | 0xA1 |
---|---|---|
WiFi,AP&TCP Server connect | WiFi,AP, & TCP Server disconnect | Send sensor data to TCP Server |
Diff: main.cpp
- Revision:
- 10:248b81efda00
- Parent:
- 9:d1861b00e0fd
- Child:
- 11:54a1a576df9f
--- a/main.cpp Thu May 04 10:43:36 2017 +0000 +++ b/main.cpp Sat May 06 00:08:06 2017 +0000 @@ -33,8 +33,8 @@ WIFIDevice wifi; TCPSocketConnection sock_tcp; -//char* ECHO_SERVER_ADDRESS = "10.0.1.13"; -char* ECHO_SERVER_ADDRESS = "192.168.2.184"; +char* ECHO_SERVER_ADDRESS = "10.0.1.13"; +//char* ECHO_SERVER_ADDRESS = "192.168.1.7"; int ECHO_SERVER_PORT = 1030; uint8_t initialValueForDOORCharacteristic = 0xFF; @@ -139,7 +139,6 @@ wait_ms(8); if (BLE_RX_CMD != 0xA1) { if (i > 40){ - pc.printf(""); pc.printf("*HR=%03d#", hrm.hrm.hreat_rate); i=0; } i++; @@ -148,16 +147,14 @@ if (BLE_RX_CMD == 0xA1){ ADV_manuf[5] = 0xF1; if (isWiFiEnable == true){ - if (isConnect == true) { -#if 1 + if (isConnect == true) { if (j > 2){ - pc.printf(""); pc.printf("*HR=%03d#", hrm.hrm.hreat_rate); j = 0; - }j++; - #endif + }j++; sprintf(out_buffer,"hrm:%03d yaw:%6.2f pitch:%6.2f roll:%6.2f\n", hrm.hrm.hreat_rate, imu.euler.yaw, imu.euler.pitch, imu.euler.roll); sock_tcp.send_all(out_buffer, sizeof(out_buffer) - 1); + sock_tcp.set_blocking(false, 200);// Timeout after 0.2s isCloudFiling = true; } else { if (sock_tcp.connect(ECHO_SERVER_ADDRESS, ECHO_SERVER_PORT) < 0) { @@ -214,12 +211,13 @@ if (isWiFiEnable == false) { eth.init(); - //wifi.setNetwork(M2M_WIFI_SEC_WPA_PSK, "SOG", "0227322327"); - wifi.setNetwork(M2M_WIFI_SEC_WPA_PSK, "20-4F-5_Guest", "11223344"); + wifi.setNetwork(M2M_WIFI_SEC_WPA_PSK, "SOG", "0227322327"); + //wifi.setNetwork(M2M_WIFI_SEC_WPA_PSK, "netis_2.4G_cybing", "11223344"); eth.connect(); while(true) { if (wifi.is_AP_connected()==1) break; } + sock_tcp.set_blocking(false, 1200);// Timeout after 1.2s #if DEBUG_LOG pc.printf("Connect Success! \n"); pc.printf("MAC: %s\n", eth.getMACAddress());