Exemple #1
0
static void cmd_primary(int argcp, char **argvp)
{
    bt_uuid_t uuid;

    if (conn_state != STATE_CONNECTED) {
        printf("Command failed: disconnected\n");
        goto done;
    }

    if (argcp == 1) {
        gatt_discover_primary(attrib, NULL, primary_all_cb, NULL);
        goto done;
    }

    if (bt_string_to_uuid(&uuid, argvp[1]) < 0) {
        printf("Invalid UUID\n");
        goto done;
    }

    gatt_discover_primary(attrib, &uuid, primary_by_uuid_cb, NULL);
    return;

done:
    printf("\r%s", get_prompt());
    fflush(stdout);
}
Exemple #2
0
static gboolean primary(gpointer user_data)
{
	GAttrib *attrib = user_data;

	if (opt_uuid)
		gatt_discover_primary(attrib, opt_uuid, primary_by_uuid_cb,
									NULL);
	else
		gatt_discover_primary(attrib, NULL, primary_all_cb, NULL);

	return FALSE;
}
Exemple #3
0
static void cmd_primary(int argcp, char **argvp)
{
	bt_uuid_t uuid;

	if (conn_state != STATE_CONNECTED) {
		resp_error(err_BAD_STATE);
		return;
	}

	if (argcp == 1) {
		gatt_discover_primary(attrib, NULL, primary_all_cb, NULL);
		return;
	}

	if (bt_string_to_uuid(&uuid, argvp[1]) < 0) {
		resp_error(err_BAD_PARAM);
		return;
	}

	gatt_discover_primary(attrib, &uuid, primary_by_uuid_cb, NULL);
}
Exemple #4
0
static void cmd_primary(int argcp, char **argvp)
{
	bt_uuid_t uuid;

	if (conn_state != STATE_CONNECTED) {
		failed("Disconnected\n");
		return;
	}

	if (argcp == 1) {
		gatt_discover_primary(attrib, NULL, primary_all_cb, NULL);
		return;
	}

	if (bt_string_to_uuid(&uuid, argvp[1]) < 0) {
		error("Invalid UUID\n");
		return;
	}

	gatt_discover_primary(attrib, &uuid, primary_by_uuid_cb, NULL);
}
static int discover_services(gpointer data)
{
    GAttrib *attrib = data;

    if (get_state() != STATE_CONNECTED) {
      printf("device is already disconnected\n");
      return -1;
    }
    gatt_discover_primary(attrib, NULL, discover_services_cb, NULL);
    g_main_loop_run(event_loop);
    return 0;
}
Exemple #6
0
static void discover_services(void)
{
        if (conn_state != STATE_CONNECTED) {
                failed("Disconnected\n");
                return;
        }
        
        bt_uuid_t uuid;
        if (bt_string_to_uuid(&uuid, ANKI_STR_SERVICE_UUID) < 0) {
                error("Error attempting to discover service for UUID: %s\n", ANKI_STR_SERVICE_UUID);
                return;
        }

	gatt_discover_primary(attrib, &uuid, discover_services_cb, NULL);
}
Exemple #7
0
bool bt_hog_attach(struct bt_hog *hog, void *gatt)
{
	struct gatt_primary *primary = hog->primary;
	GSList *l;

	if (hog->attrib)
		return false;

	hog->attrib = g_attrib_ref(gatt);

	if (!primary) {
		gatt_discover_primary(hog->attrib, NULL, primary_cb, hog);
		return true;
	}

	if (hog->scpp)
		bt_scpp_attach(hog->scpp, gatt);

	if (hog->dis)
		bt_dis_attach(hog->dis, gatt);

	if (hog->bas)
		bt_bas_attach(hog->bas, gatt);

	for (l = hog->instances; l; l = l->next) {
		struct bt_hog *instance = l->data;

		bt_hog_attach(instance, gatt);
	}

	if (hog->reports == NULL) {
		gatt_discover_char(hog->attrib, primary->range.start,
						primary->range.end, NULL,
						char_discovered_cb, hog);
		return true;
	}

	for (l = hog->reports; l; l = l->next) {
		struct report *r = l->data;

		r->notifyid = g_attrib_register(hog->attrib,
					ATT_OP_HANDLE_NOTIFY,
					r->decl->value_handle,
					report_value_cb, r, NULL);
	}

	return true;
}