example/gatt_heart_rate_client: skip reading Sensor Location if Characteristic not available

This commit is contained in:
Matthias Ringwald 2019-10-24 20:59:09 +02:00
parent 6d466148c0
commit ddd48cb85d

View File

@ -207,6 +207,11 @@ static void handle_gatt_client_event(uint8_t packet_type, uint16_t channel, uint
state = TC_CONNECTED;
break;
}
if (body_sensor_location_characteristic.value_handle == 0){
printf("Sensor Location characteristic not available.\n");
state = TC_CONNECTED;
break;
}
state = TC_W4_HEART_RATE_MEASUREMENT_CHARACTERISTIC;
printf("Read Body Sensor Location.\n");
state = TC_W4_SENSOR_LOCATION;
@ -223,6 +228,8 @@ static void handle_gatt_client_event(uint8_t packet_type, uint16_t channel, uint
case GATT_EVENT_CHARACTERISTIC_VALUE_QUERY_RESULT:
body_sensor_location = gatt_event_characteristic_value_query_result_get_value(packet)[0];
printf("Sensor Location: %u\n", body_sensor_location);
break;
case GATT_EVENT_QUERY_COMPLETE:
state = TC_CONNECTED;
break;
default: