Esempio n. 1
0
static struct health_channel *search_channel_by_mdl(struct mcap_mdl *mdl)
{
	const struct queue_entry *apps_entry, *devices_entry;
	struct health_app *app;
	struct health_channel *channel;
	struct health_device *dev;

	DBG("");

	apps_entry = queue_get_entries(apps);
	while (apps_entry) {
		app = apps_entry->data;
		devices_entry = queue_get_entries(app->devices);
		while (devices_entry) {
			dev = devices_entry->data;
			channel = queue_find(dev->channels,
						match_channel_by_mdl, mdl);

			if (channel)
				return channel;

			devices_entry = devices_entry->next;
		}

		apps_entry = apps_entry->next;
	}

	return NULL;
}
Esempio n. 2
0
static struct health_channel *search_channel_by_id(uint16_t id)
{
	const struct queue_entry *apps_entry, *devices_entry;
	struct health_app *app;
	struct health_channel *channel;
	struct health_device *dev;

	DBG("");

	apps_entry = queue_get_entries(apps);
	while (apps_entry) {
		app = apps_entry->data;
		devices_entry = queue_get_entries(app->devices);
		while (devices_entry) {
			dev = devices_entry->data;
			channel = queue_find(dev->channels, match_channel_by_id,
								INT_TO_PTR(id));

			if (channel)
				return channel;

			devices_entry = devices_entry->next;
		}

		apps_entry = apps_entry->next;
	}

	return NULL;
}
Esempio n. 3
0
static struct gatt_db_service *find_insert_loc(struct gatt_db *db,
						uint16_t start, uint16_t end,
						struct gatt_db_service **after)
{
	const struct queue_entry *services_entry;
	struct gatt_db_service *service;
	uint16_t cur_start, cur_end;

	*after = NULL;

	services_entry = queue_get_entries(db->services);

	while (services_entry) {
		service = services_entry->data;

		gatt_db_service_get_handles(service, &cur_start, &cur_end);

		if (start >= cur_start && start <= cur_end)
			return service;

		if (end >= cur_start && end <= cur_end)
			return service;

		if (end < cur_start)
			return NULL;

		*after = service;
		services_entry = services_entry->next;
	}

	return NULL;
}
Esempio n. 4
0
static void handle_notify(struct bt_att *att, uint8_t opcode, uint8_t *pdu,
								ssize_t pdu_len)
{
	const struct queue_entry *entry;
	bool found;

	if ((opcode & ATT_OP_SIGNED_MASK) && !att->crypto) {
		if (!handle_signed(att, opcode, pdu, pdu_len))
			return;
		pdu_len -= BT_ATT_SIGNATURE_LEN;
	}

	bt_att_ref(att);

	found = false;
	entry = queue_get_entries(att->notify_list);

	while (entry) {
		struct att_notify *notify = entry->data;

		entry = entry->next;

		if (!opcode_match(notify->opcode, opcode))
			continue;

		found = true;

		if (notify->callback)
			notify->callback(opcode, pdu, pdu_len,
							notify->user_data);

		/* callback could remove all entries from notify list */
		if (queue_isempty(att->notify_list))
			break;
	}

	/*
	 * If this was a request and no handler was registered for it, respond
	 * with "Not Supported"
	 */
	if (!found && get_op_type(opcode) == ATT_OP_TYPE_REQ)
		respond_not_supported(att, opcode);

	bt_att_unref(att);
}
Esempio n. 5
0
void gatt_db_read_by_group_type(struct gatt_db *db, uint16_t start_handle,
							uint16_t end_handle,
							const bt_uuid_t type,
							struct queue *queue)
{
	const struct queue_entry *services_entry;
	struct gatt_db_service *service;
	uint16_t grp_start, grp_end, uuid_size;

	uuid_size = 0;

	services_entry = queue_get_entries(db->services);

	while (services_entry) {
		service = services_entry->data;

		if (!service->active)
			goto next_service;

		if (bt_uuid_cmp(&type, &service->attributes[0]->uuid))
			goto next_service;

		grp_start = service->attributes[0]->handle;
		grp_end = grp_start + service->num_handles - 1;

		if (grp_end < start_handle || grp_start > end_handle)
			goto next_service;

		if (grp_start < start_handle || grp_start > end_handle)
			goto next_service;

		if (!uuid_size)
			uuid_size = service->attributes[0]->value_len;
		else if (uuid_size != service->attributes[0]->value_len)
			return;

		queue_push_tail(queue, service->attributes[0]);

next_service:
		services_entry = services_entry->next;
	}
}
Esempio n. 6
0
static struct health_app *search_app_by_mdepid(uint8_t mdepid)
{
	const struct queue_entry *apps_entry;
	struct health_app *app;

	DBG("");

	apps_entry = queue_get_entries(apps);
	while (apps_entry) {
		app = apps_entry->data;

		if (queue_find(app->mdeps, match_mdep_by_id,
							INT_TO_PTR(mdepid)))
			return app;

		apps_entry = apps_entry->next;
	}

	return NULL;
}
Esempio n. 7
0
static struct health_device *search_dev_by_mcl(struct mcap_mcl *mcl)
{
	const struct queue_entry *apps_entry;
	struct health_app *app;
	struct health_device *dev;

	DBG("");

	apps_entry = queue_get_entries(apps);
	while (apps_entry) {
		app = apps_entry->data;

		dev = queue_find(app->devices, match_dev_by_mcl, mcl);

		if (dev)
			return dev;

		apps_entry = apps_entry->next;
	}

	return NULL;
}