1. Add Seperate APIs for Monitor and reporter role.
2. Add Sperate callback for proximity profile connection.
3. Add API to set scan filter for Proximity UUID
Change-Id: Ia733b9fa2758cc641ee5cfb5eb090cd8ecf4573b
Signed-off-by: h.sandeep <h.sandeep@samsung.com>
/* Manufacture ID for Apple iBeacons */
#define COMPANY_ID_APPLE 0x004C
+/* Priximity Services UUID */
+#define PXP_IMMEDIATE_ALERT_SVC_UUID "1802"
+#define PXP_LINK_LOSS_SVC_UUID "1803"
+#define PXP_TX_POWER_SVC_UUID "1804"
+
/**
* @internal
* @brief Bluetooth callback.
BT_EVENT_GET_RSSI_EVENT, /**< Get RSSI Strength callback */
BT_EVENT_LE_READ_MAXIMUM_DATA_LENGTH, /**< Read maximun LE data length callback */
BT_EVENT_SUPPORTED_TRUSTED_PROFILE_EVENT, /**< Trusted Profile callback */
- BT_EVENT_PROXIMITY_PROPERTY_CHANGED, /**< Proximity property changed */
+ BT_EVENT_PROXIMITY_CONNECTION_STATE_CHANGED, /**< Proximity Monitor/Reporter Connection sgate changed */
+ BT_EVENT_PROXIMITY_REPORTER_PROPERTY_CHANGED, /**< Proximity property changed */
#if defined(TIZEN_PROFILE_WEARABLE) || defined(TIZEN_PROFILE_IVI)
BT_EVENT_PBAP_CONNECTION_STATUS, /**< PBAP connection status callback */
BT_EVENT_PBAP_PHONEBOOK_SIZE, /**< PBAP Phonebook Size status callback */
int bt_device_le_set_data_length_change_cb(
_bt_le_set_data_length_changed_cb callback, void *user_data);
+/**
+ * @internal
+ * @brief Reads if the Proximity profile is registered or not.
+ */
+int _bt_check_proximity_is_initialized(bool *is_initialized);
+
+/**
+ * @internal
+ * @brief Calls the connection state changed callback for proximity profile.
+ */
+int _bt_proximity_connection_set_state_changed(int result, const char *remote_address, bool connected);
+
#ifdef __cplusplus
}
#endif
/**
* @internal
- * @brief Register the Proximity Profile.
+ * @brief Creates the Proximity Profile Reporter Role.
*/
-int bt_proximity_register(bt_proximity_role_t role, bt_proximity_property_changed_cb callback, void *user_data);
+int bt_proximity_reporter_create(bt_proximity_reporter_h *reporter);
/**
* @internal
- * @brief Unregister the Proximity Profile.
+ * @brief Destroys the Proximity Profile Monitor Role.
*/
-int bt_proximity_unregister(bt_proximity_role_t role);
+int bt_proximity_reporter_destroy(bt_proximity_reporter_h reporter);
/**
* @internal
- * @brief Set the Proximity Profile property value.
+ * @brief Creates the Proximity Profile Reporter Role.
*/
-int bt_proximity_set_property(const char *remote_address, bt_proximity_property_t property, int value);
+int bt_proximity_monitor_create(const char *remote_address, bt_proximity_monitor_h *monitor);
/**
* @internal
- * @brief Read the Proximity Profile property value.
+ * @brief Creates the Proximity Profile Monitor Role.
*/
-int bt_proximity_get_property(const char *remote_address, bt_proximity_property_t property, int *value);
+int bt_proximity_monitor_destroy(bt_proximity_monitor_h monitor);
/**
* @internal
- * @brief Lists the Proximity Profile property/service supported.
+ * @brief Proximity Monitor initiates the connection to remote reporter device.
*/
-int bt_proximity_get_supported_services(const char *remote_address, int *supported_services);
+int bt_proximity_monitor_connect(bt_proximity_monitor_h monitor);
+
+/**
+ * @internal
+ * @brief Proximity Monitor disconnects with the remote reporter device.
+ */
+int bt_proximity_monitor_disconnect(bt_proximity_monitor_h monitor);
+
+/**
+ * @internal
+ * @brief Sets proximity monitor connection state changed event change callback.
+ */
+int bt_proximity_monitor_set_connection_state_changed_cb(bt_proximity_monitor_h monitor,
+ bt_proximity_monitor_connection_state_changed_cb callback, void *user_data);
+
+/**
+ * @internal
+ * @brief Unsets proximity monitor connection state changed event change callback.
+ */
+int bt_proximity_monitor_unset_connection_state_changed_cb(bt_proximity_monitor_h monitor);
+
+/**
+ * @internal
+ * @brief Sets proximity reporter connection state changed event change callback.
+ */
+int bt_proximity_reporter_set_connection_state_changed_cb(bt_proximity_reporter_h reporter,
+ bt_proximity_reporter_connection_state_changed_cb callback, void *user_data);
+
+/**
+ * @internal
+ * @brief Unsets proximity reporter connection state changed event change callback.
+ */
+int bt_proximity_reporter_unset_connection_state_changed_cb(bt_proximity_reporter_h reporter);
+
+/**
+ * @internal
+ * @brief Sets proximity reporter properties change callback.
+ */
+int bt_proximity_reporter_set_property_changed_cb(bt_proximity_reporter_h reporter,
+ bt_proximity_reporter_property_changed_cb callback, void *user_data);
+
+/**
+ * @internal
+ * @brief Unsets proximity reporter properties change callback.
+ */
+int bt_proximity_reporter_unset_property_changed_cb(bt_proximity_reporter_h reporter);
+
+/**
+ * @internal
+ * @brief Set the Proximity Profile monitor linkloss alert value.
+ */
+int bt_proximity_monitor_set_linkloss_alert(bt_proximity_monitor_h monitor, int value);
+
+/**
+ * @internal
+ * @brief Set the Proximity Profile monitor immediate alert value.
+ */
+int bt_proximity_monitor_set_immediate_alert(bt_proximity_monitor_h monitor, int value);
+
+/**
+ * @internal
+ * @brief Read the Proximity Profile monitor linkloss alert value.
+ */
+int bt_proximity_monitor_get_linkloss_alert(bt_proximity_monitor_h monitor, int *value);
+
+/**
+ * @internal
+ * @brief Read the Proximity Profile monitor immediate alert value.
+ */
+int bt_proximity_monitor_get_immediate_alert(bt_proximity_monitor_h monitor, int *value);
+
+/**
+ * @internal
+ * @brief Read the Proximity Profile monitor Signal level value.
+ */
+int bt_proximity_monitor_get_signal_level(bt_proximity_monitor_h monitor, int *value);
+
+/**
+ * @internal
+ * @brief Read the Proximity Profile reporter linkloss alert value.
+ */
+int bt_proximity_reporter_get_linkloss_alert(const char *remote_address, int *value);
+
+/**
+ * @internal
+ * @brief Read the Proximity Profile reporter immediate alert value.
+ */
+int bt_proximity_reporter_get_immediate_alert(const char *remote_address, int *value);
/**
* @internal
*/
int bt_adapter_le_free_ibeacon_report(bt_adapter_ibeacon_scan_result_info_s *ibeacon_info);
+/**
+ * @internal
+ * @brief API to Set the Proximity uuids scan report
+ */
+int bt_adapter_le_scan_filter_set_proximity_uuid(bt_scan_filter_h scan_filter);
+
+/**
+ * @internal
+ * @brief API to Unset the Proximity uuids scan report
+ */
+int bt_adapter_le_scan_filter_unset_proximity_uuid(bt_scan_filter_h scan_filter);
+
/**
* @}
*/
typedef void (*bt_ipsp_connection_state_changed_cb)
(int result, bool connected, const char *remote_address, const char *iface_name, void *user_data);
+/**
+ * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE
+ * @brief The handle of a Proximity Monitor client handle which is associated with a remote device.
+ * @since_tizen 3.0
+ */
+typedef void *bt_proximity_monitor_h;
+
+/**
+ * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE
+ * @brief The handle of a Proximity Reporter server.
+ * @since_tizen 3.0
+ */
+typedef void *bt_proximity_reporter_h;
+
+/**
+ * @internal
+ * @since_tizen 3.0
+ * @brief Proximity profile reporter property changed callback
+ */
+typedef void (*bt_proximity_reporter_property_changed_cb)
+ (int result, const char *remote_address, int service_type, int prop_value, void *user_data);
+
+/**
+ * @internal
+ * @since_tizen 3.0
+ * @brief Proximity monitor profile connection state changed callback
+ */
+typedef void (*bt_proximity_monitor_connection_state_changed_cb)
+ (int result, const char *remote_address, bt_proximity_monitor_h monitor, bool connected, int supported_service, void *user_data);
+
/**
* @internal
- * @brief Proximity profile property changed callback
+ * @since_tizen 3.0
+ * @brief Proximity reporter profile connection state changed callback
*/
-typedef void (*bt_proximity_property_changed_cb)
- (int result, const char *remote_address, int role, int service_type, int prop_value, void *user_data);
+typedef void (*bt_proximity_reporter_connection_state_changed_cb)
+ (int result, const char *remote_address, bt_proximity_reporter_h reporter, bool connected, int supported_service, void *user_data);
/**
* @internal
/**
* @internal
- * @brief Register the Proximity Profile.
+ * @brief Creates the Proximity Profile Reporter Role.
*/
-int bt_proximity_register(bt_proximity_role_t role, bt_proximity_property_changed_cb callback, void *user_data);
+int bt_proximity_reporter_create(bt_proximity_reporter_h *reporter);
/**
* @internal
- * @brief Unregister the Proximity Profile.
+ * @brief Destroys the Proximity Profile Monitor Role.
*/
-int bt_proximity_unregister(bt_proximity_role_t role);
+int bt_proximity_reporter_destroy(bt_proximity_reporter_h reporter);
/**
* @internal
- * @brief Set the Proximity Profile property value.
+ * @brief Creates the Proximity Profile Reporter Role.
*/
-int bt_proximity_set_property(const char *remote_address, bt_proximity_property_t property, int value);
+int bt_proximity_monitor_create(const char *remote_address, bt_proximity_monitor_h *monitor);
/**
* @internal
- * @brief Read the Proximity Profile property value.
+ * @brief Creates the Proximity Profile Monitor Role.
*/
-int bt_proximity_get_property(const char *remote_address, bt_proximity_property_t property, int *value);
+int bt_proximity_monitor_destroy(bt_proximity_monitor_h monitor);
/**
* @internal
- * @brief Lists the Proximity Profile property/service supported.
+ * @brief Proximity Monitor initiates the connection to remote reporter device.
*/
-int bt_proximity_get_supported_services(const char *remote_address, int *supported_services);
+int bt_proximity_monitor_connect(bt_proximity_monitor_h monitor);
+
+/**
+ * @internal
+ * @brief Proximity Monitor disconnects with the remote reporter device.
+ */
+int bt_proximity_monitor_disconnect(bt_proximity_monitor_h monitor);
+
+/**
+ * @internal
+ * @brief Sets proximity monitor connection state changed event change callback.
+ */
+int bt_proximity_monitor_set_connection_state_changed_cb(bt_proximity_monitor_h monitor,
+ bt_proximity_monitor_connection_state_changed_cb callback, void *user_data);
+
+/**
+ * @internal
+ * @brief Unsets proximity monitor connection state changed event change callback.
+ */
+int bt_proximity_monitor_unset_connection_state_changed_cb(bt_proximity_monitor_h monitor);
+
+/**
+ * @internal
+ * @brief Sets proximity reporter connection state changed event change callback.
+ */
+int bt_proximity_reporter_set_connection_state_changed_cb(bt_proximity_reporter_h reporter,
+ bt_proximity_reporter_connection_state_changed_cb callback, void *user_data);
+
+/**
+ * @internal
+ * @brief Unsets proximity reporter connection state changed event change callback.
+ */
+int bt_proximity_reporter_unset_connection_state_changed_cb(bt_proximity_reporter_h reporter);
+
+/**
+ * @internal
+ * @brief Sets proximity reporter properties change callback.
+ */
+int bt_proximity_reporter_set_property_changed_cb(bt_proximity_reporter_h reporter,
+ bt_proximity_reporter_property_changed_cb callback, void *user_data);
+
+/**
+ * @internal
+ * @brief Unsets proximity reporter properties change callback.
+ */
+int bt_proximity_reporter_unset_property_changed_cb(bt_proximity_reporter_h reporter);
+
+/**
+ * @internal
+ * @brief Set the Proximity Profile monitor linkloss alert value.
+ */
+int bt_proximity_monitor_set_linkloss_alert(bt_proximity_monitor_h monitor, int value);
+
+/**
+ * @internal
+ * @brief Set the Proximity Profile monitor immediate alert value.
+ */
+int bt_proximity_monitor_set_immediate_alert(bt_proximity_monitor_h monitor, int value);
+
+/**
+ * @internal
+ * @brief Read the Proximity Profile monitor linkloss alert value.
+ */
+int bt_proximity_monitor_get_linkloss_alert(bt_proximity_monitor_h monitor, int *value);
+
+/**
+ * @internal
+ * @brief Read the Proximity Profile monitor immediate alert value.
+ */
+int bt_proximity_monitor_get_immediate_alert(bt_proximity_monitor_h monitor, int *value);
+
+/**
+ * @internal
+ * @brief Read the Proximity Profile monitor Signal level value.
+ */
+int bt_proximity_monitor_get_signal_level(bt_proximity_monitor_h monitor, int *value);
+
+/**
+ * @internal
+ * @brief Read the Proximity Profile reporter linkloss alert value.
+ */
+int bt_proximity_reporter_get_linkloss_alert(const char *remote_address, int *value);
+
+/**
+ * @internal
+ * @brief Read the Proximity Profile reporter immediate alert value.
+ */
+int bt_proximity_reporter_get_immediate_alert(const char *remote_address, int *value);
/**
* @internal
*/
int bt_adapter_le_free_ibeacon_report(bt_adapter_ibeacon_scan_result_info_s *ibeacon_info);
+/**
+ * @internal
+ * @brief API to Set the Proximity uuids scan report
+ */
+int bt_adapter_le_scan_filter_set_proximity_uuid(bt_scan_filter_h scan_filter);
+
+/**
+ * @internal
+ * @brief API to Unset the Proximity uuids scan report
+ */
+int bt_adapter_le_scan_filter_unset_proximity_uuid(bt_scan_filter_h scan_filter);
+
/**
* @}
*/
typedef void (*bt_ipsp_connection_state_changed_cb)
(int result, bool connected, const char *remote_address, const char *iface_name, void *user_data);
+/**
+ * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE
+ * @brief The handle of a Proximity Monitor client handle which is associated with a remote device.
+ * @since_tizen 3.0
+ */
+typedef void *bt_proximity_monitor_h;
+
+/**
+ * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE
+ * @brief The handle of a Proximity Reporter server.
+ * @since_tizen 3.0
+ */
+typedef void *bt_proximity_reporter_h;
+
+/**
+ * @internal
+ * @since_tizen 3.0
+ * @brief Proximity profile reporter property changed callback
+ */
+typedef void (*bt_proximity_reporter_property_changed_cb)
+ (int result, const char *remote_address, int service_type, int prop_value, void *user_data);
+
+/**
+ * @internal
+ * @since_tizen 3.0
+ * @brief Proximity monitor profile connection state changed callback
+ */
+typedef void (*bt_proximity_monitor_connection_state_changed_cb)
+ (int result, const char *remote_address, bt_proximity_monitor_h monitor, bool connected, int supported_service, void *user_data);
+
+/**
+ * @internal
+ * @since_tizen 3.0
+ * @brief Proximity reporter profile connection state changed callback
+ */
+typedef void (*bt_proximity_reporter_connection_state_changed_cb)
+ (int result, const char *remote_address, bt_proximity_reporter_h reporter, bool connected, int supported_service, void *user_data);
+
/**
* @internal
* @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE
char *device_name, char *remote_addr,
char *pass_key, void *user_data);
-/**
- * @brief Proximity profile property changed callback
- */
-typedef void (*bt_proximity_property_changed_cb)
- (int result, const char *remote_address, int role, int service_type, int prop_value, void *user_data);
-
/**
* @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_HF_MODULE
* @brief Samsung XSAT Vendor dependent command.
/**
* @internal
- * @brief Register the Proximity Profile.
+ * @brief Creates the Proximity Profile Reporter Role.
*/
-int bt_proximity_register(bt_proximity_role_t role, bt_proximity_property_changed_cb callback, void *user_data);
+int bt_proximity_reporter_create(bt_proximity_reporter_h *reporter);
/**
* @internal
- * @brief Unregister the Proximity Profile.
+ * @brief Destroys the Proximity Profile Monitor Role.
*/
-int bt_proximity_unregister(bt_proximity_role_t role);
+int bt_proximity_reporter_destroy(bt_proximity_reporter_h reporter);
/**
* @internal
- * @brief Set the Proximity Profile property value.
+ * @brief Creates the Proximity Profile Reporter Role.
*/
-int bt_proximity_set_property(const char *remote_address, bt_proximity_property_t property, int value);
+int bt_proximity_monitor_create(const char *remote_address, bt_proximity_monitor_h *monitor);
/**
* @internal
- * @brief Read the Proximity Profile property value.
+ * @brief Creates the Proximity Profile Monitor Role.
*/
-int bt_proximity_get_property(const char *remote_address, bt_proximity_property_t property, int *value);
+int bt_proximity_monitor_destroy(bt_proximity_monitor_h monitor);
/**
* @internal
- * @brief Lists the Proximity Profile property/service supported.
+ * @brief Proximity Monitor initiates the connection to remote reporter device.
*/
-int bt_proximity_get_supported_services(const char *remote_address, int *supported_services);
+int bt_proximity_monitor_connect(bt_proximity_monitor_h monitor);
+
+/**
+ * @internal
+ * @brief Proximity Monitor disconnects with the remote reporter device.
+ */
+int bt_proximity_monitor_disconnect(bt_proximity_monitor_h monitor);
+
+/**
+ * @internal
+ * @brief Sets proximity monitor connection state changed event change callback.
+ */
+int bt_proximity_monitor_set_connection_state_changed_cb(bt_proximity_monitor_h monitor,
+ bt_proximity_monitor_connection_state_changed_cb callback, void *user_data);
+
+/**
+ * @internal
+ * @brief Unsets proximity monitor connection state changed event change callback.
+ */
+int bt_proximity_monitor_unset_connection_state_changed_cb(bt_proximity_monitor_h monitor);
+
+/**
+ * @internal
+ * @brief Sets proximity reporter connection state changed event change callback.
+ */
+int bt_proximity_reporter_set_connection_state_changed_cb(bt_proximity_reporter_h reporter,
+ bt_proximity_reporter_connection_state_changed_cb callback, void *user_data);
+
+/**
+ * @internal
+ * @brief Unsets proximity reporter connection state changed event change callback.
+ */
+int bt_proximity_reporter_unset_connection_state_changed_cb(bt_proximity_reporter_h reporter);
+
+/**
+ * @internal
+ * @brief Sets proximity reporter properties change callback.
+ */
+int bt_proximity_reporter_set_property_changed_cb(bt_proximity_reporter_h reporter,
+ bt_proximity_reporter_property_changed_cb callback, void *user_data);
+
+/**
+ * @internal
+ * @brief Unsets proximity reporter properties change callback.
+ */
+int bt_proximity_reporter_unset_property_changed_cb(bt_proximity_reporter_h reporter);
+
+/**
+ * @internal
+ * @brief Set the Proximity Profile monitor linkloss alert value.
+ */
+int bt_proximity_monitor_set_linkloss_alert(bt_proximity_monitor_h monitor, int value);
+
+/**
+ * @internal
+ * @brief Set the Proximity Profile monitor immediate alert value.
+ */
+int bt_proximity_monitor_set_immediate_alert(bt_proximity_monitor_h monitor, int value);
+
+/**
+ * @internal
+ * @brief Read the Proximity Profile monitor linkloss alert value.
+ */
+int bt_proximity_monitor_get_linkloss_alert(bt_proximity_monitor_h monitor, int *value);
+
+/**
+ * @internal
+ * @brief Read the Proximity Profile monitor immediate alert value.
+ */
+int bt_proximity_monitor_get_immediate_alert(bt_proximity_monitor_h monitor, int *value);
+
+/**
+ * @internal
+ * @brief Read the Proximity Profile monitor Signal level value.
+ */
+int bt_proximity_monitor_get_signal_level(bt_proximity_monitor_h monitor, int *value);
+
+/**
+ * @internal
+ * @brief Read the Proximity Profile reporter linkloss alert value.
+ */
+int bt_proximity_reporter_get_linkloss_alert(const char *remote_address, int *value);
+
+/**
+ * @internal
+ * @brief Read the Proximity Profile reporter immediate alert value.
+ */
+int bt_proximity_reporter_get_immediate_alert(const char *remote_address, int *value);
/**
* @internal
*/
int bt_adapter_le_free_ibeacon_report(bt_adapter_ibeacon_scan_result_info_s *ibeacon_info);
+/**
+ * @internal
+ * @brief API to Set the Proximity uuids scan report
+ */
+int bt_adapter_le_scan_filter_set_proximity_uuid(bt_scan_filter_h scan_filter);
+
+/**
+ * @internal
+ * @brief API to Unset the Proximity uuids scan report
+ */
+int bt_adapter_le_scan_filter_unset_proximity_uuid(bt_scan_filter_h scan_filter);
+
/**
* @}
*/
typedef void (*bt_ipsp_connection_state_changed_cb)
(int result, bool connected, const char *remote_address, const char *iface_name, void *user_data);
+/**
+ * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE
+ * @brief The handle of a Proximity Monitor client handle which is associated with a remote device.
+ * @since_tizen 3.0
+ */
+typedef void *bt_proximity_monitor_h;
+
+/**
+ * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_SERVER_MODULE
+ * @brief The handle of a Proximity Reporter server.
+ * @since_tizen 3.0
+ */
+typedef void *bt_proximity_reporter_h;
+
+/**
+ * @internal
+ * @since_tizen 3.0
+ * @brief Proximity profile reporter property changed callback
+ */
+typedef void (*bt_proximity_reporter_property_changed_cb)
+ (int result, const char *remote_address, int service_type, int prop_value, void *user_data);
+
+/**
+ * @internal
+ * @since_tizen 3.0
+ * @brief Proximity monitor profile connection state changed callback
+ */
+typedef void (*bt_proximity_monitor_connection_state_changed_cb)
+ (int result, const char *remote_address, bt_proximity_monitor_h monitor, bool connected, int supported_service, void *user_data);
+
+/**
+ * @internal
+ * @since_tizen 3.0
+ * @brief Proximity reporter profile connection state changed callback
+ */
+typedef void (*bt_proximity_reporter_connection_state_changed_cb)
+ (int result, const char *remote_address, bt_proximity_reporter_h reporter, bool connected, int supported_service, void *user_data);
+
/**
* @internal
* @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE
char *device_name, char *remote_addr,
char *pass_key, void *user_data);
-/**
- * @brief Proximity profile property changed callback
- */
-typedef void (*bt_proximity_property_changed_cb)
- (int result, const char *remote_address, int role, int service_type, int prop_value, void *user_data);
-
/**
* @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_HF_MODULE
* @brief Samsung XSAT Vendor dependent command.
BT_CHECK_SUPPORTED_FEATURE(BT_FEATURE_LE); \
}
+static bt_scan_filter_h pxp_linkloss_alert_filter;
+static bt_scan_filter_h pxp_immediate_alert_filter;
+static bt_scan_filter_h pxp_signal_loss_filter;
+
static GSList *advertiser_list = NULL;
/* LCOV_EXCL_START */
return BT_ERROR_NONE;
}
+int bt_adapter_le_scan_filter_set_proximity_uuid(bt_scan_filter_h scan_filter)
+{
+ int ret;
+
+ BT_CHECK_LE_SUPPORT();
+ BT_CHECK_INIT_STATUS();
+ BT_CHECK_INPUT_PARAMETER(scan_filter);
+
+ /* register Linkloss alert scan filter */
+ ret = bt_adapter_le_create_scan_filter(&pxp_linkloss_alert_filter);
+ if (ret == BT_ERROR_NONE) {
+
+ ret = bt_adapter_le_scan_filter_set_service_uuid(pxp_linkloss_alert_filter, PXP_LINK_LOSS_SVC_UUID);
+ if (ret == BT_ERROR_NONE)
+ ret = bt_adapter_le_register_scan_filter(pxp_linkloss_alert_filter);
+ if (ret != BT_ERROR_NONE) {
+ bt_adapter_le_unregister_scan_filter(pxp_linkloss_alert_filter);
+ pxp_linkloss_alert_filter = NULL;
+ }
+ } else {
+ return BT_ERROR_OPERATION_FAILED;
+ }
+
+ /* register Immediate alert scan filter */
+ ret = bt_adapter_le_create_scan_filter(&pxp_immediate_alert_filter);
+ if (ret == BT_ERROR_NONE) {
+
+ ret = bt_adapter_le_scan_filter_set_service_uuid(pxp_immediate_alert_filter, PXP_IMMEDIATE_ALERT_SVC_UUID);
+ if (ret == BT_ERROR_NONE)
+ ret = bt_adapter_le_register_scan_filter(pxp_immediate_alert_filter);
+ if (ret != BT_ERROR_NONE) {
+ bt_adapter_le_unregister_scan_filter(pxp_immediate_alert_filter);
+ pxp_immediate_alert_filter = NULL;
+ }
+ } else {
+ return BT_ERROR_OPERATION_FAILED;
+ }
+
+ /* register Signal loss scan filter */
+ ret = bt_adapter_le_create_scan_filter(&pxp_signal_loss_filter);
+ if (ret == BT_ERROR_NONE) {
+
+ ret = bt_adapter_le_scan_filter_set_service_uuid(pxp_signal_loss_filter, PXP_TX_POWER_SVC_UUID);
+ if (ret == BT_ERROR_NONE)
+ ret = bt_adapter_le_register_scan_filter(pxp_signal_loss_filter);
+ if (ret != BT_ERROR_NONE) {
+ bt_adapter_le_unregister_scan_filter(pxp_signal_loss_filter);
+ pxp_signal_loss_filter = NULL;
+ }
+ } else {
+ return BT_ERROR_OPERATION_FAILED;
+ }
+ return ret;
+}
+
+int bt_adapter_le_scan_filter_unset_proximity_uuid(bt_scan_filter_h scan_filter)
+{
+ int ret = BT_ERROR_NONE;
+
+ BT_CHECK_LE_SUPPORT();
+ BT_CHECK_INIT_STATUS();
+ BT_CHECK_INPUT_PARAMETER(scan_filter);
+
+ /* unregister Linkloss alert scan filter */
+ if (pxp_linkloss_alert_filter) {
+ ret = bt_adapter_le_unregister_scan_filter(pxp_linkloss_alert_filter);
+ pxp_linkloss_alert_filter = NULL;
+ }
+
+ /* unregister Immediate alert scan filter */
+ if (pxp_immediate_alert_filter) {
+ ret = bt_adapter_le_unregister_scan_filter(pxp_immediate_alert_filter);
+ pxp_immediate_alert_filter = NULL;
+ }
+
+ /* unregister Signal loss scan filter */
+ if (pxp_signal_loss_filter) {
+ ret = bt_adapter_le_unregister_scan_filter(pxp_signal_loss_filter);
+ pxp_signal_loss_filter = NULL;
+ }
+
+ return ret;
+}
/* LCOV_EXCL_STOP */
int bt_adapter_passkey_reply(char *passkey, bool authentication_reply)
case BLUETOOTH_EVENT_ADVERTISING_STARTED:
case BLUETOOTH_EVENT_ADVERTISING_STOPPED:
case BLUETOOTH_EVENT_GATT_CONNECTED:
+ case BLUETOOTH_EVENT_GATT_DISCONNECTED:
case BLUETOOTH_EVENT_GATT_SERVER_VALUE_CHANGED:
case BLUETOOTH_EVENT_GATT_SERVER_NOTIFICATION_STATE_CHANGED:
case BLUETOOTH_EVENT_GATT_SERVER_READ_REQUESTED:
case BLUETOOTH_EVENT_GATT_CONNECTED: {
bt_gatt_client_s *client_s;
bt_gatt_connection_state_changed_cb cb = NULL;
+ bool is_pxp_initialized = FALSE;
BT_INFO("BLUETOOTH_EVENT_GATT_CONNECTED");
_bt_convert_address_to_string(&device_addr,
(bluetooth_device_address_t *)(param->param_data));
if (cb)
cb(_bt_get_error_code(param->result), TRUE, device_addr,
bt_event_slot_container[event_index].user_data);
+
+ /* The below check is for calling the callback for proximity profile reporter/Monitor role */
+ _bt_check_proximity_is_initialized(&is_pxp_initialized);
+ if (is_pxp_initialized)
+ _bt_proximity_connection_set_state_changed(param->result, device_addr, TRUE);
+
g_free(device_addr);
device_addr = NULL;
break;
case BLUETOOTH_EVENT_GATT_DISCONNECTED: {
bt_gatt_client_s *client_s;
bt_gatt_connection_state_changed_cb cb = NULL;
+ bool is_pxp_initialized = FALSE;
BT_INFO("BLUETOOTH_EVENT_GATT_DISCONNECTED");
_bt_convert_address_to_string(&device_addr,
(bluetooth_device_address_t *)(param->param_data));
if (cb)
cb(_bt_get_error_code(param->result), FALSE, device_addr,
bt_event_slot_container[event_index].user_data);
+ /* The below check is for calling the callback for proximity profile reporter/Monitor role */
+ _bt_check_proximity_is_initialized(&is_pxp_initialized);
+ if (is_pxp_initialized)
+ _bt_proximity_connection_set_state_changed(param->result, device_addr, FALSE);
+
g_free(device_addr);
device_addr = NULL;
break;
bt_pxp_property_info = (bt_pxp_property_changed_params_t *)(param->param_data);
_bt_convert_address_to_string(&device_addr, &bt_pxp_property_info->device_address);
- ((bt_proximity_property_changed_cb)bt_event_slot_container[event_index].callback) /* LCOV_EXCL_LINE */
+ ((bt_proximity_reporter_property_changed_cb)bt_event_slot_container[event_index].callback) /* LCOV_EXCL_LINE */
(_bt_get_error_code(param->result), device_addr,
- bt_pxp_property_info->role, bt_pxp_property_info->service_type,
+ bt_pxp_property_info->service_type,
bt_pxp_property_info->alert_lvl, bt_event_slot_container[event_index].user_data);
if (device_addr != NULL)
case BLUETOOTH_EVENT_IPSP_INIT_STATE_CHANGED:
return BT_EVENT_IPSP_INIT_STATE_CHANGED;
case BLUETOOTH_EVENT_PXP_PROPERTY_CHANGED:
- return BT_EVENT_PROXIMITY_PROPERTY_CHANGED;
+ return BT_EVENT_PROXIMITY_REPORTER_PROPERTY_CHANGED;
default:
return -1;
}
#include "bluetooth_internal.h"
#include "bluetooth_private.h"
-static int role_registered = -1;
+typedef struct {
+ bt_gatt_h linkloss_service;
+ bt_gatt_h immediate_service;
+} bt_proximity_service_info_t;
+
+typedef struct {
+ bt_proximity_service_info_t services;
+} bt_proximity_reporter_server_s;
+
+typedef struct {
+ bt_proximity_reporter_server_s reporter_server;
+ bool services_supported;
+ bool connected;
+
+ const void *connection_callback;
+ void *user_data;
+} bt_proximity_reporter_s;
+
+typedef struct {
+ GSList *services;
+ char *remote_address;
+ bool services_discovered;
+ bool connected;
+
+ const void *connection_callback;
+ void *user_data;
+} bt_proximity_monitor_s;
+
+GSList *proximity_monitor_list;
+
+static bool pxp_monitor_initialized = false;
+static bool pxp_reporter_initialized = false;
+static int pxp_monitor_supported_services = false;
+static bt_proximity_reporter_s *reporter_s = NULL;
+
+#define BT_CHECK_GATT_PXP_SUPPORT() \
+{ \
+ BT_CHECK_SUPPORTED_FEATURE(BT_FEATURE_COMMON); \
+ BT_CHECK_SUPPORTED_FEATURE(BT_FEATURE_LE); \
+}
-int bt_proximity_register(bt_proximity_role_t role, bt_proximity_property_changed_cb callback, void *user_data)
+int bt_proximity_reporter_create(bt_proximity_reporter_h *reporter)
{
int error_code = BT_ERROR_NONE;
- BT_CHECK_SUPPORTED_FEATURE(BT_FEATURE_COMMON);
+ BT_CHECK_GATT_PXP_SUPPORT();
BT_CHECK_INIT_STATUS();
- BT_CHECK_INPUT_PARAMETER(callback); /* LCOV_EXCL_LINE */
- if (role == BT_PROXIMITY_REPORTER) {
- /* register Reporter Role Here */
- error_code = _bt_get_error_code(bluetooth_register_proximity_reporter());
- if (error_code != BT_ERROR_NONE)
- BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), error_code);
+ if (reporter_s != NULL)
+ return BT_ERROR_ALREADY_DONE;
+
+ /* register Reporter Role Here */
+ error_code = _bt_get_error_code(bluetooth_proximity_reporter_register());
+ if (error_code != BT_ERROR_NONE)
+ BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), error_code);
+ else
+ pxp_reporter_initialized = true;
+
+ reporter_s = g_malloc0(sizeof(*reporter_s));
+ if (reporter_s == NULL) {
+ error_code = BT_ERROR_OUT_OF_MEMORY;
+ BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), error_code);
+ return error_code;
}
- role_registered = role;
+ *reporter = (bt_proximity_reporter_s *)reporter_s;
+ error_code = bt_gatt_service_create(PXP_LINK_LOSS_SVC_UUID, BT_GATT_SERVICE_TYPE_PRIMARY,
+ &reporter_s->reporter_server.services.linkloss_service);
+ if (error_code != BT_ERROR_NONE)
+ BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), error_code);
+
+ error_code = bt_gatt_service_create(PXP_IMMEDIATE_ALERT_SVC_UUID, BT_GATT_SERVICE_TYPE_PRIMARY,
+ &reporter_s->reporter_server.services.linkloss_service);
+ if (error_code != BT_ERROR_NONE)
+ BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), error_code);
- /* register the callback, common for both reporter and monitor roles */
- _bt_set_cb(BT_EVENT_PROXIMITY_PROPERTY_CHANGED, callback, user_data);
+ /* By default the bluez stack supports Link loss and immediate alert service when we register */
+ reporter_s->services_supported = BT_PROXIMITY_LINKLOSS_ALERT | BT_PROXIMITY_IMMEDIATE_ALERT;
+ /* Start Advertising with Proximity services */
return error_code;
}
-int bt_proximity_unregister(bt_proximity_role_t role)
+int bt_proximity_reporter_destroy(bt_proximity_reporter_h reporter)
{
int error_code = BT_ERROR_NONE;
- BT_CHECK_SUPPORTED_FEATURE(BT_FEATURE_COMMON);
+ BT_CHECK_GATT_PXP_SUPPORT();
BT_CHECK_INIT_STATUS();
+ BT_CHECK_INPUT_PARAMETER(reporter);
- if (role == BT_PROXIMITY_REPORTER) {
- /* Unregister Reporter Role Here */
- error_code = _bt_get_error_code(bluetooth_unregister_proximity_reporter());
- if (error_code != BT_ERROR_NONE)
- BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), error_code);
+ if (reporter_s == NULL)
+ return BT_ERROR_NOT_INITIALIZED;
+
+ if (!pxp_reporter_initialized)
+ return BT_ERROR_NOT_INITIALIZED;
+
+ /* Unregister Reporter Role Here */
+ error_code = _bt_get_error_code(bluetooth_proximity_reporter_unregister());
+ if (error_code != BT_ERROR_NONE)
+ BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), error_code);
+ else
+ pxp_reporter_initialized = false;
+
+ bt_gatt_destroy(reporter_s->reporter_server.services.linkloss_service);
+ bt_gatt_destroy(reporter_s->reporter_server.services.linkloss_service);
+ reporter_s->services_supported = 0;
+
+ g_free(reporter_s);
+ reporter_s = NULL;
+
+ return error_code;
+}
+
+int _bt_check_proximity_is_initialized(bool *is_initialized)
+{
+ BT_CHECK_GATT_PXP_SUPPORT();
+ BT_CHECK_INIT_STATUS();
+ BT_CHECK_INPUT_PARAMETER(is_initialized);
+
+ if (pxp_reporter_initialized || pxp_monitor_initialized)
+ *is_initialized = TRUE;
+ else
+ *is_initialized = FALSE;
+
+ return BT_ERROR_NONE;
+}
+
+static bt_proximity_monitor_s *_bt_proximity_minotr_find(const char *remote_address)
+{
+ GSList *l;
+
+ for (l = proximity_monitor_list; l; l = g_slist_next(l)) {
+ bt_proximity_monitor_s *c = (bt_proximity_monitor_s *)l->data;
+
+ if (!g_ascii_strcasecmp(c->remote_address, remote_address))
+ return c;
}
+ return NULL;
+}
+
+static int _bt_proximity_monitor_addr_info_cmp(gconstpointer a1, gconstpointer a2)
+{
+ const bt_proximity_monitor_s *c = a1;
+ const bt_proximity_monitor_s *b = a2;
- /* unregister the callback, common for both reporter and monitor roles */
- _bt_unset_cb(BT_EVENT_PROXIMITY_PROPERTY_CHANGED);
- role_registered = -1;
+ return g_ascii_strcasecmp(c->remote_address, b->remote_address);
+}
+
+
+int _bt_proximity_connection_set_state_changed(int result, const char *remote_address, bool connected)
+{
+ int service_type = 0;
+ int error_code = BT_ERROR_NONE;
+ BT_DBG("bt_proximity_connection_state_changed");
+ if (pxp_monitor_initialized) {
+ bt_proximity_monitor_s *monitor_s = NULL;
+
+ monitor_s = _bt_proximity_minotr_find(remote_address);
+ if (monitor_s) {
+ bluetooth_device_address_t addr_hex = { {0,} };
+ _bt_convert_address_to_hex(&addr_hex, remote_address);
+ error_code = bluetooth_proximity_monitor_get_supported_services(&addr_hex, &service_type);
+ if (error_code != BT_ERROR_NONE)
+ BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), error_code);
+
+ monitor_s->connected = connected;
+ monitor_s->services_discovered = service_type;
+ pxp_monitor_supported_services = service_type;
+ proximity_monitor_list = g_slist_insert_sorted(proximity_monitor_list,
+ monitor_s, _bt_proximity_monitor_addr_info_cmp);
+ if (monitor_s->connection_callback)
+ ((bt_proximity_monitor_connection_state_changed_cb)monitor_s->connection_callback)
+ (result, remote_address, monitor_s, connected, service_type, monitor_s->user_data);
+ }
+ }
+ if (pxp_reporter_initialized) {
+ if (reporter_s) {
+ service_type = reporter_s->services_supported;
+ reporter_s->connected = connected;
+ if (reporter_s->connection_callback)
+ ((bt_proximity_reporter_connection_state_changed_cb)reporter_s->connection_callback)
+ (result, remote_address, reporter_s, connected, service_type, reporter_s->user_data);
+ }
+ }
return error_code;
}
-int bt_proximity_set_property(const char *remote_address, bt_proximity_property_t property, int value)
+int bt_proximity_monitor_create(const char *remote_address, bt_proximity_monitor_h *monitor)
{
int error_code = BT_ERROR_NONE;
+ bt_proximity_monitor_s *monitor_s = NULL;
+ bool connected = false;
bluetooth_device_address_t addr_hex = { {0,} };
+ int service_type = 0;
+ GSList *l;
+
+ BT_CHECK_GATT_PXP_SUPPORT();
+ BT_CHECK_INIT_STATUS();
+ BT_CHECK_INPUT_PARAMETER(remote_address); /* LCOV_EXCL_START */
+ BT_CHECK_INPUT_PARAMETER(monitor); /* LCOV_EXCL_START */
+
+ for (l = proximity_monitor_list; l; l = g_slist_next(l)) {
+ bt_proximity_monitor_s *c = (bt_proximity_monitor_s *)l->data;
+
+ if (!g_ascii_strcasecmp(c->remote_address, remote_address)) {
+ BT_ERR("Gatt client for %s is already created",
+ remote_address);
+ return BT_ERROR_ALREADY_DONE;
+ }
+ }
+
+ monitor_s = g_malloc0(sizeof(*monitor_s));
+ if (monitor_s == NULL) {
+ error_code = BT_ERROR_OUT_OF_MEMORY;
+ BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), error_code);
+ return error_code;
+ }
+
+ monitor_s->remote_address = g_strdup(remote_address);
+ if (monitor_s->remote_address == NULL) {
+ free(monitor_s);
+ error_code = BT_ERROR_OUT_OF_MEMORY;
+ BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), error_code);
+ return error_code;
+ }
+
+ *monitor = (bt_proximity_monitor_h)monitor_s;
+ proximity_monitor_list = g_slist_append(proximity_monitor_list, monitor_s);
+
+ if (bt_device_is_profile_connected(remote_address, BT_PROFILE_GATT,
+ &connected) != BT_ERROR_NONE)
+ BT_ERR("bt_device_is_profile_connected is failed");
+ monitor_s->connected = connected;
+
+ _bt_convert_address_to_hex(&addr_hex, remote_address);
+
+ if (bluetooth_proximity_monitor_get_supported_services(&addr_hex,
+ &service_type) != BT_ERROR_NONE)
+ BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), error_code);
+ monitor_s->services_discovered = service_type;
+
+ pxp_monitor_initialized = true;
+
+ BT_INFO("Proximity Monitor Handle is created");
+
+ return error_code;
+}
+
+int bt_proximity_monitor_destroy(bt_proximity_monitor_h monitor)
+{
+ bt_proximity_monitor_s *monitor_s = (bt_proximity_monitor_s *)monitor;
+
+ BT_CHECK_GATT_PXP_SUPPORT();
+ BT_CHECK_INIT_STATUS();
+ BT_CHECK_INPUT_PARAMETER(monitor); /* LCOV_EXCL_START */
+
+ if(_bt_proximity_minotr_find(monitor_s->remote_address) == NULL)
+ return BT_ERROR_REMOTE_DEVICE_NOT_CONNECTED;
+
+ if (monitor_s->connection_callback) {
+ monitor_s->connection_callback = NULL;
+ monitor_s->user_data = NULL;
+ }
+ pxp_monitor_supported_services = 0;
+
+ g_free(monitor_s->remote_address);
+ proximity_monitor_list = g_slist_remove(proximity_monitor_list, monitor_s);
+ g_free(monitor_s);
+
+ return BT_ERROR_NONE; /* LCOV_EXCL_STOP */
+}
+
+int bt_proximity_monitor_connect(bt_proximity_monitor_h monitor)
+{
+ int error_code;
+ bt_proximity_monitor_s *monitor_s = (bt_proximity_monitor_s *)monitor;
+
+ BT_CHECK_GATT_PXP_SUPPORT();
+ BT_CHECK_INIT_STATUS();
+ BT_CHECK_INPUT_PARAMETER(monitor_s);
+
+ if(_bt_proximity_minotr_find(monitor_s->remote_address) == NULL)
+ return BT_ERROR_REMOTE_DEVICE_NOT_CONNECTED;
+
+ error_code = bt_gatt_connect(monitor_s->remote_address, FALSE);
+
+ if (error_code != BT_ERROR_NONE)
+ BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), error_code);
+
+ return error_code;
+}
+
+int bt_proximity_monitor_disconnect(bt_proximity_monitor_h monitor)
+{
+ int error_code;
+ bt_proximity_monitor_s *monitor_s = (bt_proximity_monitor_s *)monitor;
+
+ BT_CHECK_GATT_PXP_SUPPORT();
+ BT_CHECK_INIT_STATUS();
+ BT_CHECK_INPUT_PARAMETER(monitor_s);
+
+ if(_bt_proximity_minotr_find(monitor_s->remote_address) == NULL)
+ return BT_ERROR_REMOTE_DEVICE_NOT_CONNECTED;
+
+ error_code = bt_gatt_disconnect(monitor_s->remote_address);
+
+ if (error_code != BT_ERROR_NONE)
+ BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), error_code);
+
+ return error_code;
+}
+
+int bt_proximity_monitor_set_connection_state_changed_cb(bt_proximity_monitor_h monitor,
+ bt_proximity_monitor_connection_state_changed_cb callback, void *user_data)
+{
+ bt_proximity_monitor_s *monitor_s = (bt_proximity_monitor_s *)monitor;
BT_CHECK_SUPPORTED_FEATURE(BT_FEATURE_COMMON);
BT_CHECK_INIT_STATUS();
- BT_CHECK_INPUT_PARAMETER(remote_address); /* LCOV_EXCL_LINE */
+ BT_CHECK_INPUT_PARAMETER(monitor_s);
+ BT_CHECK_INPUT_PARAMETER(callback);
+
+ if(_bt_proximity_minotr_find(monitor_s->remote_address) == NULL)
+ return BT_ERROR_REMOTE_DEVICE_NOT_CONNECTED;
+
+ /* register the callback */
+ monitor_s->connection_callback = callback;
+ monitor_s->user_data = user_data;
+
+ proximity_monitor_list = g_slist_insert_sorted(proximity_monitor_list,
+ monitor_s, _bt_proximity_monitor_addr_info_cmp);
+
+ return BT_ERROR_NONE;
+}
+
+int bt_proximity_monitor_unset_connection_state_changed_cb(bt_proximity_monitor_h monitor)
+{
+ bt_proximity_monitor_s *monitor_s = (bt_proximity_monitor_s *)monitor;
+
+ BT_CHECK_SUPPORTED_FEATURE(BT_FEATURE_COMMON);
+ BT_CHECK_INIT_STATUS();
+ BT_CHECK_INPUT_PARAMETER(monitor_s);
+
+ if(_bt_proximity_minotr_find(monitor_s->remote_address) == NULL)
+ return BT_ERROR_REMOTE_DEVICE_NOT_CONNECTED;
+
+ /* unregister the callback */
+ monitor_s->connection_callback = NULL;
+ monitor_s->user_data = NULL;
+
+ proximity_monitor_list = g_slist_insert_sorted(proximity_monitor_list,
+ monitor_s, _bt_proximity_monitor_addr_info_cmp);
+
+ return BT_ERROR_NONE;
+}
+
+int bt_proximity_reporter_set_connection_state_changed_cb(bt_proximity_reporter_h reporter,
+ bt_proximity_reporter_connection_state_changed_cb callback, void *user_data)
+{
+ bt_proximity_reporter_s *reporter_l = (bt_proximity_reporter_s *)reporter;
+
+ BT_CHECK_SUPPORTED_FEATURE(BT_FEATURE_COMMON);
+ BT_CHECK_INIT_STATUS();
+ BT_CHECK_INPUT_PARAMETER(reporter_l);
+ BT_CHECK_INPUT_PARAMETER(callback);
+
+ /* register the callback */
+ reporter_s->connection_callback = callback;
+ reporter_s->user_data = user_data;
+
+ return BT_ERROR_NONE;
+}
+
+int bt_proximity_reporter_unset_connection_state_changed_cb(bt_proximity_reporter_h reporter)
+{
+ bt_proximity_reporter_s *reporter_l = (bt_proximity_reporter_s *)reporter;
+
+ BT_CHECK_SUPPORTED_FEATURE(BT_FEATURE_COMMON);
+ BT_CHECK_INIT_STATUS();
+ BT_CHECK_INPUT_PARAMETER(reporter_l);
+
+ /* unregister the callback */
+ reporter_l->connection_callback = NULL;
+ reporter_l->user_data = NULL;
+
+ return BT_ERROR_NONE;
+}
+
+int bt_proximity_reporter_set_property_changed_cb(bt_proximity_reporter_h reporter,
+ bt_proximity_reporter_property_changed_cb callback, void *user_data)
+{
+ bt_proximity_reporter_s *reporter_l = (bt_proximity_reporter_s *)reporter;
+
+ BT_CHECK_SUPPORTED_FEATURE(BT_FEATURE_COMMON);
+ BT_CHECK_INIT_STATUS();
+ BT_CHECK_INPUT_PARAMETER(reporter_l);
+ BT_CHECK_INPUT_PARAMETER(callback);
+
+ /* register the callback */
+ _bt_set_cb(BT_EVENT_PROXIMITY_REPORTER_PROPERTY_CHANGED, callback, user_data);
+
+ return BT_ERROR_NONE;
+}
- if (role_registered != BT_PROXIMITY_MONITOR)
+int bt_proximity_reporter_unset_property_changed_cb(bt_proximity_reporter_h reporter)
+{
+ bt_proximity_reporter_s *reporter_l = (bt_proximity_reporter_s *)reporter;
+
+ BT_CHECK_SUPPORTED_FEATURE(BT_FEATURE_COMMON);
+ BT_CHECK_INIT_STATUS();
+ BT_CHECK_INPUT_PARAMETER(reporter_l);
+
+ /* unregister the callback */
+ _bt_unset_cb(BT_EVENT_PROXIMITY_REPORTER_PROPERTY_CHANGED);
+
+ return BT_ERROR_NONE;
+}
+
+int bt_proximity_monitor_set_linkloss_alert(bt_proximity_monitor_h monitor, int value)
+{
+ int error_code = BT_ERROR_NONE;
+ bt_proximity_monitor_s *monitor_s = (bt_proximity_monitor_s *)monitor;
+ bluetooth_device_address_t addr_hex = { {0,} };
+
+ BT_CHECK_GATT_PXP_SUPPORT();
+ BT_CHECK_INIT_STATUS();
+ BT_CHECK_INPUT_PARAMETER(monitor); /* LCOV_EXCL_LINE */
+
+ if(_bt_proximity_minotr_find(monitor_s->remote_address) == NULL)
+ return BT_ERROR_REMOTE_DEVICE_NOT_CONNECTED;
+
+ if (!(pxp_monitor_supported_services & BT_PROXIMITY_LINKLOSS_ALERT))
return BT_ERROR_NOT_SUPPORTED;
- _bt_convert_address_to_hex(&addr_hex, remote_address); /* LCOV_EXCL_LINE */
+ _bt_convert_address_to_hex(&addr_hex, monitor_s->remote_address); /* LCOV_EXCL_LINE */
- error_code = _bt_get_error_code(bluetooth_set_proximity_property(&addr_hex, property, value));
+ error_code = _bt_get_error_code(bluetooth_proximity_monitor_set_property(&addr_hex,
+ BT_PROXIMITY_LINKLOSS_ALERT, value));
if (error_code != BT_ERROR_NONE)
BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), error_code);
return error_code;
}
-int bt_proximity_get_property(const char *remote_address, bt_proximity_property_t property, int *value)
+int bt_proximity_monitor_set_immediate_alert(bt_proximity_monitor_h monitor, int value)
{
int error_code = BT_ERROR_NONE;
+ bt_proximity_monitor_s *monitor_s = (bt_proximity_monitor_s *)monitor;
bluetooth_device_address_t addr_hex = { {0,} };
- BT_CHECK_SUPPORTED_FEATURE(BT_FEATURE_COMMON);
+ BT_CHECK_GATT_PXP_SUPPORT();
BT_CHECK_INIT_STATUS();
- BT_CHECK_INPUT_PARAMETER(remote_address); /* LCOV_EXCL_LINE */
+ BT_CHECK_INPUT_PARAMETER(monitor); /* LCOV_EXCL_LINE */
- if (role_registered != BT_PROXIMITY_MONITOR)
+ if(_bt_proximity_minotr_find(monitor_s->remote_address) == NULL)
+ return BT_ERROR_REMOTE_DEVICE_NOT_CONNECTED;
+
+ if (!(pxp_monitor_supported_services & BT_PROXIMITY_IMMEDIATE_ALERT))
return BT_ERROR_NOT_SUPPORTED;
- _bt_convert_address_to_hex(&addr_hex, remote_address); /* LCOV_EXCL_LINE */
+ _bt_convert_address_to_hex(&addr_hex, monitor_s->remote_address); /* LCOV_EXCL_LINE */
+
+ error_code = _bt_get_error_code(bluetooth_proximity_monitor_set_property(&addr_hex,
+ BT_PROXIMITY_IMMEDIATE_ALERT, value));
+ if (error_code != BT_ERROR_NONE)
+ BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), error_code);
+
+ return error_code;
+}
+
+int bt_proximity_monitor_get_linkloss_alert(bt_proximity_monitor_h monitor, int *value)
+{
+ int error_code = BT_ERROR_NONE;
+ bt_proximity_monitor_s *monitor_s = (bt_proximity_monitor_s *)monitor;
+ bluetooth_device_address_t addr_hex = { {0,} };
+
+ BT_CHECK_GATT_PXP_SUPPORT();
+ BT_CHECK_INIT_STATUS();
+ BT_CHECK_INPUT_PARAMETER(monitor); /* LCOV_EXCL_LINE */
+
+ if(_bt_proximity_minotr_find(monitor_s->remote_address) == NULL)
+ return BT_ERROR_REMOTE_DEVICE_NOT_CONNECTED;
+
+ if (!(pxp_monitor_supported_services & BT_PROXIMITY_LINKLOSS_ALERT))
+ return BT_ERROR_NOT_SUPPORTED;
+
+ _bt_convert_address_to_hex(&addr_hex, monitor_s->remote_address); /* LCOV_EXCL_LINE */
- error_code = _bt_get_error_code(bluetooth_get_proximity_property(&addr_hex, property, value));
+ error_code = _bt_get_error_code(bluetooth_proximity_monitor_get_property(&addr_hex,
+ BT_PROXIMITY_LINKLOSS_ALERT, value));
if (error_code != BT_ERROR_NONE)
BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), error_code);
+ return error_code;
+}
+
+int bt_proximity_monitor_get_immediate_alert(bt_proximity_monitor_h monitor, int *value)
+{
+ int error_code = BT_ERROR_NONE;
+ bt_proximity_monitor_s *monitor_s = (bt_proximity_monitor_s *)monitor;
+ bluetooth_device_address_t addr_hex = { {0,} };
+
+ BT_CHECK_GATT_PXP_SUPPORT();
+ BT_CHECK_INIT_STATUS();
+ BT_CHECK_INPUT_PARAMETER(monitor); /* LCOV_EXCL_LINE */
+
+ if(_bt_proximity_minotr_find(monitor_s->remote_address) == NULL)
+ return BT_ERROR_REMOTE_DEVICE_NOT_CONNECTED;
+
+ if (!(pxp_monitor_supported_services & BT_PROXIMITY_IMMEDIATE_ALERT))
+ return BT_ERROR_NOT_SUPPORTED;
+
+ _bt_convert_address_to_hex(&addr_hex, monitor_s->remote_address); /* LCOV_EXCL_LINE */
+
+ error_code = _bt_get_error_code(bluetooth_proximity_monitor_get_property(&addr_hex,
+ BT_PROXIMITY_IMMEDIATE_ALERT, value));
+
+ if (error_code != BT_ERROR_NONE)
+ BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), error_code);
return error_code;
}
-int bt_proximity_get_supported_services(const char *remote_address, int *supported_services)
+int bt_proximity_monitor_get_signal_level(bt_proximity_monitor_h monitor, int *value)
{
int error_code = BT_ERROR_NONE;
+ bt_proximity_monitor_s *monitor_s = (bt_proximity_monitor_s *)monitor;
bluetooth_device_address_t addr_hex = { {0,} };
- BT_CHECK_SUPPORTED_FEATURE(BT_FEATURE_COMMON);
+ BT_CHECK_GATT_PXP_SUPPORT();
+ BT_CHECK_INIT_STATUS();
+ BT_CHECK_INPUT_PARAMETER(monitor); /* LCOV_EXCL_LINE */
+
+ if(_bt_proximity_minotr_find(monitor_s->remote_address) == NULL)
+ return BT_ERROR_REMOTE_DEVICE_NOT_CONNECTED;
+
+ if (!(pxp_monitor_supported_services & BT_PROXIMITY_TX_POWER))
+ return BT_ERROR_NOT_SUPPORTED;
+
+ _bt_convert_address_to_hex(&addr_hex, monitor_s->remote_address); /* LCOV_EXCL_LINE */
+
+ error_code = _bt_get_error_code(bluetooth_proximity_monitor_get_property(&addr_hex,
+ BT_PROXIMITY_TX_POWER, value));
+
+ if (error_code != BT_ERROR_NONE)
+ BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), error_code);
+
+ return error_code;
+}
+
+int bt_proximity_reporter_get_linkloss_alert(const char *remote_address, int *value)
+{
+ int error_code = BT_ERROR_NONE;
+ bluetooth_device_address_t addr_hex = { {0,} };
+
+ BT_CHECK_GATT_PXP_SUPPORT();
BT_CHECK_INIT_STATUS();
BT_CHECK_INPUT_PARAMETER(remote_address); /* LCOV_EXCL_LINE */
- if (role_registered != BT_PROXIMITY_MONITOR)
+ if (reporter_s == NULL)
+ return BT_ERROR_NOT_INITIALIZED;
+
+ if (!(reporter_s->services_supported & BT_PROXIMITY_LINKLOSS_ALERT))
return BT_ERROR_NOT_SUPPORTED;
_bt_convert_address_to_hex(&addr_hex, remote_address); /* LCOV_EXCL_LINE */
- error_code = _bt_get_error_code(bluetooth_get_proximity_supported_services(&addr_hex, supported_services));
+ error_code = _bt_get_error_code(bluetooth_proximity_reporter_get_property(&addr_hex,
+ BT_PROXIMITY_LINKLOSS_ALERT, value));
if (error_code != BT_ERROR_NONE)
BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), error_code);
return error_code;
}
+int bt_proximity_reporter_get_immediate_alert(const char *remote_address, int *value)
+{
+ int error_code = BT_ERROR_NONE;
+ bluetooth_device_address_t addr_hex = { {0,} };
+
+ BT_CHECK_GATT_PXP_SUPPORT();
+ BT_CHECK_INIT_STATUS();
+ BT_CHECK_INPUT_PARAMETER(remote_address); /* LCOV_EXCL_LINE */
+
+ if (reporter_s == NULL)
+ return BT_ERROR_NOT_INITIALIZED;
+
+ if (!(reporter_s->services_supported & BT_PROXIMITY_IMMEDIATE_ALERT))
+ return BT_ERROR_NOT_SUPPORTED;
+
+ _bt_convert_address_to_hex(&addr_hex, remote_address); /* LCOV_EXCL_LINE */
+
+ error_code = _bt_get_error_code(bluetooth_proximity_reporter_get_property(&addr_hex,
+ BT_PROXIMITY_IMMEDIATE_ALERT, value));
+
+ if (error_code != BT_ERROR_NONE)
+ BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), error_code);
+
+ return error_code;
+}
/* LCOV_EXCL_STOP */
gatt_handle_t custom_h;
gatt_handle_t ipsp_h;
+bt_proximity_reporter_h reporter;
+bt_proximity_monitor_h monitor;
+bt_scan_filter_h pxp_scan_filter;
+
#ifdef TIZEN_FEATURE_ENABLE_LEGACY_GATT_CLIENT
bt_gatt_attribute_h service_clone[MAX_SERVICES];
bt_gatt_attribute_h characteristics[MAX_SERVICES];
/* HPS functions */
{"BACK"
, BT_UNIT_TEST_FUNCTION_BACK},
- {"Proximity (Register)"
- , BT_UNIT_TEST_FUNCTION_PXP_REGISTER},
- {"Proximity (Unregister)"
- , BT_UNIT_TEST_FUNCTION_PXP_UNREGISTER},
- {"Proximity (Connect as Monitor)"
+ {"Proximity Reporter(Register)"
+ , BT_UNIT_TEST_FUNCTION_PXP_REPORTER_REGISTER},
+ {"Proximity Reporter(Unregister)"
+ , BT_UNIT_TEST_FUNCTION_PXP_REPORTER_UNREGISTER},
+ {"Proximity Reporter(Start Advertising Proximity Reporter)"
+ , BT_UNIT_TEST_FUNCTION_PXP_REPORTER_START_ADVERTISING},
+ {"Proximity Reporter (Set State Changed callback)"
+ , BT_UNIT_TEST_FUNCTION_PXP_REPORTER_SET_CONNECTION_STATE_CHANGED_CB},
+ {"Proximity Reporter (UnSet State Changed callback)"
+ , BT_UNIT_TEST_FUNCTION_PXP_REPORTER_UNSET_CONNECTION_STATE_CHANGED_CB},
+ {"Proximity Reporter (Set Property Changed callback)"
+ , BT_UNIT_TEST_FUNCTION_PXP_REPORTER_SET_PROPERTIES_CHANGED_CB},
+ {"Proximity Reporter (UnSet Property Changed callback)"
+ , BT_UNIT_TEST_FUNCTION_PXP_REPORTER_UNSET_PROPERTIES_CHANGED_CB},
+ {"Proximity Reporter(Read Linkloss Alert Level)"
+ , BT_UNIT_TEST_FUNCTION_PXP_REPORTER_READ_LINKLOSS_ALERT},
+ {"Proximity Reporter(Read Immediate Alert Level)"
+ , BT_UNIT_TEST_FUNCTION_PXP_REPORTER_READ_IMMEDIATE_ALERT},
+ {"Proximity Monitor(Create)"
+ , BT_UNIT_TEST_FUNCTION_PXP_MONITOR_CREATE},
+ {"Proximity Monitor(Destroy)"
+ , BT_UNIT_TEST_FUNCTION_PXP_MONITOR_DESTROY},
+ {"Proximity Monitor(Connect)"
, BT_UNIT_TEST_FUNCTION_PXP_MONITOR_CONNECT},
- {"Proximity (Disconnect Monitor)"
+ {"Proximity Monitor(Disconnect)"
, BT_UNIT_TEST_FUNCTION_PXP_MONITOR_DISCONNECT},
- {"Proximity (Write Alert Level)"
- , BT_UNIT_TEST_FUNCTION_PXP_WRITE_ALERT_LEVEL},
- {"Proximity (Read Alert Level)"
- , BT_UNIT_TEST_FUNCTION_PXP_READ_ALERT_LEVEL},
- {"Proximity (Get Supported Services)"
- , BT_UNIT_TEST_FUNCTION_PXP_GET_SUPPORTED_SERVICES},
+ {"Proximity Monitor (Set State Changed callback)"
+ , BT_UNIT_TEST_FUNCTION_PXP_MONITOR_SET_CONNECTION_STATE_CHANGED_CB},
+ {"Proximity Monitor (UnSet State Changed callback)"
+ , BT_UNIT_TEST_FUNCTION_PXP_MONITOR_UNSET_CONNECTION_STATE_CHANGED_CB},
+ {"Proximity Monitor(Set LE Scan Filter for Proximity UUID)"
+ , BT_UNIT_TEST_FUNCTION_PXP_MONITOR_SET_SCAN_FILTER_SERVICE_UUID},
+ {"Proximity Monitor(Unet LE Scan Filter for Proximity UUID)"
+ , BT_UNIT_TEST_FUNCTION_PXP_MONITOR_UNSET_SCAN_FILTER_SERVICE_UUID},
+ {"Proximity Monitor(Write Linkloss Alert Level)"
+ , BT_UNIT_TEST_FUNCTION_PXP_MONITOR_WRITE_LINKLOSS_ALERT},
+ {"Proximity Monitor(Write Immediate Alert Level)"
+ , BT_UNIT_TEST_FUNCTION_PXP_MONITOR_WRITE_IMMEDIATE_ALERT},
+ {"Proximity Monitor(Read Linkloss Alert Level)"
+ , BT_UNIT_TEST_FUNCTION_PXP_MONITOR_READ_LINKLOSS_ALERT},
+ {"Proximity Monitor(Read Immediate Alert Level)"
+ , BT_UNIT_TEST_FUNCTION_PXP_MONITOR_READ_IMMEDIATE_ALERT},
+ {"Proximity Monitor(Read Signal Level)"
+ , BT_UNIT_TEST_FUNCTION_PXP_MONITOR_READ_SIGNAL_LEVEL},
{"Select this menu to set parameters and then select the function again."
, BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS},
{NULL , 0x0000},
return;
}
-void __bt_pxp_montior_connection_state_changed_cb(int result,
- bool connected, const char *remote_address, void *user_data)
+void __bt_proximity_reporter_property_changed_cb(int result, const char *remote_address,
+ int service_type, int prop_value, void *user_data)
{
- int ret;
- TC_PRT("result: %s", __bt_get_error_message(result));
- if (connected) {
- int property = 0;
-
- TC_PRT("PXP Monitor connected(address = %s)", remote_address);
+ TC_PRT("reporter_property result [%s]", __bt_get_error_message(result));
+ TC_PRT("remote_address : %s", remote_address);
+ TC_PRT("service_type : %d", service_type);
+ TC_PRT("prop_value : %d", prop_value);
+}
- ret = bt_proximity_get_supported_services(remote_addr, &property);
- TC_PRT("bt_proximity_get_supported_service returns %s\n",
- __bt_get_error_message(ret));
- if (ret == BT_ERROR_NONE) {
- TC_PRT("PXP Monitor supported Service\n");
- if (property & BT_PROXIMITY_LINKLOSS_ALERT)
+void __bt_proximity_monitor_connection_state_changed_cb(int result, const char *remote_address,
+ bt_proximity_monitor_h monitor_s, bool connected, int supported_service, void *user_data)
+{
+ TC_PRT("result: %s", __bt_get_error_message(result));
+ if (result == BT_ERROR_NONE) {
+ if (connected) {
+ TC_PRT("PXP connected(address = %s)", remote_address);
+ TC_PRT("PXP Reporter supported Service\n");
+ if (supported_service & BT_PROXIMITY_LINKLOSS_ALERT)
TC_PRT("BT_PROXIMITY_LINKLOSS_ALERT\n");
- if (property & BT_PROXIMITY_IMMEDIATE_ALERT)
+ if (supported_service & BT_PROXIMITY_IMMEDIATE_ALERT)
TC_PRT("BT_PROXIMITY_IMMEDIATE_ALERT\n");
- if (property & BT_PROXIMITY_TX_POWER)
- TC_PRT("BT_PROXIMITY_TX_POWER\n");
+ if (supported_service & BT_PROXIMITY_TX_POWER)
+ TC_PRT("BT_PROXIMITY_TX_POWER");
+ } else {
+ TC_PRT("PXP DISconnected");
}
- } else {
- TC_PRT("PXP Monitor DISconnected");
- ret = bt_gatt_unset_connection_state_changed_cb();
}
}
-void __bt_proximity_property_changed_cb(int result, const char *remote_address,
- int role, int service_type,
- int prop_value, void *user_data)
+void __bt_proximity_reporter_connection_state_changed_cb(int result, const char *remote_address,
+ bt_proximity_reporter_h reporter_s, bool connected, int supported_service, void *user_data)
{
- TC_PRT("result [%s]", __bt_get_error_message(result));
- TC_PRT("remote_address : %s", remote_address);
- TC_PRT("Role : %d", role);
- TC_PRT("service_type : %d", service_type);
- TC_PRT("prop_value : %d", prop_value);
+ TC_PRT("result: %s", __bt_get_error_message(result));
+ if (result == BT_ERROR_NONE) {
+ if (connected) {
+ TC_PRT("PXP connected(address = %s)", remote_address);
+ TC_PRT("PXP Reporter supported Service\n");
+ if (supported_service & BT_PROXIMITY_LINKLOSS_ALERT)
+ TC_PRT("BT_PROXIMITY_LINKLOSS_ALERT\n");
+ if (supported_service & BT_PROXIMITY_IMMEDIATE_ALERT)
+ TC_PRT("BT_PROXIMITY_IMMEDIATE_ALERT\n");
+ if (supported_service & BT_PROXIMITY_TX_POWER)
+ TC_PRT("BT_PROXIMITY_TX_POWER");
+ } else {
+ TC_PRT("PXP DISconnected");
+ }
+ }
}
void __bt_gatt_server_notification_sent_cb(int result,
case BT_UNIT_TEST_TABLE_PXP: {
switch (test_id) {
- case BT_UNIT_TEST_FUNCTION_PXP_REGISTER:
- case BT_UNIT_TEST_FUNCTION_PXP_UNREGISTER: {
+ case BT_UNIT_TEST_FUNCTION_PXP_MONITOR_WRITE_LINKLOSS_ALERT:
+ case BT_UNIT_TEST_FUNCTION_PXP_MONITOR_WRITE_IMMEDIATE_ALERT: {
if (param_index == 0) {
g_test_param.param_count = 1;
g_test_param.params = g_malloc0(sizeof(char *) *g_test_param.param_count);
param_type = BT_UNIT_TEST_PARAM_TYPE_INT;
}
- if (param_index > 0) {
- g_test_param.params[param_index - 1] = g_malloc0(strlen(param) + 1);
- strncpy(g_test_param.params[param_index - 1], param, strlen(param));
- }
-
- if (param_index == g_test_param.param_count) {
- need_to_set_params = false;
-#ifdef ARCH64
- test_input_callback((void *)(uintptr_t)test_id);
-#else
- test_input_callback((void *)test_id);
-#endif
- param_index = 0;
- return 0;
- }
- switch (param_index) {
- case 0:
- TC_PRT("Input Value Type (avail. : \n0.BT_PROXIMITY_REPORTER, \n1.BT_PROXIMITY_MONITOR");
- break;
- }
-
- TC_PRT("Input param(%d) type:%s",
- param_index + 1, param_type);
- param_index++;
-
- break;
- }
- case BT_UNIT_TEST_FUNCTION_PXP_WRITE_ALERT_LEVEL: {
- if (param_index == 0) {
- g_test_param.param_count = 2;
- g_test_param.params = g_malloc0(sizeof(char *) *g_test_param.param_count);
- param_type = BT_UNIT_TEST_PARAM_TYPE_INT;
- }
-
if (param_index > 0) {
int len = strlen(param);
g_test_param.params[param_index - 1] = g_malloc0(len + 1);
switch (param_index) {
case 0:
- TC_PRT("Input Value Type (avail. : \n1.BT_PROXIMITY_LINKLOSS_ALERT, \n2.BT_PROXIMITY_IMMEDIATE_ALERT");
- break;
- case 1:
TC_PRT("Input Value Type (avail. : \n0.NONE, \n1.MILD, \n2.HIGH");
break;
}
break;
}
- case BT_UNIT_TEST_FUNCTION_PXP_READ_ALERT_LEVEL: {
- if (param_index == 0) {
- g_test_param.param_count = 1;
- g_test_param.params = g_malloc0(sizeof(char *) *g_test_param.param_count);
- param_type = BT_UNIT_TEST_PARAM_TYPE_INT;
- }
-
- if (param_index > 0) {
- int len = strlen(param);
- g_test_param.params[param_index - 1] = g_malloc0(len + 1);
- /* Remove new line character */
- param[len - 1] = '\0';
- strncpy(g_test_param.params[param_index - 1], param, strlen(param));
- }
-
- if (param_index == g_test_param.param_count) {
- need_to_set_params = false;
-#ifdef ARCH64
- test_input_callback((void *)(uintptr_t)test_id);
-#else
- test_input_callback((void *)test_id);
-#endif
- param_index = 0;
- return 0;
- }
-
- switch (param_index) {
- case 0:
- TC_PRT("Input Value Type (avail. : \n1.BT_PROXIMITY_LINKLOSS_ALERT, \n2.BT_PROXIMITY_IMMEDIATE_ALERT");
- break;
- }
-
- TC_PRT("Input param(%d) type:%s",
- param_index + 1, param_type);
- param_index++;
-
- break;
- }
-
default:
TC_PRT("There is no param to set\n");
need_to_set_params = false;
case BT_UNIT_TEST_TABLE_PXP: {
switch (test_id) {
- case BT_UNIT_TEST_FUNCTION_PXP_REGISTER: {
- int role;
- if (g_test_param.param_count < 1) {
- TC_PRT("Input parameters first");
- break;
+ case BT_UNIT_TEST_FUNCTION_PXP_REPORTER_REGISTER: {
+ if (reporter) {
+ ret = bt_proximity_reporter_destroy(reporter);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+
+ ret = bt_proximity_reporter_unset_property_changed_cb(reporter);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+
+ ret = bt_proximity_reporter_unset_connection_state_changed_cb(reporter);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ reporter = NULL;
}
- role = atoi(g_test_param.params[0]);
- ret = bt_proximity_register(role, __bt_proximity_property_changed_cb, NULL);
+ ret = bt_proximity_reporter_create(&reporter);
TC_PRT("returns %s\n", __bt_get_error_message(ret));
break;
}
- case BT_UNIT_TEST_FUNCTION_PXP_UNREGISTER: {
- int role;
- if (g_test_param.param_count < 1) {
- TC_PRT("Input parameters first");
- break;
+ case BT_UNIT_TEST_FUNCTION_PXP_REPORTER_UNREGISTER: {
+ ret = bt_proximity_reporter_unset_connection_state_changed_cb(reporter);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+
+ ret = bt_proximity_reporter_unset_property_changed_cb(reporter);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+
+
+ ret = bt_proximity_reporter_destroy(reporter);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ reporter = NULL;
+ break;
+ }
+ case BT_UNIT_TEST_FUNCTION_PXP_MONITOR_CREATE: {
+ if (monitor) {
+ ret = bt_proximity_monitor_disconnect(monitor);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+
+ ret = bt_proximity_monitor_unset_connection_state_changed_cb(monitor);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+
+ ret = bt_proximity_monitor_destroy(monitor);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ monitor = NULL;
}
- role = atoi(g_test_param.params[0]);
- ret = bt_proximity_unregister(role);
+ ret = bt_proximity_monitor_create(remote_addr, &monitor);
TC_PRT("returns %s\n", __bt_get_error_message(ret));
break;
+
}
- case BT_UNIT_TEST_FUNCTION_PXP_MONITOR_CONNECT: {
- bool auto_connect = false;
+ case BT_UNIT_TEST_FUNCTION_PXP_MONITOR_DESTROY: {
+ ret = bt_proximity_monitor_unset_connection_state_changed_cb(monitor);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
- ret = bt_gatt_connect(remote_addr, auto_connect);
+ ret = bt_proximity_monitor_destroy(monitor);
TC_PRT("returns %s\n", __bt_get_error_message(ret));
- ret = bt_gatt_set_connection_state_changed_cb(
- __bt_pxp_montior_connection_state_changed_cb,
+ monitor = NULL;
+ break;
+ }
+ case BT_UNIT_TEST_FUNCTION_PXP_MONITOR_CONNECT: {
+ ret = bt_proximity_monitor_connect(monitor);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ }
+ case BT_UNIT_TEST_FUNCTION_PXP_MONITOR_DISCONNECT: {
+ ret = bt_proximity_monitor_disconnect(monitor);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ }
+ case BT_UNIT_TEST_FUNCTION_PXP_MONITOR_SET_CONNECTION_STATE_CHANGED_CB: {
+ ret = bt_proximity_monitor_set_connection_state_changed_cb(monitor,
+ __bt_proximity_monitor_connection_state_changed_cb,
NULL);
TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ }
+ case BT_UNIT_TEST_FUNCTION_PXP_MONITOR_UNSET_CONNECTION_STATE_CHANGED_CB: {
+ ret = bt_proximity_monitor_unset_connection_state_changed_cb(monitor);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ }
+ case BT_UNIT_TEST_FUNCTION_PXP_REPORTER_SET_CONNECTION_STATE_CHANGED_CB: {
+ ret = bt_proximity_reporter_set_connection_state_changed_cb(reporter,
+ __bt_proximity_reporter_connection_state_changed_cb,
+ NULL);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ }
+ case BT_UNIT_TEST_FUNCTION_PXP_REPORTER_UNSET_CONNECTION_STATE_CHANGED_CB: {
+ ret = bt_proximity_reporter_unset_connection_state_changed_cb(reporter);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ }
+ case BT_UNIT_TEST_FUNCTION_PXP_REPORTER_SET_PROPERTIES_CHANGED_CB: {
+ ret = bt_proximity_reporter_set_property_changed_cb(reporter,
+ __bt_proximity_reporter_property_changed_cb,
+ NULL);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ }
+ case BT_UNIT_TEST_FUNCTION_PXP_REPORTER_UNSET_PROPERTIES_CHANGED_CB: {
+ ret = bt_proximity_reporter_unset_property_changed_cb(reporter);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ }
+ case BT_UNIT_TEST_FUNCTION_PXP_MONITOR_SET_SCAN_FILTER_SERVICE_UUID: {
+ if (pxp_scan_filter) {
+ ret = bt_adapter_le_scan_filter_unset_proximity_uuid(pxp_scan_filter);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+
+ ret = bt_adapter_le_destroy_scan_filter(pxp_scan_filter);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ pxp_scan_filter = NULL;
+ }
+ ret = bt_adapter_le_create_scan_filter(&pxp_scan_filter);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+
+ ret = bt_adapter_le_scan_filter_set_proximity_uuid(pxp_scan_filter);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+
+ ret = bt_adapter_le_register_scan_filter(pxp_scan_filter);
+ if (ret != BT_ERROR_NONE)
+ TC_PRT("failed with [0x%04x]", ret);
break;
}
- case BT_UNIT_TEST_FUNCTION_PXP_MONITOR_DISCONNECT: {
- ret = bt_gatt_disconnect(remote_addr);
+ case BT_UNIT_TEST_FUNCTION_PXP_MONITOR_UNSET_SCAN_FILTER_SERVICE_UUID: {
+ ret = bt_adapter_le_scan_filter_unset_proximity_uuid(pxp_scan_filter);
TC_PRT("returns %s\n", __bt_get_error_message(ret));
+
+ ret = bt_adapter_le_destroy_scan_filter(pxp_scan_filter);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ pxp_scan_filter = NULL;
+
break;
}
- case BT_UNIT_TEST_FUNCTION_PXP_WRITE_ALERT_LEVEL: {
- int property, alert_value;
- if (g_test_param.param_count < 2) {
+ case BT_UNIT_TEST_FUNCTION_PXP_REPORTER_START_ADVERTISING: {
+ /* Add Reporter service in advertising data */
+ advertiser = advertiser_list[advertiser_index];
+ if (advertiser == NULL) {
+ ret = bt_adapter_le_create_advertiser(&advertiser);
+ if (ret != BT_ERROR_NONE) {
+ TC_PRT("created le advertiser(%d)", ret);
+ break;
+ }
+
+ advertiser_list[advertiser_index] = advertiser;
+ ret = bt_adapter_le_set_advertising_device_name(advertiser,
+ BT_ADAPTER_LE_PACKET_SCAN_RESPONSE, true);
+ if (ret != BT_ERROR_NONE) {
+ TC_PRT("set device name [0x%04x]", ret);
+ break;
+ }
+ }
+
+ ret = bt_adapter_le_add_advertising_service_solicitation_uuid(advertiser,
+ BT_ADAPTER_LE_PACKET_ADVERTISING, PXP_IMMEDIATE_ALERT_SVC_UUID);
+ if (ret != BT_ERROR_NONE) {
+ TC_PRT("add service_solicitation_uuid [0x%04x]", ret);
+ break;
+ }
+
+ ret = bt_adapter_le_add_advertising_service_solicitation_uuid(advertiser,
+ BT_ADAPTER_LE_PACKET_ADVERTISING, PXP_LINK_LOSS_SVC_UUID);
+ if (ret != BT_ERROR_NONE) {
+ TC_PRT("add service_solicitation_uuid [0x%04x]", ret);
+ break;
+ }
+
+ /* Start advertising PXP Reporter service */
+ bt_adapter_le_advertising_state_changed_cb cb;
+
+ if (advertiser_index == 0) cb = __bt_adapter_le_advertising_state_changed_cb;
+ else if (advertiser_index == 1) cb = __bt_adapter_le_advertising_state_changed_cb_2;
+ else cb = __bt_adapter_le_advertising_state_changed_cb_3;
+
+ advertiser = advertiser_list[advertiser_index];
+
+ advertiser_index++;
+ advertiser_index %= 3;
+
+ TC_PRT("advertiser: %p", advertiser);
+
+ ret = bt_adapter_le_start_advertising_new(advertiser, cb, NULL);
+ if (ret < BT_ERROR_NONE)
+ TC_PRT("failed with [0x%04x]", ret);
+
+ break;
+ }
+ case BT_UNIT_TEST_FUNCTION_PXP_MONITOR_WRITE_LINKLOSS_ALERT: {
+ int alert_value;
+ if (g_test_param.param_count < 1) {
TC_PRT("Input parameters first");
break;
}
- property = atoi(g_test_param.params[0]);
- alert_value = atoi(g_test_param.params[1]);
- ret = bt_proximity_set_property(remote_addr, property, alert_value);
+
+ alert_value = atoi(g_test_param.params[0]);
+ ret = bt_proximity_monitor_set_linkloss_alert(monitor, alert_value);
TC_PRT("returns %s\n", __bt_get_error_message(ret));
break;
}
- case BT_UNIT_TEST_FUNCTION_PXP_READ_ALERT_LEVEL: {
- int alert_level = 0;
- int property;
+ case BT_UNIT_TEST_FUNCTION_PXP_MONITOR_WRITE_IMMEDIATE_ALERT: {
+ int alert_value;
if (g_test_param.param_count < 1) {
TC_PRT("Input parameters first");
break;
}
- property = atoi(g_test_param.params[0]);
- ret = bt_proximity_get_property(remote_addr, property, &alert_level);
- TC_PRT("returns %s, alert_level: %d\n", __bt_get_error_message(ret), alert_level);
+
+ alert_value = atoi(g_test_param.params[0]);
+ ret = bt_proximity_monitor_set_immediate_alert(monitor, alert_value);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
break;
}
- case BT_UNIT_TEST_FUNCTION_PXP_GET_SUPPORTED_SERVICES: {
- int property = 0;
- ret = bt_proximity_get_supported_services(remote_addr, &property);
- TC_PRT("returns %s\n", __bt_get_error_message(ret));
- if (ret == BT_ERROR_NONE) {
- if (property & BT_PROXIMITY_LINKLOSS_ALERT)
- TC_PRT("BT_PROXIMITY_LINKLOSS_ALERT");
- if (property & BT_PROXIMITY_IMMEDIATE_ALERT)
- TC_PRT("BT_PROXIMITY_IMMEDIATE_ALERT");
- if (property & BT_PROXIMITY_TX_POWER)
- TC_PRT("BT_PROXIMITY_TX_POWER");
- }
+ case BT_UNIT_TEST_FUNCTION_PXP_MONITOR_READ_LINKLOSS_ALERT: {
+ int alert_level = 0;
+ ret = bt_proximity_monitor_get_linkloss_alert(monitor, &alert_level);
+ TC_PRT("returns %s, alert_level: %d\n", __bt_get_error_message(ret), alert_level);
+ break;
+ }
+ case BT_UNIT_TEST_FUNCTION_PXP_MONITOR_READ_IMMEDIATE_ALERT: {
+ int alert_level = 0;
+ ret = bt_proximity_monitor_get_immediate_alert(monitor, &alert_level);
+ TC_PRT("returns %s, alert_level: %d\n", __bt_get_error_message(ret), alert_level);
+ break;
+ }
+ case BT_UNIT_TEST_FUNCTION_PXP_MONITOR_READ_SIGNAL_LEVEL: {
+ int alert_level = 0;
+ ret = bt_proximity_monitor_get_signal_level(monitor, &alert_level);
+ TC_PRT("returns %s, signal_level: %d\n", __bt_get_error_message(ret), alert_level);
+ break;
+ }
+ case BT_UNIT_TEST_FUNCTION_PXP_REPORTER_READ_LINKLOSS_ALERT: {
+ int alert_level = 0;
+ ret = bt_proximity_reporter_get_linkloss_alert(remote_addr, &alert_level);
+ TC_PRT("returns %s, alert_level: %d\n", __bt_get_error_message(ret), alert_level);
+ break;
+ }
+ case BT_UNIT_TEST_FUNCTION_PXP_REPORTER_READ_IMMEDIATE_ALERT: {
+ int alert_level = 0;
+ ret = bt_proximity_reporter_get_immediate_alert(remote_addr, &alert_level);
+ TC_PRT("returns %s, alert_level: %d\n", __bt_get_error_message(ret), alert_level);
break;
}
case BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS:
BT_UNIT_TEST_FUNCTION_APP_CONTROL_2_4_BT_ONOFF,
BT_UNIT_TEST_FUNCTION_APP_CONTROL_2_4_BT_VISIBILITY,
BT_UNIT_TEST_FUNCTION_CHECK_FEATURE,
- BT_UNIT_TEST_FUNCTION_PXP_REGISTER = 1,
- BT_UNIT_TEST_FUNCTION_PXP_UNREGISTER,
+ BT_UNIT_TEST_FUNCTION_PXP_REPORTER_REGISTER = 1,
+ BT_UNIT_TEST_FUNCTION_PXP_REPORTER_UNREGISTER,
+ BT_UNIT_TEST_FUNCTION_PXP_REPORTER_START_ADVERTISING,
+ BT_UNIT_TEST_FUNCTION_PXP_REPORTER_SET_CONNECTION_STATE_CHANGED_CB,
+ BT_UNIT_TEST_FUNCTION_PXP_REPORTER_UNSET_CONNECTION_STATE_CHANGED_CB,
+ BT_UNIT_TEST_FUNCTION_PXP_REPORTER_SET_PROPERTIES_CHANGED_CB,
+ BT_UNIT_TEST_FUNCTION_PXP_REPORTER_UNSET_PROPERTIES_CHANGED_CB,
+ BT_UNIT_TEST_FUNCTION_PXP_REPORTER_READ_LINKLOSS_ALERT,
+ BT_UNIT_TEST_FUNCTION_PXP_REPORTER_READ_IMMEDIATE_ALERT,
+ BT_UNIT_TEST_FUNCTION_PXP_MONITOR_CREATE,
+ BT_UNIT_TEST_FUNCTION_PXP_MONITOR_DESTROY,
BT_UNIT_TEST_FUNCTION_PXP_MONITOR_CONNECT,
BT_UNIT_TEST_FUNCTION_PXP_MONITOR_DISCONNECT,
- BT_UNIT_TEST_FUNCTION_PXP_WRITE_ALERT_LEVEL,
- BT_UNIT_TEST_FUNCTION_PXP_READ_ALERT_LEVEL,
- BT_UNIT_TEST_FUNCTION_PXP_GET_SUPPORTED_SERVICES,
+ BT_UNIT_TEST_FUNCTION_PXP_MONITOR_SET_CONNECTION_STATE_CHANGED_CB,
+ BT_UNIT_TEST_FUNCTION_PXP_MONITOR_UNSET_CONNECTION_STATE_CHANGED_CB,
+ BT_UNIT_TEST_FUNCTION_PXP_MONITOR_SET_SCAN_FILTER_SERVICE_UUID,
+ BT_UNIT_TEST_FUNCTION_PXP_MONITOR_UNSET_SCAN_FILTER_SERVICE_UUID,
+ BT_UNIT_TEST_FUNCTION_PXP_MONITOR_WRITE_LINKLOSS_ALERT,
+ BT_UNIT_TEST_FUNCTION_PXP_MONITOR_WRITE_IMMEDIATE_ALERT,
+ BT_UNIT_TEST_FUNCTION_PXP_MONITOR_READ_LINKLOSS_ALERT,
+ BT_UNIT_TEST_FUNCTION_PXP_MONITOR_READ_IMMEDIATE_ALERT,
+ BT_UNIT_TEST_FUNCTION_PXP_MONITOR_READ_SIGNAL_LEVEL,
BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS = 0XFF,
} bt_unit_test_function_e;