Пример #1
0
gboolean mcap_get_mdep(struct mcap_device *device, struct mcap_application *app,
				mcap_continue_mdep_f func, gpointer data,
				GDestroyNotify destroy, GError **err)
{
		DBG("");
	struct get_mdep_data *mdep_data;
	bdaddr_t dst, src;
	uuid_t uuid;

	device_get_address(device->dev, &dst,NULL);
	adapter_get_address(device_get_adapter(device->dev), &src);

	mdep_data = g_new0(struct get_mdep_data, 1);
	mdep_data->app = mcap_application_ref(app);
	mdep_data->func = func;
	mdep_data->data = data;
	mdep_data->destroy = destroy;
	char dd[100] = {};
	ba2str(&dst,dd);
	DBG("dst device = %s",dd);
	sdp_uuid32_create(&uuid, 0x1400);
//	bt_string2uuid(&uuid, 0x1400);
	if (bt_search_service(&src, &dst, &uuid, get_mdep_cb, mdep_data,
							free_mdep_data)) {
		g_set_error(err, MCAP_ERROR, MCAP_CONNECTION_ERROR,
						"Can't get remote SDP record");
		g_free(mdep_data);
		return FALSE;
	}

	return TRUE;
}
Пример #2
0
gboolean mcap_establish_mcl(struct mcap_device *device,
						mcap_continue_proc_f func,
						gpointer data,
						GDestroyNotify destroy,
						GError **err)
{ DBG("");
		DBG("");
	struct conn_mcl_data *conn_data;
	bdaddr_t dst, src;
	uuid_t uuid;

	device_get_address(device->dev, &dst,NULL);
	adapter_get_address(device_get_adapter(device->dev), &src);

	conn_data = g_new0(struct conn_mcl_data, 1);
	conn_data->refs = 1;
	conn_data->func = func;
	conn_data->data = data;
	conn_data->destroy = destroy;
	conn_data->dev = mcap_device_ref(device);
	sdp_uuid32_create(&uuid, 0x001e);

	//bt_string2uuid(&uuid, 0x001e);
	if (bt_search_service(&src, &dst, &uuid, search_cb, conn_data,
						destroy_con_mcl_data)) {
		g_set_error(err, MCAP_ERROR, MCAP_CONNECTION_ERROR,
						"Can't get remote SDP record");
		g_free(conn_data);
		return FALSE;
	}

	return TRUE;
}
Пример #3
0
int str2uuid( const char *uuid_str, uuid_t *uuid ) {
    uint32_t uuid_int[4];
    char *endptr;

    if( strlen( uuid_str ) == 36 ) {
        // Parse uuid128 standard format: 12345678-9012-3456-7890-123456789012
        char buf[9] = { 0 };

        if( uuid_str[8] != '-' && uuid_str[13] != '-' &&
            uuid_str[18] != '-'  && uuid_str[23] != '-' ) {
            return 0;
        }
        // first 8-bytes
        strncpy(buf, uuid_str, 8);
        uuid_int[0] = htonl( strtoul( buf, &endptr, 16 ) );
        if( endptr != buf + 8 ) return 0;

        // second 8-bytes
        strncpy(buf, uuid_str+9, 4);
        strncpy(buf+4, uuid_str+14, 4);
        uuid_int[1] = htonl( strtoul( buf, &endptr, 16 ) );
        if( endptr != buf + 8 ) return 0;

        // third 8-bytes
        strncpy(buf, uuid_str+19, 4);
        strncpy(buf+4, uuid_str+24, 4);
        uuid_int[2] = htonl( strtoul( buf, &endptr, 16 ) );
        if( endptr != buf + 8 ) return 0;

        // fourth 8-bytes
        strncpy(buf, uuid_str+28, 8);
        uuid_int[3] = htonl( strtoul( buf, &endptr, 16 ) );
        if( endptr != buf + 8 ) return 0;

        if( uuid != NULL ) sdp_uuid128_create( uuid, uuid_int );
    } else if ( strlen( uuid_str ) == 8 ) {
        // 32-bit reserved UUID
        uint32_t i = strtoul( uuid_str, &endptr, 16 );
        if( endptr != uuid_str + 8 ) return 0;
        if( uuid != NULL ) sdp_uuid32_create( uuid, i );
    } else if( strlen( uuid_str ) == 4 ) {
        // 16-bit reserved UUID
        int i = strtol( uuid_str, &endptr, 16 );
        if( endptr != uuid_str + 4 ) return 0;
        if( uuid != NULL ) sdp_uuid16_create( uuid, i );
    } else {
        return 0;
    }

    return 1;
}