bt_hrp_sensor_advertising_state_changed_cb adv_app_cb; //application callback for updating state changes
bt_gatt_server_characteristic_notification_state_changed_cb notif_app_cb; //application callback for updating notification
bt_body_sensor_location_e body_sensor_location; //body sensor location
- bool cccd_enabled;
GSList *hrs_collector_connected_list; //connected collector list , to be updated when read or write cccd request comes from client
} bt_hrp_server_info_s;
void *conn_cb_user_data; //
char *hrs_service_handle; /* HRS Primary Service Handle */
char *dis_service_handle; /* DIS Primary Service Handle */
- bool cccd_enabled; /* TDS Control Point CCCD is enabled or not */
+ bool cccd_enabled; /* CCCD is enabled or not */
bt_hrp_collector_heart_rate_value_changed_cb char_update_cb;
bt_hrp_collector_bsl_read_completed_cb bsl_read_cb;
} bt_hrp_collector_s;
+static const char * const bsl_str_enum[] = {
+ "other",
+ "chest",
+ "wrist",
+ "finger",
+ "hand",
+ "earlobe",
+ "foot",
+};
+
+
GSList *hrp_collector_list;
static bt_adapter_le_scan_result_cb scan_cb; //le scan application callback
static bt_hrp_collector_s *_bt_hrp_collector_find(const char *remote_address);
bt_gatt_server_h server, bt_gatt_h gatt_handle,
int offset, void *user_data)
{
+ char *bsl_str_loc = g_strdup(bsl_str_enum[hrp_server_info_s.body_sensor_location]);
BT_INFO("[HR] __bt_gatt_server_read_value_requested_cb");
BT_INFO("[HR] remote_address %s", remote_address);
BT_INFO("[HR] gatt_handle %s", (char *)gatt_handle);
BT_INFO("[HR] Offset %d", offset);
-#if TODO
- else {
- /* Send Cached response*/
- bt_gatt_server_send_response(request_id,
- BLUETOOTH_GATT_ATT_REQUEST_TYPE_READ, offset,
- resp_status, char_value_1, 3 - offset);
- }
-#endif
+ /* Send Cached response*/
+ bt_gatt_server_send_response(request_id,
+ BT_GATT_REQUEST_TYPE_READ, offset,
+ BT_ATT_ERROR_NONE, bsl_str_loc, strlen(bsl_str_loc));
+ g_free(bsl_str_loc);
+
}
static void _bt_hrp_sensor_initilize(void)
{
- hrp_server_info_s.is_notify_cb_set = false;
hrp_server_info_s.hrp_sensor = NULL;
hrp_server_info_s.hrp_service = NULL;
hrp_server_info_s.dis_service = NULL;
hrp_server_info_s.hrs_collector_connected_list = NULL;
hrp_server_info_s.is_in_contact = true;
- hrp_server_info_s.cccd_enabled = true; //by default
-
if (hrp_server_info_s.is_hr_value_init == false)
hrp_server_info_s.hr_value = 0;
BT_INFO("[HR]IsConnected : %d", connected);
BT_INFO("[HR]Remote Address : %s", remote_address);
bool isappend = true;
- int error_code = BT_ERROR_NOT_INITIALIZED;
- /*To do Check for if it for sensor or collector */
/*If Sensor */
- if (hrp_server_info_s.hrp_sensor == NULL) {
+ if (hrp_server_info_s.hrp_sensor != NULL) {
+ BT_INFO("[HR] bt_hrp_le_connection_state_changed_cb Sensor!!");
GSList *iter = hrp_server_info_s.hrs_collector_connected_list;
g_slist_append(hrp_server_info_s.hrs_collector_connected_list, (gpointer)client_s);
}
- if (connected == true && hrp_server_info_s.is_notify_cb_set == false) {
- error_code = bt_gatt_server_notify_characteristic_changed_value(hrp_server_info_s.hrs_characteristic,
- __bt_hrp_notification_send_cb, NULL, NULL);
- if (error_code != BT_ERROR_NONE)
- BT_ERR("bt_gatt_server_notify_characteristic_changed_value : %s\n", _bt_convert_error_to_string(error_code));
- hrp_server_info_s.is_notify_cb_set = true;
- }
-
} else {
/*If Collector*/
bt_hrp_collector_s *collector_s = _bt_hrp_collector_find(remote_address);
return error_code;
}
- if (hrp_server_info_s.cccd_enabled) {
- error_code = bt_gatt_set_int_value(hrp_server_info_s.hrs_characteristic,
- BT_DATA_TYPE_UINT16, heartrate, 1);
- if (error_code != BT_ERROR_NONE) {
- BT_ERR("[HR]bt_gatt_set_int_value failed with [0x%04x]", error_code);
- return error_code;
- }
+ error_code = bt_gatt_set_int_value(hrp_server_info_s.hrs_characteristic,
+ BT_DATA_TYPE_UINT16, heartrate, 1);
+ if (error_code != BT_ERROR_NONE) {
+ BT_ERR("[HR]bt_gatt_set_int_value failed with [0x%04x]", error_code);
+ return error_code;
+ }
+
+ error_code = bt_gatt_server_notify_characteristic_changed_value(hrp_server_info_s.hrs_characteristic,
+ __bt_hrp_notification_send_cb, NULL, NULL);
+ if (error_code != BT_ERROR_NONE) {
+ BT_ERR("bt_gatt_server_notify_characteristic_changed_value : %s\n", _bt_convert_error_to_string(error_code));
+ return error_code;
}
return error_code;
return error_code;
}
- hrp_server_info_s.is_notify_cb_set = false;
hrp_server_info_s.is_hr_value_init = false;
hrp_server_info_s.hr_value = 0;
hrp_server_info_s.is_energy_supported = false;
hrp_server_info_s.adv_app_cb = NULL;
hrp_server_info_s.notif_app_cb = NULL;
hrp_server_info_s.body_sensor_location = BT_BSL_NOTSUPPORTED;
- hrp_server_info_s.cccd_enabled = false;
g_slist_free_full(hrp_server_info_s.hrs_collector_connected_list, _bt_hrp_sensor_client_info_free);