*/
oal_status_t device_reply_auth_request(bt_address_t * addr, oal_service_t service_type, int accept, int always);
+/**
+ * @brief Set a device as authorized or unauthorized
+ *
+ * @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
+ *
+ * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
+ * @retval #OAL_STATUS_SUCCESS Successful
+ *
+ * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
+ *
+ * @see OAL_EVENT_DEVICE_AUTHORIZE_REQUEST
+ */
+oal_status_t device_set_authorized(bt_address_t * addr, int authorize);
+
#ifdef __cplusplus
}
#endif /* __cplusplus */
return OAL_STATUS_SUCCESS;
}
+oal_status_t device_set_authorized(bt_address_t * addr, int authorize)
+{
+ int res;
+ bdstr_t bdstr;
+
+ CHECK_OAL_INITIALIZED();
+
+ OAL_CHECK_PARAMETER(addr, return);
+
+ API_TRACE("[%s] %d", bdt_bd2str(addr, &bdstr), authorize);
+
+ res = blued_api->set_authorization((bt_bdaddr_t *)addr, authorize);
+ if (res != BT_STATUS_SUCCESS) {
+ BT_ERR("set_authorization error: [%s]", status2string(res));
+ BT_ERR("%d", authorize);
+ 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)
{
result = _bt_passkey_confirmation_reply(confirmation_reply);
break;
}
+ case BT_SET_AUTHORIZATION: {
+ bluetooth_device_address_t address = { {0} };
+ gboolean authorize;
+ __bt_service_get_parameters(in_param1,
+ &address, sizeof(bluetooth_device_address_t));
+ __bt_service_get_parameters(in_param2,
+ &authorize, sizeof(gboolean));
+ result = _bt_set_authorization(&address, authorize);
+ break;
+ }
case BT_HID_CONNECT: {
bluetooth_device_address_t address = { {0} };
return BLUETOOTH_ERROR_NONE;
BT_DBG("-");
}
+
+int _bt_set_authorization(bluetooth_device_address_t *device_address,
+ gboolean authorize)
+{
+ int ret = OAL_STATUS_SUCCESS;
+ BT_DBG("+");
+
+ BT_CHECK_PARAMETER(device_address, return);
+ BT_INFO("Device to be Trusted? [%d]", authorize);
+
+ ret = device_set_authorized((bt_address_t*)device_address, authorize);
+ if (ret != OAL_STATUS_SUCCESS) {
+ BT_ERR("device_set_authorized: %d", ret);
+ return BLUETOOTH_ERROR_INTERNAL;
+ }
+
+ return BLUETOOTH_ERROR_NONE;
+}
int _bt_passkey_confirmation_reply(gboolean confirmation_reply);
-
+int _bt_set_authorization(bluetooth_device_address_t *device_address,
+ gboolean authorize);
#ifdef __cplusplus
}
#endif /* __cplusplus */