![](/media/cache/group/ST_logo_2020_blue_V_cmyk.jpg.50x50_q85.jpg)
X-NUCLEO-IKS01A1 Environmental/Motion sensors data transmitted via X-NUCLEO-IDB04A1 BLE board. Compatible with iOS/Android ST BlueMS V2.1 application.
Dependencies: BLE_API X_NUCLEO_IDB0XA1 X_NUCLEO_IKS01A1 mbed
Fork of Bluemicrosystem1 by
BlueMicrosystem application
This application is the mbed equivalent of ST BlueMicrosystem1 and provides an example of motion and environmental data exported via Bluetooth Low Energy to an Android or IOS device.
It runs on a ST NUCLEO-F401RE board connected with a X-NUCLEO-IKS01A1 and a X-NUCLEO-IDB04A1 expansion boards and is compatible with Android and iOS ST BlueMS smartphone applications (based on Android and iOS BlueST SDKs).
By default the application is not providing sensor fusion and activity recognition features. However sensor fusion can be enabled following the steps below:
- Download and install osxMotionFX library on your PC.
- Obtain the free license for your board following the instructions
- Copy the correct license into Middlewares/ST/STM32_OSX_MotionFX_Library/osx_license.h of your mbed program folder
- Copy Middlewares/ST/STM32_OSX_MotionFX_Library/Inc/osx_motion_fx.h file
- Rename the provided .lib Keil binary library giving it a .ar extension, then copy it into Middlewares/ST/STM32_OSX_MotionFX_Library/Lib of your mbed program folder
- Enable USE_SENSOR_FUSION_LIB macro into MotionFX_Manager.h file and recompile.
Revision 13:d00147d01d4e, committed 2016-06-21
- Comitter:
- mapellil
- Date:
- Tue Jun 21 13:04:42 2016 +0000
- Parent:
- 12:baf8b5294320
- Commit message:
- updated BLE lib link, defined BLE offsets as #define
Changed in this revision
--- a/Bluemicrosystem1_NewBLE.lib Mon Jun 20 15:46:53 2016 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -https://developer.mbed.org/teams/ST-Expansion-SW-Team/code/Bluemicrosystem1_NewBLE/#ff82699c696e
--- a/CustomConfigService.h Mon Jun 20 15:46:53 2016 +0000 +++ b/CustomConfigService.h Tue Jun 21 13:04:42 2016 +0000 @@ -98,17 +98,17 @@ } bool isConfHandle (Gap::Handle_t handle) { - if (handle == configw2stCharacteristic.getValueAttribute().getHandle()-1) return true; + if (handle == configw2stCharacteristic.getValueAttribute().getHandle() - BLE_HANDLE_VALUE_OFFSET) return true; return false; } void enNotify (Gap::Handle_t handle) { - if (isConfHandle(handle-2)) { + if (isConfHandle(handle - BLE_HANDLE_EN_DIS_OFFSET)) { PRINTF("enNotify! %d\n\r", handle); isEnabledConfNotify = true; return; } } void disNotify (Gap::Handle_t handle) { - if (isConfHandle(handle-2)) { + if (isConfHandle(handle - BLE_HANDLE_EN_DIS_OFFSET)) { isEnabledConfNotify = false; return; } }
--- a/CustomConsoleService.h Mon Jun 20 15:46:53 2016 +0000 +++ b/CustomConsoleService.h Tue Jun 21 13:04:42 2016 +0000 @@ -133,23 +133,23 @@ } bool isTermHandle (Gap::Handle_t handle) { - if (handle == consTermCharacteristic.getValueAttribute().getHandle()-1) return true; + if (handle == consTermCharacteristic.getValueAttribute().getHandle() - BLE_HANDLE_VALUE_OFFSET) return true; return false; } bool isStderrHandle (Gap::Handle_t handle) { - if (handle == consStderrCharacteristic.getValueAttribute().getHandle()-1) return true; + if (handle == consStderrCharacteristic.getValueAttribute().getHandle() - BLE_HANDLE_VALUE_OFFSET) return true; return false; } void enNotify (Gap::Handle_t handle) { - if (isTermHandle(handle-2)) { isEnabledTermNotify = true; return; } - if (isStderrHandle(handle-2)) { isEnabledStderrNotify = true; return; } + if (isTermHandle(handle - BLE_HANDLE_EN_DIS_OFFSET)) { isEnabledTermNotify = true; return; } + if (isStderrHandle(handle - BLE_HANDLE_EN_DIS_OFFSET)) { isEnabledStderrNotify = true; return; } } void disNotify (Gap::Handle_t handle) { - if (isTermHandle(handle-2)) { isEnabledTermNotify = false; return; } - if (isStderrHandle(handle-2)) { isEnabledStderrNotify = false; return; } + if (isTermHandle(handle - BLE_HANDLE_EN_DIS_OFFSET)) { isEnabledTermNotify = false; return; } + if (isStderrHandle(handle - BLE_HANDLE_EN_DIS_OFFSET)) { isEnabledStderrNotify = false; return; } }
--- a/CustomSensorsService.h Mon Jun 20 15:46:53 2016 +0000 +++ b/CustomSensorsService.h Tue Jun 21 13:04:42 2016 +0000 @@ -222,9 +222,8 @@ if (isAccGyroMagNotificationEn()) return sendEnvAccGyroMag (Acc, Gyro, Magn, TimeStamp, magOffset); return 0; } - void enNotify (Gap::Handle_t a_handle) { - Gap::Handle_t handle = a_handle-2; + Gap::Handle_t handle = a_handle - BLE_HANDLE_EN_DIS_OFFSET; if (isTempHandle(handle)) { isEnabledTempNotify = true; memset(pastenvTemperature,0,TEMP_DATA_LEN); @@ -259,8 +258,8 @@ } void disNotify (Gap::Handle_t a_handle) { - Gap::Handle_t handle = a_handle-2; - if (isTempHandle(handle)) { + Gap::Handle_t handle = a_handle - BLE_HANDLE_EN_DIS_OFFSET; + if (isTempHandle(handle)) { isEnabledTempNotify = false; memset(pastenvTemperature,0,TEMP_DATA_LEN); return; @@ -283,7 +282,7 @@ isEnabledAccNotify = false; return; } - if (isMagHandle(handle)) { + if (isMagHandle(handle)) { isEnabledMagNotify = false; return; } @@ -322,34 +321,34 @@ } bool isTempHandle (Gap::Handle_t handle) { - if (handle == envTemperatureCharacteristic.getValueAttribute().getHandle()-1) return true; + if (handle == envTemperatureCharacteristic.getValueAttribute().getHandle() - BLE_HANDLE_VALUE_OFFSET) return true; return false; } bool isHumHandle (Gap::Handle_t handle) { - if (handle == envHumidityCharacteristic.getValueAttribute().getHandle()-1) return true; + if (handle == envHumidityCharacteristic.getValueAttribute().getHandle() - BLE_HANDLE_VALUE_OFFSET) return true; return false; } bool isPresHandle (Gap::Handle_t handle) { - if (handle == envPressureCharacteristic.getValueAttribute().getHandle()-1) return true; + if (handle == envPressureCharacteristic.getValueAttribute().getHandle() - BLE_HANDLE_VALUE_OFFSET) return true; return false; } bool isMagHandle (Gap::Handle_t handle) { - if (handle == envMagnetometerCharacteristic.getValueAttribute().getHandle()-1) return true; + if (handle == envMagnetometerCharacteristic.getValueAttribute().getHandle() - BLE_HANDLE_VALUE_OFFSET) return true; return false; } bool isAccHandle (Gap::Handle_t handle) { - if (handle == envAccelerometerCharacteristic.getValueAttribute().getHandle()-1) return true; + if (handle == envAccelerometerCharacteristic.getValueAttribute().getHandle() - BLE_HANDLE_VALUE_OFFSET) return true; return false; } bool isGyroHandle (Gap::Handle_t handle) { - if (handle == envGyroCharacteristic.getValueAttribute().getHandle()-1) return true; + if (handle == envGyroCharacteristic.getValueAttribute().getHandle() - BLE_HANDLE_VALUE_OFFSET) return true; return false; } bool isAccGyroMagHandle (Gap::Handle_t handle) { - if (handle == envAccGyroMagCharacteristic.getValueAttribute().getHandle()-1) return true; + if (handle == envAccGyroMagCharacteristic.getValueAttribute().getHandle() - BLE_HANDLE_VALUE_OFFSET) return true; return false; }
--- a/CustomSoftwareService.h Mon Jun 20 15:46:53 2016 +0000 +++ b/CustomSoftwareService.h Tue Jun 21 13:04:42 2016 +0000 @@ -134,22 +134,22 @@ } void enNotify (Gap::Handle_t handle) { - if (isQuatHandle(handle-2)) { isEnabledQuatNotify = true; return; } - if (isFloatQuatHandle(handle-2)) { isEnabledFloatQuatnotify = true; return; } + if (isQuatHandle(handle - BLE_HANDLE_EN_DIS_OFFSET)) { isEnabledQuatNotify = true; return; } + if (isFloatQuatHandle(handle - BLE_HANDLE_EN_DIS_OFFSET)) { isEnabledFloatQuatnotify = true; return; } } void disNotify (Gap::Handle_t handle) { - if (isQuatHandle(handle-2)) { isEnabledQuatNotify = false; return; } - if (isFloatQuatHandle(handle-2)) { isEnabledFloatQuatnotify = false; return; } + if (isQuatHandle(handle - BLE_HANDLE_EN_DIS_OFFSET)) { isEnabledQuatNotify = false; return; } + if (isFloatQuatHandle(handle - BLE_HANDLE_EN_DIS_OFFSET)) { isEnabledFloatQuatnotify = false; return; } } bool isQuatHandle (Gap::Handle_t handle) { - if (handle == swQuaternionsCharacteristic.getValueAttribute().getHandle()-1) return true; + if (handle == swQuaternionsCharacteristic.getValueAttribute().getHandle() - BLE_HANDLE_VALUE_OFFSET) return true; return false; } bool isFloatQuatHandle (Gap::Handle_t handle) { - if (handle == swFloatQuaternionsCharacteristic.getValueAttribute().getHandle()-1) return true; + if (handle == swFloatQuaternionsCharacteristic.getValueAttribute().getHandle() - BLE_HANDLE_VALUE_OFFSET) return true; return false; }
--- a/X_NUCLEO_IDB0XA1.lib Mon Jun 20 15:46:53 2016 +0000 +++ b/X_NUCLEO_IDB0XA1.lib Tue Jun 21 13:04:42 2016 +0000 @@ -1,1 +1,1 @@ -http://developer.mbed.org/teams/ST-Expansion-SW-Team/code/X_NUCLEO_IDB0XA1/#b94d080127c7 +http://developer.mbed.org/teams/ST/code/X_NUCLEO_IDB0XA1/#920ecc2451b5
--- a/main.cpp Mon Jun 20 15:46:53 2016 +0000 +++ b/main.cpp Tue Jun 21 13:04:42 2016 +0000 @@ -486,9 +486,8 @@ uint32_t PresToSend; int32_t decPart, intPart; AxesRaw_TypeDef Magn, Acc, Gyro; - Gap::Handle_t handle = eventDataP->handle-1; + Gap::Handle_t handle = eventDataP->handle - BLE_HANDLE_VALUE_OFFSET; - printf ("onDataReadCallback\n\r"); #ifdef CUST_SENS_SERV if (p_customsensorservice->isTempHandle(handle)) { p_mems_expansion_board->ht_sensor->GetTemperature(&temp); @@ -542,9 +541,9 @@ #endif } -static void myonDataWriteCallback(const GattWriteCallbackParams *eventDataP) +static void onDataWriteCallback(const GattWriteCallbackParams *eventDataP) { - Gap::Handle_t handle = eventDataP->handle-1; + Gap::Handle_t handle = eventDataP->handle - BLE_HANDLE_VALUE_OFFSET; PRINTF("onEventCallback!!\n\r"); printf (" myonDataWriteCallback attr_handle: %x att_data[4]: %d data_length: %d\n\r", eventDataP->handle, eventDataP->data[4], eventDataP->len ); @@ -741,7 +740,7 @@ p_BLEdev->gattServer().onConfirmationReceived(onConfirmationReceivedCallback); p_BLEdev->gattServer().onDataSent(onDataSentCallback); p_BLEdev->gattServer().onDataRead(onDataReadCallback); - p_BLEdev->gattServer().onDataWritten(myonDataWriteCallback); + p_BLEdev->gattServer().onDataWritten(onDataWriteCallback); p_BLEdev->gap().onConnection(onConnectionCallback); p_BLEdev->gap().onDisconnection(onDisconnectionCallback); p_BLEdev->gap().onTimeout(onTimeoutCallback);
--- a/main.h Mon Jun 20 15:46:53 2016 +0000 +++ b/main.h Tue Jun 21 13:04:42 2016 +0000 @@ -113,6 +113,10 @@ #define BLE_ADVERTISING_INTERVAL 1000 //#define BLE_ADVERTISING_INTERVAL 160 /* 100ms; in multiples of 0.625ms. */ +#define BLE_HANDLE_EN_DIS_OFFSET 2 // Offset from En/Dis UUID 2902 to UUID 2803 (Characteristic UUID) +#define BLE_HANDLE_VALUE_OFFSET 1 // Offset from Value UUID xxx to to UUID 2803 (Characteristic UUID) + + typedef enum ConnectionStatus_t { DISCONNECTED =0, CONNECTED =1