@@ -66,7 +66,8 @@ int MotionService::OnStepCountRequested(uint16_t attributeHandle, ble_gatt_acces
6666
6767 int res = os_mbuf_append (context->om , &buffer, 4 );
6868 return (res == 0 ) ? 0 : BLE_ATT_ERR_INSUFFICIENT_RES;
69- } else if (attributeHandle == motionValuesHandle) {
69+ }
70+ if (attributeHandle == motionValuesHandle) {
7071 int16_t buffer[3 ] = {motionController.X (), motionController.Y (), motionController.Z ()};
7172
7273 int res = os_mbuf_append (context->om , buffer, 3 * sizeof (int16_t ));
@@ -76,8 +77,9 @@ int MotionService::OnStepCountRequested(uint16_t attributeHandle, ble_gatt_acces
7677}
7778
7879void MotionService::OnNewStepCountValue (uint32_t stepCount) {
79- if (!stepCountNoficationEnabled)
80+ if (!stepCountNotificationEnabled) {
8081 return ;
82+ }
8183
8284 uint32_t buffer = stepCount;
8385 auto * om = ble_hs_mbuf_from_flat (&buffer, 4 );
@@ -92,8 +94,9 @@ void MotionService::OnNewStepCountValue(uint32_t stepCount) {
9294}
9395
9496void MotionService::OnNewMotionValues (int16_t x, int16_t y, int16_t z) {
95- if (!motionValuesNoficationEnabled)
97+ if (!motionValuesNotificationEnabled) {
9698 return ;
99+ }
97100
98101 int16_t buffer[3 ] = {x, y, z};
99102 auto * om = ble_hs_mbuf_from_flat (buffer, 3 * sizeof (int16_t ));
@@ -108,15 +111,17 @@ void MotionService::OnNewMotionValues(int16_t x, int16_t y, int16_t z) {
108111}
109112
110113void MotionService::SubscribeNotification (uint16_t attributeHandle) {
111- if (attributeHandle == stepCountHandle)
112- stepCountNoficationEnabled = true ;
113- else if (attributeHandle == motionValuesHandle)
114- motionValuesNoficationEnabled = true ;
114+ if (attributeHandle == stepCountHandle) {
115+ stepCountNotificationEnabled = true ;
116+ } else if (attributeHandle == motionValuesHandle) {
117+ motionValuesNotificationEnabled = true ;
118+ }
115119}
116120
117121void MotionService::UnsubscribeNotification (uint16_t attributeHandle) {
118- if (attributeHandle == stepCountHandle)
119- stepCountNoficationEnabled = false ;
120- else if (attributeHandle == motionValuesHandle)
121- motionValuesNoficationEnabled = false ;
122+ if (attributeHandle == stepCountHandle) {
123+ stepCountNotificationEnabled = false ;
124+ } else if (attributeHandle == motionValuesHandle) {
125+ motionValuesNotificationEnabled = false ;
126+ }
122127}
0 commit comments