static int set_remote_device_property(bt_bdaddr_t *remote_addr, const bt_property_t *property) { struct hal_cmd_set_remote_device_prop *cmd; uint8_t buf[sizeof(*cmd) + property->len]; DBG("bdaddr: %s prop: %s", bdaddr2str(remote_addr), bt_property_type_t2str(property->type)); if (!interface_ready()) return BT_STATUS_NOT_READY; cmd = (void *) buf; memcpy(cmd->bdaddr, remote_addr, sizeof(cmd->bdaddr)); /* type match IPC type */ cmd->type = property->type; cmd->len = property->len; memcpy(cmd->val, property->val, property->len); return hal_ipc_cmd(HAL_SERVICE_ID_BLUETOOTH, HAL_OP_SET_REMOTE_DEVICE_PROP, sizeof(buf), cmd, 0, NULL, NULL); }
static void acl_state_changed_cb(bt_status_t status, bt_bdaddr_t *remote_bd_addr, bt_acl_state_t state) { haltest_info("%s: status=%s remote_bd_addr=%s state=%s\n", __func__, bt_status_t2str(status), bdaddr2str(remote_bd_addr), bt_acl_state_t2str(state)); }
static void remote_device_properties_cb(bt_status_t status, bt_bdaddr_t *bd_addr, int num_properties, bt_property_t *properties) { haltest_info("%s: status=%s bd_addr=%s num_properties=%d\n", __func__, bt_status_t2str(status), bdaddr2str(bd_addr), num_properties); add_remote_device(bd_addr); dump_properties(num_properties, properties); }
static int remove_bond(const bt_bdaddr_t *bd_addr) { struct hal_cmd_remove_bond cmd; DBG("bdaddr: %s", bdaddr2str(bd_addr)); if (!interface_ready()) return BT_STATUS_NOT_READY; memcpy(cmd.bdaddr, bd_addr, sizeof(cmd.bdaddr)); return hal_ipc_cmd(HAL_SERVICE_ID_BLUETOOTH, HAL_OP_REMOVE_BOND, sizeof(cmd), &cmd, 0, NULL, NULL); }
static int get_remote_services(bt_bdaddr_t *remote_addr) { struct hal_cmd_get_remote_services cmd; DBG("bdaddr: %s", bdaddr2str(remote_addr)); if (!interface_ready()) return BT_STATUS_NOT_READY; memcpy(cmd.bdaddr, remote_addr, sizeof(cmd.bdaddr)); return hal_ipc_cmd(HAL_SERVICE_ID_BLUETOOTH, HAL_OP_GET_REMOTE_SERVICES, sizeof(cmd), &cmd, 0, NULL, NULL); }
/* * Callback for get_remote_mas_instances */ static void btmce_remote_mas_instances_cb(bt_status_t status, bt_bdaddr_t *bd_addr, int num_instances, btmce_mas_instance_t *instances) { int i; haltest_info("%s: status=%s bd_addr=%s num_instance=%d\n", __func__, bt_status_t2str(status), bdaddr2str(bd_addr), num_instances); for (i = 0; i < num_instances; i++) haltest_info("id=%d scn=%d msg_types=%d name=%s\n", instances[i].id, instances[i].scn, instances[i].msg_types, instances[i].p_name); }
static int pin_reply(const bt_bdaddr_t *bd_addr, uint8_t accept, uint8_t pin_len, bt_pin_code_t *pin_code) { struct hal_cmd_pin_reply cmd; DBG("bdaddr: %s", bdaddr2str(bd_addr)); if (!interface_ready()) return BT_STATUS_NOT_READY; memcpy(cmd.bdaddr, bd_addr, sizeof(cmd.bdaddr)); cmd.accept = accept; cmd.pin_len = pin_len; memcpy(cmd.pin_code, pin_code, sizeof(cmd.pin_code)); return hal_ipc_cmd(HAL_SERVICE_ID_BLUETOOTH, HAL_OP_PIN_REPLY, sizeof(cmd), &cmd, 0, NULL, NULL); }
static int ssp_reply(const bt_bdaddr_t *bd_addr, bt_ssp_variant_t variant, uint8_t accept, uint32_t passkey) { struct hal_cmd_ssp_reply cmd; DBG("bdaddr: %s", bdaddr2str(bd_addr)); if (!interface_ready()) return BT_STATUS_NOT_READY; memcpy(cmd.bdaddr, bd_addr, sizeof(cmd.bdaddr)); /* type match IPC type */ cmd.ssp_variant = variant; cmd.accept = accept; cmd.passkey = passkey; return hal_ipc_cmd(HAL_SERVICE_ID_BLUETOOTH, HAL_OP_SSP_REPLY, sizeof(cmd), &cmd, 0, NULL, NULL); }
static int get_remote_device_property(bt_bdaddr_t *remote_addr, bt_property_type_t type) { struct hal_cmd_get_remote_device_prop cmd; DBG("bdaddr: %s prop: %s", bdaddr2str(remote_addr), bt_property_type_t2str(type)); if (!interface_ready()) return BT_STATUS_NOT_READY; memcpy(cmd.bdaddr, remote_addr, sizeof(cmd.bdaddr)); /* type match IPC type */ cmd.type = type; return hal_ipc_cmd(HAL_SERVICE_ID_BLUETOOTH, HAL_OP_GET_REMOTE_DEVICE_PROP, sizeof(cmd), &cmd, 0, NULL, NULL); }
const char *btproperty2str(const bt_property_t *property) { static char buf[4096]; char *p; p = buf + sprintf(buf, "type=%s len=%d val=", bt_property_type_t2str(property->type), property->len); switch (property->type) { case BT_PROPERTY_BDNAME: case BT_PROPERTY_REMOTE_FRIENDLY_NAME: snprintf(p, property->len + 1, "%s", ((bt_bdname_t *) property->val)->name); break; case BT_PROPERTY_BDADDR: sprintf(p, "%s", bdaddr2str((bt_bdaddr_t *) property->val)); break; case BT_PROPERTY_CLASS_OF_DEVICE: sprintf(p, "%06x", *((int *) property->val)); break; case BT_PROPERTY_TYPE_OF_DEVICE: sprintf(p, "%s", bt_device_type_t2str( *((bt_device_type_t *) property->val))); break; case BT_PROPERTY_REMOTE_RSSI: sprintf(p, "%d", *((char *) property->val)); break; case BT_PROPERTY_ADAPTER_SCAN_MODE: sprintf(p, "%s", bt_scan_mode_t2str(*((bt_scan_mode_t *) property->val))); break; case BT_PROPERTY_ADAPTER_DISCOVERY_TIMEOUT: sprintf(p, "%d", *((int *) property->val)); break; case BT_PROPERTY_ADAPTER_BONDED_DEVICES: { int count = property->len / sizeof(bt_bdaddr_t); char *ptr = property->val; strcat(p, "{"); while (count--) { strcat(p, bdaddr2str((bt_bdaddr_t *) ptr)); if (count) strcat(p, ", "); ptr += sizeof(bt_bdaddr_t); } strcat(p, "}"); } break; case BT_PROPERTY_UUIDS: { int count = property->len / sizeof(bt_uuid_t); uint8_t *ptr = property->val; strcat(p, "{"); while (count--) { strcat(p, btuuid2str(ptr)); if (count) strcat(p, ", "); ptr += sizeof(bt_uuid_t); } strcat(p, "}"); } break; case BT_PROPERTY_SERVICE_RECORD: { bt_service_record_t *rec = property->val; sprintf(p, "{%s, %d, %s}", btuuid2str(rec->uuid.uu), rec->channel, rec->name); } break; default: sprintf(p, "%p", property->val); } return buf; }