コード例 #1
0
static void refresh_discovered_cb(uint8_t status, GSList *chars,
								void *user_data)
{
	struct bt_scpp *scan = user_data;
	struct gatt_char *chr;
	uint16_t start, end;
	bt_uuid_t uuid;

	if (status) {
		error("Scan Refresh %s", att_ecode2str(status));
		return;
	}

	if (!chars) {
		DBG("Scan Refresh not supported");
		return;
	}

	chr = chars->data;

	DBG("Scan Refresh handle: 0x%04x", chr->value_handle);

	start = chr->value_handle + 1;
	end = scan->primary->range.end;

	if (start > end)
		return;

	scan->refresh_handle = chr->value_handle;

	bt_uuid16_create(&uuid, GATT_CLIENT_CHARAC_CFG_UUID);

	discover_desc(scan, scan->attrib, start, end, &uuid,
					discover_descriptor_cb, user_data);
}
コード例 #2
0
ファイル: bas.c プロジェクト: Klamath233/BlueZ
static void bas_discovered_cb(uint8_t status, GSList *chars, void *user_data)
{
	struct gatt_request *req = user_data;
	struct bt_bas *bas = req->user_data;
	struct gatt_char *chr;
	uint16_t start, end;
	bt_uuid_t uuid;

	destroy_gatt_req(req);

	if (status) {
		error("Battery: %s", att_ecode2str(status));
		return;
	}

	chr = chars->data;
	bas->handle = chr->value_handle;

	DBG("Battery handle: 0x%04x", bas->handle);

	read_char(bas, bas->attrib, bas->handle, read_value_cb, bas);

	start = chr->value_handle + 1;
	end = bas->primary->range.end;

	bt_uuid16_create(&uuid, GATT_CLIENT_CHARAC_CFG_UUID);

	discover_desc(bas, bas->attrib, start, end, &uuid,
						discover_descriptor_cb, bas);
}
コード例 #3
0
static void discover_char_cb(uint8_t status, GSList *chars, void *user_data)
{
	struct csc *csc = user_data;
	uint16_t feature_val_handle = 0;

	if (status) {
		error("Discover CSCS characteristics: %s",
							att_ecode2str(status));
		return;
	}

	for (; chars; chars = chars->next) {
		struct gatt_char *c = chars->data;
		struct gatt_char *c_next =
				(chars->next ? chars->next->data : NULL);

		if (g_strcmp0(c->uuid, CSC_MEASUREMENT_UUID) == 0) {
			csc->attio_measurement_id =
				g_attrib_register(csc->attrib,
					ATT_OP_HANDLE_NOTIFY, c->value_handle,
					measurement_notify_handler, csc, NULL);

			discover_desc(csc, c, c_next);
		} else if (g_strcmp0(c->uuid, CSC_FEATURE_UUID) == 0) {
			feature_val_handle = c->value_handle;
		} else if (g_strcmp0(c->uuid, SENSOR_LOCATION_UUID) == 0) {
			DBG("Sensor Location supported");
			gatt_read_char(csc->attrib, c->value_handle,
							read_location_cb, csc);
		} else if (g_strcmp0(c->uuid, SC_CONTROL_POINT_UUID) == 0) {
			DBG("SC Control Point supported");
			csc->controlpoint_val_handle = c->value_handle;

			csc->attio_controlpoint_id = g_attrib_register(
					csc->attrib, ATT_OP_HANDLE_IND,
					c->value_handle,
					controlpoint_ind_handler, csc, NULL);

			discover_desc(csc, c, c_next);
		}
	}

	if (feature_val_handle > 0)
		gatt_read_char(csc->attrib, feature_val_handle,
							read_feature_cb, csc);
}