#include "attrib/gatt.h"
#include "btio/btio.h"
+#define GATT_SUCCESS 0x00000000
+#define GATT_FAILURE 0x00000101
+
struct gatt_client {
int32_t id;
uint8_t uuid[16];
status = HAL_STATUS_SUCCESS;
- ev.status = status;
+ ev.status = GATT_SUCCESS;
ev.client_if = client->id;
memcpy(ev.app_uuid, client->uuid, sizeof(client->uuid));
if (status) {
error("gatt: Discover all primary services failed: %s",
att_ecode2str(status));
- ev.status = HAL_STATUS_FAILED;
+ ev.status = GATT_FAILURE;
goto done;
}
if (!services) {
info("gatt: No primary services found");
- ev.status = HAL_STATUS_SUCCESS;
+ ev.status = GATT_SUCCESS;
goto done;
}
sizeof(ev_res), &ev_res);
}
- ev.status = HAL_STATUS_SUCCESS;
+ ev.status = GATT_SUCCESS;
done:
ev.conn_id = dev->conn_id;
struct gatt_device *dev = user_data;
int32_t id = PTR_TO_INT(data);
- send_client_disconnect_notify(id, dev, HAL_STATUS_SUCCESS);
+ send_client_disconnect_notify(id, dev, GATT_SUCCESS);
}
static bool is_device_wating_for_connect(const bdaddr_t *addr,
struct hal_ev_gatt_client_connect ev;
GAttrib *attrib;
static uint32_t conn_id = 0;
- uint8_t status;
+ int32_t status;
/* Take device from conn waiting queue */
dev = queue_remove_if(conn_wait_queue, match_dev_by_bdaddr, addr);
if (gerr) {
error("gatt: connection failed %s", gerr->message);
- status = HAL_STATUS_FAILED;
+ status = GATT_FAILURE;
goto reply;
}
attrib = g_attrib_new(io);
if (!attrib) {
error("gatt: unable to create new GAttrib instance");
- status = HAL_STATUS_FAILED;
+ status = GATT_FAILURE;
goto reply;
}
if (!queue_push_tail(conn_list, dev)) {
error("gatt: Cannot push dev on conn_list");
connection_cleanup(dev);
- status = HAL_STATUS_FAILED;
+ status = GATT_FAILURE;
goto reply;
}
- status = HAL_STATUS_SUCCESS;
+ status = GATT_SUCCESS;
goto reply;
reply:
struct hal_ev_gatt_client_connect ev;
ev.conn_id = dev->conn_id;
- ev.status = HAL_STATUS_SUCCESS;
+ ev.status = GATT_SUCCESS;
ev.client_if = cmd->client_if;
bdaddr2android(&addr, &ev.bda);
* If this is last client, this is still OK to do because on connect
* request we do le scan and wait until remote device start
* advertisement */
- send_client_disconnect_notify(cmd->client_if, dev, HAL_STATUS_SUCCESS);
+ send_client_disconnect_notify(cmd->client_if, dev, GATT_SUCCESS);
/* If there is more clients just return */
if (!queue_isempty(dev->clients))
bt_uuid_t included_uuid;
ev.conn_id = device->conn_id;
- ev.status = HAL_STATUS_SUCCESS;
+ ev.status = GATT_SUCCESS;
ev.srvc_id.inst_id = 0;
uuid2android(&uuid, ev.srvc_id.uuid);
/* Android expects notification with error status in the end */
ev.conn_id = device->conn_id;
- ev.status = HAL_STATUS_FAILED;
+ ev.status = GATT_FAILURE;
ev.srvc_id.inst_id = 0;
uuid2android(&uuid, ev.srvc_id.uuid);
struct hal_ev_gatt_client_get_characteristic ev;
memset(&ev, 0, sizeof(ev));
- ev.status = ch ? HAL_STATUS_SUCCESS : HAL_STATUS_FAILED;
+ ev.status = ch ? GATT_SUCCESS : GATT_FAILURE;
if (ch) {
ev.char_prop = ch->ch.properties;
struct service *service;
int32_t conn_id = 0;
uint8_t status;
+ int32_t gatt_status;
bdaddr_t addr;
DBG("");
status = HAL_STATUS_SUCCESS;
failed:
- send_register_for_notification_ev(conn_id, 1, status, &cmd->srvc_id,
- &cmd->char_id);
+ gatt_status = status ? GATT_SUCCESS : GATT_FAILURE;
+ send_register_for_notification_ev(conn_id, 1, gatt_status,
+ &cmd->srvc_id, &cmd->char_id);
ipc_send_rsp(hal_ipc, HAL_SERVICE_ID_GATT,
HAL_OP_GATT_CLIENT_REGISTER_FOR_NOTIFICATION,
status);
struct gatt_device *dev;
int32_t conn_id = 0;
uint8_t status;
+ int32_t gatt_status;
bdaddr_t addr;
DBG("");
status = HAL_STATUS_SUCCESS;
failed:
- send_register_for_notification_ev(conn_id, 0, status, &cmd->srvc_id,
- &cmd->char_id);
+ gatt_status = status ? GATT_SUCCESS : GATT_FAILURE;
+ send_register_for_notification_ev(conn_id, 0, gatt_status,
+ &cmd->srvc_id, &cmd->char_id);
ipc_send_rsp(hal_ipc, HAL_SERVICE_ID_GATT,
HAL_OP_GATT_CLIENT_DEREGISTER_FOR_NOTIFICATION,