![](/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.
Diff: main.cpp
- Revision:
- 12:baf8b5294320
- Parent:
- 11:ff82699c696e
- Child:
- 13:d00147d01d4e
--- a/main.cpp Fri Jun 17 14:04:14 2016 +0000 +++ b/main.cpp Mon Jun 20 15:46:53 2016 +0000 @@ -486,55 +486,56 @@ uint32_t PresToSend; int32_t decPart, intPart; AxesRaw_TypeDef Magn, Acc, Gyro; + Gap::Handle_t handle = eventDataP->handle-1; printf ("onDataReadCallback\n\r"); #ifdef CUST_SENS_SERV - if (p_customsensorservice->isTempHandle(eventDataP->handle)) { + if (p_customsensorservice->isTempHandle(handle)) { p_mems_expansion_board->ht_sensor->GetTemperature(&temp); floatToInt(temp, &intPart, &decPart, 1); TempToSend = intPart*10+decPart; p_customsensorservice->sendEnvTemperature(TempToSend, TimeStamp); - } else if (p_customsensorservice->isHumHandle(eventDataP->handle)) { + } else if (p_customsensorservice->isHumHandle(handle)) { p_mems_expansion_board->ht_sensor->GetHumidity(&hum); floatToInt(hum, &intPart, &decPart, 1); HumToSend = intPart*10+decPart; p_customsensorservice->sendEnvHumidity(HumToSend, TimeStamp); - } else if (p_customsensorservice->isPresHandle(eventDataP->handle)) { + } else if (p_customsensorservice->isPresHandle(handle)) { p_mems_expansion_board->pt_sensor->GetPressure(&pres); floatToInt(pres, &intPart, &decPart, 1); PresToSend = intPart*100+decPart; p_customsensorservice->sendEnvPressure(PresToSend, TimeStamp); - } else if (p_customsensorservice->isGyroHandle(eventDataP->handle)) { + } else if (p_customsensorservice->isGyroHandle(handle)) { p_mems_expansion_board->GetGyroscope()->Get_G_Axes((int32_t *)&Gyro); p_customsensorservice->sendEnvGyroscope (&Gyro, TimeStamp); - } else if (p_customsensorservice->isAccHandle(eventDataP->handle)) { + } else if (p_customsensorservice->isAccHandle(handle)) { p_mems_expansion_board->GetAccelerometer()->Get_X_Axes((int32_t *)&Acc); p_customsensorservice->sendEnvAccelerometer (&Acc, TimeStamp); - } else if (p_customsensorservice->isMagHandle(eventDataP->handle)) { + } else if (p_customsensorservice->isMagHandle(handle)) { p_mems_expansion_board->magnetometer->Get_M_Axes((int32_t *)&Magn); p_customsensorservice->sendEnvMagnetometer(&Magn, TimeStamp, magOffset); - } else if (p_customsensorservice->isAccGyroMagHandle(eventDataP->handle)) { + } else if (p_customsensorservice->isAccGyroMagHandle(handle)) { p_customsensorservice->sendEnvAccGyroMag (&Acc, &Gyro, &Magn, TimeStamp, magOffset); } #endif #ifdef CUST_SW_SERV - if (p_customsoftwareservice->isQuatHandle(eventDataP->handle)) { + if (p_customsoftwareservice->isQuatHandle(handle)) { // p_customsoftwareservice->updateQuaternions(quat_axes, TimeStamp); // dont need to update because already calculated/update into main loop - } else if (p_customsoftwareservice->isFloatQuatHandle(eventDataP->handle)) { + } else if (p_customsoftwareservice->isFloatQuatHandle(handle)) { // p_customsoftwareservice->updateFloatQuaternions(QuatFloat, TimeStamp); // dont need to update because already calculated/update into main loop } #endif #ifdef CUST_CONFIG_SERV - if (p_customconfigservice->isConfHandle(eventDataP->handle)) { + if (p_customconfigservice->isConfHandle(handle)) { p_customconfigservice->sendConfigState(MASK_CALIB_SENSORFUSION_SHORT, W2ST_COMMAND_CAL_STATUS, isCal, TimeStamp); p_customconfigservice->sendConfigState(MASK_CALIB_SENSORFUSION_FLOAT, W2ST_COMMAND_CAL_STATUS, isCal, TimeStamp); } @@ -543,15 +544,16 @@ static void myonDataWriteCallback(const GattWriteCallbackParams *eventDataP) { + Gap::Handle_t handle = eventDataP->handle-1; PRINTF("onEventCallback!!\n\r"); - printf (" myonDataWriteCallback attr_handle: %x att_data[0]: %d data_length: %d\n\r", eventDataP->handle, eventDataP->data[0], eventDataP->len ); + printf (" myonDataWriteCallback attr_handle: %x att_data[4]: %d data_length: %d\n\r", eventDataP->handle, eventDataP->data[4], eventDataP->len ); #ifdef CUST_CONFIG_SERV - if (p_customconfigservice->isConfHandle(eventDataP->handle)) { + if (p_customconfigservice->isConfHandle(handle)) { /* Received one write command from Client on calibration characteristc */ uint32_t FeatureMask = (eventDataP->data[3]) | (eventDataP->data[2]<<8) | (eventDataP->data[1]<<16) | (eventDataP->data[0]<<24); - uint8_t Command = eventDataP->data[4]; + uint8_t Command = eventDataP->data[4]; switch (Command) { case W2ST_COMMAND_CAL_STATUS: @@ -560,7 +562,6 @@ p_customconfigservice->sendConfigState(FeatureMask, Command, isCal, TimeStamp); break; case W2ST_COMMAND_CAL_RESET: - /* Reset the calibration */ ForceReCalibration=1; break; @@ -581,10 +582,10 @@ } #endif #ifdef CUST_CONS_SERV -// printf ("-------------->>> attr_handle: %x\n\r", attr_handle); -// if (p_customconsoleservice->isTermHandle(attr_handle -1)) { -// p_customconsoleservice->updateTerm(att_data,data_length); -// } + if (p_customconsoleservice->isTermHandle(handle)) { + printf ("Console handle: %x data: %s\n\r", handle, eventDataP->data); +// p_customconsoleservice->updateTerm((uint8_t*)eventDataP->data,eventDataP->len); + } #endif