Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: BNO055_AS7000 NNN50_WIFI_API
Fork of NNN50_BLEWIFISensor by
Revision 13:5b96cb34bc70, committed 2017-05-22
- Comitter:
- tsungta
- Date:
- Mon May 22 08:07:48 2017 +0000
- Parent:
- 12:91a59631ee5f
- Child:
- 14:62377c06ead2
- Commit message:
- Update BNO055 and remove AS7000 to avoid I2C LLD hangup; Comment out set_blocking so the default setting set_blocking = 'true' is applied
Changed in this revision
--- a/AS7000.lib Sat May 06 01:41:48 2017 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -http://developer.mbed.org/users/sog_yang/code/AS7000/#7dbd9ffd82cc
--- a/BNO055.lib Sat May 06 01:41:48 2017 +0000 +++ b/BNO055.lib Mon May 22 08:07:48 2017 +0000 @@ -1,1 +1,1 @@ -https://developer.mbed.org/users/sog_yang/code/BNO055/#f04b0a4c8057 +https://developer.mbed.org/users/sog_yang/code/BNO055/#1914e07be563
--- a/main.cpp Sat May 06 01:41:48 2017 +0000
+++ b/main.cpp Mon May 22 08:07:48 2017 +0000
@@ -1,6 +1,6 @@
#include "mbed.h"
#include "BNO055.h"
-#include "AS7000.h"
+//#include "AS7000.h"
#include "ble/BLE.h"
#include "ble/Gap.h"
#include "ble/services/BatteryService.h"
@@ -8,7 +8,7 @@
#include "EthernetInterface.h"
#include "WIFIDevice.h"
-#define DEBUG_LOG 0
+#define DEBUG_LOG 1
union IP {
unsigned int ip;
@@ -26,16 +26,16 @@
DOORService *doorServicePtr;
BNO055 imu(p0,p30);
-AS7000 hrm(p0,p30);
+//AS7000 hrm(p0,p30);
Serial pc(USBTX, USBRX);
DigitalInOut myOutputPin(USBTX);
EthernetInterface eth;
WIFIDevice wifi;
TCPSocketConnection sock_tcp;
-char* AP_SSID = "SOG";
-char* AP_PWD = "1122334455667788";
-char* TCP_SERVER_ADDRESS = "10.0.1.13";
+char* AP_SSID = "TWCYNPC0209_Mac mini";
+char* AP_PWD = "mayday55555";
+char* TCP_SERVER_ADDRESS = "192.168.2.7";
int TCP_SERVER_PORT = 1030;
uint8_t initialValueForDOORCharacteristic = 0xFF;
@@ -117,7 +117,7 @@
int main (void) {
myOutputPin.mode(PullUp);
pc.baud(38400);
- hrm.enable();
+ imu.enable();
imu.reset();
imu.setmode(OPERATION_MODE_NDOF);
@@ -134,13 +134,14 @@
while (true) {
+ wait_ms(8);
+ imu.hr_only();
wait_ms(2);
imu.get_angles(); //query the i2c device
- hrm.hr_only();
wait_ms(8);
if (BLE_RX_CMD != 0xA1) {
if (i > 40){
- pc.printf("*HR=%03d#", hrm.hrm.hreat_rate);
+ pc.printf("*HR=%03d# yaw:%6.2f#", imu.hrm.hreat_rate, imu.euler.yaw);
i=0;
} i++;
}
@@ -150,19 +151,19 @@
if (isWiFiEnable == true){
if (isConnect == true) {
if (j > 2){
- pc.printf("*HR=%03d#", hrm.hrm.hreat_rate);
+ pc.printf("*HR=%03d#", imu.hrm.hreat_rate);
j = 0;
}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);
+ sprintf(out_buffer,"hrm:%03d yaw:%6.2f pitch:%6.2f roll:%6.2f\n", imu.hrm.hreat_rate, imu.euler.yaw, imu.euler.pitch, imu.euler.roll);
+ //sock_tcp.set_blocking(false, 1500);// Timeout after 0.2s
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(TCP_SERVER_ADDRESS, TCP_SERVER_PORT) < 0) {
isConnect = false;
BLE_RX_CMD = 0xFF;
#if DEBUG_LOG
- pc.printf("Unable to connect to (%s) on port (%d)\n", ECHO_SERVER_ADDRESS, ECHO_SERVER_PORT);
+ pc.printf("Unable to connect to (%s) on port (%d)\n", TCP_SERVER_ADDRESS, TCP_SERVER_PORT);
#endif
ADV_manuf[4] = 0xCF;
BLE_RX_CMD = 0xFF;
@@ -170,7 +171,7 @@
isConnect = true;
ADV_manuf[4] = 0xF1;
#if DEBUG_LOG
- pc.printf("Connected to Server at %s\n",ECHO_SERVER_ADDRESS);
+ pc.printf("Connected to Server at %s\n",TCP_SERVER_ADDRESS);
#endif
}
}
@@ -217,7 +218,7 @@
while(true) {
if (wifi.is_AP_connected()==1) break;
}
- sock_tcp.set_blocking(false, 1200);// Timeout after 1.2s
+ //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());
@@ -240,7 +241,7 @@
if (isWiFiEnable == true) {
if (sock_tcp.connect(TCP_SERVER_ADDRESS, TCP_SERVER_PORT) < 0) {
#if DEBUG_LOG
- pc.printf("Unable to connect to (%s) on port (%d)\n", ECHO_SERVER_ADDRESS, ECHO_SERVER_PORT);
+ pc.printf("Unable to connect to (%s) on port (%d)\n", TCP_SERVER_ADDRESS, TCP_SERVER_PORT);
#endif
sock_tcp.close();
ADV_manuf[4] = 0xCF;
@@ -249,7 +250,7 @@
isCloudFiling = false;
ADV_manuf[4] = 0xF1;
#if DEBUG_LOG
- pc.printf("Connected to Server at %s\n",ECHO_SERVER_ADDRESS);
+ pc.printf("Connected to Server at %s\n",TCP_SERVER_ADDRESS);
#endif
}
}
