Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 4 Nov 2008 11:45:05 +0000 (GMT)
From:      Iain Hibbert <plunky@rya-online.net>
To:        Guido Falsi <mad@madpilot.net>
Cc:        freebsd-bluetooth@freebsd.org
Subject:   Re: RFComm behaviour with nokia mobiles
Message-ID:  <1225799105.807983.1164.nullmailer@galant.ukfsn.org>
In-Reply-To: <20081104111947.GB62907@megatron.madpilot.net>
References:  <20081104111947.GB62907@megatron.madpilot.net>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, 4 Nov 2008, Guido Falsi wrote:

> I completed the gnokii adaption to talk to freebsd sdp and it tries
> to connwect to rf channel 15 on both phnes, the same rfcomm_sppd
> tries. It loooks like the correct one in fact, but even after
> associating the phone with hcsecd I can't really connect.

can you show what the output of sdpcontrol is when examining this service?

(try search for protocol 0x0003 should give all RFCOMM channels)

IIRC if you are connecting to a serial port service then it is not always
the case that there will be an AT command interpreter at the other end..

also, the patch below adds support to print out the primary language
ServiceName to the port of sdpcontrol I made for NetBSD. It might not
apply cleanly to original sdpcontrol but should not be too difficult to
adapt and it seems quite useful..

I haven't committed it here because its not really complete as the string
that is produced is not guaranteed to be ASCII (the spec recommends using
UTF-8) but I would have to examine the languagebase settings and do some
iconv magic to get it 100% correct.

iain

--- /usr/src/usr.bin/sdpquery/search.c	2007-11-09 20:10:29.000000000 +0000
+++ search.c	2008-11-01 17:26:52.000000000 +0000
@@ -83,7 +83,9 @@ static uint32_t	attrs[] =
 	SDP_ATTR_RANGE(	SDP_ATTR_PROTOCOL_DESCRIPTOR_LIST,
 			SDP_ATTR_PROTOCOL_DESCRIPTOR_LIST),
 	SDP_ATTR_RANGE(	SDP_ATTR_BLUETOOTH_PROFILE_DESCRIPTOR_LIST,
-			SDP_ATTR_BLUETOOTH_PROFILE_DESCRIPTOR_LIST)
+			SDP_ATTR_BLUETOOTH_PROFILE_DESCRIPTOR_LIST),
+	SDP_ATTR_RANGE(	SDP_ATTR_PRIMARY_LANGUAGE_BASE_ID + SDP_ATTR_SERVICE_NAME_OFFSET,
+			SDP_ATTR_PRIMARY_LANGUAGE_BASE_ID + SDP_ATTR_SERVICE_NAME_OFFSET),
 };
 #define attrs_len	(sizeof(attrs)/sizeof(attrs[0]))

@@ -524,6 +526,47 @@ print_bluetooth_profile_descriptor_list(
 	}
 } /* print_bluetooth_profile_descriptor_list */

+static void
+print_service_name(uint8_t const *start, uint8_t const *end)
+{
+	uint32_t	type, len;
+
+	if (end - start < 2) {
+		fprintf(stderr, "Invalid Service Name. " \
+				"Too short, len=%zd\n", end - start);
+		return;
+	}
+
+	SDP_GET8(type, start);
+	switch (type) {
+	case SDP_DATA_STR8:
+		SDP_GET8(len, start);
+		break;
+
+	case SDP_DATA_STR16:
+		SDP_GET16(len, start);
+		break;
+
+	case SDP_DATA_STR32:
+		SDP_GET32(len, start);
+		break;
+
+	default:
+		fprintf(stderr, "Invalid Service Name. " \
+				"Not a string, type=%#x\n", type);
+		return;
+		/* NOT REACHED */
+	}
+
+	if (start + len > end) {
+		fprintf(stderr, "Invalid Service Name. " \
+				"Too short, len=%d (%zd)\n", len, end - start);
+		return;
+	}
+
+	fprintf(stdout, "\t\"%*.*s\"\n", len, len, start);
+} /* print_service_name */
+
 struct service {
 	const char	*name;
 	uint16_t	class;
@@ -651,6 +694,12 @@ do_sdp_search(bdaddr_t *laddr, bdaddr_t
 					values[n].value + values[n].vlen);
 			break;

+		case SDP_ATTR_PRIMARY_LANGUAGE_BASE_ID + SDP_ATTR_SERVICE_NAME_OFFSET:
+			fprintf(stdout, "Service Name:\n");
+			print_service_name(values[n].value,
+					values[n].value + values[n].vlen);
+			break;
+
 		default:
 			fprintf(stderr, "Unexpected attribute ID=%#4.4x\n",
 					values[n].attr);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1225799105.807983.1164.nullmailer>