4 * Copyright (c) 2015 -2016 Samsung Electronics Co., Ltd All Rights Reserved.
6 * Contact: Anupam Roy <anupam.r@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
29 #include "bt-hal-log.h"
30 #include "bt-hal-msg.h"
31 #include "bt-hal-utils.h"
33 #include <bt-hal-adapter-dbus-handler.h>
34 #include <bt-hal-device-dbus-handler.h>
35 #include <bt-hal-hidhost.h>
36 #include <bt-hal-socket.h>
37 #include <bt-hal-av.h>
38 #include <bt-hal-hf.h>
39 #include <bt-hal-hdp.h>
40 #include <bt-hal-a2dp-sink.h>
41 #include <bt-hal-avrcp-tg.h>
42 #include <bt-hal-avrcp-ctrl.h>
43 #include <bt-hal-gatt.h>
45 #include <bt-hal-adapter-le.h>
48 #define enum_prop_to_hal(prop, hal_prop, type) do { \
51 prop.len = sizeof(e); \
52 e = *((uint8_t *) (hal_prop->val)); \
55 static const bt_callbacks_t *bt_hal_cbacks = NULL;
58 /* Forward declarations */
59 static void __bt_adapter_props_to_hal(bt_property_t *send_props, struct hal_property *prop, uint8_t num_props, uint16_t len);
60 static void __bt_device_props_to_hal(bt_property_t *send_props,
61 struct hal_property *prop, uint8_t num_props,
63 static void __bt_hal_handle_adapter_state_changed(void *buf, uint16_t len);
64 static void __bt_hal_handle_adapter_property_changed(void *buf, uint16_t len);
65 static void __bt_hal_handle_stack_messages(int message, void *buf, uint16_t len);
66 static void __bt_hal_handle_adapter_discovery_state_changed(void *buf, uint16_t len);
67 static void __bt_hal_handle_device_found_event(void *buf, uint16_t len);
68 static void __bt_hal_handle_bond_state_changed_event(void *buf, uint16_t len);
69 static void __bt_hal_handle_device_acl_state_changed_event(void *buf, uint16_t len);
70 static void __bt_hal_handle_ssp_request_event(void *buf, uint16_t len);
71 static void __bt_hal_handle_pin_request_event(void *buf, uint16_t len);
73 static void __bt_hal_handle_device_trust_state_changed_event(void *buf, uint16_t len);
75 static bool interface_ready(void)
77 return bt_hal_cbacks != NULL;
80 static int init(bt_callbacks_t *callbacks)
83 DBG("HAL library Initialization..");
85 if (interface_ready())
86 return BT_STATUS_DONE;
88 bt_hal_cbacks = callbacks;
89 DBG("Store HAL stack msg handler callback");
90 _bt_hal_dbus_store_stack_msg_cb(__bt_hal_handle_stack_messages);
91 ret = _bt_hal_initialize_event_receiver(__bt_hal_handle_stack_messages);
93 if (ret == BT_STATUS_SUCCESS)
94 return BT_STATUS_SUCCESS;
96 return BT_STATUS_FAIL;
99 return BT_STATUS_SUCCESS;
103 static int enable(void)
105 return _bt_hal_dbus_enable_adapter();
108 /* Disable Adapter */
109 static int disable(void)
111 return _bt_hal_dbus_disable_adapter();
115 /* Tizen Specific Reset Adapter */
116 static int reset(void)
118 return _bt_hal_dbus_reset_adapter();
122 static void cleanup(void)
128 /* Tizen Specific Get Powered state */
129 static int get_adapter_powered_status(uint8_t *state)
132 ERR("Invalid param");
133 return BT_STATUS_PARM_INVALID;
136 return _bt_hal_get_adapter_powered_state(state);
140 static int get_adapter_properties(void)
142 return _bt_hal_dbus_get_adapter_properties();
145 static int get_adapter_property(bt_property_type_t type)
147 return _bt_hal_dbus_get_adapter_property(type);
150 static int set_adapter_property(const bt_property_t *property)
153 ERR("Invalid param");
154 return BT_STATUS_PARM_INVALID;
157 return _bt_hal_dbus_set_adapter_property(property);
160 static int get_remote_device_properties(bt_bdaddr_t *remote_addr)
163 ERR("Invalid param");
164 return BT_STATUS_PARM_INVALID;
167 return _bt_hal_dbus_get_remote_device_properties(remote_addr);
170 static int get_remote_device_property(bt_bdaddr_t *remote_addr,
171 bt_property_type_t type)
173 return BT_STATUS_UNSUPPORTED;
176 static int set_remote_device_property(bt_bdaddr_t *remote_addr,
177 const bt_property_t *property)
179 return _bt_hal_dbus_set_remote_device_property(remote_addr, property);
182 static int get_remote_service_record(bt_bdaddr_t *remote_addr, bt_uuid_t *uuid)
184 return BT_STATUS_UNSUPPORTED;
187 static int get_remote_services(bt_bdaddr_t *remote_addr)
190 ERR("Invalid param");
191 return BT_STATUS_PARM_INVALID;
193 return _bt_hal_dbus_get_remote_device_services(remote_addr);
196 static int start_discovery(void)
198 return _bt_hal_dbus_start_discovery(false, 0x00);
202 static int start_custom_discovery(bt_disc_role_type_t disc_type)
204 return _bt_hal_dbus_start_discovery(true, disc_type);
208 static int cancel_discovery(void)
210 return _bt_hal_dbus_stop_discovery();
213 static int create_bond(const bt_bdaddr_t *bd_addr, int transport)
216 return _bt_hal_device_create_bond(bd_addr, transport);
219 static int cancel_bond(const bt_bdaddr_t *bd_addr)
221 return _bt_hal_device_cancel_bond(bd_addr);
224 static int remove_bond(const bt_bdaddr_t *bd_addr)
227 return _bt_hal_device_remove_bond(bd_addr);
230 static int pin_reply(const bt_bdaddr_t *bd_addr, uint8_t accept,
231 uint8_t pin_len, bt_pin_code_t *pin_code)
233 return _bt_hal_device_legacy_pin_reply(bd_addr, accept, pin_len, (char*)pin_code);
236 static int ssp_reply(const bt_bdaddr_t *bd_addr, bt_ssp_variant_t variant,
237 uint8_t accept, uint32_t passkey)
239 return _bt_hal_device_ssp_reply(bd_addr, variant, accept, passkey);
242 static const void *get_profile_interface(const char *profile_id)
244 /*TODO: Profile interfaces to be included later*/
245 DBG("%s", profile_id);
247 if (!interface_ready())
250 if (!strncmp(profile_id, BT_PROFILE_HIDHOST_ID, strlen(profile_id)))
251 return bt_get_hidhost_interface();
253 if (!strcmp(profile_id, BT_PROFILE_SOCKETS_ID))
254 return bt_get_socket_interface();
256 if (!strcmp(profile_id, BT_PROFILE_PAN_ID))
259 if (!strcmp(profile_id, BT_PROFILE_ADVANCED_AUDIO_ID))
260 return bt_get_av_interface();
262 if (!strcmp(profile_id, BT_PROFILE_AV_RC_ID))
263 return bt_get_avrcp_tg_interface();
265 if (!strcmp(profile_id, BT_PROFILE_HANDSFREE_ID))
266 return bt_get_hf_interface();
268 if (!strcmp(profile_id, BT_PROFILE_GATT_ID))
269 return bt_get_gatt_interface();
271 if (!strcmp(profile_id, BT_PROFILE_HEALTH_ID))
272 return bt_get_hl_interface();
274 if (!strcmp(profile_id, BT_PROFILE_AV_RC_CTRL_ID))
275 return bt_get_avrcp_ctrl_interface();
277 if (!strcmp(profile_id, BT_PROFILE_HANDSFREE_CLIENT_ID))
280 if (!strcmp(profile_id, BT_PROFILE_MAP_CLIENT_ID))
283 if (!strcmp(profile_id, BT_PROFILE_ADVANCED_AUDIO_SINK_ID))
284 return bt_get_a2dp_sink_interface();
289 static int dut_mode_configure(uint8_t enable)
291 return BT_STATUS_UNSUPPORTED;
294 static int dut_mode_send(uint16_t opcode, uint8_t *buf, uint8_t buf_len)
296 return BT_STATUS_UNSUPPORTED;
299 static int le_test_mode(uint16_t opcode, uint8_t *buf, uint8_t buf_len)
301 return BT_STATUS_UNSUPPORTED;
304 static int config_hci_snoop_log(uint8_t enable)
306 return BT_STATUS_UNSUPPORTED;
309 static int get_connection_state(const bt_bdaddr_t *bd_addr)
312 return _bt_hal_device_get_connection_state(bd_addr);
315 static int set_os_callouts(bt_os_callouts_t *callouts)
317 DBG("callouts: %p", callouts);
319 /* TODO: implement */
321 return BT_STATUS_UNSUPPORTED;
324 static int read_energy_info(void)
326 return BT_STATUS_UNSUPPORTED;
329 static int authorize_response(const bt_bdaddr_t *bd_addr, bt_service_id_t service_id,
330 uint8_t authorize, uint8_t save_settings)
333 return _bt_hal_device_authorize_response(bd_addr, service_id, authorize, save_settings);
336 int set_authorization(bt_bdaddr_t *bd_addr, uint8_t auth)
339 return _bt_hal_device_set_trust(bd_addr, auth);
343 static int get_service_connection_state(const bt_bdaddr_t *bd_addr, bt_service_id_t rem_svc_id)
346 return _bt_hal_device_get_service_connection_state(bd_addr, rem_svc_id);
349 static int set_agent_osp_server(uint32_t type, uint8_t enable)
352 return _bt_hal_device_set_osp_server(type, enable);
355 static int set_trusted_profile(bt_bdaddr_t *bd_addr, bt_trusted_profile_t profile, uint8_t trust)
358 return _bt_hal_device_set_trusted_profile(bd_addr, profile, trust);
361 static int get_trusted_profile(bt_bdaddr_t *bd_addr, bt_trusted_profile_t profile, uint32_t *trusted)
364 return _bt_hal_device_get_trusted_profile(bd_addr, profile, trusted);
368 static const bt_interface_t bluetooth_if = {
369 .size = sizeof(bt_interface_t),
378 .le_enable = _bt_hal_le_enable,
379 .le_disable = _bt_hal_le_disable,
383 .get_adapter_powered_status = get_adapter_powered_status,
385 .get_adapter_properties = get_adapter_properties,
386 .get_adapter_property = get_adapter_property,
387 .set_adapter_property = set_adapter_property,
388 .get_remote_device_properties = get_remote_device_properties,
389 .get_remote_device_property = get_remote_device_property,
390 .set_remote_device_property = set_remote_device_property,
391 .get_remote_service_record = get_remote_service_record,
392 .get_remote_services = get_remote_services,
393 .start_discovery = start_discovery,
395 .start_custom_discovery = start_custom_discovery,
397 .cancel_discovery = cancel_discovery,
398 .create_bond = create_bond,
399 .remove_bond = remove_bond,
400 .cancel_bond = cancel_bond,
401 .pin_reply = pin_reply,
402 .ssp_reply = ssp_reply,
403 .get_profile_interface = get_profile_interface,
404 .dut_mode_configure = dut_mode_configure,
405 .dut_mode_send = dut_mode_send,
406 .le_test_mode = le_test_mode,
407 .config_hci_snoop_log = config_hci_snoop_log,
408 .get_connection_state = get_connection_state,
409 .set_os_callouts = set_os_callouts,
410 .read_energy_info = read_energy_info,
411 /* Tizen Specific API's*/
412 .authorize_response = authorize_response,
413 .set_authorization = set_authorization,
415 .get_service_connection_state = get_service_connection_state,
416 .set_agent_osp_server = set_agent_osp_server,
417 .set_trusted_profile = set_trusted_profile,
418 .get_trusted_profile = get_trusted_profile,
422 static const bt_interface_t *get_bluetooth_interface(void)
425 return &bluetooth_if;
428 static int close_bluetooth(struct hw_device_t *device)
436 static int open_bluetooth(const struct hw_module_t *module, char const *name,
437 struct hw_device_t **device)
439 bluetooth_device_t *dev = malloc(sizeof(bluetooth_device_t));
443 memset(dev, 0, sizeof(bluetooth_device_t));
444 dev->common.tag = HARDWARE_DEVICE_TAG;
445 dev->common.version = 0;
446 dev->common.module = (struct hw_module_t *) module;
447 dev->common.close = close_bluetooth;
448 dev->get_bluetooth_interface = get_bluetooth_interface;
450 *device = (struct hw_device_t *) dev;
455 static struct hw_module_methods_t bluetooth_module_methods = {
456 .open = open_bluetooth,
459 struct hw_module_t HAL_MODULE_INFO_SYM = {
460 .tag = HARDWARE_MODULE_TAG,
463 .id = BT_HARDWARE_MODULE_ID,
464 .name = "Bluetooth stack",
465 .author = "Intel Corporation",
466 .methods = &bluetooth_module_methods
469 static void __bt_hal_handle_adapter_state_changed(void *buf, uint16_t len)
471 struct hal_ev_adapter_state_changed *ev = buf;
473 DBG("Adapter State: %d", ev->state);
475 if (bt_hal_cbacks->adapter_state_changed_cb)
476 bt_hal_cbacks->adapter_state_changed_cb(ev->state);
480 static void __bt_hal_handle_le_state_changed(void *buf, uint16_t len)
482 struct hal_ev_le_state_changed *ev = buf;
484 DBG("Adapter State: %d", ev->state);
486 if (bt_hal_cbacks->le_state_changed_cb)
487 bt_hal_cbacks->le_state_changed_cb(ev->state);
491 static void __bt_adapter_props_to_hal(bt_property_t *send_props, struct hal_property *prop,
492 uint8_t num_props, uint16_t len)
497 for (i = 0; i < num_props; i++) {
498 if (sizeof(*prop) + prop->len > len) {
499 ERR("invalid adapter properties(%zu > %u), cant process further properties!!!",
500 sizeof(*prop) + prop->len, len);
504 send_props[i].type = prop->type;
506 switch (prop->type) {
507 /* TODO: Add Adapter Properties */
509 send_props[i].len = prop->len;
510 send_props[i].val = prop->val;
514 DBG("prop[%d]: %s", i, btproperty2str(&send_props[i]));
516 len -= sizeof(*prop) + prop->len;
517 buf += sizeof(*prop) + prop->len;
525 static void __bt_device_props_to_hal(bt_property_t *send_props,
526 struct hal_property *prop, uint8_t num_props,
534 for (i = 0; i < num_props; i++) {
536 if (sizeof(*prop) + prop->len > len) {
537 ERR("invalid device properties (%zu > %u), cant process further properties!!!",
538 sizeof(*prop) + prop->len, len);
542 send_props[i].type = prop->type;
544 DBG("HAL prop Type [%d]", prop->type);
546 switch (prop->type) {
547 case HAL_PROP_DEVICE_TYPE:
549 DBG("Device property:HAL_PROP_DEVICE_TYPE:");
550 enum_prop_to_hal(send_props[i], prop,
554 case HAL_PROP_DEVICE_VERSION_INFO:
556 DBG("Device property: HAL_PROP_DEVICE_VERSION_INFO");
557 static bt_remote_version_t e;
558 const struct hal_prop_device_info *p;
559 send_props[i].val = &e;
560 send_props[i].len = sizeof(e);
561 p = (struct hal_prop_device_info *) prop->val;
562 e.manufacturer = p->manufacturer;
563 e.sub_ver = p->sub_version;
564 e.version = p->version;
567 case HAL_PROP_DEVICE_SERVICE_REC:
569 DBG("Device property: HAL_PROP_DEVICE_SERVICE_REC");
570 static bt_service_record_t e;
571 const struct hal_prop_device_service_rec *p;
572 send_props[i].val = &e;
573 send_props[i].len = sizeof(e);
574 p = (struct hal_prop_device_service_rec *) prop->val;
575 memset(&e, 0, sizeof(e));
576 memcpy(&e.channel, &p->channel, sizeof(e.channel));
577 memcpy(e.uuid.uu, p->uuid, sizeof(e.uuid.uu));
578 memcpy(e.name, p->name, p->name_len);
582 send_props[i].len = prop->len;
583 send_props[i].val = prop->val;
587 DBG("prop[%d]: %s, len: %d", i, btproperty2str(&send_props[i]), prop->len);
588 len -= sizeof(*prop) + prop->len;
589 buf += sizeof(*prop) + prop->len;
599 ERR("invalid device properties (%u bytes left), ", len);
602 static void __bt_hal_handle_adapter_property_changed(void *buf, uint16_t len)
604 struct hal_ev_adapter_props_changed *ev = (struct hal_ev_adapter_props_changed *)buf;
605 bt_property_t props[ev->num_props];
608 if (!bt_hal_cbacks->adapter_properties_cb)
612 __bt_adapter_props_to_hal(props, ev->props, ev->num_props, len);
614 if (bt_hal_cbacks->adapter_properties_cb)
615 bt_hal_cbacks->adapter_properties_cb(ev->status, ev->num_props, props);
618 static void __bt_hal_handle_adapter_discovery_state_changed(void *buf, uint16_t len)
620 struct hal_ev_discovery_state_changed *ev = (struct hal_ev_discovery_state_changed *)buf;
624 if (bt_hal_cbacks->discovery_state_changed_cb)
625 bt_hal_cbacks->discovery_state_changed_cb(ev->state);
628 static void __bt_hal_handle_device_found_event(void *buf, uint16_t len)
630 struct hal_ev_device_found *ev = (struct hal_ev_device_found *) buf;
631 bt_property_t props[ev->num_props];
634 if (!bt_hal_cbacks->device_found_cb)
638 __bt_device_props_to_hal(props, ev->props, ev->num_props, len);
640 bt_hal_cbacks->device_found_cb(ev->num_props, props);
643 static void __bt_hal_handle_remote_device_properties_event(void *buf, uint16_t len)
645 struct hal_ev_remote_device_props *ev = (struct hal_ev_remote_device_props *) buf;
647 bt_property_t props[ev->num_props];
651 if (!bt_hal_cbacks->remote_device_properties_cb)
655 __bt_device_props_to_hal(props, ev->props, ev->num_props, len);
656 memcpy(bd_addr.address, ev->bdaddr, 6);
657 bt_hal_cbacks->remote_device_properties_cb(
658 ev->status, &bd_addr, ev->num_props, props);
662 static void __bt_hal_handle_bond_state_changed_event(void *buf, uint16_t len)
665 struct hal_ev_bond_state_changed *ev = (struct hal_ev_bond_state_changed *)buf;
669 memcpy(bd_addr.address, ev->bdaddr, 6);
671 DBG("[0x%x]", bd_addr.address[0]);
672 DBG("[0x%x]", bd_addr.address[1]);
673 DBG("[0x%x]", bd_addr.address[2]);
674 DBG("[0x%x]", bd_addr.address[3]);
675 DBG("[0x%x]", bd_addr.address[4]);
676 DBG("[0x%x]", bd_addr.address[5]);
678 DBG("Bonding State changed Status [0x%x]", ev->status);
679 DBG("Bonding State [0x%x]", ev->state);
681 if (!bt_hal_cbacks->bond_state_changed_cb) {
682 ERR("HAL User bond_state_changed_callback is not set!!");
686 bt_hal_cbacks->bond_state_changed_cb(ev->status, &bd_addr, ev->state);
690 static void __bt_hal_handle_device_acl_state_changed_event(void *buf, uint16_t len)
692 struct hal_ev_acl_state_changed *ev = (struct hal_ev_acl_state_changed*)buf;
696 memcpy(bd_addr.address, ev->bdaddr, 6);
698 DBG("[0x%x]", bd_addr.address[0]);
699 DBG("[0x%x]", bd_addr.address[1]);
700 DBG("[0x%x]", bd_addr.address[2]);
701 DBG("[0x%x]", bd_addr.address[3]);
702 DBG("[0x%x]", bd_addr.address[4]);
703 DBG("[0x%x]", bd_addr.address[5]);
705 DBG("ACL Status [0x%x]", ev->status);
706 DBG("ACL State [0x%x]", ev->state);
708 if (!bt_hal_cbacks->acl_state_changed_cb) {
709 ERR("HAL User acl_state_changed_cb is not set!!");
713 bt_hal_cbacks->acl_state_changed_cb(ev->status, &bd_addr, ev->state);
717 static void __bt_hal_handle_device_le_conn_state_changed_event(void *buf, uint16_t len)
719 struct hal_ev_acl_state_changed *ev = (struct hal_ev_acl_state_changed*)buf;
723 memcpy(bd_addr.address, ev->bdaddr, 6);
725 DBG("Address: [%02X:%02X:%02X:%02X:%02X:%02X]", bd_addr.address[0],
726 bd_addr.address[1], bd_addr.address[2], bd_addr.address[3],
727 bd_addr.address[4], bd_addr.address[5]);
728 DBG("LE conn Status [0x%x]", ev->status);
729 DBG("LE conn State [0x%x]", ev->state);
732 if (!bt_hal_cbacks->le_conn_state_changed_cb) {
733 ERR("HAL User le_conn_state_changed_cb is not set!!");
737 bt_hal_cbacks->le_conn_state_changed_cb(ev->status, &bd_addr, ev->state);
742 static void __bt_hal_handle_authorize_request_event(void *buf, uint16_t len)
744 struct hal_ev_authorize_request *ev = (struct hal_ev_authorize_request *)buf;
749 memcpy(bd_addr.address, ev->bdaddr, 6);
752 DBG("[0x%x]", bd_addr.address[0]);
753 DBG("[0x%x]", bd_addr.address[1]);
754 DBG("[0x%x]", bd_addr.address[2]);
755 DBG("[0x%x]", bd_addr.address[3]);
756 DBG("[0x%x]", bd_addr.address[4]);
757 DBG("[0x%x]", bd_addr.address[5]);
759 DBG("Service Id: [%u]", ev->service_id);
761 if (!bt_hal_cbacks->authorize_request_cb) {
762 ERR("HAL User authorize_request_cb is not set!!");
766 bt_hal_cbacks->authorize_request_cb(&bd_addr, ev->service_id);
771 static void __bt_hal_handle_socket_authorize_request_event(void *buf, uint16_t len)
773 struct hal_ev_sock_conn_auth *ev = buf;
779 memcpy(bd_addr.address, ev->bdaddr, 6);
780 memcpy(uuid.uu, ev->uuid, 16);
782 if (!bt_hal_cbacks->socket_authorize_request_cb) {
783 ERR("HAL User socket_authorize_request_cb is not set!!");
787 bt_hal_cbacks->socket_authorize_request_cb(&bd_addr, &uuid);
792 static void __bt_hal_handle_ssp_request_event(void *buf, uint16_t len)
794 struct hal_ev_ssp_request *ev = (struct hal_ev_ssp_request *)buf;
799 memcpy(bd_addr.address, ev->bdaddr, 6);
800 memcpy(bd_name.name, ev->name, 248);
803 DBG("[0x%x]", bd_addr.address[0]);
804 DBG("[0x%x]", bd_addr.address[1]);
805 DBG("[0x%x]", bd_addr.address[2]);
806 DBG("[0x%x]", bd_addr.address[3]);
807 DBG("[0x%x]", bd_addr.address[4]);
808 DBG("[0x%x]", bd_addr.address[5]);
810 DBG("COD [%d]", ev->class_of_dev);
811 DBG("pairing variant [%d]", ev->pairing_variant);
812 DBG("passkey [%d]", ev->passkey);
814 if (!bt_hal_cbacks->ssp_request_cb) {
815 ERR("HAL User ssp_request_cb is not set!!");
819 bt_hal_cbacks->ssp_request_cb(&bd_addr, &bd_name,
821 ev->pairing_variant, ev->passkey);
825 static void __bt_hal_handle_pin_request_event(void *buf, uint16_t len)
827 struct hal_ev_pin_request *ev = (struct hal_ev_pin_request *)buf;
832 memcpy(bd_addr.address, ev->bdaddr, 6);
833 memcpy(bd_name.name, ev->name, 248);
836 DBG("[0x%x]", bd_addr.address[0]);
837 DBG("[0x%x]", bd_addr.address[1]);
838 DBG("[0x%x]", bd_addr.address[2]);
839 DBG("[0x%x]", bd_addr.address[3]);
840 DBG("[0x%x]", bd_addr.address[4]);
841 DBG("[0x%x]", bd_addr.address[5]);
843 DBG("COD [%u]", ev->class_of_dev);
845 if (!bt_hal_cbacks->pin_request_cb) {
846 ERR("HAL User pin_request_cb is not set!!");
850 bt_hal_cbacks->pin_request_cb(&bd_addr, &bd_name,
855 static void __bt_hal_handle_device_trust_state_changed_event(void *buf, uint16_t len)
857 struct hal_ev_device_trust_state_changed *ev = (struct hal_ev_device_trust_state_changed*)buf;
861 memcpy(bd_addr.address, ev->bdaddr, 6);
863 DBG("[0x%x]", bd_addr.address[0]);
864 DBG("[0x%x]", bd_addr.address[1]);
865 DBG("[0x%x]", bd_addr.address[2]);
866 DBG("[0x%x]", bd_addr.address[3]);
867 DBG("[0x%x]", bd_addr.address[4]);
868 DBG("[0x%x]", bd_addr.address[5]);
870 DBG("Device Trusted? [0x%x]", ev->trust);
872 if (!bt_hal_cbacks->device_trust_state_changed_cb) {
873 ERR("HAL User device_trust_state_changed_cb is not set!!");
877 bt_hal_cbacks->device_trust_state_changed_cb(&bd_addr, ev->trust);
881 static void __bt_hal_handle_stack_messages(int message, void *buf, uint16_t len)
885 case HAL_EV_ADAPTER_STATE_CHANGED:
886 DBG("Event: HAL_EV_ADAPTER_STATE_CHANGED");
887 __bt_hal_handle_adapter_state_changed(buf, len);
889 case HAL_EV_ADAPTER_PROPS_CHANGED:
890 DBG("Event: HAL_EV_ADAPTER_PROPS_CHANGED");
891 __bt_hal_handle_adapter_property_changed(buf, len);
893 case HAL_EV_DISCOVERY_STATE_CHANGED:
894 DBG("Event: HAL_EV_DISCOVERY_STATE_CHANGED");
895 __bt_hal_handle_adapter_discovery_state_changed(buf, len);
897 case HAL_EV_DEVICE_FOUND:
898 DBG("Event: HAL_EV_DEVICE_FOUND");
899 __bt_hal_handle_device_found_event(buf, len);
901 case HAL_EV_REMOTE_DEVICE_PROPS:
902 DBG("Event: HAL_EV_REMOTE_DEVICE_PROPS");
903 __bt_hal_handle_remote_device_properties_event(buf, len);
905 case HAL_EV_BOND_STATE_CHANGED:
906 DBG("Event: HAL_EV_BOND_STATE_CHANGED:");
907 __bt_hal_handle_bond_state_changed_event(buf, len);
909 case HAL_EV_ACL_STATE_CHANGED:
910 DBG("Event: HAL_ACL_STATE_CONNECTED or Disconnected");
911 __bt_hal_handle_device_acl_state_changed_event(buf, len);
913 case HAL_EV_LE_CONN_STATE_CHANGED:
914 DBG("Event: HAL_LE_CONN_STATE_CONNECTED or Disconnected");
915 __bt_hal_handle_device_le_conn_state_changed_event(buf, len);
917 case HAL_EV_SSP_REQUEST:
918 DBG("Event: HAL_EV_SSP_REQUEST");
919 __bt_hal_handle_ssp_request_event(buf, len);
921 case HAL_EV_PIN_REQUEST:
922 DBG("Event: HAL_EV_PIN_REQUEST");
923 __bt_hal_handle_pin_request_event(buf, len);
925 case HAL_EV_AUTHORIZE_REQUEST:
926 DBG("Event: HAL_EV_AUTHORIZE_REQUEST");
927 __bt_hal_handle_authorize_request_event(buf, len);
929 case HAL_EV_DEVICE_TRUST_CHANGED:
930 DBG("Event: HAL_EV_DEVICE_TRUST_CHANGED");
931 __bt_hal_handle_device_trust_state_changed_event(buf, len);
934 case HAL_EV_SOCK_AUTHORIZE_REQUEST:
935 DBG("Event: HAL_EV_AUTHORIZE_REQUEST");
936 __bt_hal_handle_socket_authorize_request_event(buf, len);
938 case HAL_EV_LE_STATE_CHANGED:
939 DBG("Event: HAL_EV_LE_STATE_CHANGED");
940 __bt_hal_handle_le_state_changed(buf, len);
944 DBG("Event Currently not handled!!");