*/
oal_status_t device_reply_ssp_consent(bt_address_t * addr, int accept);
+/**
+ * @brief Accept or reject authorization request for a connection from remote device
+ *
+ * @details authorize = TRUE: all connections from this device will be auto accepted without any auth-event
+ * authorize = FALSE: all connections from this device will result in auth request event
+ *
+ * @param[in] always If TRUE, future connection requests will be automatically accepted.
+ *
+ * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
+ * @retval #OAL_STATUS_SUCCESS Successful
+ *
+ * @pre OAL_EVENT_DEVICE_AUTHORIZE_REQUEST should have been recieved by application.
+ *
+ * @see OAL_EVENT_DEVICE_AUTHORIZE_REQUEST
+ */
+oal_status_t device_reply_auth_request(bt_address_t * addr, oal_service_t service_type, int accept, int always);
#ifdef __cplusplus
}
return OAL_STATUS_SUCCESS;
}
+oal_status_t device_reply_auth_request(bt_address_t * addr, oal_service_t service_type, int accept, int always)
+{
+ int res;
+ bdstr_t bdstr;
+
+ CHECK_OAL_INITIALIZED();
+
+ OAL_CHECK_PARAMETER(addr, return);
+
+ API_TRACE("[%s] Accept: %d, always: %d, service_type: %d", bdt_bd2str(addr, &bdstr), accept, always, service_type);
+
+ res = blued_api->authorize_response((bt_bdaddr_t *)addr, service_type, accept, always);
+ if (res != BT_STATUS_SUCCESS) {
+ BT_ERR("authorize_response error: [%s]", status2string(res));
+ BT_ERR("Accept: [%d], always: [%d], service_type: [%d]", accept, always, service_type);
+ return convert_to_oal_status(res);
+ }
+
+ return OAL_STATUS_SUCCESS;
+}
+
void cb_device_properties(bt_status_t status, bt_bdaddr_t *bd_addr,
int num_properties, bt_property_t *properties)
{
{
oal_service_t service_d = auth_event->service_id;
gchar address[BT_ADDRESS_STR_LEN];
+ int res;
_bt_convert_addr_type_to_string(address, auth_event->address.addr);
BT_INFO("service_d: %d", service_d);
- /* TODO: Add Reply to Authorization requests */
switch(service_d) {
case HID_SERVICE_ID:
BT_INFO("Incoming HID Profile conn Req from device addr [%s]", address);
BT_INFO("Incoming AVRCP Profile conn Req from device addr [%s]", address);
break;
default:
+ /* For now, reject authorization for any service apart from above switch cases */
BT_INFO("Incoming Profile conn req with service ID [%d] from device addr [%s]", service_d, address);
- break;
+ res = device_reply_auth_request((bt_address_t*)&auth_event->address, service_d, FALSE, FALSE);
+ if (res != OAL_STATUS_SUCCESS)
+ BT_ERR("authorize_response: %d", res);
+ return;
}
+
+ /* Auto accept authorization request for HID, A2DP and AVRCP profiles */
+ res = device_reply_auth_request((bt_address_t*)&auth_event->address, service_d, TRUE, FALSE);
+ if (res != OAL_STATUS_SUCCESS)
+ BT_ERR("authorize_response: %d", res);
BT_INFO("-");
}