* [PATCH] Changed MDP profile name and macros to HDP
From: Elvis Pfützenreuter @ 2010-05-06 20:38 UTC (permalink / raw)
To: linux-bluetooth; +Cc: epx
---
lib/sdp.c | 6 +++---
lib/sdp.h | 12 ++++++------
tools/sdptool.c | 6 +++---
3 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/lib/sdp.c b/lib/sdp.c
index aa22c63..ca3b4c4 100644
--- a/lib/sdp.c
+++ b/lib/sdp.c
@@ -201,9 +201,9 @@ static struct tupla ServiceClass[] = {
{ VIDEO_SOURCE_SVCLASS_ID, "Video Source" },
{ VIDEO_SINK_SVCLASS_ID, "Video Sink" },
{ VIDEO_DISTRIBUTION_SVCLASS_ID, "Video Distribution" },
- { MDP_SVCLASS_ID, "MDP" },
- { MDP_SOURCE_SVCLASS_ID, "MDP Source" },
- { MDP_SINK_SVCLASS_ID, "MDP Sink" },
+ { HDP_SVCLASS_ID, "HDP" },
+ { HDP_SOURCE_SVCLASS_ID, "HDP Source" },
+ { HDP_SINK_SVCLASS_ID, "HDP Sink" },
{ APPLE_AGENT_SVCLASS_ID, "Apple Agent" },
{ 0 }
};
diff --git a/lib/sdp.h b/lib/sdp.h
index 5b2901f..9c15ace 100644
--- a/lib/sdp.h
+++ b/lib/sdp.h
@@ -140,9 +140,9 @@ extern "C" {
#define VIDEO_SOURCE_SVCLASS_ID 0x1303
#define VIDEO_SINK_SVCLASS_ID 0x1304
#define VIDEO_DISTRIBUTION_SVCLASS_ID 0x1305
-#define MDP_SVCLASS_ID 0x1400
-#define MDP_SOURCE_SVCLASS_ID 0x1401
-#define MDP_SINK_SVCLASS_ID 0x1402
+#define HDP_SVCLASS_ID 0x1400
+#define HDP_SOURCE_SVCLASS_ID 0x1401
+#define HDP_SINK_SVCLASS_ID 0x1402
#define APPLE_AGENT_SVCLASS_ID 0x2112
/*
@@ -212,9 +212,9 @@ extern "C" {
#define VIDEO_SOURCE_PROFILE_ID VIDEO_SOURCE_SVCLASS_ID
#define VIDEO_SINK_PROFILE_ID VIDEO_SINK_SVCLASS_ID
#define VIDEO_DISTRIBUTION_PROFILE_ID VIDEO_DISTRIBUTION_SVCLASS_ID
-#define MDP_PROFILE_ID MDP_SVCLASS_ID
-#define MDP_SOURCE_PROFILE_ID MDP_SROUCE_SVCLASS_ID
-#define MDP_SINK_PROFILE_ID MDP_SINK_SVCLASS_ID
+#define HDP_PROFILE_ID HDP_SVCLASS_ID
+#define HDP_SOURCE_PROFILE_ID HDP_SROUCE_SVCLASS_ID
+#define HDP_SINK_PROFILE_ID HDP_SINK_SVCLASS_ID
#define APPLE_AGENT_PROFILE_ID APPLE_AGENT_SVCLASS_ID
/*
diff --git a/tools/sdptool.c b/tools/sdptool.c
index 89166ae..1de53e8 100644
--- a/tools/sdptool.c
+++ b/tools/sdptool.c
@@ -322,9 +322,9 @@ static struct uuid_def uuid16_names[] = {
{ 0x1303, "VideoSource", NULL, 0 },
{ 0x1304, "VideoSink", NULL, 0 },
{ 0x1305, "VideoDistribution", NULL, 0 },
- { 0x1400, "MDP", NULL, 0 },
- { 0x1401, "MDPSource", NULL, 0 },
- { 0x1402, "MDPSink", NULL, 0 },
+ { 0x1400, "HDP", NULL, 0 },
+ { 0x1401, "HDPSource", NULL, 0 },
+ { 0x1402, "HDPSink", NULL, 0 },
{ 0x2112, "AppleAgent", NULL, 0 },
};
--
1.7.0.4
^ permalink raw reply related
* Re: [PATCH] Changed MDP profile name and macros to HDP
From: Johan Hedberg @ 2010-05-06 20:51 UTC (permalink / raw)
To: Elvis Pfützenreuter; +Cc: linux-bluetooth, marcel
In-Reply-To: <1273178318-10490-1-git-send-email-epx@signove.com>
Hi Elvis,
On Thu, May 06, 2010, Elvis Pfützenreuter wrote:
> --- a/lib/sdp.h
> +++ b/lib/sdp.h
> @@ -140,9 +140,9 @@ extern "C" {
> #define VIDEO_SOURCE_SVCLASS_ID 0x1303
> #define VIDEO_SINK_SVCLASS_ID 0x1304
> #define VIDEO_DISTRIBUTION_SVCLASS_ID 0x1305
> -#define MDP_SVCLASS_ID 0x1400
> -#define MDP_SOURCE_SVCLASS_ID 0x1401
> -#define MDP_SINK_SVCLASS_ID 0x1402
> +#define HDP_SVCLASS_ID 0x1400
> +#define HDP_SOURCE_SVCLASS_ID 0x1401
> +#define HDP_SINK_SVCLASS_ID 0x1402
> #define APPLE_AGENT_SVCLASS_ID 0x2112
>
> /*
> @@ -212,9 +212,9 @@ extern "C" {
> #define VIDEO_SOURCE_PROFILE_ID VIDEO_SOURCE_SVCLASS_ID
> #define VIDEO_SINK_PROFILE_ID VIDEO_SINK_SVCLASS_ID
> #define VIDEO_DISTRIBUTION_PROFILE_ID VIDEO_DISTRIBUTION_SVCLASS_ID
> -#define MDP_PROFILE_ID MDP_SVCLASS_ID
> -#define MDP_SOURCE_PROFILE_ID MDP_SROUCE_SVCLASS_ID
> -#define MDP_SINK_PROFILE_ID MDP_SINK_SVCLASS_ID
> +#define HDP_PROFILE_ID HDP_SVCLASS_ID
> +#define HDP_SOURCE_PROFILE_ID HDP_SROUCE_SVCLASS_ID
> +#define HDP_SINK_PROFILE_ID HDP_SINK_SVCLASS_ID
> #define APPLE_AGENT_PROFILE_ID APPLE_AGENT_SVCLASS_ID
Thanks for the patch!
Since this essentially breaks the library API we should probably
consider leaving the MDP defines there as "synonyms" and then just add
the HDP defines with the same values. However I'll leave it for Marcel
to decide how important this non-breakage is.
Btw, the commit message summary line should be in the form "Change ..."
or "Fix ..." (not "Changed ...") to be consistent with the rest of the
commit history.
Johan
^ permalink raw reply
* Re: [PATCH] Changed MDP profile name and macros to HDP
From: Nathan Holstein @ 2010-05-06 20:51 UTC (permalink / raw)
To: linux-bluetooth; +Cc: epx
In-Reply-To: <1273178318-10490-1-git-send-email-epx@signove.com>
On Thu, 2010-05-06 at 17:38 -0300, Elvis Pfützenreuter wrote:
> ---
> lib/sdp.c | 6 +++---
> lib/sdp.h | 12 ++++++------
> tools/sdptool.c | 6 +++---
> 3 files changed, 12 insertions(+), 12 deletions(-)
>
> diff --git a/lib/sdp.c b/lib/sdp.c
> index aa22c63..ca3b4c4 100644
> --- a/lib/sdp.c
> +++ b/lib/sdp.c
> @@ -201,9 +201,9 @@ static struct tupla ServiceClass[] = {
> { VIDEO_SOURCE_SVCLASS_ID, "Video Source" },
> { VIDEO_SINK_SVCLASS_ID, "Video Sink" },
> { VIDEO_DISTRIBUTION_SVCLASS_ID, "Video Distribution" },
> - { MDP_SVCLASS_ID, "MDP" },
> - { MDP_SOURCE_SVCLASS_ID, "MDP Source" },
> - { MDP_SINK_SVCLASS_ID, "MDP Sink" },
> + { HDP_SVCLASS_ID, "HDP" },
> + { HDP_SOURCE_SVCLASS_ID, "HDP Source" },
> + { HDP_SINK_SVCLASS_ID, "HDP Sink" },
> { APPLE_AGENT_SVCLASS_ID, "Apple Agent" },
> { 0 }
> };
> diff --git a/lib/sdp.h b/lib/sdp.h
> index 5b2901f..9c15ace 100644
> --- a/lib/sdp.h
> +++ b/lib/sdp.h
> @@ -140,9 +140,9 @@ extern "C" {
> #define VIDEO_SOURCE_SVCLASS_ID 0x1303
> #define VIDEO_SINK_SVCLASS_ID 0x1304
> #define VIDEO_DISTRIBUTION_SVCLASS_ID 0x1305
> -#define MDP_SVCLASS_ID 0x1400
> -#define MDP_SOURCE_SVCLASS_ID 0x1401
> -#define MDP_SINK_SVCLASS_ID 0x1402
> +#define HDP_SVCLASS_ID 0x1400
> +#define HDP_SOURCE_SVCLASS_ID 0x1401
> +#define HDP_SINK_SVCLASS_ID 0x1402
> #define APPLE_AGENT_SVCLASS_ID 0x2112
>
> /*
> @@ -212,9 +212,9 @@ extern "C" {
> #define VIDEO_SOURCE_PROFILE_ID VIDEO_SOURCE_SVCLASS_ID
> #define VIDEO_SINK_PROFILE_ID VIDEO_SINK_SVCLASS_ID
> #define VIDEO_DISTRIBUTION_PROFILE_ID VIDEO_DISTRIBUTION_SVCLASS_ID
> -#define MDP_PROFILE_ID MDP_SVCLASS_ID
> -#define MDP_SOURCE_PROFILE_ID MDP_SROUCE_SVCLASS_ID
> -#define MDP_SINK_PROFILE_ID MDP_SINK_SVCLASS_ID
> +#define HDP_PROFILE_ID HDP_SVCLASS_ID
> +#define HDP_SOURCE_PROFILE_ID HDP_SROUCE_SVCLASS_ID
Careful...there's a typo here from old versions of Bluez. This should
be "HDP_SOURCE_SVCLASS_ID" not "HDP_SROUCE_SVCLASS_ID".
> +#define HDP_SINK_PROFILE_ID HDP_SINK_SVCLASS_ID
> #define APPLE_AGENT_PROFILE_ID APPLE_AGENT_SVCLASS_ID
>
> /*
> diff --git a/tools/sdptool.c b/tools/sdptool.c
> index 89166ae..1de53e8 100644
> --- a/tools/sdptool.c
> +++ b/tools/sdptool.c
> @@ -322,9 +322,9 @@ static struct uuid_def uuid16_names[] = {
> { 0x1303, "VideoSource", NULL, 0 },
> { 0x1304, "VideoSink", NULL, 0 },
> { 0x1305, "VideoDistribution", NULL, 0 },
> - { 0x1400, "MDP", NULL, 0 },
> - { 0x1401, "MDPSource", NULL, 0 },
> - { 0x1402, "MDPSink", NULL, 0 },
> + { 0x1400, "HDP", NULL, 0 },
> + { 0x1401, "HDPSource", NULL, 0 },
> + { 0x1402, "HDPSink", NULL, 0 },
> { 0x2112, "AppleAgent", NULL, 0 },
> };
--nathan
^ permalink raw reply
* [PATCH v2] Change MDP profile name and macros to HDP
From: Elvis Pfützenreuter @ 2010-05-06 21:20 UTC (permalink / raw)
To: linux-bluetooth; +Cc: epx
---
lib/sdp.c | 6 +++---
lib/sdp.h | 18 ++++++++++++------
tools/sdptool.c | 6 +++---
3 files changed, 18 insertions(+), 12 deletions(-)
diff --git a/lib/sdp.c b/lib/sdp.c
index aa22c63..ca3b4c4 100644
--- a/lib/sdp.c
+++ b/lib/sdp.c
@@ -201,9 +201,9 @@ static struct tupla ServiceClass[] = {
{ VIDEO_SOURCE_SVCLASS_ID, "Video Source" },
{ VIDEO_SINK_SVCLASS_ID, "Video Sink" },
{ VIDEO_DISTRIBUTION_SVCLASS_ID, "Video Distribution" },
- { MDP_SVCLASS_ID, "MDP" },
- { MDP_SOURCE_SVCLASS_ID, "MDP Source" },
- { MDP_SINK_SVCLASS_ID, "MDP Sink" },
+ { HDP_SVCLASS_ID, "HDP" },
+ { HDP_SOURCE_SVCLASS_ID, "HDP Source" },
+ { HDP_SINK_SVCLASS_ID, "HDP Sink" },
{ APPLE_AGENT_SVCLASS_ID, "Apple Agent" },
{ 0 }
};
diff --git a/lib/sdp.h b/lib/sdp.h
index 5b2901f..f31e654 100644
--- a/lib/sdp.h
+++ b/lib/sdp.h
@@ -140,9 +140,12 @@ extern "C" {
#define VIDEO_SOURCE_SVCLASS_ID 0x1303
#define VIDEO_SINK_SVCLASS_ID 0x1304
#define VIDEO_DISTRIBUTION_SVCLASS_ID 0x1305
-#define MDP_SVCLASS_ID 0x1400
-#define MDP_SOURCE_SVCLASS_ID 0x1401
-#define MDP_SINK_SVCLASS_ID 0x1402
+#define HDP_SVCLASS_ID 0x1400
+#define MDP_SVCLASS_ID HDP_SVCLASS_ID
+#define HDP_SOURCE_SVCLASS_ID 0x1401
+#define MDP_SOURCE_SVCLASS_ID HDP_SOURCE_SVCLASS_ID
+#define HDP_SINK_SVCLASS_ID 0x1402
+#define MDP_SINK_SVCLASS_ID HDP_SINK_SVCLASS_ID
#define APPLE_AGENT_SVCLASS_ID 0x2112
/*
@@ -212,9 +215,12 @@ extern "C" {
#define VIDEO_SOURCE_PROFILE_ID VIDEO_SOURCE_SVCLASS_ID
#define VIDEO_SINK_PROFILE_ID VIDEO_SINK_SVCLASS_ID
#define VIDEO_DISTRIBUTION_PROFILE_ID VIDEO_DISTRIBUTION_SVCLASS_ID
-#define MDP_PROFILE_ID MDP_SVCLASS_ID
-#define MDP_SOURCE_PROFILE_ID MDP_SROUCE_SVCLASS_ID
-#define MDP_SINK_PROFILE_ID MDP_SINK_SVCLASS_ID
+#define HDP_PROFILE_ID HDP_SVCLASS_ID
+#define MDP_PROFILE_ID HDP_PROFILE_ID
+#define HDP_SOURCE_PROFILE_ID HDP_SOURCE_SVCLASS_ID
+#define MDP_SOURCE_PROFILE_ID HDP_SOURCE_PROFILE_ID
+#define HDP_SINK_PROFILE_ID HDP_SINK_SVCLASS_ID
+#define MDP_SINK_PROFILE_ID HDP_SINK_PROFILE_ID
#define APPLE_AGENT_PROFILE_ID APPLE_AGENT_SVCLASS_ID
/*
diff --git a/tools/sdptool.c b/tools/sdptool.c
index 89166ae..1de53e8 100644
--- a/tools/sdptool.c
+++ b/tools/sdptool.c
@@ -322,9 +322,9 @@ static struct uuid_def uuid16_names[] = {
{ 0x1303, "VideoSource", NULL, 0 },
{ 0x1304, "VideoSink", NULL, 0 },
{ 0x1305, "VideoDistribution", NULL, 0 },
- { 0x1400, "MDP", NULL, 0 },
- { 0x1401, "MDPSource", NULL, 0 },
- { 0x1402, "MDPSink", NULL, 0 },
+ { 0x1400, "HDP", NULL, 0 },
+ { 0x1401, "HDPSource", NULL, 0 },
+ { 0x1402, "HDPSink", NULL, 0 },
{ 0x2112, "AppleAgent", NULL, 0 },
};
--
1.7.0.4
^ permalink raw reply related
* multiple HCI_UART protocols over hci_ldisc
From: Pavan Savoy @ 2010-05-06 22:04 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Marcel Holtmann, maxk
Hi Marcel,=0A=0AI am working on a line discipline which in many respects is=
similar to the hci_ldisc, but only extended to do plenty of other function=
ality.=0A=0AOne road block which i have hit is to support multiple devices/=
or as Alan Cox puts it "avoid single device limits"=0A=0ASo, in somewhat re=
lation to this, I wanted to ask, If in a system I have 2 UARTs both connect=
ed to BT chips but only from different vendors say TI/HCI-Ll and broadcomm =
with BCSP .. =0A=0ACan I have those 2 protocols on top of HCI-ldisc on diff=
erent UARTs at the same time?=0AIs something like that feasible?=0A=0A
^ permalink raw reply
* [PATCH 1/6] Removed extra spaces at end of line in compat dir
From: Jose Antonio Santos Cadenas @ 2010-05-06 22:27 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Jose Antonio Santos Cadenas
---
compat/bnep.c | 10 +++++-----
compat/dun.c | 4 ++--
compat/dund.c | 6 +++---
compat/hidd.c | 2 +-
compat/msdun.c | 8 ++++----
compat/pand.c | 8 ++++----
compat/sdp.c | 12 ++++++------
7 files changed, 25 insertions(+), 25 deletions(-)
diff --git a/compat/bnep.c b/compat/bnep.c
index 71eb0cc..2e4fb9d 100644
--- a/compat/bnep.c
+++ b/compat/bnep.c
@@ -93,7 +93,7 @@ int bnep_init(void)
}
/* Temporary ioctl compatibility hack */
- {
+ {
struct bnep_connlist_req req;
struct bnep_conninfo ci[1];
@@ -194,19 +194,19 @@ static int bnep_connadd(int sk, uint16_t role, char *dev)
return 0;
}
-struct __service_16 {
+struct __service_16 {
uint16_t dst;
uint16_t src;
} __attribute__ ((packed));
-struct __service_32 {
+struct __service_32 {
uint16_t unused1;
uint16_t dst;
uint16_t unused2;
uint16_t src;
} __attribute__ ((packed));
-struct __service_128 {
+struct __service_128 {
uint16_t unused1;
uint16_t dst;
uint16_t unused2[8];
@@ -246,7 +246,7 @@ int bnep_accept_connection(int sk, uint16_t role, char *dev)
return bnep_connadd(sk, role, dev);
}
-/* Create BNEP connection
+/* Create BNEP connection
* sk - Connect L2CAP socket
* role - Local role
* service - Remote service
diff --git a/compat/dun.c b/compat/dun.c
index 3f4b46f..59f036f 100644
--- a/compat/dun.c
+++ b/compat/dun.c
@@ -158,7 +158,7 @@ static int dun_exec(char *tty, char *prog, char **args)
{
int pid = fork();
int fd;
-
+
switch (pid) {
case -1:
return -1;
@@ -244,7 +244,7 @@ int dun_cleanup(void)
static int show_conn(struct rfcomm_dev_info *di, unsigned long arg)
{
pid_t pid;
-
+
if (di->state == BT_CONNECTED &&
(di->flags & (1<<RFCOMM_REUSE_DLC)) &&
(di->flags & (1<<RFCOMM_TTY_ATTACHED)) &&
diff --git a/compat/dund.c b/compat/dund.c
index deb2852..af1b536 100644
--- a/compat/dund.c
+++ b/compat/dund.c
@@ -247,7 +247,7 @@ static int create_connection(char *dst, bdaddr_t *bdaddr, int mrouter)
sa.rc_bdaddr = src_addr;
if (bind(sk, (struct sockaddr *) &sa, sizeof(sa)))
- syslog(LOG_ERR, "Bind failed. %s(%d)",
+ syslog(LOG_ERR, "Bind failed. %s(%d)",
strerror(errno), errno);
sa.rc_channel = ch;
@@ -337,7 +337,7 @@ static int do_connect(void)
for (i = 0; i < n; i++) {
char dst[40];
ba2str(&ii[i].bdaddr, dst);
-
+
r = create_connection(dst, &ii[i].bdaddr, 0);
if (r < 0) {
terminate = 1;
@@ -405,7 +405,7 @@ static struct option main_lopts[] = {
static const char *main_sopts = "hsc:k:Kr:i:lnp::DQ::AESMP:C::P:Xam:u";
-static const char *main_help =
+static const char *main_help =
"Bluetooth LAP (LAN Access over PPP) daemon version %s\n"
"Usage:\n"
"\tdund <options> [pppd options]\n"
diff --git a/compat/hidd.c b/compat/hidd.c
index 40bf663..88944cf 100644
--- a/compat/hidd.c
+++ b/compat/hidd.c
@@ -573,7 +573,7 @@ static void do_search(int ctl, bdaddr_t *bdaddr, uint8_t subclass, int fakehid,
for (i = 0; i < num_rsp; i++) {
memcpy(class, (info+i)->dev_class, 3);
- if ((class[0] == 0x00 && class[2] == 0x00 &&
+ if ((class[0] == 0x00 && class[2] == 0x00 &&
(class[1] == 0x40 || class[1] == 0x1f)) ||
(class[0] == 0x10 && class[1] == 0x02 && class[2] == 0x40)) {
bacpy(&dst, &(info+i)->bdaddr);
diff --git a/compat/msdun.c b/compat/msdun.c
index 2d592d7..ae88c0c 100644
--- a/compat/msdun.c
+++ b/compat/msdun.c
@@ -58,7 +58,7 @@ static int w4_str(int fd, char *str)
char buf[40];
unsigned len = 0;
int r;
-
+
while (1) {
r = read(fd, buf + len, sizeof(buf) - len - 1);
if (r < 0) {
@@ -92,7 +92,7 @@ static int ms_server(int fd)
write_n(fd, "CLIENTSERVER", 12);
case MS_PPP:
return MS_SUCCESS;
- default:
+ default:
return MS_FAILED;
}
}
@@ -123,7 +123,7 @@ int ms_dun(int fd, int server, int timeo)
alarm(0);
signal(SIGALRM, osig);
-
+
switch (r) {
case MS_SUCCESS:
case MS_PPP:
@@ -142,7 +142,7 @@ int ms_dun(int fd, int server, int timeo)
}
alarm(timeout);
-
+
if (server)
r = ms_server(fd);
else
diff --git a/compat/pand.c b/compat/pand.c
index e38cfb6..c3860fa 100644
--- a/compat/pand.c
+++ b/compat/pand.c
@@ -343,7 +343,7 @@ static int create_connection(char *dst, bdaddr_t *bdaddr)
bacpy(&l2a.l2_bdaddr, bdaddr);
l2a.l2_psm = htobs(BNEP_PSM);
- if (!connect(sk, (struct sockaddr *) &l2a, sizeof(l2a)) &&
+ if (!connect(sk, (struct sockaddr *) &l2a, sizeof(l2a)) &&
!bnep_create_connection(sk, role, service, netdev)) {
syslog(LOG_INFO, "%s connected", netdev);
@@ -430,7 +430,7 @@ static int do_connect(void)
ba2str(&ii[i].bdaddr, dst);
if (use_sdp) {
- syslog(LOG_INFO, "Searching for %s on %s",
+ syslog(LOG_INFO, "Searching for %s on %s",
bnep_svc2str(service), dst);
if (bnep_sdp_search(&src_addr, &ii[i].bdaddr, service) <= 0)
@@ -488,7 +488,7 @@ static int write_pidfile(void)
strerror(errno), errno);
return -1;
}
-
+
/* We're already running; send a SIGHUP (we presume that they
* are calling ifup for a reason, so they probably want to
* rescan) and then exit cleanly and let things go on in the
@@ -571,7 +571,7 @@ static struct option main_lopts[] = {
static const char *main_sopts = "hsc:k:Kr:d:e:i:lnp::DQ::AESMC::P:u:o:z";
-static const char *main_help =
+static const char *main_help =
"Bluetooth PAN daemon version %s\n"
"Usage:\n"
"\tpand <options>\n"
diff --git a/compat/sdp.c b/compat/sdp.c
index 358a02c..8898136 100644
--- a/compat/sdp.c
+++ b/compat/sdp.c
@@ -368,7 +368,7 @@ int get_alternate_device_info(const bdaddr_t *src, const bdaddr_t *dst, uint16_t
return -EIO;
}
-void bnep_sdp_unregister(void)
+void bnep_sdp_unregister(void)
{
if (record && sdp_record_unregister(session, record))
syslog(LOG_ERR, "Service record unregistration failed.");
@@ -424,7 +424,7 @@ int bnep_sdp_register(bdaddr_t *device, uint16_t role)
/* Supported protocols */
{
- uint16_t ptype[4] = {
+ uint16_t ptype[4] = {
0x0800, /* IPv4 */
0x0806, /* ARP */
};
@@ -483,7 +483,7 @@ int bnep_sdp_register(bdaddr_t *device, uint16_t role)
profile[0].version = 0x0100;
pfseq = sdp_list_append(NULL, &profile[0]);
sdp_set_profile_descs(record, pfseq);
-
+
sdp_set_info_attr(record, "Group Network Service", name, desc);
break;
@@ -558,7 +558,7 @@ int bnep_sdp_search(bdaddr_t *src, bdaddr_t *dst, uint16_t service)
static unsigned char async_uuid[] = { 0x03, 0x50, 0x27, 0x8F, 0x3D, 0xCA, 0x4E, 0x62,
0x83, 0x1D, 0xA4, 0x11, 0x65, 0xFF, 0x90, 0x6C };
-void dun_sdp_unregister(void)
+void dun_sdp_unregister(void)
{
if (record && sdp_record_unregister(session, record))
syslog(LOG_ERR, "Service record unregistration failed.");
@@ -575,7 +575,7 @@ int dun_sdp_register(bdaddr_t *device, uint8_t channel, int type)
session = sdp_connect(BDADDR_ANY, BDADDR_LOCAL, 0);
if (!session) {
- syslog(LOG_ERR, "Failed to connect to the local SDP server. %s(%d)",
+ syslog(LOG_ERR, "Failed to connect to the local SDP server. %s(%d)",
strerror(errno), errno);
return -1;
}
@@ -670,7 +670,7 @@ int dun_sdp_search(bdaddr_t *src, bdaddr_t *dst, int *channel, int type)
s = sdp_connect(src, dst, 0);
if (!s) {
- syslog(LOG_ERR, "Failed to connect to the SDP server. %s(%d)",
+ syslog(LOG_ERR, "Failed to connect to the SDP server. %s(%d)",
strerror(errno), errno);
return -1;
}
--
1.7.0.4
^ permalink raw reply related
* [PATCH 2/6] Remove extra spaces at end of line in lib dir
From: Jose Antonio Santos Cadenas @ 2010-05-06 22:27 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Jose Antonio Santos Cadenas
In-Reply-To: <1273184832-8265-1-git-send-email-santoscadenas@gmail.com>
---
lib/bluetooth.c | 2 +-
lib/hci.c | 10 ++--
lib/hci.h | 6 +-
lib/sdp.h | 2 +-
lib/sdp_lib.h | 130 +++++++++++++++++++++++++++---------------------------
5 files changed, 75 insertions(+), 75 deletions(-)
diff --git a/lib/bluetooth.c b/lib/bluetooth.c
index e8f8341..9e4b242 100644
--- a/lib/bluetooth.c
+++ b/lib/bluetooth.c
@@ -55,7 +55,7 @@ char *batostr(const bdaddr_t *ba)
return NULL;
sprintf(str, "%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X",
- ba->b[0], ba->b[1], ba->b[2],
+ ba->b[0], ba->b[1], ba->b[2],
ba->b[3], ba->b[4], ba->b[5]);
return str;
diff --git a/lib/hci.c b/lib/hci.c
index 858b9f1..114d066 100644
--- a/lib/hci.c
+++ b/lib/hci.c
@@ -54,7 +54,7 @@ typedef struct {
unsigned int val;
} hci_map;
-static char *hci_bit2str(hci_map *m, unsigned int val)
+static char *hci_bit2str(hci_map *m, unsigned int val)
{
char *str = malloc(120);
char *ptr = str;
@@ -95,7 +95,7 @@ static int hci_str2bit(hci_map *map, char *str, unsigned int *val)
return set;
}
-static char *hci_uint2str(hci_map *m, unsigned int val)
+static char *hci_uint2str(hci_map *m, unsigned int val)
{
char *str = malloc(50);
char *ptr = str;
@@ -209,7 +209,7 @@ char *hci_dflagstostr(uint32_t flags)
if (hci_test_bit(m->val, &flags))
ptr += sprintf(ptr, "%s ", m->str);
m++;
- }
+ }
return str;
}
@@ -959,7 +959,7 @@ int hci_inquiry(int dev_id, int len, int nrsp, const uint8_t *lap, inquiry_info
errno = ENODEV;
return -1;
}
- }
+ }
dd = socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_HCI);
if (dd < 0)
@@ -1009,7 +1009,7 @@ done:
return ret;
}
-/* Open HCI device.
+/* Open HCI device.
* Returns device descriptor (dd). */
int hci_open_dev(int dev_id)
{
diff --git a/lib/hci.h b/lib/hci.h
index 883f5dc..996dab3 100644
--- a/lib/hci.h
+++ b/lib/hci.h
@@ -733,14 +733,14 @@ typedef struct {
typedef struct {
uint8_t name[248];
} __attribute__ ((packed)) change_local_name_cp;
-#define CHANGE_LOCAL_NAME_CP_SIZE 248
+#define CHANGE_LOCAL_NAME_CP_SIZE 248
#define OCF_READ_LOCAL_NAME 0x0014
typedef struct {
uint8_t status;
uint8_t name[248];
} __attribute__ ((packed)) read_local_name_rp;
-#define READ_LOCAL_NAME_RP_SIZE 249
+#define READ_LOCAL_NAME_RP_SIZE 249
#define OCF_READ_CONN_ACCEPT_TIMEOUT 0x0015
typedef struct {
@@ -828,7 +828,7 @@ typedef struct {
uint8_t status;
uint8_t dev_class[3];
} __attribute__ ((packed)) read_class_of_dev_rp;
-#define READ_CLASS_OF_DEV_RP_SIZE 4
+#define READ_CLASS_OF_DEV_RP_SIZE 4
#define OCF_WRITE_CLASS_OF_DEV 0x0024
typedef struct {
diff --git a/lib/sdp.h b/lib/sdp.h
index 5b2901f..a33e0a8 100644
--- a/lib/sdp.h
+++ b/lib/sdp.h
@@ -297,7 +297,7 @@ extern "C" {
#define SDP_ATTR_HID_BOOT_DEVICE 0x020e
/*
- * These identifiers are based on the SDP spec stating that
+ * These identifiers are based on the SDP spec stating that
* "base attribute id of the primary (universal) language must be 0x0100"
*
* Other languages should have their own offset; e.g.:
diff --git a/lib/sdp_lib.h b/lib/sdp_lib.h
index cef3131..e506ac1 100644
--- a/lib/sdp_lib.h
+++ b/lib/sdp_lib.h
@@ -47,7 +47,7 @@ sdp_list_t *sdp_list_remove(sdp_list_t *list, void *d);
sdp_list_t *sdp_list_insert_sorted(sdp_list_t *list, void *data, sdp_comp_func_t f);
void sdp_list_free(sdp_list_t *list, sdp_free_func_t f);
-static inline int sdp_list_len(const sdp_list_t *list)
+static inline int sdp_list_len(const sdp_list_t *list)
{
int n = 0;
for (; list; list = list->next)
@@ -118,9 +118,9 @@ typedef void sdp_callback_t(uint8_t type, uint16_t status, uint8_t *rsp, size_t
/*
* create an L2CAP connection to a Bluetooth device
- *
+ *
* INPUT:
- *
+ *
* bdaddr_t *src:
* Address of the local device to use to make the connection
* (or BDADDR_ANY)
@@ -174,29 +174,29 @@ int sdp_set_uuidseq_attr(sdp_record_t *rec, uint16_t attr, sdp_list_t *seq);
int sdp_get_uuidseq_attr(const sdp_record_t *rec, uint16_t attr, sdp_list_t **seqp);
/*
- * NOTE that none of the functions below will update the SDP server,
+ * NOTE that none of the functions below will update the SDP server,
* unless the {register, update}sdp_record_t() function is invoked.
- * All functions which return an integer value, return 0 on success
+ * All functions which return an integer value, return 0 on success
* or -1 on failure.
*/
/*
* Create an attribute and add it to the service record's attribute list.
- * This consists of the data type descriptor of the attribute,
+ * This consists of the data type descriptor of the attribute,
* the value of the attribute and the attribute identifier.
*/
int sdp_attr_add_new(sdp_record_t *rec, uint16_t attr, uint8_t dtd, const void *p);
/*
* Set the information attributes of the service record.
- * The set of attributes comprises service name, description
+ * The set of attributes comprises service name, description
* and provider name
*/
void sdp_set_info_attr(sdp_record_t *rec, const char *name, const char *prov, const char *desc);
/*
* Set the ServiceClassID attribute to the sequence specified by seq.
- * Note that the identifiers need to be in sorted order from the most
+ * Note that the identifiers need to be in sorted order from the most
* specific to the most generic service class that this service
* conforms to.
*/
@@ -207,8 +207,8 @@ static inline int sdp_set_service_classes(sdp_record_t *rec, sdp_list_t *seq)
/*
* Get the service classes to which the service conforms.
- *
- * When set, the list contains elements of ServiceClassIdentifer(uint16_t)
+ *
+ * When set, the list contains elements of ServiceClassIdentifer(uint16_t)
* ordered from most specific to most generic
*/
static inline int sdp_get_service_classes(const sdp_record_t *rec, sdp_list_t **seqp)
@@ -218,8 +218,8 @@ static inline int sdp_get_service_classes(const sdp_record_t *rec, sdp_list_t **
/*
* Set the BrowseGroupList attribute to the list specified by seq.
- *
- * A service can belong to one or more service groups
+ *
+ * A service can belong to one or more service groups
* and the list comprises such group identifiers (UUIDs)
*/
static inline int sdp_set_browse_groups(sdp_record_t *rec, sdp_list_t *seq)
@@ -238,24 +238,24 @@ int sdp_set_access_protos(sdp_record_t *rec, const sdp_list_t *proto);
int sdp_set_add_access_protos(sdp_record_t *rec, const sdp_list_t *proto);
/*
- * Get protocol port (i.e. PSM for L2CAP, Channel for RFCOMM)
+ * Get protocol port (i.e. PSM for L2CAP, Channel for RFCOMM)
*/
int sdp_get_proto_port(const sdp_list_t *list, int proto);
/*
- * Get protocol descriptor.
+ * Get protocol descriptor.
*/
sdp_data_t *sdp_get_proto_desc(sdp_list_t *list, int proto);
/*
- * Set the LanguageBase attributes to the values specified in list
- * (a linked list of sdp_lang_attr_t objects, one for each language in
+ * Set the LanguageBase attributes to the values specified in list
+ * (a linked list of sdp_lang_attr_t objects, one for each language in
* which user-visible attributes are present).
*/
int sdp_set_lang_attr(sdp_record_t *rec, const sdp_list_t *list);
/*
- * Set the ServiceInfoTimeToLive attribute of the service.
+ * Set the ServiceInfoTimeToLive attribute of the service.
* This is the number of seconds that this record is guaranteed
* not to change after being obtained by a client.
*/
@@ -266,8 +266,8 @@ static inline int sdp_set_service_ttl(sdp_record_t *rec, uint32_t ttl)
/*
* Set the ServiceRecordState attribute of a service. This is
- * guaranteed to change if there is any kind of modification to
- * the record.
+ * guaranteed to change if there is any kind of modification to
+ * the record.
*/
static inline int sdp_set_record_state(sdp_record_t *rec, uint32_t state)
{
@@ -275,7 +275,7 @@ static inline int sdp_set_record_state(sdp_record_t *rec, uint32_t state)
}
/*
- * Set the ServiceID attribute of a service.
+ * Set the ServiceID attribute of a service.
*/
void sdp_set_service_id(sdp_record_t *rec, uuid_t uuid);
@@ -286,7 +286,7 @@ void sdp_set_group_id(sdp_record_t *rec, uuid_t grouuuid);
/*
* Set the ServiceAvailability attribute of a service.
- *
+ *
* Note that this represents the relative availability
* of the service: 0x00 means completely unavailable;
* 0xFF means maximum availability.
@@ -298,7 +298,7 @@ static inline int sdp_set_service_avail(sdp_record_t *rec, uint8_t avail)
/*
* Set the profile descriptor list attribute of a record.
- *
+ *
* Each element in the list is an object of type
* sdp_profile_desc_t which is a definition of the
* Bluetooth profile that this service conforms to.
@@ -307,41 +307,41 @@ int sdp_set_profile_descs(sdp_record_t *rec, const sdp_list_t *desc);
/*
* Set URL attributes of a record.
- *
- * ClientExecutableURL: a URL to a client's platform specific (WinCE,
+ *
+ * ClientExecutableURL: a URL to a client's platform specific (WinCE,
* PalmOS) executable code that can be used to access this service.
- *
+ *
* DocumentationURL: a URL pointing to service documentation
- *
+ *
* IconURL: a URL to an icon that can be used to represent this service.
- *
+ *
* Note: pass NULL for any URLs that you don't want to set or remove
*/
void sdp_set_url_attr(sdp_record_t *rec, const char *clientExecURL, const char *docURL, const char *iconURL);
/*
- * a service search request.
- *
+ * a service search request.
+ *
* INPUT :
- *
+ *
* sdp_list_t *search
* list containing elements of the search
* pattern. Each entry in the list is a UUID
* of the service to be searched
- *
+ *
* uint16_t max_rec_num
* An integer specifying the maximum number of
* entries that the client can handle in the response.
- *
+ *
* OUTPUT :
- *
+ *
* int return value
- * 0
+ * 0
* The request completed successfully. This does not
* mean the requested services were found
* -1
* The request completed unsuccessfully
- *
+ *
* sdp_list_t *rsp_list
* This variable is set on a successful return if there are
* non-zero service handles. It is a singly linked list of
@@ -350,33 +350,33 @@ void sdp_set_url_attr(sdp_record_t *rec, const char *clientExecURL, const char *
int sdp_service_search_req(sdp_session_t *session, const sdp_list_t *search, uint16_t max_rec_num, sdp_list_t **rsp_list);
/*
- * a service attribute request.
- *
+ * a service attribute request.
+ *
* INPUT :
- *
+ *
* uint32_t handle
* The handle of the service for which the attribute(s) are
* requested
- *
+ *
* sdp_attrreq_type_t reqtype
* Attribute identifiers are 16 bit unsigned integers specified
* in one of 2 ways described below :
* SDP_ATTR_REQ_INDIVIDUAL - 16bit individual identifiers
* They are the actual attribute identifiers in ascending order
- *
+ *
* SDP_ATTR_REQ_RANGE - 32bit identifier range
* The high-order 16bits is the start of range
* the low-order 16bits are the end of range
* 0x0000 to 0xFFFF gets all attributes
- *
+ *
* sdp_list_t *attrid_list
* Singly linked list containing attribute identifiers desired.
- * Every element is either a uint16_t(attrSpec = SDP_ATTR_REQ_INDIVIDUAL)
+ * Every element is either a uint16_t(attrSpec = SDP_ATTR_REQ_INDIVIDUAL)
* or a uint32_t(attrSpec=SDP_ATTR_REQ_RANGE)
- *
+ *
* OUTPUT :
* int return value
- * 0
+ * 0
* The request completed successfully. This does not
* mean the requested services were found
* -1
@@ -388,38 +388,38 @@ sdp_record_t *sdp_service_attr_req(sdp_session_t *session, uint32_t handle, sdp_
* This is a service search request combined with the service
* attribute request. First a service class match is done and
* for matching service, requested attributes are extracted
- *
+ *
* INPUT :
- *
+ *
* sdp_list_t *search
* Singly linked list containing elements of the search
* pattern. Each entry in the list is a UUID(DataTypeSDP_UUID16)
* of the service to be searched
- *
+ *
* AttributeSpecification attrSpec
* Attribute identifiers are 16 bit unsigned integers specified
* in one of 2 ways described below :
* SDP_ATTR_REQ_INDIVIDUAL - 16bit individual identifiers
* They are the actual attribute identifiers in ascending order
- *
+ *
* SDP_ATTR_REQ_RANGE - 32bit identifier range
* The high-order 16bits is the start of range
* the low-order 16bits are the end of range
* 0x0000 to 0xFFFF gets all attributes
- *
+ *
* sdp_list_t *attrid_list
* Singly linked list containing attribute identifiers desired.
- * Every element is either a uint16_t(attrSpec = SDP_ATTR_REQ_INDIVIDUAL)
+ * Every element is either a uint16_t(attrSpec = SDP_ATTR_REQ_INDIVIDUAL)
* or a uint32_t(attrSpec=SDP_ATTR_REQ_RANGE)
- *
+ *
* OUTPUT :
* int return value
- * 0
+ * 0
* The request completed successfully. This does not
* mean the requested services were found
* -1
* The request completed unsuccessfully due to a timeout
- *
+ *
* sdp_list_t *rsp_list
* This variable is set on a successful return to point to
* service(s) found. Each element of this list is of type
@@ -434,12 +434,12 @@ sdp_record_t *sdp_record_alloc(void);
void sdp_record_free(sdp_record_t *rec);
/*
- * Register a service record.
- *
- * Note: It is the responsbility of the Service Provider to create the
+ * Register a service record.
+ *
+ * Note: It is the responsbility of the Service Provider to create the
* record first and set its attributes using setXXX() methods.
- *
- * The service provider must then call sdp_record_register() to make
+ *
+ * The service provider must then call sdp_record_register() to make
* the service record visible to SDP clients. This function returns 0
* on success or -1 on failure (and sets errno).
*/
@@ -493,14 +493,14 @@ int sdp_svclass_uuid2strn(const uuid_t *uuid, char *str, size_t n);
int sdp_profile_uuid2strn(const uuid_t *uuid, char *str, size_t n);
/*
- * In all the sdp_get_XXX(handle, XXX *xxx) functions below,
+ * In all the sdp_get_XXX(handle, XXX *xxx) functions below,
* the XXX * is set to point to the value, should it exist
* and 0 is returned. If the value does not exist, -1 is
* returned and errno set to ENODATA.
*
* In all the methods below, the memory management rules are
* simple. Don't free anything! The pointer returned, in the
- * case of constructed types, is a pointer to the contents
+ * case of constructed types, is a pointer to the contents
* of the sdp_record_t.
*/
@@ -516,7 +516,7 @@ int sdp_get_add_access_protos(const sdp_record_t *rec, sdp_list_t **protos);
/*
* Extract the list of browse groups to which the service belongs.
- * When set, seqp contains elements of GroupID (uint16_t)
+ * When set, seqp contains elements of GroupID (uint16_t)
*/
static inline int sdp_get_browse_groups(const sdp_record_t *rec, sdp_list_t **seqp)
{
@@ -524,9 +524,9 @@ static inline int sdp_get_browse_groups(const sdp_record_t *rec, sdp_list_t **se
}
/*
- * Extract language attribute meta-data of the service record.
+ * Extract language attribute meta-data of the service record.
* For each language in the service record, LangSeq has a struct of type
- * sdp_lang_attr_t.
+ * sdp_lang_attr_t.
*/
int sdp_get_lang_attr(const sdp_record_t *rec, sdp_list_t **langSeq);
@@ -540,8 +540,8 @@ int sdp_get_lang_attr(const sdp_record_t *rec, sdp_list_t **langSeq);
int sdp_get_profile_descs(const sdp_record_t *rec, sdp_list_t **profDesc);
/*
- * Extract SDP server version numbers
- *
+ * Extract SDP server version numbers
+ *
* Note: that this is an attribute of the SDP server only and
* contains a list of uint16_t each of which represent the
* major and minor SDP version numbers supported by this server
--
1.7.0.4
^ permalink raw reply related
* [PATCH 3/6] Remove extra spaces from sdpd-request.c
From: Jose Antonio Santos Cadenas @ 2010-05-06 22:27 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Jose Antonio Santos Cadenas
In-Reply-To: <1273184832-8265-1-git-send-email-santoscadenas@gmail.com>
---
src/sdpd-request.c | 18 +++++++++---------
1 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/src/sdpd-request.c b/src/sdpd-request.c
index 88d0afa..a8af8e4 100644
--- a/src/sdpd-request.c
+++ b/src/sdpd-request.c
@@ -98,7 +98,7 @@ struct attrid {
/*
* Generic data element sequence extractor. Builds
- * a list whose elements are those found in the
+ * a list whose elements are those found in the
* sequence. The data type of elements found in the
* sequence is returned in the reference pDataType
*/
@@ -301,8 +301,8 @@ static int sdp_cstate_get(uint8_t *buffer, size_t len,
* specified in the "search pattern" must be present in the
* "target pattern". Here "search pattern" is the set of UUIDs
* specified by the service discovery client and "target pattern"
- * is the set of UUIDs present in a service record.
- *
+ * is the set of UUIDs present in a service record.
+ *
* Return 1 if each and every UUID in the search
* pattern exists in the target pattern, 0 if the
* match succeeds and -1 on error.
@@ -420,7 +420,7 @@ static int service_search_req(sdp_req_t *req, sdp_buf_t *buf)
sdp_record_t *rec = (sdp_record_t *) list->data;
SDPDBG("Checking svcRec : 0x%x", rec->handle);
-
+
if (sdp_match_uuid(pattern, rec->pattern) > 0 &&
sdp_check_access(rec->handle, &req->device)) {
rsp_count++;
@@ -429,7 +429,7 @@ static int service_search_req(sdp_req_t *req, sdp_buf_t *buf)
handleSize += sizeof(uint32_t);
}
}
-
+
SDPDBG("Match count: %d", rsp_count);
buf->data_size += handleSize;
@@ -525,7 +525,7 @@ static int service_search_req(sdp_req_t *req, sdp_buf_t *buf)
}
}
-done:
+done:
if (cstate)
free(cstate);
if (pattern)
@@ -684,11 +684,11 @@ static int service_attr_req(sdp_req_t *req, sdp_buf_t *buf)
SDPDBG("SvcRecHandle : 0x%x", handle);
SDPDBG("max_rsp_size : %d", max_rsp_size);
- /*
+ /*
* Calculate Attribute size acording to MTU
* We can send only (MTU - sizeof(sdp_pdu_hdr_t) - sizeof(sdp_cont_state_t))
*/
- max_rsp_size = MIN(max_rsp_size, req->mtu - sizeof(sdp_pdu_hdr_t) -
+ max_rsp_size = MIN(max_rsp_size, req->mtu - sizeof(sdp_pdu_hdr_t) -
sizeof(uint32_t) - SDP_CONT_STATE_SIZE - sizeof(uint16_t));
/* pull header for AttributeList byte count */
@@ -840,7 +840,7 @@ static int service_search_attr_req(sdp_req_t *req, sdp_buf_t *buf)
tmpbuf.buf_size = USHRT_MAX;
memset(tmpbuf.data, 0, USHRT_MAX);
- /*
+ /*
* Calculate Attribute size acording to MTU
* We can send only (MTU - sizeof(sdp_pdu_hdr_t) - sizeof(sdp_cont_state_t))
*/
--
1.7.0.4
^ permalink raw reply related
* [PATCH 4/6] Remove extra spaces in test dir
From: Jose Antonio Santos Cadenas @ 2010-05-06 22:27 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Jose Antonio Santos Cadenas
In-Reply-To: <1273184832-8265-1-git-send-email-santoscadenas@gmail.com>
---
test/hciemu.c | 6 +++---
test/hstest.c | 2 +-
test/rctest.c | 10 +++++-----
test/scotest.c | 2 +-
test/test-textfile.c | 4 ++--
5 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/test/hciemu.c b/test/hciemu.c
index 457add4..a20374f 100644
--- a/test/hciemu.c
+++ b/test/hciemu.c
@@ -295,7 +295,7 @@ static void command_complete(uint16_t ogf, uint16_t ocf, int plen, void *data)
he = (void *) ptr; ptr += HCI_EVENT_HDR_SIZE;
he->evt = EVT_CMD_COMPLETE;
- he->plen = EVT_CMD_COMPLETE_SIZE + plen;
+ he->plen = EVT_CMD_COMPLETE_SIZE + plen;
cc = (void *) ptr; ptr += EVT_CMD_COMPLETE_SIZE;
@@ -327,7 +327,7 @@ static void connect_request(struct vhci_conn *conn)
he = (void *) ptr; ptr += HCI_EVENT_HDR_SIZE;
he->evt = EVT_CONN_REQUEST;
- he->plen = EVT_CONN_REQUEST_SIZE;
+ he->plen = EVT_CONN_REQUEST_SIZE;
cr = (void *) ptr; ptr += EVT_CONN_REQUEST_SIZE;
@@ -355,7 +355,7 @@ static void connect_complete(struct vhci_conn *conn)
he = (void *) ptr; ptr += HCI_EVENT_HDR_SIZE;
he->evt = EVT_CONN_COMPLETE;
- he->plen = EVT_CONN_COMPLETE_SIZE;
+ he->plen = EVT_CONN_COMPLETE_SIZE;
cc = (void *) ptr; ptr += EVT_CONN_COMPLETE_SIZE;
diff --git a/test/hstest.c b/test/hstest.c
index f24bc33..08f2257 100644
--- a/test/hstest.c
+++ b/test/hstest.c
@@ -277,7 +277,7 @@ int main(int argc, char *argv[])
case PLAY:
rlen = read(fd, buf, rlen);
- wlen = 0;
+ wlen = 0;
p = buf;
while (rlen > sco_mtu) {
wlen += write(sd, p, sco_mtu);
diff --git a/test/rctest.c b/test/rctest.c
index a938a54..b3804f5 100644
--- a/test/rctest.c
+++ b/test/rctest.c
@@ -436,7 +436,7 @@ static void recv_mode(int sk)
if (r < 0)
syslog(LOG_ERR, "Read failed: %s (%d)",
strerror(errno), errno);
- return;
+ return;
}
if (timestamp) {
@@ -459,15 +459,15 @@ static void recv_mode(int sk)
seq = sq;
}
seq++;
-
+
/* Check length */
l = btohs(*(uint16_t *) (buf + 4));
if (r != l) {
syslog(LOG_INFO, "size missmatch: %d -> %d", r, l);
continue;
}
-
- /* Verify data */
+
+ /* Verify data */
for (i = 6; i < r; i++) {
if (buf[i] != 0x7f)
syslog(LOG_INFO, "data missmatch: byte %d 0x%2.2x", i, buf[i]);
@@ -511,7 +511,7 @@ static void do_send(int sk)
*(uint32_t *) buf = htobl(seq);
*(uint16_t *) (buf + 4) = htobs(data_size);
seq++;
-
+
if (send(sk, buf, data_size, 0) <= 0) {
syslog(LOG_ERR, "Send failed: %s (%d)",
strerror(errno), errno);
diff --git a/test/scotest.c b/test/scotest.c
index a3d3ed2..50b622a 100644
--- a/test/scotest.c
+++ b/test/scotest.c
@@ -230,7 +230,7 @@ static void recv_mode(int sk)
if (r < 0)
syslog(LOG_ERR, "Read failed: %s (%d)",
strerror(errno), errno);
- return;
+ return;
}
total += r;
}
diff --git a/test/test-textfile.c b/test/test-textfile.c
index ab2f513..970e9e7 100644
--- a/test/test-textfile.c
+++ b/test/test-textfile.c
@@ -65,7 +65,7 @@ int main(int argc, char *argv[])
sprintf(key, "00:00:00:00:00:00");
- if (textfile_del(filename, key) < 0)
+ if (textfile_del(filename, key) < 0)
fprintf(stderr, "%s (%d)\n", strerror(errno), errno);
memset(value, 0, sizeof(value));
@@ -88,7 +88,7 @@ int main(int argc, char *argv[])
if (textfile_put(filename, key, value) < 0)
fprintf(stderr, "%s (%d)\n", strerror(errno), errno);
- if (textfile_del(filename, key) < 0)
+ if (textfile_del(filename, key) < 0)
fprintf(stderr, "%s (%d)\n", strerror(errno), errno);
str = textfile_get(filename, key);
--
1.7.0.4
^ permalink raw reply related
* [PATCH 5/6] Remove extra spaces from tools dir
From: Jose Antonio Santos Cadenas @ 2010-05-06 22:27 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Jose Antonio Santos Cadenas
In-Reply-To: <1273184832-8265-1-git-send-email-santoscadenas@gmail.com>
---
tools/bccmd.c | 2 +-
tools/dfutool.c | 4 +-
tools/hciattach.c | 48 +++++++++++++++++++++++-----------------------
tools/hciattach_st.c | 12 +++++-----
tools/hciattach_ti.c | 2 +-
tools/hciattach_tialt.c | 22 ++++++++++----------
tools/hciconfig.c | 6 ++--
tools/kword.h | 2 +-
tools/main.c | 6 ++--
tools/ppporc.c | 4 +-
tools/sdptool.c | 36 +++++++++++++++++-----------------
11 files changed, 72 insertions(+), 72 deletions(-)
diff --git a/tools/bccmd.c b/tools/bccmd.c
index 921bd20..686e858 100644
--- a/tools/bccmd.c
+++ b/tools/bccmd.c
@@ -984,7 +984,7 @@ static int cmd_psread(int transport, int argc, char *argv[])
str = NULL;
}
- printf("// %s%s\n&%04x =", str ? "PSKEY_" : "",
+ printf("// %s%s\n&%04x =", str ? "PSKEY_" : "",
str ? str : val, pskey);
for (i = 0; i < length; i++)
printf(" %02x%02x", array[(i * 2) + 7], array[(i * 2) + 6]);
diff --git a/tools/dfutool.c b/tools/dfutool.c
index 551af6b..16dd62e 100644
--- a/tools/dfutool.c
+++ b/tools/dfutool.c
@@ -341,7 +341,7 @@ static void cmd_verify(char *device, int argc, char **argv)
size = st.st_size;
if (!(buf = malloc(size))) {
- perror("Unable to allocate file buffer");
+ perror("Unable to allocate file buffer");
exit(1);
}
@@ -442,7 +442,7 @@ static void cmd_upgrade(char *device, int argc, char **argv)
filesize = st.st_size;
if (!(buf = malloc(filesize))) {
- perror("Unable to allocate file buffer");
+ perror("Unable to allocate file buffer");
exit(1);
}
diff --git a/tools/hciattach.c b/tools/hciattach.c
index 364c5ff..b13db1b 100644
--- a/tools/hciattach.c
+++ b/tools/hciattach.c
@@ -146,10 +146,10 @@ int set_speed(int fd, struct termios *ti, int speed)
return tcsetattr(fd, TCSANOW, ti);
}
-/*
+/*
* Read an HCI event from the given file descriptor.
*/
-int read_hci_event(int fd, unsigned char* buf, int size)
+int read_hci_event(int fd, unsigned char* buf, int size)
{
int remain, r;
int count = 0;
@@ -177,9 +177,9 @@ int read_hci_event(int fd, unsigned char* buf, int size)
}
/* Now we read the parameters. */
- if (buf[2] < (size - 3))
+ if (buf[2] < (size - 3))
remain = buf[2];
- else
+ else
remain = size - 3;
while ((count - 3) < remain) {
@@ -192,8 +192,8 @@ int read_hci_event(int fd, unsigned char* buf, int size)
return count;
}
-/*
- * Ericsson specific initialization
+/*
+ * Ericsson specific initialization
*/
static int ericsson(int fd, struct uart_t *u, struct termios *ti)
{
@@ -247,8 +247,8 @@ static int ericsson(int fd, struct uart_t *u, struct termios *ti)
return 0;
}
-/*
- * Digianswer specific initialization
+/*
+ * Digianswer specific initialization
*/
static int digi(int fd, struct uart_t *u, struct termios *ti)
{
@@ -306,7 +306,7 @@ static int read_check(int fd, void *buf, int count)
do {
res = read(fd, buf, count);
if (res != -1) {
- buf += res;
+ buf += res;
count -= res;
}
} while (count && (errno == 0 || errno == EINTR));
@@ -480,8 +480,8 @@ static int bcsp(int fd, struct uart_t *u, struct termios *ti)
return 0;
}
-/*
- * CSR specific initialization
+/*
+ * CSR specific initialization
* Inspired strongly by code in OpenBT and experimentations with Brainboxes
* Pcmcia card.
* Jean Tourrilhes <jt@hpl.hp.com> - 14.11.01
@@ -544,7 +544,7 @@ static int csr(int fd, struct uart_t *u, struct termios *ti)
return -1;
}
- /* Event code 0xFF is for vendor-specific events, which is
+ /* Event code 0xFF is for vendor-specific events, which is
* what we're looking for. */
} while (resp[1] != 0xFF);
@@ -560,7 +560,7 @@ static int csr(int fd, struct uart_t *u, struct termios *ti)
}
#endif
/* Display that to user */
- fprintf(stderr, "CSR build ID 0x%02X-0x%02X\n",
+ fprintf(stderr, "CSR build ID 0x%02X-0x%02X\n",
resp[15] & 0xFF, resp[14] & 0xFF);
/* Try to read the current speed of the CSR chip */
@@ -588,7 +588,7 @@ static int csr(int fd, struct uart_t *u, struct termios *ti)
return -1;
}
- /* Event code 0xFF is for vendor-specific events, which is
+ /* Event code 0xFF is for vendor-specific events, which is
* what we're looking for. */
} while (resp[1] != 0xFF);
@@ -602,7 +602,7 @@ static int csr(int fd, struct uart_t *u, struct termios *ti)
#endif
if (u->speed > 1500000) {
- fprintf(stderr, "Speed %d too high. Remaining at %d baud\n",
+ fprintf(stderr, "Speed %d too high. Remaining at %d baud\n",
u->speed, u->init_speed);
u->speed = u->init_speed;
} else if (u->speed != 57600 && uart_speed(u->speed) == B57600) {
@@ -652,8 +652,8 @@ static int csr(int fd, struct uart_t *u, struct termios *ti)
return 0;
}
-/*
- * Silicon Wave specific initialization
+/*
+ * Silicon Wave specific initialization
* Thomas Moser <thomas.moser@tmoser.ch>
*/
static int swave(int fd, struct uart_t *u, struct termios *ti)
@@ -669,7 +669,7 @@ static int swave(int fd, struct uart_t *u, struct termios *ti)
// Subcommand", e.g. "soft reset" to make the changes effective.
cmd[0] = HCI_COMMAND_PKT; // it's a command packet
- cmd[1] = 0x0B; // OCF 0x0B = param access set
+ cmd[1] = 0x0B; // OCF 0x0B = param access set
cmd[2] = 0xfc; // OGF bx111111 = vendor specific
cmd[3] = 0x06; // 6 bytes of data following
cmd[4] = 0x01; // param sub command
@@ -703,9 +703,9 @@ static int swave(int fd, struct uart_t *u, struct termios *ti)
return -1;
}
- // We should wait for a "GET Event" to confirm the success of
- // the baud rate setting. Wait some time before reading. Better:
- // read with timeout, parse data
+ // We should wait for a "GET Event" to confirm the success of
+ // the baud rate setting. Wait some time before reading. Better:
+ // read with timeout, parse data
// until correct answer, else error handling ... todo ...
nanosleep(&tm, NULL);
@@ -749,7 +749,7 @@ static int swave(int fd, struct uart_t *u, struct termios *ti)
// now the uart baud rate on the silicon wave module is set and effective.
// change our own baud rate as well. Then there is a reset event comming in
// on the *new* baud rate. This is *undocumented*! The packet looks like this:
- // 04 FF 01 0B (which would make that a confirmation of 0x0B = "Param
+ // 04 FF 01 0B (which would make that a confirmation of 0x0B = "Param
// subcommand class". So: change to new baud rate, read with timeout, parse
// data, error handling. BTW: all param access in Silicon Wave is done this way.
// Maybe this code would belong in a seperate file, or at least code reuse...
@@ -1259,7 +1259,7 @@ int main(int argc, char *argv[])
fprintf(stderr, "Unknown device type or id\n");
exit(1);
}
-
+
break;
case 2:
@@ -1300,7 +1300,7 @@ int main(int argc, char *argv[])
n = init_uart(dev, u, send_break);
if (n < 0) {
- perror("Can't initialize device");
+ perror("Can't initialize device");
exit(1);
}
diff --git a/tools/hciattach_st.c b/tools/hciattach_st.c
index f10bcf6..dbb7c47 100644
--- a/tools/hciattach_st.c
+++ b/tools/hciattach_st.c
@@ -140,7 +140,7 @@ static int load_file(int dd, uint16_t version, const char *suffix)
return -errno;
}
- found_fw_file = 0;
+ found_fw_file = 0;
while (1) {
d = readdir(dir);
if (!d)
@@ -203,14 +203,14 @@ int stlc2500_init(int dd, bdaddr_t *bdaddr)
int len;
int err;
- /* Hci_Cmd_Ericsson_Read_Revision_Information */
+ /* Hci_Cmd_Ericsson_Read_Revision_Information */
len = do_command(dd, 0xff, 0x000f, NULL, 0, buf, sizeof(buf));
if (len < 0)
return -1;
printf("%s\n", buf);
- /* HCI_Read_Local_Version_Information */
+ /* HCI_Read_Local_Version_Information */
len = do_command(dd, 0x04, 0x0001, NULL, 0, buf, sizeof(buf));
if (len < 0)
return -1;
@@ -219,7 +219,7 @@ int stlc2500_init(int dd, bdaddr_t *bdaddr)
err = load_file(dd, version, ".ptc");
if (err < 0) {
- if (err == -ENOENT)
+ if (err == -ENOENT)
fprintf(stderr, "No ROM patch file loaded.\n");
else
return -1;
@@ -227,7 +227,7 @@ int stlc2500_init(int dd, bdaddr_t *bdaddr)
err = load_file(dd, buf[2] << 8 | buf[1], ".ssf");
if (err < 0) {
- if (err == -ENOENT)
+ if (err == -ENOENT)
fprintf(stderr, "No static settings file loaded.\n");
else
return -1;
@@ -237,7 +237,7 @@ int stlc2500_init(int dd, bdaddr_t *bdaddr)
cmd[1] = 0x06;
bacpy((bdaddr_t *) (cmd + 2), bdaddr);
- /* Hci_Cmd_ST_Store_In_NVDS */
+ /* Hci_Cmd_ST_Store_In_NVDS */
len = do_command(dd, 0xff, 0x0022, cmd, 8, buf, sizeof(buf));
if (len < 0)
return -1;
diff --git a/tools/hciattach_ti.c b/tools/hciattach_ti.c
index bf91e40..7627bc1 100644
--- a/tools/hciattach_ti.c
+++ b/tools/hciattach_ti.c
@@ -446,7 +446,7 @@ int texas_init(int fd, struct termios *ti)
memset(resp,'\0', 100);
- /* It is possible to get software version with manufacturer specific
+ /* It is possible to get software version with manufacturer specific
HCI command HCI_VS_TI_Version_Number. But the only thing you get more
is if this is point-to-point or point-to-multipoint module */
diff --git a/tools/hciattach_tialt.c b/tools/hciattach_tialt.c
index 11a7ebd..1ba009c 100644
--- a/tools/hciattach_tialt.c
+++ b/tools/hciattach_tialt.c
@@ -68,10 +68,10 @@ static int read_command_complete(int fd, unsigned short opcode, unsigned char le
/* Read reply. */
FAILIF(read_hci_event(fd, (unsigned char *)&resp, sizeof(resp)) < 0,
"Failed to read response");
-
+
/* Parse speed-change reply */
FAILIF(resp.uart_prefix != HCI_EVENT_PKT,
- "Error in response: not an event packet, but 0x%02x!\n",
+ "Error in response: not an event packet, but 0x%02x!\n",
resp.uart_prefix);
FAILIF(resp.hci_hdr.evt != EVT_CMD_COMPLETE, /* event must be event-complete */
@@ -107,7 +107,7 @@ static int texas_load_firmware(int fd, const char *firmware) {
fprintf(stdout, "Opening firmware file: %s\n", firmware);
- FAILIF(fw < 0,
+ FAILIF(fw < 0,
"Could not open firmware file %s: %s (%d).\n",
firmware, strerror(errno), errno);
@@ -123,17 +123,17 @@ static int texas_load_firmware(int fd, const char *firmware) {
break;
FAILIF(nr != sizeof(cmdp), "Could not read H4 + HCI header!\n");
FAILIF(*cmdp != HCI_COMMAND_PKT, "Command is not an H4 command packet!\n");
-
+
FAILIF(read(fw, data, cmd->plen) != cmd->plen,
"Could not read %d bytes of data for command with opcode %04x!\n",
cmd->plen,
cmd->opcode);
-
+
{
int nw;
#if 0
- fprintf(stdout, "\topcode 0x%04x (%d bytes of data).\n",
- cmd->opcode,
+ fprintf(stdout, "\topcode 0x%04x (%d bytes of data).\n",
+ cmd->opcode,
cmd->plen);
#endif
struct iovec iov_cmd[2];
@@ -142,18 +142,18 @@ static int texas_load_firmware(int fd, const char *firmware) {
iov_cmd[1].iov_base = data;
iov_cmd[1].iov_len = cmd->plen;
nw = writev(fd, iov_cmd, 2);
- FAILIF(nw != (int) sizeof(cmd) + cmd->plen,
+ FAILIF(nw != (int) sizeof(cmd) + cmd->plen,
"Could not send entire command (sent only %d bytes)!\n",
nw);
}
/* Wait for response */
- if (read_command_complete(fd,
+ if (read_command_complete(fd,
cmd->opcode,
cmd->plen) < 0) {
return -1;
}
-
+
} while(1);
fprintf(stdout, "Firmware upload successful.\n");
@@ -170,7 +170,7 @@ int texasalt_init(int fd, int speed, struct termios *ti)
memset(resp,'\0', 100);
- /* It is possible to get software version with manufacturer specific
+ /* It is possible to get software version with manufacturer specific
HCI command HCI_VS_TI_Version_Number. But the only thing you get more
is if this is point-to-point or point-to-multipoint module */
diff --git a/tools/hciconfig.c b/tools/hciconfig.c
index 3f687e0..06c9459 100644
--- a/tools/hciconfig.c
+++ b/tools/hciconfig.c
@@ -453,7 +453,7 @@ static void cmd_name(int ctl, int hdev, char *opt)
hci_close_dev(dd);
}
-/*
+/*
* see http://www.bluetooth.org/assigned-numbers/baseband.htm --- all
* strings are reproduced verbatim
*/
@@ -562,7 +562,7 @@ static char *get_minor_device_name(int major, int minor)
break;
case 5: /* peripheral */ {
static char cls_str[48];
-
+
cls_str[0] = '\0';
switch(minor & 48) {
@@ -1380,7 +1380,7 @@ static void cmd_page_to(int ctl, int hdev, char *opt)
exit(1);
}
print_dev_hdr(&di);
-
+
timeout = btohs(rp.timeout);
printf("\tPage timeout: %u slots (%.2f ms)\n",
timeout, (float)timeout * 0.625);
diff --git a/tools/kword.h b/tools/kword.h
index e1cffcc..81a2a88 100644
--- a/tools/kword.h
+++ b/tools/kword.h
@@ -28,7 +28,7 @@ struct keyword_t {
int type;
};
-extern struct keyword_t rfcomm_keyword[];
+extern struct keyword_t rfcomm_keyword[];
int rfcomm_find_keyword(struct keyword_t *keyword, char *string);
diff --git a/tools/main.c b/tools/main.c
index 3baa61d..6800445 100644
--- a/tools/main.c
+++ b/tools/main.c
@@ -118,7 +118,7 @@ static void print_dev_info(struct rfcomm_dev_info *di)
printf("rfcomm%d: %s channel %d %s %s\n",
di->id, addr, di->channel,
- rfcomm_state[di->state],
+ rfcomm_state[di->state],
di->flags ? rfcomm_flagstostr(di->flags) : "");
}
@@ -717,7 +717,7 @@ static void usage(void)
"\t-E, --encrypt Enable encryption\n"
"\t-S, --secure Secure connection\n"
"\t-M, --master Become the master of a piconet\n"
- "\t-f, --config [file] Specify alternate config file\n"
+ "\t-f, --config [file] Specify alternate config file\n"
"\t-a Show all devices (default)\n"
"\n");
@@ -743,7 +743,7 @@ static struct option main_options[] = {
{ 0, 0, 0, 0 }
};
-int main(int argc, char *argv[])
+int main(int argc, char *argv[])
{
bdaddr_t bdaddr;
int i, opt, ctl, dev_id, show_all = 0;
diff --git a/tools/ppporc.c b/tools/ppporc.c
index eab1818..ca44b40 100644
--- a/tools/ppporc.c
+++ b/tools/ppporc.c
@@ -147,7 +147,7 @@ static int process_data(int fd)
p[0].fd = 0;
p[0].events = POLLIN | POLLERR | POLLHUP | POLLNVAL;
-
+
p[1].fd = fd;
p[1].events = POLLIN | POLLERR | POLLHUP | POLLNVAL;
@@ -156,7 +156,7 @@ static int process_data(int fd)
while (!__io_canceled) {
p[0].revents = 0;
p[1].revents = 0;
-
+
err = poll(p, 2, -1);
if (err < 0)
break;
diff --git a/tools/sdptool.c b/tools/sdptool.c
index 89166ae..7cca3ca 100644
--- a/tools/sdptool.c
+++ b/tools/sdptool.c
@@ -753,7 +753,7 @@ static void print_raw_attr(sdp_record_t *rec)
* Set attributes with single values in SDP record
* Jean II
*/
-static int set_attrib(sdp_session_t *sess, uint32_t handle, uint16_t attrib, char *value)
+static int set_attrib(sdp_session_t *sess, uint32_t handle, uint16_t attrib, char *value)
{
sdp_list_t *attrid_list;
uint32_t range = 0x0000ffff;
@@ -783,7 +783,7 @@ static int set_attrib(sdp_session_t *sess, uint32_t handle, uint16_t attrib, cha
sdp_attr_add_new(rec, attrib, SDP_UUID16, &value_uuid.value.uuid16);
} else if (!strncasecmp(value, "0x", 2)) {
/* Int */
- uint32_t value_int;
+ uint32_t value_int;
value_int = strtoul(value + 2, NULL, 16);
printf("Adding attrib 0x%X int 0x%X to record 0x%X\n",
attrib, value_int, handle);
@@ -811,7 +811,7 @@ static struct option set_options[] = {
{ 0, 0, 0, 0 }
};
-static const char *set_help =
+static const char *set_help =
"Usage:\n"
"\tget record_handle attrib_id attrib_value\n";
@@ -949,7 +949,7 @@ static struct option seq_options[] = {
{ 0, 0, 0, 0 }
};
-static const char *seq_help =
+static const char *seq_help =
"Usage:\n"
"\tget record_handle attrib_id attrib_values\n";
@@ -1685,7 +1685,7 @@ static int add_simaccess(sdp_session_t *session, svc_info_t *si)
sdp_record_t record;
uint8_t u8 = si->channel? si->channel : 8;
uint16_t u16 = 0x31;
- sdp_data_t *channel, *features;
+ sdp_data_t *channel, *features;
int ret = 0;
memset((void *)&record, 0, sizeof(sdp_record_t));
@@ -2250,7 +2250,7 @@ static int add_hid_keyb(sdp_session_t *session, svc_info_t *si)
static const uint16_t intr = 0x13;
static const uint16_t hid_attr[] = { 0x100, 0x111, 0x40, 0x0d, 0x01, 0x01 };
static const uint16_t hid_attr2[] = { 0x0, 0x01, 0x100, 0x1f40, 0x01, 0x01 };
- const uint8_t hid_spec[] = {
+ const uint8_t hid_spec[] = {
0x05, 0x01, // usage page
0x09, 0x06, // keyboard
0xa1, 0x01, // key codes
@@ -2263,14 +2263,14 @@ static int add_hid_keyb(sdp_session_t *session, svc_info_t *si)
0x75, 0x01, // input data variable absolute
0x95, 0x08, // report count
0x81, 0x02, // report size
- 0x75, 0x08,
- 0x95, 0x01,
- 0x81, 0x01,
- 0x75, 0x01,
+ 0x75, 0x08,
+ 0x95, 0x01,
+ 0x81, 0x01,
+ 0x75, 0x01,
0x95, 0x05,
0x05, 0x08,
0x19, 0x01,
- 0x29, 0x05,
+ 0x29, 0x05,
0x91, 0x02,
0x75, 0x03,
0x95, 0x01,
@@ -3526,7 +3526,7 @@ static struct option add_options[] = {
{ 0, 0, 0, 0 }
};
-static const char *add_help =
+static const char *add_help =
"Usage:\n"
"\tadd [--handle=RECORD_HANDLE --channel=CHANNEL] service\n";
@@ -3591,7 +3591,7 @@ static int del_service(bdaddr_t *bdaddr, void *arg)
sdp_session_t *sess;
sdp_record_t *rec;
- if (!arg) {
+ if (!arg) {
printf("Record handle was not specified.\n");
return -1;
}
@@ -3630,7 +3630,7 @@ static struct option del_options[] = {
{ 0, 0, 0, 0 }
};
-static const char *del_help =
+static const char *del_help =
"Usage:\n"
"\tdel record_handle\n";
@@ -3771,7 +3771,7 @@ static struct option browse_options[] = {
{ 0, 0, 0, 0 }
};
-static const char *browse_help =
+static const char *browse_help =
"Usage:\n"
"\tbrowse [--tree] [--raw] [--xml] [--uuid uuid] [--l2cap] [bdaddr]\n";
@@ -3837,7 +3837,7 @@ static struct option search_options[] = {
{ 0, 0, 0, 0}
};
-static const char *search_help =
+static const char *search_help =
"Usage:\n"
"\tsearch [--bdaddr bdaddr] [--tree] [--raw] [--xml] SERVICE\n"
"SERVICE is a name (string) or UUID (0x1002)\n";
@@ -3996,7 +3996,7 @@ static struct option records_options[] = {
{ 0, 0, 0, 0 }
};
-static const char *records_help =
+static const char *records_help =
"Usage:\n"
"\trecords [--tree] [--raw] [--xml] bdaddr\n";
@@ -4066,7 +4066,7 @@ static struct option get_options[] = {
{ 0, 0, 0, 0 }
};
-static const char *get_help =
+static const char *get_help =
"Usage:\n"
"\tget [--tree] [--raw] [--xml] [--bdaddr bdaddr] record_handle\n";
--
1.7.0.4
^ permalink raw reply related
* [PATCH 6/6] Change end of line from DOS to UNIX
From: Jose Antonio Santos Cadenas @ 2010-05-06 22:27 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Jose Antonio Santos Cadenas
In-Reply-To: <1273184832-8265-1-git-send-email-santoscadenas@gmail.com>
Files tools/ubcsp.c and tools/ubcsp.h had DOS end of line now they
are changed to UNIX end of line
---
tools/ubcsp.c | 2360 ++++++++++++++++++++++++++++----------------------------
tools/ubcsp.h | 414 +++++-----
2 files changed, 1387 insertions(+), 1387 deletions(-)
diff --git a/tools/ubcsp.c b/tools/ubcsp.c
index 93b8c0f..3d4cd99 100644
--- a/tools/ubcsp.c
+++ b/tools/ubcsp.c
@@ -1,1180 +1,1180 @@
-/*
- *
- * BlueZ - Bluetooth protocol stack for Linux
- *
- * Copyright (C) 2000-2005 CSR Ltd.
- *
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
- * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-/*****************************************************************************/
-/*****************************************************************************/
-/*****************************************************************************/
-/** **/
-/** ubcsp,c **/
-/** **/
-/** MicroBCSP - a very low cost implementation of the BCSP protocol **/
-/** **/
-/*****************************************************************************/
-
-#include "ubcsp.h"
-
-#if SHOW_PACKET_ERRORS || SHOW_LE_STATES
-#include <stdio.h>
-#include <windows.h>
-#endif
-
-static uint16 ubcsp_calc_crc (uint8 ch, uint16 crc);
-static uint16 ubcsp_crc_reverse (uint16);
-
-/*****************************************************************************/
-/** **/
-/** Constant Data - ROM **/
-/** **/
-/*****************************************************************************/
-
-/* This is the storage for the link establishment messages */
-
-static const uint8 ubcsp_le_buffer[4][4] =
- {
- { 0xDA, 0xDC, 0xED, 0xED },
- { 0xAC, 0xAF, 0xEF, 0xEE },
- { 0xAD, 0xEF, 0xAC, 0xED },
- { 0xDE, 0xAD, 0xD0, 0xD0 },
- };
-
-/* These are the link establishment headers */
-/* The two version are for the CRC and non-CRC varients */
-
-#if UBCSP_CRC
-static const uint8 ubcsp_send_le_header[4] =
- {
- 0x40, 0x41, 0x00, 0x7E
- };
-#else
-static const uint8 ubcsp_send_le_header[4] =
- {
- 0x00, 0x41, 0x00, 0xBE
- };
-#endif
-
-/*****************************************************************************/
-/** **/
-/** Static Data - RAM **/
-/** **/
-/*****************************************************************************/
-
-/* This is the storage for all state data for ubcsp */
-
-static struct ubcsp_configuration ubcsp_config;
-
-/* This is the ACK packet header - this will be overwritten when
- we create an ack packet */
-
-static uint8 ubcsp_send_ack_header[4] =
- {
- 0x00, 0x00, 0x00, 0x00
- };
-
-/* This is the deslip lookup table */
-
-static const uint8 ubcsp_deslip[2] =
- {
- SLIP_FRAME, SLIP_ESCAPE,
- };
-
-/* This is a state machine table for link establishment */
-
-static uint8 next_le_packet[16] =
- {
- ubcsp_le_sync, // uninit
- ubcsp_le_conf, // init
- ubcsp_le_none, // active
- ubcsp_le_none,
- ubcsp_le_sync_resp, // sync_resp
- ubcsp_le_sync_resp,
- ubcsp_le_none,
- ubcsp_le_none,
- ubcsp_le_none, // conf_resp
- ubcsp_le_conf_resp,
- ubcsp_le_conf_resp,
- ubcsp_le_none,
- };
-
-/* This is the storage required for building send and crc data */
-
-static uint8 ubcsp_send_header[4];
-static uint8 ubcsp_send_crc[2];
-
-/* This is where the receive header is stored before the payload arrives */
-
-static uint8 ubcsp_receive_header[4];
-
-/*****************************************************************************/
-/** **/
-/** Code - ROM or RAM **/
-/** **/
-/*****************************************************************************/
-
-/*****************************************************************************/
-/** **/
-/** ubcsp_initialize **/
-/** **/
-/** This initializes the state of the ubcsp engine to a known values **/
-/** **/
-/*****************************************************************************/
-
-void ubcsp_initialize (void)
-{
- ubcsp_config.ack_number = 0;
- ubcsp_config.sequence_number = 0;
- ubcsp_config.send_ptr = 0;
- ubcsp_config.send_size = 0;
- ubcsp_config.receive_index = -4;
-
- ubcsp_config.delay = 0;
-
-#if SHOW_LE_STATES
- printf ("Hello Link Uninitialized\n");
-#endif
-
- ubcsp_config.link_establishment_state = ubcsp_le_uninitialized;
- ubcsp_config.link_establishment_packet = ubcsp_le_sync;
-}
-
-/*****************************************************************************/
-/** **/
-/** ubcsp_send_packet **/
-/** **/
-/** This sends a packet structure for sending to the ubcsp engine **/
-/** This can only be called when the activity indication from ubcsp_poll **/
-/** indicates that a packet can be sent with UBCSP_PACKET_SENT **/
-/** **/
-/*****************************************************************************/
-
-void ubcsp_send_packet (struct ubcsp_packet *send_packet)
-{
- /* Initialize the send data to the packet we want to send */
-
- ubcsp_config.send_packet = send_packet;
-
- /* we cannot send the packet at the moment
- when we can at the moment, just set things to 0 */
-
- ubcsp_config.send_size = 0;
- ubcsp_config.send_ptr = 0;
-}
-
-/*****************************************************************************/
-/** **/
-/** ubcsp_receive_packet **/
-/** **/
-/** This sends a packet structure for receiving to the ubcsp engine **/
-/** This can only be called when the activity indication from ubcsp_poll **/
-/** indicates that a packet can be sent with UBCSP_PACKET_RECEIVED **/
-/** **/
-/*****************************************************************************/
-
-void ubcsp_receive_packet (struct ubcsp_packet *receive_packet)
-{
- /* Initialize the receive data to the packet we want to receive */
-
- ubcsp_config.receive_packet = receive_packet;
-
- /* setup to receive the header first */
-
- ubcsp_config.receive_index = -4;
-}
-
-/*****************************************************************************/
-/** **/
-/** ubcsp_calc_crc **/
-/** **/
-/** Takes the next 8 bit value ch, and updates the crc with this value **/
-/** **/
-/*****************************************************************************/
-
-
-#ifdef UBCSP_CRC
-
-static uint16 ubcsp_calc_crc (uint8 ch, uint16 crc)
-{
- /* Calculate the CRC using the above 16 entry lookup table */
-
- static const uint16 crc_table[] =
- {
- 0x0000, 0x1081, 0x2102, 0x3183,
- 0x4204, 0x5285, 0x6306, 0x7387,
- 0x8408, 0x9489, 0xa50a, 0xb58b,
- 0xc60c, 0xd68d, 0xe70e, 0xf78f
- };
-
- /* Do this four bits at a time - more code, less space */
-
- crc = (crc >> 4) ^ crc_table[(crc ^ ch) & 0x000f];
- crc = (crc >> 4) ^ crc_table[(crc ^ (ch >> 4)) & 0x000f];
-
- return crc;
-}
-
-/*****************************************************************************/
-/** **/
-/** ubcsp_crc_reverse **/
-/** **/
-/** Reserves the bits in crc and returns the new value **/
-/** **/
-/*****************************************************************************/
-
-static uint16 ubcsp_crc_reverse (uint16 crc)
-{
- int32
- b,
- rev;
-
- /* Reserse the bits to compute the actual CRC value */
-
- for (b = 0, rev=0; b < 16; b++)
- {
- rev = rev << 1;
- rev |= (crc & 1);
- crc = crc >> 1;
- }
-
- return rev;
-}
-
-#endif
-
-/*****************************************************************************/
-/** **/
-/** ubcsp_put_slip_uart **/
-/** **/
-/** Outputs a single octet to the uart **/
-/** If the octet needs to be escaped, then output the escape value **/
-/** and then store the second octet to be output later **/
-/** **/
-/*****************************************************************************/
-
-static void ubcsp_put_slip_uart (uint8 ch)
-{
- /* output a single UART octet */
-
- /* If it needs to be escaped, then output the escape octet
- and set the send_slip_escape so that the next time we
- output the second octet for the escape correctly.
- This is done right at the top of ubcsp_poll */
-
- if (ch == SLIP_FRAME)
- {
- put_uart (SLIP_ESCAPE);
- ubcsp_config.send_slip_escape = SLIP_ESCAPE_FRAME;
- }
- else if (ch == SLIP_ESCAPE)
- {
- put_uart (SLIP_ESCAPE);
- ubcsp_config.send_slip_escape = SLIP_ESCAPE_ESCAPE;
- }
- else
- {
- /* Not escaped, so just output octet */
-
- put_uart (ch);
- }
-}
-
-/*****************************************************************************/
-/** **/
-/** ubcsp_which_le_payload **/
-/** **/
-/** Check the payload of this packet, and determine which of the four **/
-/** link establishment packets this was. **/
-/** Can return 5 if it is not a valid link establishment packet **/
-/** **/
-/*****************************************************************************/
-
-static uint32 ubcsp_which_le_payload (const uint8 *payload)
-{
- static int32
- octet,
- loop;
-
- /* Search through the various link establishment payloads to find
- which one we have received */
-
- for (loop = 0; loop < 4; loop ++)
- {
- for (octet = 0; octet < 4; octet ++)
- {
- if (payload[octet] != ubcsp_le_buffer[loop][octet])
- {
- /* Bad match, just to loop again */
- goto bad_match_loop;
- }
- }
-
- /* All the octets matched, return the value */
-
- return loop;
-
- /* Jumps out of octet loop if we got a bad match */
-bad_match_loop:
- {}
- }
-
- /* Non of the link establishment payloads matched - return invalid value */
-
- return 5;
-}
-
-/*****************************************************************************/
-/** **/
-/** ubcsp_recevied_packet **/
-/** **/
-/** This function is called when we have a SLIP END octet and a full **/
-/** packet header and possibly data in the receive packet **/
-/** **/
-/*****************************************************************************/
-
-static uint8 ubcsp_recevied_packet (void)
-{
- static uint8
- receive_crc,
- receive_seq,
- receive_ack,
- activity;
-
-#if UBCSP_CRC
- static int32
- loop;
-
- static uint16
- crc;
-#endif
-
- static uint16
- length;
-
- /* Keep track of what activity this received packet will cause */
-
- activity = 0;
-
- /*** Do all error checks that we can ***/
-
- /* First check the header checksum */
-
- if (((ubcsp_receive_header[0] + ubcsp_receive_header[1] + ubcsp_receive_header[2] + ubcsp_receive_header[3]) & 0xff) != 0xff)
- {
- /* Header Checksum Error */
-
-#if SHOW_PACKET_ERRORS
- printf ("\n######################## Header Checksum Error %02X %02X %02X %02X\n",
- ubcsp_receive_header[0],
- ubcsp_receive_header[1],
- ubcsp_receive_header[2],
- ubcsp_receive_header[3]);
-#endif
-
- /* If we have a header checksum error, send an ack in return
- this gets a packet to be resent as quickly as possible */
-
- ubcsp_config.send_ack = 1;
-
- return activity;
- }
-
- /* Decode the received packets header */
-
- ubcsp_config.receive_packet->reliable = (ubcsp_receive_header[0] & 0x80) >> 7;
-
- receive_crc = (ubcsp_receive_header[0] & 0x40) >> 6;
- receive_ack = (ubcsp_receive_header[0] & 0x38) >> 3;
- receive_seq = (ubcsp_receive_header[0] & 0x07);
-
- ubcsp_config.receive_packet->channel = (ubcsp_receive_header[1] & 0x0f);
-
- length =
- ((ubcsp_receive_header[1] & 0xf0) >> 4) |
- (ubcsp_receive_header[2] << 4);
-
-#if SHOW_PACKET_ERRORS
- if (ubcsp_config.receive_packet->reliable)
- {
- printf (" : %10d Recv SEQ: %d ACK %d\n",
- GetTickCount () % 100000,
- receive_seq,
- receive_ack);
- }
- else if (ubcsp_config.receive_packet->channel != 1)
- {
- printf (" : %10d Recv ACK %d\n",
- GetTickCount () % 100000,
- receive_ack);
- }
-#endif
-
- /* Check for length errors */
-
-#if UBCSP_CRC
- if (receive_crc)
- {
- /* If this packet had a CRC, then the length of the payload
- should be 2 less than the received size of the payload */
-
- if (length + 2 != ubcsp_config.receive_index)
- {
- /* Slip Length Error */
-
-#if SHOW_PACKET_ERRORS
- printf ("\n######################## Slip Length Error (With CRC) %d,%d\n", length, ubcsp_config.receive_index - 2);
-#endif
-
- /* If we have a payload length error, send an ack in return
- this gets a packet to be resent as quickly as possible */
-
- ubcsp_config.send_ack = 1;
- return activity;
- }
-
- /* We have a CRC at the end of this packet */
-
- ubcsp_config.receive_index -= 2;
-
- /* Calculate the packet CRC */
-
- crc = 0xffff;
-
- /* CRC the packet header */
-
- for (loop = 0; loop < 4; loop ++)
- {
- crc = ubcsp_calc_crc (ubcsp_receive_header[loop], crc);
- }
-
- /* CRC the packet payload - without the CRC bytes */
-
- for (loop = 0; loop < ubcsp_config.receive_index; loop ++)
- {
- crc = ubcsp_calc_crc (ubcsp_config.receive_packet->payload[loop], crc);
- }
-
- /* Reverse the CRC */
-
- crc = ubcsp_crc_reverse (crc);
-
- /* Check the CRC is correct */
-
- if
- (
- (((crc & 0xff00) >> 8) != ubcsp_config.receive_packet->payload[ubcsp_config.receive_index]) ||
- ((crc & 0xff) != ubcsp_config.receive_packet->payload[ubcsp_config.receive_index + 1])
- )
- {
-#if SHOW_PACKET_ERRORS
- printf ("\n######################## CRC Error\n");
-#endif
-
- /* If we have a packet crc error, send an ack in return
- this gets a packet to be resent as quickly as possible */
-
- ubcsp_config.send_ack = 1;
- return activity;
- }
- }
- else
- {
-#endif
- /* No CRC present, so just check the length of payload with that received */
-
- if (length != ubcsp_config.receive_index)
- {
- /* Slip Length Error */
-
-#if SHOW_PACKET_ERRORS
- printf ("\n######################## Slip Length Error (No CRC) %d,%d\n", length, ubcsp_config.receive_index);
-#endif
-
- /* If we have a payload length error, send an ack in return
- this gets a packet to be resent as quickly as possible */
-
- ubcsp_config.send_ack = 1;
- return activity;
- }
-#if UBCSP_CRC
- }
-#endif
-
- /*** We have a fully formed packet having passed all data integrity checks ***/
-
- /* Check if we have an ACK for the last packet we sent */
-
- if (receive_ack != ubcsp_config.sequence_number)
- {
- /* Since we only have a window size of 1, if the ACK is not equal to SEQ
- then the packet was sent */
-
- if
- (
- (ubcsp_config.send_packet) &&
- (ubcsp_config.send_packet->reliable)
- )
- {
- /* We had sent a reliable packet, so clear this packet
- Then increament the sequence number for the next packet */
-
- ubcsp_config.send_packet = 0;
- ubcsp_config.sequence_number ++;
- ubcsp_config.delay = 0;
-
- /* Notify the caller that we have SENT a packet */
-
- activity |= UBCSP_PACKET_SENT;
- }
- }
-
- /*** Now we can concentrate of the packet we have received ***/
-
- /* Check for Link Establishment packets */
-
- if (ubcsp_config.receive_packet->channel == 1)
- {
- /* Link Establishment */
-
- ubcsp_config.delay = 0;
-
- /* Find which link establishment packet this payload means
- This could return 5, meaning none */
-
- switch (ubcsp_which_le_payload (ubcsp_config.receive_packet->payload))
- {
- case 0:
- {
- /* SYNC Recv'd */
-
-#if SHOW_LE_STATES
- printf ("Recv SYNC\n");
-#endif
-
- /* If we receive a SYNC, then we respond to it with a SYNC RESP
- but only if we are not active.
- If we are active, then we have a PEER RESET */
-
- if (ubcsp_config.link_establishment_state < ubcsp_le_active)
- {
- ubcsp_config.link_establishment_resp = 1;
- }
- else
- {
- /* Peer reset !!!! */
-
-#if SHOW_LE_STATES
- printf ("\n\n\n\n\nPEER RESET\n\n");
-#endif
-
- /* Reinitialize the link */
-
- ubcsp_initialize ();
-
- /* Tell the host what has happened */
-
- return UBCSP_PEER_RESET;
- }
- break;
- }
-
- case 1:
- {
- /* SYNC RESP Recv'd */
-
-#if SHOW_LE_STATES
- printf ("Recv SYNC RESP\n");
-#endif
-
- /* If we receive a SYNC RESP, push us into the initialized state */
-
- if (ubcsp_config.link_establishment_state < ubcsp_le_initialized)
- {
-#if SHOW_LE_STATES
- printf ("Link Initialized\n");
-#endif
- ubcsp_config.link_establishment_state = ubcsp_le_initialized;
- }
-
- break;
- }
-
- case 2:
- {
- /* CONF Recv'd */
-
-#if SHOW_LE_STATES
- printf ("Recv CONF\n");
-#endif
-
- /* If we receive a CONF, and we are initialized or active
- then respond with a CONF RESP */
-
- if (ubcsp_config.link_establishment_state >= ubcsp_le_initialized)
- {
- ubcsp_config.link_establishment_resp = 2;
- }
-
- break;
- }
-
- case 3:
- {
- /* CONF RESP Recv'd */
-
-#if SHOW_LE_STATES
- printf ("Recv CONF RESP\n");
-#endif
-
- /* If we received a CONF RESP, then push us into the active state */
-
- if (ubcsp_config.link_establishment_state < ubcsp_le_active)
- {
-#if SHOW_LE_STATES
- printf ("Link Active\n");
-#endif
-
- ubcsp_config.link_establishment_state = ubcsp_le_active;
- ubcsp_config.send_size = 0;
-
- return activity | UBCSP_PACKET_SENT;
- }
-
- break;
- }
- }
-
- /* We have finished processing Link Establishment packets */
- }
- else if (ubcsp_config.receive_index)
- {
- /* We have some payload data we need to process
- but only if we are active - otherwise, we just ignore it */
-
- if (ubcsp_config.link_establishment_state == ubcsp_le_active)
- {
- if (ubcsp_config.receive_packet->reliable)
- {
- /* If the packet we've just received was reliable
- then send an ACK */
-
- ubcsp_config.send_ack = 1;
-
- /* We the sequence number we received is the same as
- the last ACK we sent, then we have received a packet in sequence */
-
- if (receive_seq == ubcsp_config.ack_number)
- {
- /* Increase the ACK number - which will be sent in the next ACK
- or normal packet we send */
-
- ubcsp_config.ack_number ++;
-
- /* Set the values in the receive_packet structure, so the caller
- knows how much data we have */
-
- ubcsp_config.receive_packet->length = length;
- ubcsp_config.receive_packet = 0;
-
- /* Tell the caller that we have received a packet, and that it
- will be ACK'ed */
-
- activity |= UBCSP_PACKET_RECEIVED | UBCSP_PACKET_ACK;
- }
- }
- else
- {
- /* Set the values in the receive_packet structure, so the caller
- knows how much data we have */
-
- ubcsp_config.receive_packet->length = length;
- ubcsp_config.receive_packet = 0;
-
- /* Tell the caller that we have received a packet */
-
- activity |= UBCSP_PACKET_RECEIVED;
- }
- }
- }
-
- /* Just return any activity that occured */
-
- return activity;
-}
-
-/*****************************************************************************/
-/** **/
-/** ubcsp_setup_packet **/
-/** **/
-/** This function is called to setup a packet to be sent **/
-/** This allows just a header, or a header and payload to be sent **/
-/** It also allows the header checksum to be precalcuated **/
-/** or calculated here **/
-/** part1 is always 4 bytes **/
-/** **/
-/*****************************************************************************/
-
-static void ubcsp_setup_packet (uint8 *part1, uint8 calc, uint8 *part2, uint16 len2)
-{
- /* If we need to calculate the checksum, do that now */
-
- if (calc)
- {
- part1[3] =
- ~(part1[0] + part1[1] + part1[2]);
- }
-
- /* Setup the header send pointer and size so we can clock this out */
-
- ubcsp_config.send_ptr = part1;
- ubcsp_config.send_size = 4;
-
- /* Setup the payload send pointer and size */
-
- ubcsp_config.next_send_ptr = part2;
- ubcsp_config.next_send_size = len2;
-
-#if UBCSP_CRC
- /* Initialize the crc as required */
-
- ubcsp_config.send_crc = -1;
-
- ubcsp_config.need_send_crc = 1;
-#endif
-}
-
-/*****************************************************************************/
-/** **/
-/** ubcsp_sent_packet **/
-/** **/
-/** Called when we have finished sending a packet **/
-/** If this packet was unreliable, then notify caller, and clear the data **/
-/** **/
-/*****************************************************************************/
-
-static uint8 ubcsp_sent_packet (void)
-{
- if (ubcsp_config.send_packet)
- {
- if (!ubcsp_config.send_packet->reliable)
- {
- /* We had a packet sent that was unreliable */
-
- /* Forget about this packet */
-
- ubcsp_config.send_packet = 0;
-
- /* Notify caller that they can send another one */
-
- return UBCSP_PACKET_SENT;
- }
- }
-
- /* We didn't have a packet, or it was reliable
- Must wait for ACK before allowing another packet to be sent */
-
- return 0;
-}
-
-/*****************************************************************************/
-/** **/
-/** ubcsp_poll **/
-/** **/
-/** This is the main function for ubcsp **/
-/** It performs a number of tasks **/
-/** **/
-/** 1) Send another octet to the UART - escaping as required **/
-/** 2) Setup the payload to be sent after the header has been sent **/
-/** 3) Send the CRC for the packet if required **/
-/** **/
-/** 4) Calculate the next Link Establishment State **/
-/** 5) Send a Link Establishment packet **/
-/** 6) Send a normal packet if available **/
-/** 7) Send an ACK packet if required **/
-/** **/
-/** 8) Receive octets from UART and deslip them as required **/
-/** 9) Place received octets into receive header or receive payload buffer **/
-/** 10) Process received packet when SLIP_END is received **/
-/** **/
-/** 11) Keep track of ability of caller to delay recalling **/
-/** **/
-/*****************************************************************************/
-
-uint8 ubcsp_poll (uint8 *activity)
-{
- uint8
- delay = UBCSP_POLL_TIME_IMMEDIATE;
-
- uint8
- value;
-
- /* Assume no activity to start with */
-
- *activity = 0;
-
- /* If we don't have to delay, then send something if we can */
-
- if (!ubcsp_config.delay)
- {
- /* Do we have something we are sending to send */
-
- if (ubcsp_config.send_size)
- {
- /* We have something to send so send it */
-
- if (ubcsp_config.send_slip_escape)
- {
- /* Last time we send a SLIP_ESCAPE octet
- this time send the second escape code */
-
- put_uart (ubcsp_config.send_slip_escape);
-
- ubcsp_config.send_slip_escape = 0;
- }
- else
- {
-#if UBCSP_CRC
- /* get the value to send, and calculate CRC as we go */
-
- value = *ubcsp_config.send_ptr ++;
-
- ubcsp_config.send_crc = ubcsp_calc_crc (value, ubcsp_config.send_crc);
-
- /* Output the octet */
-
- ubcsp_put_slip_uart (value);
-#else
- /* Just output the octet*/
-
- ubcsp_put_slip_uart (*ubcsp_config.send_ptr ++);
-#endif
- }
-
- /* If we did output a SLIP_ESCAPE, then don't process the end of a block */
-
- if ((!ubcsp_config.send_slip_escape) && ((ubcsp_config.send_size = ubcsp_config.send_size - 1) == 0))
- {
- /*** We are at the end of a block - either header or payload ***/
-
- /* setup the next block */
-
- ubcsp_config.send_ptr = ubcsp_config.next_send_ptr;
- ubcsp_config.send_size = ubcsp_config.next_send_size;
- ubcsp_config.next_send_ptr = 0;
- ubcsp_config.next_send_size = 0;
-
-#if UBCSP_CRC
- /* If we have no successor block
- then we might need to send the CRC */
-
- if (!ubcsp_config.send_ptr)
- {
- if (ubcsp_config.need_send_crc)
- {
- /* reverse the CRC from what we computed along the way */
-
- ubcsp_config.need_send_crc = 0;
-
- ubcsp_config.send_crc = ubcsp_crc_reverse (ubcsp_config.send_crc);
-
- /* Save in the send_crc buffer */
-
- ubcsp_send_crc[0] = (uint8) (ubcsp_config.send_crc >> 8);
- ubcsp_send_crc[1] = (uint8) ubcsp_config.send_crc;
-
- /* Setup to send this buffer */
-
- ubcsp_config.send_ptr = ubcsp_send_crc;
- ubcsp_config.send_size = 2;
- }
- else
- {
- /* We don't need to send the crc
- either we just have, or this packet doesn't include it */
-
- /* Output the end of FRAME marker */
-
- put_uart (SLIP_FRAME);
-
- /* Check if this is an unreliable packet */
-
- *activity |= ubcsp_sent_packet ();
-
- /* We've sent the packet, so don't need to have be called quickly soon */
-
- delay = UBCSP_POLL_TIME_DELAY;
- }
- }
-#else
- /* If we have no successor block
- then we might need to send the CRC */
-
- if (!ubcsp_config.send_ptr)
- {
- /* Output the end of FRAME marker */
-
- put_uart (SLIP_FRAME);
-
- /* Check if this is an unreliable packet */
-
- *activity |= ubcsp_sent_packet ();
-
- /* We've sent the packet, so don't need to have be called quickly soon */
-
- delay = UBCSP_POLL_TIME_DELAY;
- }
-#endif
- }
- }
- else if (ubcsp_config.link_establishment_packet == ubcsp_le_none)
- {
- /* We didn't have something to send
- AND we have no Link Establishment packet to send */
-
- if (ubcsp_config.link_establishment_resp & 2)
- {
- /* Send the start of FRAME packet */
-
- put_uart (SLIP_FRAME);
-
- /* We did require a RESP packet - so setup the send */
-
- ubcsp_setup_packet ((uint8*) ubcsp_send_le_header, 0, (uint8*) ubcsp_le_buffer[ubcsp_le_conf_resp], 4);
-
- /* We have now "sent" this packet */
-
- ubcsp_config.link_establishment_resp = 0;
- }
- else if (ubcsp_config.send_packet)
- {
- /* There is a packet ready to be sent */
-
- /* Send the start of FRAME packet */
-
- put_uart (SLIP_FRAME);
-
- /* Encode up the packet header using ACK and SEQ numbers */
-
- ubcsp_send_header[0] =
- (ubcsp_config.send_packet->reliable << 7) |
-#if UBCSP_CRC
- 0x40 | /* Always use CRC's */
-#endif
- (ubcsp_config.ack_number << 3) |
- (ubcsp_config.sequence_number);
-
- /* Encode up the packet header's channel and length */
- ubcsp_send_header[1] =
- (ubcsp_config.send_packet->channel & 0x0f) |
- ((ubcsp_config.send_packet->length << 4) & 0xf0);
-
- ubcsp_send_header[2] =
- (ubcsp_config.send_packet->length >> 4) & 0xff;
-
- /* Let the ubcsp_setup_packet function calculate the header checksum */
-
- ubcsp_setup_packet ((uint8*) ubcsp_send_header, 1, ubcsp_config.send_packet->payload, ubcsp_config.send_packet->length);
-
- /* Don't need to send an ACK - we just place on in this packet */
-
- ubcsp_config.send_ack = 0;
-
-#if SHOW_PACKET_ERRORS
- printf (" : %10d Send %d Ack %d\n",
- GetTickCount () % 100000,
- ubcsp_config.sequence_number,
- ubcsp_config.ack_number);
-#endif
- }
- else if (ubcsp_config.send_ack)
- {
- /* Send the start of FRAME packet */
-
- put_uart (SLIP_FRAME);
-
-#if SHOW_PACKET_ERRORS
- printf (" : %10d Send ACK %d\n",
- GetTickCount () % 100000,
- ubcsp_config.ack_number);
-#endif
-
- /* The ack packet is already computed apart from the first octet */
-
- ubcsp_send_ack_header[0] =
-#if UBCSP_CRC
- 0x40 |
-#endif
- (ubcsp_config.ack_number << 3);
-
- /* Let the ubcsp_setup_packet function calculate the header checksum */
-
- ubcsp_setup_packet (ubcsp_send_ack_header, 1, 0, 0);
-
- /* We've now sent the ack */
-
- ubcsp_config.send_ack = 0;
- }
- else
- {
- /* We didn't have a Link Establishment response packet,
- a normal packet or an ACK packet to send */
-
- delay = UBCSP_POLL_TIME_DELAY;
- }
- }
- else
- {
-#if SHOW_PACKET_ERRORS
-// printf (" : %10d Send LE %d\n",
-// GetTickCount () % 100000,
-// ubcsp_config.link_establishment_packet);
-#endif
-
- /* Send A Link Establishment Message */
-
- put_uart (SLIP_FRAME);
-
- /* Send the Link Establishment header followed by the
- Link Establishment packet */
-
- ubcsp_setup_packet ((uint8*) ubcsp_send_le_header, 0, (uint8*) ubcsp_le_buffer[ubcsp_config.link_establishment_packet], 4);
-
- /* start sending immediately */
-
- ubcsp_config.delay = 0;
-
- /* workout what the next link establishment packet should be */
-
- ubcsp_config.link_establishment_packet = next_le_packet[ubcsp_config.link_establishment_state + ubcsp_config.link_establishment_resp * 4];
-
- /* We have now delt with any response packet that we needed */
-
- ubcsp_config.link_establishment_resp = 0;
-
- return 0;
- }
- }
-
- /* We now need to receive any octets from the UART */
-
- while ((ubcsp_config.receive_packet) && (get_uart (&value)))
- {
- /* If the last octet was SLIP_ESCAPE, then special processing is required */
-
- if (ubcsp_config.receive_slip_escape)
- {
- /* WARNING - out of range values are not detected !!!
- This will probably be caught with the checksum or CRC check */
-
- value = ubcsp_deslip[value - SLIP_ESCAPE_FRAME];
-
- ubcsp_config.receive_slip_escape = 0;
- }
- else
- {
- /* Check for the SLIP_FRAME octet - must be start or end of packet */
- if (value == SLIP_FRAME)
- {
- /* If we had a full header then we have a packet */
-
- if (ubcsp_config.receive_index >= 0)
- {
- /* process the received packet */
-
- *activity |= ubcsp_recevied_packet ();
-
- if (*activity & UBCSP_PACKET_ACK)
- {
- /* We need to ACK this packet, then don't delay its sending */
- ubcsp_config.delay = 0;
- }
- }
-
- /* Setup to receive the next packet */
-
- ubcsp_config.receive_index = -4;
-
- /* Ok, next octet */
-
- goto finished_receive;
- }
- else if (value == SLIP_ESCAPE)
- {
- /* If we receive a SLIP_ESCAPE,
- then remember to process the next special octet */
-
- ubcsp_config.receive_slip_escape = 1;
-
- goto finished_receive;
- }
- }
-
- if (ubcsp_config.receive_index < 0)
- {
- /* We are still receiving the header */
-
- ubcsp_receive_header[ubcsp_config.receive_index + 4] = value;
-
- ubcsp_config.receive_index ++;
- }
- else if (ubcsp_config.receive_index < ubcsp_config.receive_packet->length)
- {
- /* We are receiving the payload */
- /* We might stop comming here if we are receiving a
- packet which is longer than the receive_packet->length
- given by the host */
-
- ubcsp_config.receive_packet->payload[ubcsp_config.receive_index] = value;
-
- ubcsp_config.receive_index ++;
- }
-
-finished_receive:
- {
- }
- }
-
- if (ubcsp_config.delay > 0)
- {
- /* We were delayed so delay some more
- this could be cancelled if we received something */
-
- ubcsp_config.delay --;
- }
- else
- {
- /* We had no delay, so use the delay we just decided to us */
-
- ubcsp_config.delay = delay;
- }
-
- /* Report the current delay to the user */
-
- return ubcsp_config.delay;
-}
+/*
+ *
+ * BlueZ - Bluetooth protocol stack for Linux
+ *
+ * Copyright (C) 2000-2005 CSR Ltd.
+ *
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+/*****************************************************************************/
+/*****************************************************************************/
+/*****************************************************************************/
+/** **/
+/** ubcsp,c **/
+/** **/
+/** MicroBCSP - a very low cost implementation of the BCSP protocol **/
+/** **/
+/*****************************************************************************/
+
+#include "ubcsp.h"
+
+#if SHOW_PACKET_ERRORS || SHOW_LE_STATES
+#include <stdio.h>
+#include <windows.h>
+#endif
+
+static uint16 ubcsp_calc_crc (uint8 ch, uint16 crc);
+static uint16 ubcsp_crc_reverse (uint16);
+
+/*****************************************************************************/
+/** **/
+/** Constant Data - ROM **/
+/** **/
+/*****************************************************************************/
+
+/* This is the storage for the link establishment messages */
+
+static const uint8 ubcsp_le_buffer[4][4] =
+ {
+ { 0xDA, 0xDC, 0xED, 0xED },
+ { 0xAC, 0xAF, 0xEF, 0xEE },
+ { 0xAD, 0xEF, 0xAC, 0xED },
+ { 0xDE, 0xAD, 0xD0, 0xD0 },
+ };
+
+/* These are the link establishment headers */
+/* The two version are for the CRC and non-CRC varients */
+
+#if UBCSP_CRC
+static const uint8 ubcsp_send_le_header[4] =
+ {
+ 0x40, 0x41, 0x00, 0x7E
+ };
+#else
+static const uint8 ubcsp_send_le_header[4] =
+ {
+ 0x00, 0x41, 0x00, 0xBE
+ };
+#endif
+
+/*****************************************************************************/
+/** **/
+/** Static Data - RAM **/
+/** **/
+/*****************************************************************************/
+
+/* This is the storage for all state data for ubcsp */
+
+static struct ubcsp_configuration ubcsp_config;
+
+/* This is the ACK packet header - this will be overwritten when
+ we create an ack packet */
+
+static uint8 ubcsp_send_ack_header[4] =
+ {
+ 0x00, 0x00, 0x00, 0x00
+ };
+
+/* This is the deslip lookup table */
+
+static const uint8 ubcsp_deslip[2] =
+ {
+ SLIP_FRAME, SLIP_ESCAPE,
+ };
+
+/* This is a state machine table for link establishment */
+
+static uint8 next_le_packet[16] =
+ {
+ ubcsp_le_sync, // uninit
+ ubcsp_le_conf, // init
+ ubcsp_le_none, // active
+ ubcsp_le_none,
+ ubcsp_le_sync_resp, // sync_resp
+ ubcsp_le_sync_resp,
+ ubcsp_le_none,
+ ubcsp_le_none,
+ ubcsp_le_none, // conf_resp
+ ubcsp_le_conf_resp,
+ ubcsp_le_conf_resp,
+ ubcsp_le_none,
+ };
+
+/* This is the storage required for building send and crc data */
+
+static uint8 ubcsp_send_header[4];
+static uint8 ubcsp_send_crc[2];
+
+/* This is where the receive header is stored before the payload arrives */
+
+static uint8 ubcsp_receive_header[4];
+
+/*****************************************************************************/
+/** **/
+/** Code - ROM or RAM **/
+/** **/
+/*****************************************************************************/
+
+/*****************************************************************************/
+/** **/
+/** ubcsp_initialize **/
+/** **/
+/** This initializes the state of the ubcsp engine to a known values **/
+/** **/
+/*****************************************************************************/
+
+void ubcsp_initialize (void)
+{
+ ubcsp_config.ack_number = 0;
+ ubcsp_config.sequence_number = 0;
+ ubcsp_config.send_ptr = 0;
+ ubcsp_config.send_size = 0;
+ ubcsp_config.receive_index = -4;
+
+ ubcsp_config.delay = 0;
+
+#if SHOW_LE_STATES
+ printf ("Hello Link Uninitialized\n");
+#endif
+
+ ubcsp_config.link_establishment_state = ubcsp_le_uninitialized;
+ ubcsp_config.link_establishment_packet = ubcsp_le_sync;
+}
+
+/*****************************************************************************/
+/** **/
+/** ubcsp_send_packet **/
+/** **/
+/** This sends a packet structure for sending to the ubcsp engine **/
+/** This can only be called when the activity indication from ubcsp_poll **/
+/** indicates that a packet can be sent with UBCSP_PACKET_SENT **/
+/** **/
+/*****************************************************************************/
+
+void ubcsp_send_packet (struct ubcsp_packet *send_packet)
+{
+ /* Initialize the send data to the packet we want to send */
+
+ ubcsp_config.send_packet = send_packet;
+
+ /* we cannot send the packet at the moment
+ when we can at the moment, just set things to 0 */
+
+ ubcsp_config.send_size = 0;
+ ubcsp_config.send_ptr = 0;
+}
+
+/*****************************************************************************/
+/** **/
+/** ubcsp_receive_packet **/
+/** **/
+/** This sends a packet structure for receiving to the ubcsp engine **/
+/** This can only be called when the activity indication from ubcsp_poll **/
+/** indicates that a packet can be sent with UBCSP_PACKET_RECEIVED **/
+/** **/
+/*****************************************************************************/
+
+void ubcsp_receive_packet (struct ubcsp_packet *receive_packet)
+{
+ /* Initialize the receive data to the packet we want to receive */
+
+ ubcsp_config.receive_packet = receive_packet;
+
+ /* setup to receive the header first */
+
+ ubcsp_config.receive_index = -4;
+}
+
+/*****************************************************************************/
+/** **/
+/** ubcsp_calc_crc **/
+/** **/
+/** Takes the next 8 bit value ch, and updates the crc with this value **/
+/** **/
+/*****************************************************************************/
+
+
+#ifdef UBCSP_CRC
+
+static uint16 ubcsp_calc_crc (uint8 ch, uint16 crc)
+{
+ /* Calculate the CRC using the above 16 entry lookup table */
+
+ static const uint16 crc_table[] =
+ {
+ 0x0000, 0x1081, 0x2102, 0x3183,
+ 0x4204, 0x5285, 0x6306, 0x7387,
+ 0x8408, 0x9489, 0xa50a, 0xb58b,
+ 0xc60c, 0xd68d, 0xe70e, 0xf78f
+ };
+
+ /* Do this four bits at a time - more code, less space */
+
+ crc = (crc >> 4) ^ crc_table[(crc ^ ch) & 0x000f];
+ crc = (crc >> 4) ^ crc_table[(crc ^ (ch >> 4)) & 0x000f];
+
+ return crc;
+}
+
+/*****************************************************************************/
+/** **/
+/** ubcsp_crc_reverse **/
+/** **/
+/** Reserves the bits in crc and returns the new value **/
+/** **/
+/*****************************************************************************/
+
+static uint16 ubcsp_crc_reverse (uint16 crc)
+{
+ int32
+ b,
+ rev;
+
+ /* Reserse the bits to compute the actual CRC value */
+
+ for (b = 0, rev=0; b < 16; b++)
+ {
+ rev = rev << 1;
+ rev |= (crc & 1);
+ crc = crc >> 1;
+ }
+
+ return rev;
+}
+
+#endif
+
+/*****************************************************************************/
+/** **/
+/** ubcsp_put_slip_uart **/
+/** **/
+/** Outputs a single octet to the uart **/
+/** If the octet needs to be escaped, then output the escape value **/
+/** and then store the second octet to be output later **/
+/** **/
+/*****************************************************************************/
+
+static void ubcsp_put_slip_uart (uint8 ch)
+{
+ /* output a single UART octet */
+
+ /* If it needs to be escaped, then output the escape octet
+ and set the send_slip_escape so that the next time we
+ output the second octet for the escape correctly.
+ This is done right at the top of ubcsp_poll */
+
+ if (ch == SLIP_FRAME)
+ {
+ put_uart (SLIP_ESCAPE);
+ ubcsp_config.send_slip_escape = SLIP_ESCAPE_FRAME;
+ }
+ else if (ch == SLIP_ESCAPE)
+ {
+ put_uart (SLIP_ESCAPE);
+ ubcsp_config.send_slip_escape = SLIP_ESCAPE_ESCAPE;
+ }
+ else
+ {
+ /* Not escaped, so just output octet */
+
+ put_uart (ch);
+ }
+}
+
+/*****************************************************************************/
+/** **/
+/** ubcsp_which_le_payload **/
+/** **/
+/** Check the payload of this packet, and determine which of the four **/
+/** link establishment packets this was. **/
+/** Can return 5 if it is not a valid link establishment packet **/
+/** **/
+/*****************************************************************************/
+
+static uint32 ubcsp_which_le_payload (const uint8 *payload)
+{
+ static int32
+ octet,
+ loop;
+
+ /* Search through the various link establishment payloads to find
+ which one we have received */
+
+ for (loop = 0; loop < 4; loop ++)
+ {
+ for (octet = 0; octet < 4; octet ++)
+ {
+ if (payload[octet] != ubcsp_le_buffer[loop][octet])
+ {
+ /* Bad match, just to loop again */
+ goto bad_match_loop;
+ }
+ }
+
+ /* All the octets matched, return the value */
+
+ return loop;
+
+ /* Jumps out of octet loop if we got a bad match */
+bad_match_loop:
+ {}
+ }
+
+ /* Non of the link establishment payloads matched - return invalid value */
+
+ return 5;
+}
+
+/*****************************************************************************/
+/** **/
+/** ubcsp_recevied_packet **/
+/** **/
+/** This function is called when we have a SLIP END octet and a full **/
+/** packet header and possibly data in the receive packet **/
+/** **/
+/*****************************************************************************/
+
+static uint8 ubcsp_recevied_packet (void)
+{
+ static uint8
+ receive_crc,
+ receive_seq,
+ receive_ack,
+ activity;
+
+#if UBCSP_CRC
+ static int32
+ loop;
+
+ static uint16
+ crc;
+#endif
+
+ static uint16
+ length;
+
+ /* Keep track of what activity this received packet will cause */
+
+ activity = 0;
+
+ /*** Do all error checks that we can ***/
+
+ /* First check the header checksum */
+
+ if (((ubcsp_receive_header[0] + ubcsp_receive_header[1] + ubcsp_receive_header[2] + ubcsp_receive_header[3]) & 0xff) != 0xff)
+ {
+ /* Header Checksum Error */
+
+#if SHOW_PACKET_ERRORS
+ printf ("\n######################## Header Checksum Error %02X %02X %02X %02X\n",
+ ubcsp_receive_header[0],
+ ubcsp_receive_header[1],
+ ubcsp_receive_header[2],
+ ubcsp_receive_header[3]);
+#endif
+
+ /* If we have a header checksum error, send an ack in return
+ this gets a packet to be resent as quickly as possible */
+
+ ubcsp_config.send_ack = 1;
+
+ return activity;
+ }
+
+ /* Decode the received packets header */
+
+ ubcsp_config.receive_packet->reliable = (ubcsp_receive_header[0] & 0x80) >> 7;
+
+ receive_crc = (ubcsp_receive_header[0] & 0x40) >> 6;
+ receive_ack = (ubcsp_receive_header[0] & 0x38) >> 3;
+ receive_seq = (ubcsp_receive_header[0] & 0x07);
+
+ ubcsp_config.receive_packet->channel = (ubcsp_receive_header[1] & 0x0f);
+
+ length =
+ ((ubcsp_receive_header[1] & 0xf0) >> 4) |
+ (ubcsp_receive_header[2] << 4);
+
+#if SHOW_PACKET_ERRORS
+ if (ubcsp_config.receive_packet->reliable)
+ {
+ printf (" : %10d Recv SEQ: %d ACK %d\n",
+ GetTickCount () % 100000,
+ receive_seq,
+ receive_ack);
+ }
+ else if (ubcsp_config.receive_packet->channel != 1)
+ {
+ printf (" : %10d Recv ACK %d\n",
+ GetTickCount () % 100000,
+ receive_ack);
+ }
+#endif
+
+ /* Check for length errors */
+
+#if UBCSP_CRC
+ if (receive_crc)
+ {
+ /* If this packet had a CRC, then the length of the payload
+ should be 2 less than the received size of the payload */
+
+ if (length + 2 != ubcsp_config.receive_index)
+ {
+ /* Slip Length Error */
+
+#if SHOW_PACKET_ERRORS
+ printf ("\n######################## Slip Length Error (With CRC) %d,%d\n", length, ubcsp_config.receive_index - 2);
+#endif
+
+ /* If we have a payload length error, send an ack in return
+ this gets a packet to be resent as quickly as possible */
+
+ ubcsp_config.send_ack = 1;
+ return activity;
+ }
+
+ /* We have a CRC at the end of this packet */
+
+ ubcsp_config.receive_index -= 2;
+
+ /* Calculate the packet CRC */
+
+ crc = 0xffff;
+
+ /* CRC the packet header */
+
+ for (loop = 0; loop < 4; loop ++)
+ {
+ crc = ubcsp_calc_crc (ubcsp_receive_header[loop], crc);
+ }
+
+ /* CRC the packet payload - without the CRC bytes */
+
+ for (loop = 0; loop < ubcsp_config.receive_index; loop ++)
+ {
+ crc = ubcsp_calc_crc (ubcsp_config.receive_packet->payload[loop], crc);
+ }
+
+ /* Reverse the CRC */
+
+ crc = ubcsp_crc_reverse (crc);
+
+ /* Check the CRC is correct */
+
+ if
+ (
+ (((crc & 0xff00) >> 8) != ubcsp_config.receive_packet->payload[ubcsp_config.receive_index]) ||
+ ((crc & 0xff) != ubcsp_config.receive_packet->payload[ubcsp_config.receive_index + 1])
+ )
+ {
+#if SHOW_PACKET_ERRORS
+ printf ("\n######################## CRC Error\n");
+#endif
+
+ /* If we have a packet crc error, send an ack in return
+ this gets a packet to be resent as quickly as possible */
+
+ ubcsp_config.send_ack = 1;
+ return activity;
+ }
+ }
+ else
+ {
+#endif
+ /* No CRC present, so just check the length of payload with that received */
+
+ if (length != ubcsp_config.receive_index)
+ {
+ /* Slip Length Error */
+
+#if SHOW_PACKET_ERRORS
+ printf ("\n######################## Slip Length Error (No CRC) %d,%d\n", length, ubcsp_config.receive_index);
+#endif
+
+ /* If we have a payload length error, send an ack in return
+ this gets a packet to be resent as quickly as possible */
+
+ ubcsp_config.send_ack = 1;
+ return activity;
+ }
+#if UBCSP_CRC
+ }
+#endif
+
+ /*** We have a fully formed packet having passed all data integrity checks ***/
+
+ /* Check if we have an ACK for the last packet we sent */
+
+ if (receive_ack != ubcsp_config.sequence_number)
+ {
+ /* Since we only have a window size of 1, if the ACK is not equal to SEQ
+ then the packet was sent */
+
+ if
+ (
+ (ubcsp_config.send_packet) &&
+ (ubcsp_config.send_packet->reliable)
+ )
+ {
+ /* We had sent a reliable packet, so clear this packet
+ Then increament the sequence number for the next packet */
+
+ ubcsp_config.send_packet = 0;
+ ubcsp_config.sequence_number ++;
+ ubcsp_config.delay = 0;
+
+ /* Notify the caller that we have SENT a packet */
+
+ activity |= UBCSP_PACKET_SENT;
+ }
+ }
+
+ /*** Now we can concentrate of the packet we have received ***/
+
+ /* Check for Link Establishment packets */
+
+ if (ubcsp_config.receive_packet->channel == 1)
+ {
+ /* Link Establishment */
+
+ ubcsp_config.delay = 0;
+
+ /* Find which link establishment packet this payload means
+ This could return 5, meaning none */
+
+ switch (ubcsp_which_le_payload (ubcsp_config.receive_packet->payload))
+ {
+ case 0:
+ {
+ /* SYNC Recv'd */
+
+#if SHOW_LE_STATES
+ printf ("Recv SYNC\n");
+#endif
+
+ /* If we receive a SYNC, then we respond to it with a SYNC RESP
+ but only if we are not active.
+ If we are active, then we have a PEER RESET */
+
+ if (ubcsp_config.link_establishment_state < ubcsp_le_active)
+ {
+ ubcsp_config.link_establishment_resp = 1;
+ }
+ else
+ {
+ /* Peer reset !!!! */
+
+#if SHOW_LE_STATES
+ printf ("\n\n\n\n\nPEER RESET\n\n");
+#endif
+
+ /* Reinitialize the link */
+
+ ubcsp_initialize ();
+
+ /* Tell the host what has happened */
+
+ return UBCSP_PEER_RESET;
+ }
+ break;
+ }
+
+ case 1:
+ {
+ /* SYNC RESP Recv'd */
+
+#if SHOW_LE_STATES
+ printf ("Recv SYNC RESP\n");
+#endif
+
+ /* If we receive a SYNC RESP, push us into the initialized state */
+
+ if (ubcsp_config.link_establishment_state < ubcsp_le_initialized)
+ {
+#if SHOW_LE_STATES
+ printf ("Link Initialized\n");
+#endif
+ ubcsp_config.link_establishment_state = ubcsp_le_initialized;
+ }
+
+ break;
+ }
+
+ case 2:
+ {
+ /* CONF Recv'd */
+
+#if SHOW_LE_STATES
+ printf ("Recv CONF\n");
+#endif
+
+ /* If we receive a CONF, and we are initialized or active
+ then respond with a CONF RESP */
+
+ if (ubcsp_config.link_establishment_state >= ubcsp_le_initialized)
+ {
+ ubcsp_config.link_establishment_resp = 2;
+ }
+
+ break;
+ }
+
+ case 3:
+ {
+ /* CONF RESP Recv'd */
+
+#if SHOW_LE_STATES
+ printf ("Recv CONF RESP\n");
+#endif
+
+ /* If we received a CONF RESP, then push us into the active state */
+
+ if (ubcsp_config.link_establishment_state < ubcsp_le_active)
+ {
+#if SHOW_LE_STATES
+ printf ("Link Active\n");
+#endif
+
+ ubcsp_config.link_establishment_state = ubcsp_le_active;
+ ubcsp_config.send_size = 0;
+
+ return activity | UBCSP_PACKET_SENT;
+ }
+
+ break;
+ }
+ }
+
+ /* We have finished processing Link Establishment packets */
+ }
+ else if (ubcsp_config.receive_index)
+ {
+ /* We have some payload data we need to process
+ but only if we are active - otherwise, we just ignore it */
+
+ if (ubcsp_config.link_establishment_state == ubcsp_le_active)
+ {
+ if (ubcsp_config.receive_packet->reliable)
+ {
+ /* If the packet we've just received was reliable
+ then send an ACK */
+
+ ubcsp_config.send_ack = 1;
+
+ /* We the sequence number we received is the same as
+ the last ACK we sent, then we have received a packet in sequence */
+
+ if (receive_seq == ubcsp_config.ack_number)
+ {
+ /* Increase the ACK number - which will be sent in the next ACK
+ or normal packet we send */
+
+ ubcsp_config.ack_number ++;
+
+ /* Set the values in the receive_packet structure, so the caller
+ knows how much data we have */
+
+ ubcsp_config.receive_packet->length = length;
+ ubcsp_config.receive_packet = 0;
+
+ /* Tell the caller that we have received a packet, and that it
+ will be ACK'ed */
+
+ activity |= UBCSP_PACKET_RECEIVED | UBCSP_PACKET_ACK;
+ }
+ }
+ else
+ {
+ /* Set the values in the receive_packet structure, so the caller
+ knows how much data we have */
+
+ ubcsp_config.receive_packet->length = length;
+ ubcsp_config.receive_packet = 0;
+
+ /* Tell the caller that we have received a packet */
+
+ activity |= UBCSP_PACKET_RECEIVED;
+ }
+ }
+ }
+
+ /* Just return any activity that occured */
+
+ return activity;
+}
+
+/*****************************************************************************/
+/** **/
+/** ubcsp_setup_packet **/
+/** **/
+/** This function is called to setup a packet to be sent **/
+/** This allows just a header, or a header and payload to be sent **/
+/** It also allows the header checksum to be precalcuated **/
+/** or calculated here **/
+/** part1 is always 4 bytes **/
+/** **/
+/*****************************************************************************/
+
+static void ubcsp_setup_packet (uint8 *part1, uint8 calc, uint8 *part2, uint16 len2)
+{
+ /* If we need to calculate the checksum, do that now */
+
+ if (calc)
+ {
+ part1[3] =
+ ~(part1[0] + part1[1] + part1[2]);
+ }
+
+ /* Setup the header send pointer and size so we can clock this out */
+
+ ubcsp_config.send_ptr = part1;
+ ubcsp_config.send_size = 4;
+
+ /* Setup the payload send pointer and size */
+
+ ubcsp_config.next_send_ptr = part2;
+ ubcsp_config.next_send_size = len2;
+
+#if UBCSP_CRC
+ /* Initialize the crc as required */
+
+ ubcsp_config.send_crc = -1;
+
+ ubcsp_config.need_send_crc = 1;
+#endif
+}
+
+/*****************************************************************************/
+/** **/
+/** ubcsp_sent_packet **/
+/** **/
+/** Called when we have finished sending a packet **/
+/** If this packet was unreliable, then notify caller, and clear the data **/
+/** **/
+/*****************************************************************************/
+
+static uint8 ubcsp_sent_packet (void)
+{
+ if (ubcsp_config.send_packet)
+ {
+ if (!ubcsp_config.send_packet->reliable)
+ {
+ /* We had a packet sent that was unreliable */
+
+ /* Forget about this packet */
+
+ ubcsp_config.send_packet = 0;
+
+ /* Notify caller that they can send another one */
+
+ return UBCSP_PACKET_SENT;
+ }
+ }
+
+ /* We didn't have a packet, or it was reliable
+ Must wait for ACK before allowing another packet to be sent */
+
+ return 0;
+}
+
+/*****************************************************************************/
+/** **/
+/** ubcsp_poll **/
+/** **/
+/** This is the main function for ubcsp **/
+/** It performs a number of tasks **/
+/** **/
+/** 1) Send another octet to the UART - escaping as required **/
+/** 2) Setup the payload to be sent after the header has been sent **/
+/** 3) Send the CRC for the packet if required **/
+/** **/
+/** 4) Calculate the next Link Establishment State **/
+/** 5) Send a Link Establishment packet **/
+/** 6) Send a normal packet if available **/
+/** 7) Send an ACK packet if required **/
+/** **/
+/** 8) Receive octets from UART and deslip them as required **/
+/** 9) Place received octets into receive header or receive payload buffer **/
+/** 10) Process received packet when SLIP_END is received **/
+/** **/
+/** 11) Keep track of ability of caller to delay recalling **/
+/** **/
+/*****************************************************************************/
+
+uint8 ubcsp_poll (uint8 *activity)
+{
+ uint8
+ delay = UBCSP_POLL_TIME_IMMEDIATE;
+
+ uint8
+ value;
+
+ /* Assume no activity to start with */
+
+ *activity = 0;
+
+ /* If we don't have to delay, then send something if we can */
+
+ if (!ubcsp_config.delay)
+ {
+ /* Do we have something we are sending to send */
+
+ if (ubcsp_config.send_size)
+ {
+ /* We have something to send so send it */
+
+ if (ubcsp_config.send_slip_escape)
+ {
+ /* Last time we send a SLIP_ESCAPE octet
+ this time send the second escape code */
+
+ put_uart (ubcsp_config.send_slip_escape);
+
+ ubcsp_config.send_slip_escape = 0;
+ }
+ else
+ {
+#if UBCSP_CRC
+ /* get the value to send, and calculate CRC as we go */
+
+ value = *ubcsp_config.send_ptr ++;
+
+ ubcsp_config.send_crc = ubcsp_calc_crc (value, ubcsp_config.send_crc);
+
+ /* Output the octet */
+
+ ubcsp_put_slip_uart (value);
+#else
+ /* Just output the octet*/
+
+ ubcsp_put_slip_uart (*ubcsp_config.send_ptr ++);
+#endif
+ }
+
+ /* If we did output a SLIP_ESCAPE, then don't process the end of a block */
+
+ if ((!ubcsp_config.send_slip_escape) && ((ubcsp_config.send_size = ubcsp_config.send_size - 1) == 0))
+ {
+ /*** We are at the end of a block - either header or payload ***/
+
+ /* setup the next block */
+
+ ubcsp_config.send_ptr = ubcsp_config.next_send_ptr;
+ ubcsp_config.send_size = ubcsp_config.next_send_size;
+ ubcsp_config.next_send_ptr = 0;
+ ubcsp_config.next_send_size = 0;
+
+#if UBCSP_CRC
+ /* If we have no successor block
+ then we might need to send the CRC */
+
+ if (!ubcsp_config.send_ptr)
+ {
+ if (ubcsp_config.need_send_crc)
+ {
+ /* reverse the CRC from what we computed along the way */
+
+ ubcsp_config.need_send_crc = 0;
+
+ ubcsp_config.send_crc = ubcsp_crc_reverse (ubcsp_config.send_crc);
+
+ /* Save in the send_crc buffer */
+
+ ubcsp_send_crc[0] = (uint8) (ubcsp_config.send_crc >> 8);
+ ubcsp_send_crc[1] = (uint8) ubcsp_config.send_crc;
+
+ /* Setup to send this buffer */
+
+ ubcsp_config.send_ptr = ubcsp_send_crc;
+ ubcsp_config.send_size = 2;
+ }
+ else
+ {
+ /* We don't need to send the crc
+ either we just have, or this packet doesn't include it */
+
+ /* Output the end of FRAME marker */
+
+ put_uart (SLIP_FRAME);
+
+ /* Check if this is an unreliable packet */
+
+ *activity |= ubcsp_sent_packet ();
+
+ /* We've sent the packet, so don't need to have be called quickly soon */
+
+ delay = UBCSP_POLL_TIME_DELAY;
+ }
+ }
+#else
+ /* If we have no successor block
+ then we might need to send the CRC */
+
+ if (!ubcsp_config.send_ptr)
+ {
+ /* Output the end of FRAME marker */
+
+ put_uart (SLIP_FRAME);
+
+ /* Check if this is an unreliable packet */
+
+ *activity |= ubcsp_sent_packet ();
+
+ /* We've sent the packet, so don't need to have be called quickly soon */
+
+ delay = UBCSP_POLL_TIME_DELAY;
+ }
+#endif
+ }
+ }
+ else if (ubcsp_config.link_establishment_packet == ubcsp_le_none)
+ {
+ /* We didn't have something to send
+ AND we have no Link Establishment packet to send */
+
+ if (ubcsp_config.link_establishment_resp & 2)
+ {
+ /* Send the start of FRAME packet */
+
+ put_uart (SLIP_FRAME);
+
+ /* We did require a RESP packet - so setup the send */
+
+ ubcsp_setup_packet ((uint8*) ubcsp_send_le_header, 0, (uint8*) ubcsp_le_buffer[ubcsp_le_conf_resp], 4);
+
+ /* We have now "sent" this packet */
+
+ ubcsp_config.link_establishment_resp = 0;
+ }
+ else if (ubcsp_config.send_packet)
+ {
+ /* There is a packet ready to be sent */
+
+ /* Send the start of FRAME packet */
+
+ put_uart (SLIP_FRAME);
+
+ /* Encode up the packet header using ACK and SEQ numbers */
+
+ ubcsp_send_header[0] =
+ (ubcsp_config.send_packet->reliable << 7) |
+#if UBCSP_CRC
+ 0x40 | /* Always use CRC's */
+#endif
+ (ubcsp_config.ack_number << 3) |
+ (ubcsp_config.sequence_number);
+
+ /* Encode up the packet header's channel and length */
+ ubcsp_send_header[1] =
+ (ubcsp_config.send_packet->channel & 0x0f) |
+ ((ubcsp_config.send_packet->length << 4) & 0xf0);
+
+ ubcsp_send_header[2] =
+ (ubcsp_config.send_packet->length >> 4) & 0xff;
+
+ /* Let the ubcsp_setup_packet function calculate the header checksum */
+
+ ubcsp_setup_packet ((uint8*) ubcsp_send_header, 1, ubcsp_config.send_packet->payload, ubcsp_config.send_packet->length);
+
+ /* Don't need to send an ACK - we just place on in this packet */
+
+ ubcsp_config.send_ack = 0;
+
+#if SHOW_PACKET_ERRORS
+ printf (" : %10d Send %d Ack %d\n",
+ GetTickCount () % 100000,
+ ubcsp_config.sequence_number,
+ ubcsp_config.ack_number);
+#endif
+ }
+ else if (ubcsp_config.send_ack)
+ {
+ /* Send the start of FRAME packet */
+
+ put_uart (SLIP_FRAME);
+
+#if SHOW_PACKET_ERRORS
+ printf (" : %10d Send ACK %d\n",
+ GetTickCount () % 100000,
+ ubcsp_config.ack_number);
+#endif
+
+ /* The ack packet is already computed apart from the first octet */
+
+ ubcsp_send_ack_header[0] =
+#if UBCSP_CRC
+ 0x40 |
+#endif
+ (ubcsp_config.ack_number << 3);
+
+ /* Let the ubcsp_setup_packet function calculate the header checksum */
+
+ ubcsp_setup_packet (ubcsp_send_ack_header, 1, 0, 0);
+
+ /* We've now sent the ack */
+
+ ubcsp_config.send_ack = 0;
+ }
+ else
+ {
+ /* We didn't have a Link Establishment response packet,
+ a normal packet or an ACK packet to send */
+
+ delay = UBCSP_POLL_TIME_DELAY;
+ }
+ }
+ else
+ {
+#if SHOW_PACKET_ERRORS
+// printf (" : %10d Send LE %d\n",
+// GetTickCount () % 100000,
+// ubcsp_config.link_establishment_packet);
+#endif
+
+ /* Send A Link Establishment Message */
+
+ put_uart (SLIP_FRAME);
+
+ /* Send the Link Establishment header followed by the
+ Link Establishment packet */
+
+ ubcsp_setup_packet ((uint8*) ubcsp_send_le_header, 0, (uint8*) ubcsp_le_buffer[ubcsp_config.link_establishment_packet], 4);
+
+ /* start sending immediately */
+
+ ubcsp_config.delay = 0;
+
+ /* workout what the next link establishment packet should be */
+
+ ubcsp_config.link_establishment_packet = next_le_packet[ubcsp_config.link_establishment_state + ubcsp_config.link_establishment_resp * 4];
+
+ /* We have now delt with any response packet that we needed */
+
+ ubcsp_config.link_establishment_resp = 0;
+
+ return 0;
+ }
+ }
+
+ /* We now need to receive any octets from the UART */
+
+ while ((ubcsp_config.receive_packet) && (get_uart (&value)))
+ {
+ /* If the last octet was SLIP_ESCAPE, then special processing is required */
+
+ if (ubcsp_config.receive_slip_escape)
+ {
+ /* WARNING - out of range values are not detected !!!
+ This will probably be caught with the checksum or CRC check */
+
+ value = ubcsp_deslip[value - SLIP_ESCAPE_FRAME];
+
+ ubcsp_config.receive_slip_escape = 0;
+ }
+ else
+ {
+ /* Check for the SLIP_FRAME octet - must be start or end of packet */
+ if (value == SLIP_FRAME)
+ {
+ /* If we had a full header then we have a packet */
+
+ if (ubcsp_config.receive_index >= 0)
+ {
+ /* process the received packet */
+
+ *activity |= ubcsp_recevied_packet ();
+
+ if (*activity & UBCSP_PACKET_ACK)
+ {
+ /* We need to ACK this packet, then don't delay its sending */
+ ubcsp_config.delay = 0;
+ }
+ }
+
+ /* Setup to receive the next packet */
+
+ ubcsp_config.receive_index = -4;
+
+ /* Ok, next octet */
+
+ goto finished_receive;
+ }
+ else if (value == SLIP_ESCAPE)
+ {
+ /* If we receive a SLIP_ESCAPE,
+ then remember to process the next special octet */
+
+ ubcsp_config.receive_slip_escape = 1;
+
+ goto finished_receive;
+ }
+ }
+
+ if (ubcsp_config.receive_index < 0)
+ {
+ /* We are still receiving the header */
+
+ ubcsp_receive_header[ubcsp_config.receive_index + 4] = value;
+
+ ubcsp_config.receive_index ++;
+ }
+ else if (ubcsp_config.receive_index < ubcsp_config.receive_packet->length)
+ {
+ /* We are receiving the payload */
+ /* We might stop comming here if we are receiving a
+ packet which is longer than the receive_packet->length
+ given by the host */
+
+ ubcsp_config.receive_packet->payload[ubcsp_config.receive_index] = value;
+
+ ubcsp_config.receive_index ++;
+ }
+
+finished_receive:
+ {
+ }
+ }
+
+ if (ubcsp_config.delay > 0)
+ {
+ /* We were delayed so delay some more
+ this could be cancelled if we received something */
+
+ ubcsp_config.delay --;
+ }
+ else
+ {
+ /* We had no delay, so use the delay we just decided to us */
+
+ ubcsp_config.delay = delay;
+ }
+
+ /* Report the current delay to the user */
+
+ return ubcsp_config.delay;
+}
diff --git a/tools/ubcsp.h b/tools/ubcsp.h
index 6a74e9a..59ce007 100644
--- a/tools/ubcsp.h
+++ b/tools/ubcsp.h
@@ -1,208 +1,208 @@
-/*
- *
- * BlueZ - Bluetooth protocol stack for Linux
- *
- * Copyright (C) 2000-2005 CSR Ltd.
- *
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
- * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- */
-
-#ifndef UBCSP_INCLUDE_H
-#define UBCSP_INCLUDE_H
-
-/*****************************************************************************/
-/*****************************************************************************/
-/*****************************************************************************/
-/** **/
-/** ubcsp.h **/
-/** **/
-/** MicroBCSP - a very low cost implementation of the BCSP protocol **/
-/** **/
-/*****************************************************************************/
-
-/* If we wish to use CRC's, then change 0 to 1 in the next line */
-#define UBCSP_CRC 1
-
-/* Define some basic types - change these for your architecture */
-typedef unsigned char uint8;
-typedef unsigned short uint16;
-typedef unsigned int uint32;
-typedef signed char int8;
-typedef signed short int16;
-typedef signed int int32;
-
-/* The defines below require a printf function to be available */
-
-/* Do we want to show packet errors in debug output */
-#define SHOW_PACKET_ERRORS 0
-
-/* Do we want to show Link Establishment State transitions in debug output */
-#define SHOW_LE_STATES 0
-
-/*****************************************************************************/
-/** **/
-/** ubcsp_packet **/
-/** **/
-/** This is description of a bcsp packet for the upper layer **/
-/** **/
-/*****************************************************************************/
-
-struct ubcsp_packet
-{
- uint8 channel; /* Which Channel this packet is to/from */
- uint8 reliable; /* Is this packet reliable */
- uint8 use_crc; /* Does this packet use CRC data protection */
- uint16 length; /* What is the length of the payload data */
- uint8 *payload; /* The payload data itself - size of length */
-};
-
-/*****************************************************************************/
-/** **/
-/** ubcsp_configuration **/
-/** **/
-/** This is the main configuration of the ubcsp engine **/
-/** All state variables are stored in this structure **/
-/** **/
-/*****************************************************************************/
-
-enum ubcsp_link_establishment_state
-{
- ubcsp_le_uninitialized,
- ubcsp_le_initialized,
- ubcsp_le_active
-};
-
-enum ubcsp_link_establishment_packet
-{
- ubcsp_le_sync,
- ubcsp_le_sync_resp,
- ubcsp_le_conf,
- ubcsp_le_conf_resp,
- ubcsp_le_none
-};
-
-struct ubcsp_configuration
-{
- uint8 link_establishment_state;
- uint8 link_establishment_resp;
- uint8 link_establishment_packet;
-
- uint8 sequence_number:3;
- uint8 ack_number:3;
- uint8 send_ack;
- struct ubcsp_packet *send_packet;
- struct ubcsp_packet *receive_packet;
-
- uint8 receive_header_checksum;
- uint8 receive_slip_escape;
- int32 receive_index;
-
- uint8 send_header_checksum;
-#ifdef UBCSP_CRC
- uint8 need_send_crc;
- uint16 send_crc;
-#endif
- uint8 send_slip_escape;
-
- uint8 *send_ptr;
- int32 send_size;
- uint8 *next_send_ptr;
- int32 next_send_size;
-
- int8 delay;
-};
-
-/*****************************************************************************/
-/** **/
-/** ubcsp_poll sets activity from an OR of these flags **/
-/** **/
-/*****************************************************************************/
-
-#define UBCSP_PACKET_SENT 0x01
-#define UBCSP_PACKET_RECEIVED 0x02
-#define UBCSP_PEER_RESET 0x04
-#define UBCSP_PACKET_ACK 0x08
-
-/*****************************************************************************/
-/** **/
-/** This is the functional interface for ucbsp **/
-/** **/
-/*****************************************************************************/
-
-void ubcsp_initialize (void);
-void ubcsp_send_packet (struct ubcsp_packet *send_packet);
-void ubcsp_receive_packet (struct ubcsp_packet *receive_packet);
-uint8 ubcsp_poll (uint8 *activity);
-
-/*****************************************************************************/
-/** **/
-/** Slip Escape Values **/
-/** **/
-/*****************************************************************************/
-
-#define SLIP_FRAME 0xC0
-#define SLIP_ESCAPE 0xDB
-#define SLIP_ESCAPE_FRAME 0xDC
-#define SLIP_ESCAPE_ESCAPE 0xDD
-
-/*****************************************************************************/
-/*****************************************************************************/
-/*****************************************************************************/
-
-/*****************************************************************************/
-/** **/
-/** These functions need to be linked into your system **/
-/** **/
-/*****************************************************************************/
-
-/*****************************************************************************/
-/** **/
-/** put_uart outputs a single octet over the UART Tx line **/
-/** **/
-/*****************************************************************************/
-
-extern void put_uart (uint8);
-
-/*****************************************************************************/
-/** **/
-/** get_uart receives a single octet over the UART Rx line **/
-/** if no octet is available, then this returns 0 **/
-/** if an octet was read, then this is returned in the argument and **/
-/** the function returns 1 **/
-/** **/
-/*****************************************************************************/
-
-extern uint8 get_uart (uint8 *);
-
-/*****************************************************************************/
-/** **/
-/** These defines should be changed to your systems concept of 100ms **/
-/** **/
-/*****************************************************************************/
-
-#define UBCSP_POLL_TIME_IMMEDIATE 0
-#define UBCSP_POLL_TIME_DELAY 25
-
-/*****************************************************************************/
-/*****************************************************************************/
-/*****************************************************************************/
+/*
+ *
+ * BlueZ - Bluetooth protocol stack for Linux
+ *
+ * Copyright (C) 2000-2005 CSR Ltd.
+ *
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#ifndef UBCSP_INCLUDE_H
+#define UBCSP_INCLUDE_H
+
+/*****************************************************************************/
+/*****************************************************************************/
+/*****************************************************************************/
+/** **/
+/** ubcsp.h **/
+/** **/
+/** MicroBCSP - a very low cost implementation of the BCSP protocol **/
+/** **/
+/*****************************************************************************/
+
+/* If we wish to use CRC's, then change 0 to 1 in the next line */
+#define UBCSP_CRC 1
+
+/* Define some basic types - change these for your architecture */
+typedef unsigned char uint8;
+typedef unsigned short uint16;
+typedef unsigned int uint32;
+typedef signed char int8;
+typedef signed short int16;
+typedef signed int int32;
+
+/* The defines below require a printf function to be available */
+
+/* Do we want to show packet errors in debug output */
+#define SHOW_PACKET_ERRORS 0
+
+/* Do we want to show Link Establishment State transitions in debug output */
+#define SHOW_LE_STATES 0
+
+/*****************************************************************************/
+/** **/
+/** ubcsp_packet **/
+/** **/
+/** This is description of a bcsp packet for the upper layer **/
+/** **/
+/*****************************************************************************/
+
+struct ubcsp_packet
+{
+ uint8 channel; /* Which Channel this packet is to/from */
+ uint8 reliable; /* Is this packet reliable */
+ uint8 use_crc; /* Does this packet use CRC data protection */
+ uint16 length; /* What is the length of the payload data */
+ uint8 *payload; /* The payload data itself - size of length */
+};
+
+/*****************************************************************************/
+/** **/
+/** ubcsp_configuration **/
+/** **/
+/** This is the main configuration of the ubcsp engine **/
+/** All state variables are stored in this structure **/
+/** **/
+/*****************************************************************************/
+
+enum ubcsp_link_establishment_state
+{
+ ubcsp_le_uninitialized,
+ ubcsp_le_initialized,
+ ubcsp_le_active
+};
+
+enum ubcsp_link_establishment_packet
+{
+ ubcsp_le_sync,
+ ubcsp_le_sync_resp,
+ ubcsp_le_conf,
+ ubcsp_le_conf_resp,
+ ubcsp_le_none
+};
+
+struct ubcsp_configuration
+{
+ uint8 link_establishment_state;
+ uint8 link_establishment_resp;
+ uint8 link_establishment_packet;
+
+ uint8 sequence_number:3;
+ uint8 ack_number:3;
+ uint8 send_ack;
+ struct ubcsp_packet *send_packet;
+ struct ubcsp_packet *receive_packet;
+
+ uint8 receive_header_checksum;
+ uint8 receive_slip_escape;
+ int32 receive_index;
+
+ uint8 send_header_checksum;
+#ifdef UBCSP_CRC
+ uint8 need_send_crc;
+ uint16 send_crc;
+#endif
+ uint8 send_slip_escape;
+
+ uint8 *send_ptr;
+ int32 send_size;
+ uint8 *next_send_ptr;
+ int32 next_send_size;
+
+ int8 delay;
+};
+
+/*****************************************************************************/
+/** **/
+/** ubcsp_poll sets activity from an OR of these flags **/
+/** **/
+/*****************************************************************************/
+
+#define UBCSP_PACKET_SENT 0x01
+#define UBCSP_PACKET_RECEIVED 0x02
+#define UBCSP_PEER_RESET 0x04
+#define UBCSP_PACKET_ACK 0x08
+
+/*****************************************************************************/
+/** **/
+/** This is the functional interface for ucbsp **/
+/** **/
+/*****************************************************************************/
+
+void ubcsp_initialize (void);
+void ubcsp_send_packet (struct ubcsp_packet *send_packet);
+void ubcsp_receive_packet (struct ubcsp_packet *receive_packet);
+uint8 ubcsp_poll (uint8 *activity);
+
+/*****************************************************************************/
+/** **/
+/** Slip Escape Values **/
+/** **/
+/*****************************************************************************/
+
+#define SLIP_FRAME 0xC0
+#define SLIP_ESCAPE 0xDB
+#define SLIP_ESCAPE_FRAME 0xDC
+#define SLIP_ESCAPE_ESCAPE 0xDD
+
+/*****************************************************************************/
+/*****************************************************************************/
+/*****************************************************************************/
+
+/*****************************************************************************/
+/** **/
+/** These functions need to be linked into your system **/
+/** **/
+/*****************************************************************************/
+
+/*****************************************************************************/
+/** **/
+/** put_uart outputs a single octet over the UART Tx line **/
+/** **/
+/*****************************************************************************/
+
+extern void put_uart (uint8);
+
+/*****************************************************************************/
+/** **/
+/** get_uart receives a single octet over the UART Rx line **/
+/** if no octet is available, then this returns 0 **/
+/** if an octet was read, then this is returned in the argument and **/
+/** the function returns 1 **/
+/** **/
+/*****************************************************************************/
+
+extern uint8 get_uart (uint8 *);
+
+/*****************************************************************************/
+/** **/
+/** These defines should be changed to your systems concept of 100ms **/
+/** **/
+/*****************************************************************************/
+
+#define UBCSP_POLL_TIME_IMMEDIATE 0
+#define UBCSP_POLL_TIME_DELAY 25
+
+/*****************************************************************************/
+/*****************************************************************************/
+/*****************************************************************************/
#endif
--
1.7.0.4
^ permalink raw reply related
* Re: [PATCH 1/6] Removed extra spaces at end of line in compat dir
From: José Antonio Santos Cadenas @ 2010-05-06 22:29 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1273184832-8265-1-git-send-email-santoscadenas@gmail.com>
Sorry, this subject should be:
Remove extra spaces at end of line in compat dir
I'll resend it.
El Friday 07 May 2010 00:27:07 Jose Antonio Santos Cadenas escribió:
> ---
> compat/bnep.c | 10 +++++-----
> compat/dun.c | 4 ++--
> compat/dund.c | 6 +++---
> compat/hidd.c | 2 +-
> compat/msdun.c | 8 ++++----
> compat/pand.c | 8 ++++----
> compat/sdp.c | 12 ++++++------
> 7 files changed, 25 insertions(+), 25 deletions(-)
>
> diff --git a/compat/bnep.c b/compat/bnep.c
> index 71eb0cc..2e4fb9d 100644
> --- a/compat/bnep.c
> +++ b/compat/bnep.c
> @@ -93,7 +93,7 @@ int bnep_init(void)
> }
>
> /* Temporary ioctl compatibility hack */
> - {
> + {
> struct bnep_connlist_req req;
> struct bnep_conninfo ci[1];
>
> @@ -194,19 +194,19 @@ static int bnep_connadd(int sk, uint16_t role, char *dev)
> return 0;
> }
>
> -struct __service_16 {
> +struct __service_16 {
> uint16_t dst;
> uint16_t src;
> } __attribute__ ((packed));
>
> -struct __service_32 {
> +struct __service_32 {
> uint16_t unused1;
> uint16_t dst;
> uint16_t unused2;
> uint16_t src;
> } __attribute__ ((packed));
>
> -struct __service_128 {
> +struct __service_128 {
> uint16_t unused1;
> uint16_t dst;
> uint16_t unused2[8];
> @@ -246,7 +246,7 @@ int bnep_accept_connection(int sk, uint16_t role, char *dev)
> return bnep_connadd(sk, role, dev);
> }
>
> -/* Create BNEP connection
> +/* Create BNEP connection
> * sk - Connect L2CAP socket
> * role - Local role
> * service - Remote service
> diff --git a/compat/dun.c b/compat/dun.c
> index 3f4b46f..59f036f 100644
> --- a/compat/dun.c
> +++ b/compat/dun.c
> @@ -158,7 +158,7 @@ static int dun_exec(char *tty, char *prog, char **args)
> {
> int pid = fork();
> int fd;
> -
> +
> switch (pid) {
> case -1:
> return -1;
> @@ -244,7 +244,7 @@ int dun_cleanup(void)
> static int show_conn(struct rfcomm_dev_info *di, unsigned long arg)
> {
> pid_t pid;
> -
> +
> if (di->state == BT_CONNECTED &&
> (di->flags & (1<<RFCOMM_REUSE_DLC)) &&
> (di->flags & (1<<RFCOMM_TTY_ATTACHED)) &&
> diff --git a/compat/dund.c b/compat/dund.c
> index deb2852..af1b536 100644
> --- a/compat/dund.c
> +++ b/compat/dund.c
> @@ -247,7 +247,7 @@ static int create_connection(char *dst, bdaddr_t *bdaddr, int mrouter)
> sa.rc_bdaddr = src_addr;
>
> if (bind(sk, (struct sockaddr *) &sa, sizeof(sa)))
> - syslog(LOG_ERR, "Bind failed. %s(%d)",
> + syslog(LOG_ERR, "Bind failed. %s(%d)",
> strerror(errno), errno);
>
> sa.rc_channel = ch;
> @@ -337,7 +337,7 @@ static int do_connect(void)
> for (i = 0; i < n; i++) {
> char dst[40];
> ba2str(&ii[i].bdaddr, dst);
> -
> +
> r = create_connection(dst, &ii[i].bdaddr, 0);
> if (r < 0) {
> terminate = 1;
> @@ -405,7 +405,7 @@ static struct option main_lopts[] = {
>
> static const char *main_sopts = "hsc:k:Kr:i:lnp::DQ::AESMP:C::P:Xam:u";
>
> -static const char *main_help =
> +static const char *main_help =
> "Bluetooth LAP (LAN Access over PPP) daemon version %s\n"
> "Usage:\n"
> "\tdund <options> [pppd options]\n"
> diff --git a/compat/hidd.c b/compat/hidd.c
> index 40bf663..88944cf 100644
> --- a/compat/hidd.c
> +++ b/compat/hidd.c
> @@ -573,7 +573,7 @@ static void do_search(int ctl, bdaddr_t *bdaddr, uint8_t subclass, int fakehid,
>
> for (i = 0; i < num_rsp; i++) {
> memcpy(class, (info+i)->dev_class, 3);
> - if ((class[0] == 0x00 && class[2] == 0x00 &&
> + if ((class[0] == 0x00 && class[2] == 0x00 &&
> (class[1] == 0x40 || class[1] == 0x1f)) ||
> (class[0] == 0x10 && class[1] == 0x02 && class[2] == 0x40)) {
> bacpy(&dst, &(info+i)->bdaddr);
> diff --git a/compat/msdun.c b/compat/msdun.c
> index 2d592d7..ae88c0c 100644
> --- a/compat/msdun.c
> +++ b/compat/msdun.c
> @@ -58,7 +58,7 @@ static int w4_str(int fd, char *str)
> char buf[40];
> unsigned len = 0;
> int r;
> -
> +
> while (1) {
> r = read(fd, buf + len, sizeof(buf) - len - 1);
> if (r < 0) {
> @@ -92,7 +92,7 @@ static int ms_server(int fd)
> write_n(fd, "CLIENTSERVER", 12);
> case MS_PPP:
> return MS_SUCCESS;
> - default:
> + default:
> return MS_FAILED;
> }
> }
> @@ -123,7 +123,7 @@ int ms_dun(int fd, int server, int timeo)
>
> alarm(0);
> signal(SIGALRM, osig);
> -
> +
> switch (r) {
> case MS_SUCCESS:
> case MS_PPP:
> @@ -142,7 +142,7 @@ int ms_dun(int fd, int server, int timeo)
> }
>
> alarm(timeout);
> -
> +
> if (server)
> r = ms_server(fd);
> else
> diff --git a/compat/pand.c b/compat/pand.c
> index e38cfb6..c3860fa 100644
> --- a/compat/pand.c
> +++ b/compat/pand.c
> @@ -343,7 +343,7 @@ static int create_connection(char *dst, bdaddr_t *bdaddr)
> bacpy(&l2a.l2_bdaddr, bdaddr);
> l2a.l2_psm = htobs(BNEP_PSM);
>
> - if (!connect(sk, (struct sockaddr *) &l2a, sizeof(l2a)) &&
> + if (!connect(sk, (struct sockaddr *) &l2a, sizeof(l2a)) &&
> !bnep_create_connection(sk, role, service, netdev)) {
>
> syslog(LOG_INFO, "%s connected", netdev);
> @@ -430,7 +430,7 @@ static int do_connect(void)
> ba2str(&ii[i].bdaddr, dst);
>
> if (use_sdp) {
> - syslog(LOG_INFO, "Searching for %s on %s",
> + syslog(LOG_INFO, "Searching for %s on %s",
> bnep_svc2str(service), dst);
>
> if (bnep_sdp_search(&src_addr, &ii[i].bdaddr, service) <= 0)
> @@ -488,7 +488,7 @@ static int write_pidfile(void)
> strerror(errno), errno);
> return -1;
> }
> -
> +
> /* We're already running; send a SIGHUP (we presume that they
> * are calling ifup for a reason, so they probably want to
> * rescan) and then exit cleanly and let things go on in the
> @@ -571,7 +571,7 @@ static struct option main_lopts[] = {
>
> static const char *main_sopts = "hsc:k:Kr:d:e:i:lnp::DQ::AESMC::P:u:o:z";
>
> -static const char *main_help =
> +static const char *main_help =
> "Bluetooth PAN daemon version %s\n"
> "Usage:\n"
> "\tpand <options>\n"
> diff --git a/compat/sdp.c b/compat/sdp.c
> index 358a02c..8898136 100644
> --- a/compat/sdp.c
> +++ b/compat/sdp.c
> @@ -368,7 +368,7 @@ int get_alternate_device_info(const bdaddr_t *src, const bdaddr_t *dst, uint16_t
> return -EIO;
> }
>
> -void bnep_sdp_unregister(void)
> +void bnep_sdp_unregister(void)
> {
> if (record && sdp_record_unregister(session, record))
> syslog(LOG_ERR, "Service record unregistration failed.");
> @@ -424,7 +424,7 @@ int bnep_sdp_register(bdaddr_t *device, uint16_t role)
>
> /* Supported protocols */
> {
> - uint16_t ptype[4] = {
> + uint16_t ptype[4] = {
> 0x0800, /* IPv4 */
> 0x0806, /* ARP */
> };
> @@ -483,7 +483,7 @@ int bnep_sdp_register(bdaddr_t *device, uint16_t role)
> profile[0].version = 0x0100;
> pfseq = sdp_list_append(NULL, &profile[0]);
> sdp_set_profile_descs(record, pfseq);
> -
> +
> sdp_set_info_attr(record, "Group Network Service", name, desc);
> break;
>
> @@ -558,7 +558,7 @@ int bnep_sdp_search(bdaddr_t *src, bdaddr_t *dst, uint16_t service)
> static unsigned char async_uuid[] = { 0x03, 0x50, 0x27, 0x8F, 0x3D, 0xCA, 0x4E, 0x62,
> 0x83, 0x1D, 0xA4, 0x11, 0x65, 0xFF, 0x90, 0x6C };
>
> -void dun_sdp_unregister(void)
> +void dun_sdp_unregister(void)
> {
> if (record && sdp_record_unregister(session, record))
> syslog(LOG_ERR, "Service record unregistration failed.");
> @@ -575,7 +575,7 @@ int dun_sdp_register(bdaddr_t *device, uint8_t channel, int type)
>
> session = sdp_connect(BDADDR_ANY, BDADDR_LOCAL, 0);
> if (!session) {
> - syslog(LOG_ERR, "Failed to connect to the local SDP server. %s(%d)",
> + syslog(LOG_ERR, "Failed to connect to the local SDP server. %s(%d)",
> strerror(errno), errno);
> return -1;
> }
> @@ -670,7 +670,7 @@ int dun_sdp_search(bdaddr_t *src, bdaddr_t *dst, int *channel, int type)
>
> s = sdp_connect(src, dst, 0);
> if (!s) {
> - syslog(LOG_ERR, "Failed to connect to the SDP server. %s(%d)",
> + syslog(LOG_ERR, "Failed to connect to the SDP server. %s(%d)",
> strerror(errno), errno);
> return -1;
> }
>
^ permalink raw reply
* Re: multiple HCI_UART protocols over hci_ldisc
From: Max Krasnyansky @ 2010-05-06 22:30 UTC (permalink / raw)
To: Pavan Savoy; +Cc: linux-bluetooth@vger.kernel.org, Marcel Holtmann
In-Reply-To: <987394.67247.qm@web94902.mail.in2.yahoo.com>
On 05/06/2010 03:04 PM, Pavan Savoy wrote:
> Hi Marcel,
>
> I am working on a line discipline which in many respects is similar to the hci_ldisc, but only extended to do plenty of other functionality.
>
> One road block which i have hit is to support multiple devices/or as Alan Cox puts it "avoid single device limits"
>
> So, in somewhat relation to this, I wanted to ask, If in a system I have 2 UARTs both connected to BT chips but only from different vendors say TI/HCI-Ll and broadcomm with BCSP ..
>
> Can I have those 2 protocols on top of HCI-ldisc on different UARTs at the same time?
> Is something like that feasible?
Sure. You'll get two separate HCI devices in that case.
Max
^ permalink raw reply
* [PATCH 1/6] Remove extra spaces at end of line in compat dir
From: Jose Antonio Santos Cadenas @ 2010-05-06 22:30 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Jose Antonio Santos Cadenas
In-Reply-To: <1273184832-8265-1-git-send-email-santoscadenas@gmail.com>
---
compat/bnep.c | 10 +++++-----
compat/dun.c | 4 ++--
compat/dund.c | 6 +++---
compat/hidd.c | 2 +-
compat/msdun.c | 8 ++++----
compat/pand.c | 8 ++++----
compat/sdp.c | 12 ++++++------
7 files changed, 25 insertions(+), 25 deletions(-)
diff --git a/compat/bnep.c b/compat/bnep.c
index 71eb0cc..2e4fb9d 100644
--- a/compat/bnep.c
+++ b/compat/bnep.c
@@ -93,7 +93,7 @@ int bnep_init(void)
}
/* Temporary ioctl compatibility hack */
- {
+ {
struct bnep_connlist_req req;
struct bnep_conninfo ci[1];
@@ -194,19 +194,19 @@ static int bnep_connadd(int sk, uint16_t role, char *dev)
return 0;
}
-struct __service_16 {
+struct __service_16 {
uint16_t dst;
uint16_t src;
} __attribute__ ((packed));
-struct __service_32 {
+struct __service_32 {
uint16_t unused1;
uint16_t dst;
uint16_t unused2;
uint16_t src;
} __attribute__ ((packed));
-struct __service_128 {
+struct __service_128 {
uint16_t unused1;
uint16_t dst;
uint16_t unused2[8];
@@ -246,7 +246,7 @@ int bnep_accept_connection(int sk, uint16_t role, char *dev)
return bnep_connadd(sk, role, dev);
}
-/* Create BNEP connection
+/* Create BNEP connection
* sk - Connect L2CAP socket
* role - Local role
* service - Remote service
diff --git a/compat/dun.c b/compat/dun.c
index 3f4b46f..59f036f 100644
--- a/compat/dun.c
+++ b/compat/dun.c
@@ -158,7 +158,7 @@ static int dun_exec(char *tty, char *prog, char **args)
{
int pid = fork();
int fd;
-
+
switch (pid) {
case -1:
return -1;
@@ -244,7 +244,7 @@ int dun_cleanup(void)
static int show_conn(struct rfcomm_dev_info *di, unsigned long arg)
{
pid_t pid;
-
+
if (di->state == BT_CONNECTED &&
(di->flags & (1<<RFCOMM_REUSE_DLC)) &&
(di->flags & (1<<RFCOMM_TTY_ATTACHED)) &&
diff --git a/compat/dund.c b/compat/dund.c
index deb2852..af1b536 100644
--- a/compat/dund.c
+++ b/compat/dund.c
@@ -247,7 +247,7 @@ static int create_connection(char *dst, bdaddr_t *bdaddr, int mrouter)
sa.rc_bdaddr = src_addr;
if (bind(sk, (struct sockaddr *) &sa, sizeof(sa)))
- syslog(LOG_ERR, "Bind failed. %s(%d)",
+ syslog(LOG_ERR, "Bind failed. %s(%d)",
strerror(errno), errno);
sa.rc_channel = ch;
@@ -337,7 +337,7 @@ static int do_connect(void)
for (i = 0; i < n; i++) {
char dst[40];
ba2str(&ii[i].bdaddr, dst);
-
+
r = create_connection(dst, &ii[i].bdaddr, 0);
if (r < 0) {
terminate = 1;
@@ -405,7 +405,7 @@ static struct option main_lopts[] = {
static const char *main_sopts = "hsc:k:Kr:i:lnp::DQ::AESMP:C::P:Xam:u";
-static const char *main_help =
+static const char *main_help =
"Bluetooth LAP (LAN Access over PPP) daemon version %s\n"
"Usage:\n"
"\tdund <options> [pppd options]\n"
diff --git a/compat/hidd.c b/compat/hidd.c
index 40bf663..88944cf 100644
--- a/compat/hidd.c
+++ b/compat/hidd.c
@@ -573,7 +573,7 @@ static void do_search(int ctl, bdaddr_t *bdaddr, uint8_t subclass, int fakehid,
for (i = 0; i < num_rsp; i++) {
memcpy(class, (info+i)->dev_class, 3);
- if ((class[0] == 0x00 && class[2] == 0x00 &&
+ if ((class[0] == 0x00 && class[2] == 0x00 &&
(class[1] == 0x40 || class[1] == 0x1f)) ||
(class[0] == 0x10 && class[1] == 0x02 && class[2] == 0x40)) {
bacpy(&dst, &(info+i)->bdaddr);
diff --git a/compat/msdun.c b/compat/msdun.c
index 2d592d7..ae88c0c 100644
--- a/compat/msdun.c
+++ b/compat/msdun.c
@@ -58,7 +58,7 @@ static int w4_str(int fd, char *str)
char buf[40];
unsigned len = 0;
int r;
-
+
while (1) {
r = read(fd, buf + len, sizeof(buf) - len - 1);
if (r < 0) {
@@ -92,7 +92,7 @@ static int ms_server(int fd)
write_n(fd, "CLIENTSERVER", 12);
case MS_PPP:
return MS_SUCCESS;
- default:
+ default:
return MS_FAILED;
}
}
@@ -123,7 +123,7 @@ int ms_dun(int fd, int server, int timeo)
alarm(0);
signal(SIGALRM, osig);
-
+
switch (r) {
case MS_SUCCESS:
case MS_PPP:
@@ -142,7 +142,7 @@ int ms_dun(int fd, int server, int timeo)
}
alarm(timeout);
-
+
if (server)
r = ms_server(fd);
else
diff --git a/compat/pand.c b/compat/pand.c
index e38cfb6..c3860fa 100644
--- a/compat/pand.c
+++ b/compat/pand.c
@@ -343,7 +343,7 @@ static int create_connection(char *dst, bdaddr_t *bdaddr)
bacpy(&l2a.l2_bdaddr, bdaddr);
l2a.l2_psm = htobs(BNEP_PSM);
- if (!connect(sk, (struct sockaddr *) &l2a, sizeof(l2a)) &&
+ if (!connect(sk, (struct sockaddr *) &l2a, sizeof(l2a)) &&
!bnep_create_connection(sk, role, service, netdev)) {
syslog(LOG_INFO, "%s connected", netdev);
@@ -430,7 +430,7 @@ static int do_connect(void)
ba2str(&ii[i].bdaddr, dst);
if (use_sdp) {
- syslog(LOG_INFO, "Searching for %s on %s",
+ syslog(LOG_INFO, "Searching for %s on %s",
bnep_svc2str(service), dst);
if (bnep_sdp_search(&src_addr, &ii[i].bdaddr, service) <= 0)
@@ -488,7 +488,7 @@ static int write_pidfile(void)
strerror(errno), errno);
return -1;
}
-
+
/* We're already running; send a SIGHUP (we presume that they
* are calling ifup for a reason, so they probably want to
* rescan) and then exit cleanly and let things go on in the
@@ -571,7 +571,7 @@ static struct option main_lopts[] = {
static const char *main_sopts = "hsc:k:Kr:d:e:i:lnp::DQ::AESMC::P:u:o:z";
-static const char *main_help =
+static const char *main_help =
"Bluetooth PAN daemon version %s\n"
"Usage:\n"
"\tpand <options>\n"
diff --git a/compat/sdp.c b/compat/sdp.c
index 358a02c..8898136 100644
--- a/compat/sdp.c
+++ b/compat/sdp.c
@@ -368,7 +368,7 @@ int get_alternate_device_info(const bdaddr_t *src, const bdaddr_t *dst, uint16_t
return -EIO;
}
-void bnep_sdp_unregister(void)
+void bnep_sdp_unregister(void)
{
if (record && sdp_record_unregister(session, record))
syslog(LOG_ERR, "Service record unregistration failed.");
@@ -424,7 +424,7 @@ int bnep_sdp_register(bdaddr_t *device, uint16_t role)
/* Supported protocols */
{
- uint16_t ptype[4] = {
+ uint16_t ptype[4] = {
0x0800, /* IPv4 */
0x0806, /* ARP */
};
@@ -483,7 +483,7 @@ int bnep_sdp_register(bdaddr_t *device, uint16_t role)
profile[0].version = 0x0100;
pfseq = sdp_list_append(NULL, &profile[0]);
sdp_set_profile_descs(record, pfseq);
-
+
sdp_set_info_attr(record, "Group Network Service", name, desc);
break;
@@ -558,7 +558,7 @@ int bnep_sdp_search(bdaddr_t *src, bdaddr_t *dst, uint16_t service)
static unsigned char async_uuid[] = { 0x03, 0x50, 0x27, 0x8F, 0x3D, 0xCA, 0x4E, 0x62,
0x83, 0x1D, 0xA4, 0x11, 0x65, 0xFF, 0x90, 0x6C };
-void dun_sdp_unregister(void)
+void dun_sdp_unregister(void)
{
if (record && sdp_record_unregister(session, record))
syslog(LOG_ERR, "Service record unregistration failed.");
@@ -575,7 +575,7 @@ int dun_sdp_register(bdaddr_t *device, uint8_t channel, int type)
session = sdp_connect(BDADDR_ANY, BDADDR_LOCAL, 0);
if (!session) {
- syslog(LOG_ERR, "Failed to connect to the local SDP server. %s(%d)",
+ syslog(LOG_ERR, "Failed to connect to the local SDP server. %s(%d)",
strerror(errno), errno);
return -1;
}
@@ -670,7 +670,7 @@ int dun_sdp_search(bdaddr_t *src, bdaddr_t *dst, int *channel, int type)
s = sdp_connect(src, dst, 0);
if (!s) {
- syslog(LOG_ERR, "Failed to connect to the SDP server. %s(%d)",
+ syslog(LOG_ERR, "Failed to connect to the SDP server. %s(%d)",
strerror(errno), errno);
return -1;
}
--
1.7.0.4
^ permalink raw reply related
* Re: multiple HCI_UART protocols over hci_ldisc
From: Pavan Savoy @ 2010-05-06 22:38 UTC (permalink / raw)
To: Max Krasnyansky; +Cc: linux-bluetooth@vger.kernel.org, Marcel Holtmann
In-Reply-To: <4BE342F5.3060200@qualcomm.com>
Max,=0A=0A--- On Fri, 7/5/10, Max Krasnyansky <maxk@qualcomm.com> wrote:=0A=
=0A> From: Max Krasnyansky <maxk@qualcomm.com>=0A> Subject: Re: multiple HC=
I_UART protocols over hci_ldisc=0A> To: "Pavan Savoy" <pavan_savoy@yahoo.co=
.in>=0A> Cc: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel=
.org>, "Marcel Holtmann" <marcel@holtmann.org>=0A> Date: Friday, 7 May, 201=
0, 4:00 AM=0A> On 05/06/2010 03:04 PM, Pavan Savoy=0A> wrote:=0A> > Hi Marc=
el,=0A> >=0A> > I am working on a line discipline which in many=0A> respect=
s is similar to the hci_ldisc, but only extended to=0A> do plenty of other =
functionality.=0A> >=0A> > One road block which i have hit is to support mu=
ltiple=0A> devices/or as Alan Cox puts it "avoid single device limits"=0A> =
>=0A> > So, in somewhat relation to this, I wanted to ask, If=0A> in a syst=
em I have 2 UARTs both connected to BT chips but=0A> only from different ve=
ndors say TI/HCI-Ll and broadcomm with=0A> BCSP ..=0A> >=0A> > Can I have t=
hose 2 protocols on top of HCI-ldisc on=0A> different UARTs at the same tim=
e?=0A> > Is something like that feasible?=0A> Sure. You'll get two separate=
HCI devices in that case.=0A=0ABut there seems to be only 1,=0Astatic stru=
ct hci_uart_proto *hup[HCI_UART_MAX_PROTO];=0Aint hci_uart_register_proto(s=
truct hci_uart_proto *p)=0A{=0A if (p->id >=3D HCI_UART_MAX_PROTO)=
=0A return -EINVAL;=0A=0A if (hup[p->id])=0A =
return -EEXIST;=0A=0A hup[p->id] =3D p;=0A=0A return 0=
;=0A}=0A=0ASo, If suppose I have 2 UARTs both on which HCI-Ldisc exists, an=
d I try say HCI-LL on both, Now won't I get a -EEXIST for the 2nd HCI-LL ?=
=0A=0AI am a bit confused, can you explain in brief ?=0AIs there a possibil=
ity of copies of *hup[HCI_UART_MAX_PROTO] for each UART?=0A=0A> Max=0A> =0A=
=0A
^ permalink raw reply
* Re: [PATCH 6/6] Change end of line from DOS to UNIX
From: Johan Hedberg @ 2010-05-06 22:56 UTC (permalink / raw)
To: Jose Antonio Santos Cadenas; +Cc: linux-bluetooth, marcel
In-Reply-To: <1273184832-8265-6-git-send-email-santoscadenas@gmail.com>
Hi,
On Fri, May 07, 2010, Jose Antonio Santos Cadenas wrote:
> Files tools/ubcsp.c and tools/ubcsp.h had DOS end of line now they
> are changed to UNIX end of line
> ---
> tools/ubcsp.c | 2360 ++++++++++++++++++++++++++++----------------------------
> tools/ubcsp.h | 414 +++++-----
> 2 files changed, 1387 insertions(+), 1387 deletions(-)
Thanks for these cleanup patches. I've pushed the first five upstream
but am a little bit hesitant about this sixth one since it essentially
replaces every line in the existing file and I'm not sure if it's worth
having that obfuscating the commit history (e.g. git blame wouldn't be
useful anymore). Marcel, do you have any opinion about having a patch
like that in the tree?
Johan
^ permalink raw reply
* Re: HDP proposed api (ver 0.2)
From: Elvis Pfützenreuter @ 2010-05-06 23:49 UTC (permalink / raw)
To: jcaden; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <201005051255.09394.jcaden@libresoft.es>
Hi,
On 05/05/2010, at 07:55, José Antonio Santos Cadenas wrote:
>
> Health Device Profile hierarchy
> ===============================
>
> Service org.bluez
> Interface org.bluez.Hdp
> Object path [variable prefix]/{hci0,hci1,...}
>
> Methods object CreateSession(object path, dict config)
>
> Returns the object path for the new HDP session.
> The path parameter is the path of the remote object
> with the callbacks to nofity events (see
> org.bluez.HdpAgent at the end of this document)
> This petition starts an mcap session and also register
> in the SDP is needed
> Dict is defined as bellow:
> { "data_spec" : The data_spec is the data exchange
> specficication (see section 5.2.10 of
> the specification document),
> (optional)
Would be nice to include a "survival kit" about this 5.2.10, for completeness.
Like (normally = 0x01 [IEEE xxxxx], 0x00 = reserved, 0x02 = other -- )
> "end_points" : [{ (optional)
> "mdepid" : uint8, (optional)
> "role" : uint8, (mandatory)
We could use strings there, 'source' or 'sink'?
> "specs" :[{ (mandatory)
> "dtype" : uint16, (mandatory)
IMHO the key names may be more descriptive, like data_type. More about this below.
Another thing: as far as I understand, I may create a session, with well-defined MDEP IDs, roles etc. but then choose not to publish a SDP record. For example, I am an HDP source and want to have 5 MDEPs. An additional bool dict key like 'export' or 'publish' (not sure about correct BT nomenclature) would fit the bill.
"Forcing" a source to specify the MDEP IDs here, even if not publishing the record, makes checks easier further.
> "description" : string, (optional)
> }]
> }]
> }
>
> if "data_spec" is not set, no SDP record will be
> registerd, so all the other data in the dictionary
> will be ignored
See comments above
>
> Session will be closed by the call or implicitly when
> the programs leaves the bus.
>
> Possible errors: org.bluez.Error.InvalidArguments
>
> void DeleteSession(object path)
>
> Delete the HDP session identified by the object path.
> Also session will be closed if the procces that started
> it is removed from the D-Bus.
>
> Possible errors: org.bluez.Error.InvalidArguments
> org.bluez.Error.NotFound
>
> array remote_session_properties GetRemotesSessions()
typo
>
> Returns an array with the remote session_properties
> of all the visible devices.
> remote_session_properties is a dictionary like:
> [{"session_id": a_session_identification (int or string,
> probably the SDP handler + btaddr)
> "data_spec" : the remote data spec,
> "end_points":
> ["mdepid": uint8,
> "role" : uint8,
> "specs" : [{
> "dtype" : uint16,
> "description" : string, (optional)
> }]
> ]
> }]
>
> Note that only remotes with a SDP record will be
> notified by this function.
I don't get the concept of "remote sessions" of the current proposal. I understand the HDP session as a kind of "context" which holds the rest of HDP elements (published records, connections etc.)
Perhaps you meant "SDP records of HDP devices"? If so, IMHO this method should return just a list of device paths, which in turn would implement a BlueZ HDP interface that supplies further information (like my API proposal did).
I see some spread between org.bluez.Hdp and org.bluez.HdpSession. IMHO would be better to have just the context creation, as simple as possible, in org.bluez.Hdp and have everything else in org.bluez.HdpSession. (I still prefer the approach of "my" API, but I recognize that you are accomodating the notion of multiple records per [process, device] tuple.)
>
> --------------------------------------------------------------------------------
>
> Service org.bluez
> Interface org.bluez.HdpSession
> Object path [variable prefix]/{hci0,hci1,...}/{hdp0,hdp1,...}
>
> object Connect(remote_session_id)
>
> Connects with the remote session and returns its object
> path.
>
> Possible errors: org.bluez.Error.InvalidArguments
> org.bluez.Error.HdpError
>
> void Disconnect(object device, boolean delete)
>
> Disconnect from the remote device. If delete is true, any
> status will also be deleted. Otherwise, the status will
> be keeped for allowing future reconnections.
>
> Possible errors: org.bluez.Error.InvalidArguments
> org.bluez.Error.NotFound
> org.bluez.Error.HdpError
>
> --------------------------------------------------------------------------------
>
> Service org.bluez
> Interface org.bluez.HdpRemoteSession
> Object path [variable prefix]/{hci0,hci1,...}/{hdp0,hdp1,...}/rem_session_id
IMHO "remote session" feels funny. "Device record" would sound better (it is a device, so it is implied to be remote; and a record, which implies a given SDP record).
Also, I think that the device path (appended by an unique identifier of the record) would be better. After all, that path already exists when device is around.
Perhaps you tried to accomodate the notion that a data channel ID "survives" even if the device disappearrs for a short moment?
>
> boolean Echo(array{byte})
>
> Sends an echo petition to the remote session. Return True
> if response matches with the buffer sended. If some error
> is detected False value is returned and the associated
> MCL is closed.
Ok
>
> uint16 OpenDc(byte mdepid, byte config)
Could be OpenDataChannel?
>
> Creates a new data channel with the indicated config
> to the remote MCAP Data End Point (MDEP).
> The configuration should indicate the channel quality of
> service.
> Returns the data channel id.
>
> Possible errors: org.bluez.Error.InvalidArguments
> org.bluez.Error.HdpError
>
> file_descriptor GetDcFd(uint16 mdlid)
This FD should be delivered via HdpAgent exclusively. I have counted three ways an application can receive an FD, IMHO there should be exactly one.
>
> Gets a file descriptor where data can be readed or
> writed for receive or sent by the data channel.
> Returns the file descriptor
>
> Possible errors: org.bluez.Error.InvalidArguments
> org.bluez.Error.NotFound
> org.bluez.Error.HdpError
>
> void DeleteDc(uint16 mdlid)
DeleteDataChannel
>
> Deletes a data channel so it will not be available for
> use.
>
> Possible errors: org.bluez.Error.InvalidArguments
> org.bluez.Error.NotFound
> org.bluez.Error.HdpError
>
> void DeleteAllDc()
Could be overloaded with DeleteDataChannel with MDL ID = 0, perhaps, but nothing incredibly important :)
>
> Deletes all data channels so it will not be available
> for use. Typically this function is called when the
> connection with the remote device will be closed
> permanently
>
> Possible errors: org.bluez.Error.HdpError
>
> uint16 FirstRelDc()
>
> Returns the identificator of the first reliable data
> channel (ERTM) connected for this device.
>
> Possible errors: org.bluez.Error.HdpError
>
> uint16 GetBestEfforDc()
>
> Returns the id of a best effort (streamming) data
> channel if any.
>
> Possible errors: org.bluez.Error.NotFound
An use case would be good. In my vision, the application should just have one way to get the whole data connection list, and do whatever it wants, and not one new method for each type. We can e.g. guarantee that such list is in order, so the application can trust e.g. the first reliable channel on list to be what FirstRelDc() meant to return. (HDP mandates the first data channel to be reliable anyway.)
>
> array getStatus()
>
> Returns an array with all the data channels available
>
> returned array:
> [uint16, ...]
>
> Possible errors: org.bluez.Error.NotFound
Available = connected, open (MDL ID has been created) or...?
>
> HDPAgent hierarchy
> ==================
>
> (this object is implemented by the HDP client an receives notifications)
>
> Service unique name
> Interface org.bluez.HdpAgent
> Object path freely definable
>
> void DeviceConnected(object path)
>
> This method is called whenever a new device connection
> has been established over the control channel of the
> current HDP session. The objectpath contains the object
> path of the remote device.
>
> void DeviceDisconnected(object path)
>
> This method is called when a remote device is
> disconnected definitively. Any future reconnections
> will fail. Also all data channels associated to this
> device will be closed.
Perfect up to this part.
>
> void CreatedDc(object path, uint16 mdlid, filedescriptor fd)
Could be "DataChannelCreated"?
>
> This method is called when a new data channel is created
> The path contains the object path of the device whith
> the new connection is created, the mdlid the data
> channel identificator and the fd is the file descriptor
> where the data can be readed or writed.
>
> void DeletedDc(object path, uint16 mdlid)
DataChannelDeleted?
>
> This method is called when a data channel is closed.
> After this call the data channel will not be valid and
> can be reused for future created data channels.
>
> void DataReady(object path, uint16 mdlid, filedescriptor fd)
>
> This method is called when there is new data that can be
> readed in a data channel
This one I don't understand. It seems to duplicate the function of CreatedDc, even the prototype is exactly the same. Has this something to have with reconnections? (Even so, CreatedDc could be overloaded with this.)
>
> void RemoteSession(dict remote_session_properties)
>
> This methos is called when a new session is discorevered
> in a remote device. See Hdp.GetRemotes to know how the
> dictionary is formed.
Same comment about the concept of remote session.
^ permalink raw reply
* Re: multiple HCI_UART protocols over hci_ldisc
From: Suraj Sumangala @ 2010-05-07 4:46 UTC (permalink / raw)
To: Pavan Savoy
Cc: Max Krasnyansky, linux-bluetooth@vger.kernel.org, Marcel Holtmann
In-Reply-To: <549642.78851.qm@web94902.mail.in2.yahoo.com>
Hi pavan,
Pavan Savoy wrote:
> Max,
>
> --- On Fri, 7/5/10, Max Krasnyansky <maxk@qualcomm.com> wrote:
>
>> From: Max Krasnyansky <maxk@qualcomm.com>
>> Subject: Re: multiple HCI_UART protocols over hci_ldisc
>> To: "Pavan Savoy" <pavan_savoy@yahoo.co.in>
>> Cc: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>, "Marcel Holtmann" <marcel@holtmann.org>
>> Date: Friday, 7 May, 2010, 4:00 AM
>> On 05/06/2010 03:04 PM, Pavan Savoy
>> wrote:
>>> Hi Marcel,
>>>
>>> I am working on a line discipline which in many
>> respects is similar to the hci_ldisc, but only extended to
>> do plenty of other functionality.
>>> One road block which i have hit is to support multiple
>> devices/or as Alan Cox puts it "avoid single device limits"
>>> So, in somewhat relation to this, I wanted to ask, If
>> in a system I have 2 UARTs both connected to BT chips but
>> only from different vendors say TI/HCI-Ll and broadcomm with
>> BCSP ..
>>> Can I have those 2 protocols on top of HCI-ldisc on
>> different UARTs at the same time?
>>> Is something like that feasible?
>> Sure. You'll get two separate HCI devices in that case.
>
> But there seems to be only 1,
> static struct hci_uart_proto *hup[HCI_UART_MAX_PROTO];
> int hci_uart_register_proto(struct hci_uart_proto *p)
> {
> if (p->id >= HCI_UART_MAX_PROTO)
> return -EINVAL;
>
> if (hup[p->id])
> return -EEXIST;
>
> hup[p->id] = p;
>
> return 0;
> }
>
> So, If suppose I have 2 UARTs both on which HCI-Ldisc exists, and I try say HCI-LL on both, Now won't I get a -EEXIST for the 2nd HCI-LL ?
>
> I am a bit confused, can you explain in brief ?
> Is there a possibility of copies of *hup[HCI_UART_MAX_PROTO] for each UART?
>
>> Max
>>
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
The call "hci_uart_register_proto()" is used to register each protocol,
not each device.
Each protocol calls this API to register themselves during module load,
and will be called only once for each protocol during the module's lifetime.
Checkout the functions under #ifdef inside "hci_uart_init()". each of
them will be calling "hci_uart_register_proto()" to register themselves.
Whenever you attach a UART BT device, "hci_uart_set_proto()" will be
called and this will be responsible for creating an hci device, Not
"hci_uart_register_proto()"
Regards
Suraj
^ permalink raw reply
* Re: [PATCH 6/6] Change end of line from DOS to UNIX
From: José Antonio Santos Cadenas @ 2010-05-07 8:15 UTC (permalink / raw)
To: Johan Hedberg; +Cc: linux-bluetooth, marcel
In-Reply-To: <20100506225633.GA15821@jh-x301>
El Friday 07 May 2010 00:56:33 Johan Hedberg escribi=F3:
> Hi,
>=20
> On Fri, May 07, 2010, Jose Antonio Santos Cadenas wrote:
> > Files tools/ubcsp.c and tools/ubcsp.h had DOS end of line now they
> > are changed to UNIX end of line
> > ---
> > tools/ubcsp.c | 2360 ++++++++++++++++++++++++++++---------------------=
=2D------
> > tools/ubcsp.h | 414 +++++-----
> > 2 files changed, 1387 insertions(+), 1387 deletions(-)
>=20
> Thanks for these cleanup patches. I've pushed the first five upstream
> but am a little bit hesitant about this sixth one since it essentially
> replaces every line in the existing file and I'm not sure if it's worth
> having that obfuscating the commit history (e.g. git blame wouldn't be
> useful anymore). Marcel, do you have any opinion about having a patch
> like that in the tree?
That's what I put this in a separate patch. I just wanted to note that some=
files had this=20
end of line. One of them had also some lines with DOS end fo line and other=
s with UNIX eol.
>=20
> Johan
> --
> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth=
" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>=20
^ permalink raw reply
* Re: [bugreport]
From: Serhiy Kachaniuk @ 2010-05-07 8:51 UTC (permalink / raw)
To: Fabian Greffrath; +Cc: linux-bluetooth
In-Reply-To: <j2o793f89501005060318nfb8e2e84y54a2b1e9ee346ca3@mail.gmail.com>
Another interesting discovery: when bluetoothd is stopped and bluez
version is 4.60, hciconfig can show all info and i can scan for
another devices:
$ sudo hciconfig -a
hci0: Type: USB
BD Address: 00:1A:7D:0A:C8:8A ACL MTU: 377:10 SCO MTU: 16:0
UP RUNNING
RX bytes:1012 acl:0 sco:0 events:29 errors:0
TX bytes:114 acl:0 sco:0 commands:31 errors:0
Features: 0xff 0xff 0x0d 0x38 0x08 0x08 0x00 0x00
Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3
Link policy:
Link mode: SLAVE ACCEPT
Name: 'Broadcom BCM2035'
Class: 0x000000
Service Classes: Unspecified
Device Class: Miscellaneous,
HCI Ver: 1.1 (0x1) HCI Rev: 0x3 LMP Ver: 1.1 (0x1) LMP Subver: 0x800
Manufacturer: Broadcom Corporation (15)
$ hcitool scan
Scanning ...
00:1E:DC:9B:FF:C4 HBH-DS205
but afer bluetoothd start problem reappears, hciconfig doesn't show
all info and hcitool scan fails
^ permalink raw reply
* Re: HDP proposed api (ver 0.2)
From: José Antonio Santos Cadenas @ 2010-05-07 10:03 UTC (permalink / raw)
To: Elvis Pfützenreuter; +Cc: linux-bluetooth
In-Reply-To: <3CCD92AC-1578-4E78-AEE8-80AEE73511EB@signove.com>
El Friday 07 May 2010 01:49:10 escribió:
> Hi,
>
> On 05/05/2010, at 07:55, José Antonio Santos Cadenas wrote:
> > Health Device Profile hierarchy
> > ===============================
> >
> > Service org.bluez
> > Interface org.bluez.Hdp
> > Object path [variable prefix]/{hci0,hci1,...}
> >
> > Methods object CreateSession(object path, dict config)
> >
> > Returns the object path for the new HDP session.
> > The path parameter is the path of the remote object
> > with the callbacks to nofity events (see
> > org.bluez.HdpAgent at the end of this document)
> > This petition starts an mcap session and also register
> > in the SDP is needed
> > Dict is defined as bellow:
> > { "data_spec" : The data_spec is the data exchange
> >
> > specficication (see section 5.2.10 of
> > the specification document),
> > (optional)
>
> Would be nice to include a "survival kit" about this 5.2.10, for
> completeness. Like (normally = 0x01 [IEEE xxxxx], 0x00 = reserved, 0x02 =
> other -- )
I think that you mean to document the possible values that can be used here.
We think its a good Idea.
>
> > "end_points" : [{ (optional)
> >
> > "mdepid" : uint8, (optional)
> > "role" : uint8, (mandatory)
>
> We could use strings there, 'source' or 'sink'?
Good idea, its clearer for the user this way.
>
> > "specs" :[{ (mandatory)
> >
> > "dtype" : uint16, (mandatory)
>
> IMHO the key names may be more descriptive, like data_type. More about this
> below.
Ok with this too.
>
> Another thing: as far as I understand, I may create a session, with
> well-defined MDEP IDs, roles etc. but then choose not to publish a SDP
> record. For example, I am an HDP source and want to have 5 MDEPs. An
> additional bool dict key like 'export' or 'publish' (not sure about
> correct BT nomenclature) would fit the bill.
>
> "Forcing" a source to specify the MDEP IDs here, even if not publishing the
> record, makes checks easier further.
Not sure about that. Note that when you don't publish a SDP record, nobody
could connect to you, so you won't receive data channel connections request,
so you don't need to check if the mdeps are in use or not.
>
> > "description" : string, (optional)
> >
> > }]
> >
> > }]
> >
> > }
> >
> > if "data_spec" is not set, no SDP record will be
> > registerd, so all the other data in the dictionary
> > will be ignored
>
> See comments above
>
> > Session will be closed by the call or implicitly when
> > the programs leaves the bus.
> >
> > Possible errors: org.bluez.Error.InvalidArguments
> >
> > void DeleteSession(object path)
> >
> > Delete the HDP session identified by the object path.
> > Also session will be closed if the procces that started
> > it is removed from the D-Bus.
> >
> > Possible errors: org.bluez.Error.InvalidArguments
> >
> > org.bluez.Error.NotFound
> >
> > array remote_session_properties GetRemotesSessions()
>
> typo
>
> > Returns an array with the remote session_properties
> > of all the visible devices.
> > remote_session_properties is a dictionary like:
> > [{"session_id": a_session_identification (int or string,
> >
> > probably the SDP handler + btaddr)
> >
> > "data_spec" : the remote data spec,
> >
> > "end_points":
> > ["mdepid": uint8,
> >
> > "role" : uint8,
> > "specs" : [{
> >
> > "dtype" : uint16,
> > "description" : string, (optional)
> >
> > }]
> >
> > ]
> >
> > }]
> >
> > Note that only remotes with a SDP record will be
> > notified by this function.
>
> I don't get the concept of "remote sessions" of the current proposal. I
> understand the HDP session as a kind of "context" which holds the rest of
> HDP elements (published records, connections etc.)
>
> Perhaps you meant "SDP records of HDP devices"?
Yes, but not only the record, also the session. This includes the mcl (mcap
nomenclature) that can be connected to it and also all the data channel
management.
> If so, IMHO this method
> should return just a list of device paths, which in turn would implement a
> BlueZ HDP interface that supplies further information (like my API
> proposal did).
It's not a bad idea for requesting information, but we think that the connect
method should be complicated. Note that the connections are performed between
sessions, not between devices. So when you call the connect method, you will
need to pass all this atributes:
- Remote mdep_id
- Configuration
- Remote session_id
- Local session
>
> I see some spread between org.bluez.Hdp and org.bluez.HdpSession. IMHO
> would be better to have just the context creation, as simple as possible,
> in org.bluez.Hdp and have everything else in org.bluez.HdpSession. (I
> still prefer the approach of "my" API, but I recognize that you are
> accomodating the notion of multiple records per [process, device] tuple.)
It could be a little bit estrange, but we think is necessary for the session
support.
>
> > -------------------------------------------------------------------------
> > -------
> >
> > Service org.bluez
> > Interface org.bluez.HdpSession
> > Object path [variable prefix]/{hci0,hci1,...}/{hdp0,hdp1,...}
> >
> > object Connect(remote_session_id)
> >
> > Connects with the remote session and returns its object
> > path.
> >
> > Possible errors: org.bluez.Error.InvalidArguments
> >
> > org.bluez.Error.HdpError
> >
> > void Disconnect(object device, boolean delete)
> >
> > Disconnect from the remote device. If delete is true, any
> > status will also be deleted. Otherwise, the status will
> > be keeped for allowing future reconnections.
> >
> > Possible errors: org.bluez.Error.InvalidArguments
> >
> > org.bluez.Error.NotFound
> > org.bluez.Error.HdpError
> >
> > -------------------------------------------------------------------------
> > -------
> >
> > Service org.bluez
> > Interface org.bluez.HdpRemoteSession
> > Object path [variable
> > prefix]/{hci0,hci1,...}/{hdp0,hdp1,...}/rem_session_id
>
> IMHO "remote session" feels funny. "Device record" would sound better (it
> is a device, so it is implied to be remote; and a record, which implies a
> given SDP record).
Yes, "remove session" is not a good name, but as we said above, the session is
more than a device and a record. This class represent a connection between two
session (the local and the remote) not just a remote device + SDP record.
Imagine that a source without a SDP connects to a sink. The sink will need
perform operations over data channels (except connect and reconnect because
the sink don't know the remote psm's). So may be id should depend on the SDP
id.
>
> Also, I think that the device path (appended by an unique identifier of the
> record) would be better. After all, that path already exists when device
> is around.
Using only the device path has a problem, the local session is not being taken
in count. May be we could find a different representation of this, but we think
that it should represent that this is a connection between two sessions, not
between two devices or between a session and a device.
>
> Perhaps you tried to accomodate the notion that a data channel ID
> "survives" even if the device disappearrs for a short moment?
Also this, remember that MCAP allow temporal disconnections to reestablish
them in future connections to save state.
>
> > boolean Echo(array{byte})
> >
> > Sends an echo petition to the remote session. Return True
> > if response matches with the buffer sended. If some error
> > is detected False value is returned and the associated
> > MCL is closed.
>
> Ok
>
> > uint16 OpenDc(byte mdepid, byte config)
>
> Could be OpenDataChannel?
Of course :). It's more clear
>
> > Creates a new data channel with the indicated config
> > to the remote MCAP Data End Point (MDEP).
> > The configuration should indicate the channel quality of
> > service.
> > Returns the data channel id.
> >
> > Possible errors: org.bluez.Error.InvalidArguments
> >
> > org.bluez.Error.HdpError
> >
> > file_descriptor GetDcFd(uint16 mdlid)
>
> This FD should be delivered via HdpAgent exclusively. I have counted three
> ways an application can receive an FD, IMHO there should be exactly one.
Yes, only one point sounds ok. Let's think about this. We think that first we
should fixed the way the data will reach the l2cap socket from the application
"crossing" dbus. We talked about fd-passing the l2cap socket but the pipe
option may be also considered. Let's continue this in a different thread.
>
> > Gets a file descriptor where data can be readed or
> > writed for receive or sent by the data channel.
> > Returns the file descriptor
> >
> > Possible errors: org.bluez.Error.InvalidArguments
> >
> > org.bluez.Error.NotFound
> > org.bluez.Error.HdpError
> >
> > void DeleteDc(uint16 mdlid)
>
> DeleteDataChannel
Ok
>
> > Deletes a data channel so it will not be available for
> > use.
> >
> > Possible errors: org.bluez.Error.InvalidArguments
> >
> > org.bluez.Error.NotFound
> > org.bluez.Error.HdpError
> >
> > void DeleteAllDc()
>
> Could be overloaded with DeleteDataChannel with MDL ID = 0, perhaps, but
> nothing incredibly important :)
MDLID 0 is reserved in mcap. Could be 0xffff value, that is reserved in mcap for
the delete all petition. But we think that using this we are passing mcap
logic to the upper layer.
>
> > Deletes all data channels so it will not be available
> > for use. Typically this function is called when the
> > connection with the remote device will be closed
> > permanently
> >
> > Possible errors: org.bluez.Error.HdpError
> >
> > uint16 FirstRelDc()
> >
> > Returns the identificator of the first reliable data
> > channel (ERTM) connected for this device.
> >
> > Possible errors: org.bluez.Error.HdpError
> >
> > uint16 GetBestEfforDc()
> >
> > Returns the id of a best effort (streamming) data
> > channel if any.
> >
> > Possible errors: org.bluez.Error.NotFound
>
> An use case would be good. In my vision, the application should just have
> one way to get the whole data connection list, and do whatever it wants,
> and not one new method for each type. We can e.g. guarantee that such list
> is in order, so the application can trust e.g. the first reliable channel
> on list to be what FirstRelDc() meant to return. (HDP mandates the first
> data channel to be reliable anyway.)
You are ok with this. Santiago sent 1 or 2 emails yesterday with proposals
about this. We think that the best approach is (like you suggested) one
pettion that returns a dictionary of arrays sorted as you mentioned:
{ "reliable": [id1, id2,...], "best_effort": [id3, id4, ...] }
In this case, the first reliable will be id1.
>
> > array getStatus()
> >
> > Returns an array with all the data channels available
> >
> > returned array:
> > [uint16, ...]
> >
> > Possible errors: org.bluez.Error.NotFound
>
> Available = connected, open (MDL ID has been created) or...?
Available means all data channels that the user can use to send data.
Connected or not (the applicaction does not know this status with implicit
reconnections) where it can send data. We think that this petition can be
removed and changed by the described above.
>
> > HDPAgent hierarchy
> > ==================
> >
> > (this object is implemented by the HDP client an receives notifications)
> >
> > Service unique name
> > Interface org.bluez.HdpAgent
> > Object path freely definable
> >
> > void DeviceConnected(object path)
> >
> > This method is called whenever a new device connection
> > has been established over the control channel of the
> > current HDP session. The objectpath contains the object
> > path of the remote device.
> >
> > void DeviceDisconnected(object path)
> >
> > This method is called when a remote device is
> > disconnected definitively. Any future reconnections
> > will fail. Also all data channels associated to this
> > device will be closed.
>
> Perfect up to this part.
>
> > void CreatedDc(object path, uint16 mdlid, filedescriptor fd)
>
> Could be "DataChannelCreated"?
Ok
>
> > This method is called when a new data channel is created
> > The path contains the object path of the device whith
> > the new connection is created, the mdlid the data
> > channel identificator and the fd is the file descriptor
> > where the data can be readed or writed.
> >
> > void DeletedDc(object path, uint16 mdlid)
>
> DataChannelDeleted?
Ok
>
> > This method is called when a data channel is closed.
> > After this call the data channel will not be valid and
> > can be reused for future created data channels.
> >
> > void DataReady(object path, uint16 mdlid, filedescriptor fd)
> >
> > This method is called when there is new data that can be
> > readed in a data channel
>
> This one I don't understand. It seems to duplicate the function of
> CreatedDc, even the prototype is exactly the same. Has this something to
> have with reconnections? (Even so, CreatedDc could be overloaded with
> this.)
This is related with reconnections but from the other side. When the remote
reconnects and send data. Nevertheless we should fix the way the data flows (as
mentioned above) before discuss this API issues.
>
> > void RemoteSession(dict remote_session_properties)
> >
> > This methos is called when a new session is discorevered
> > in a remote device. See Hdp.GetRemotes to know how the
> > dictionary is formed.
>
> Same comment about the concept of remote session.--
Hope solved with the above comment.
Regards
^ permalink raw reply
* Re: HDP proposed api (ver 0.2)
From: José Antonio Santos Cadenas @ 2010-05-07 10:07 UTC (permalink / raw)
To: Elvis Pfützenreuter; +Cc: linux-bluetooth
In-Reply-To: <201005071203.23882.jcaden@libresoft.es>
El Friday 07 May 2010 12:03:23 José Antonio Santos Cadenas escribió:
> El Friday 07 May 2010 01:49:10 escribió:
> > Hi,
> >
> > On 05/05/2010, at 07:55, José Antonio Santos Cadenas wrote:
> > > Health Device Profile hierarchy
> > > ===============================
> > >
> > > Service org.bluez
> > > Interface org.bluez.Hdp
> > > Object path [variable prefix]/{hci0,hci1,...}
> > >
> > > Methods object CreateSession(object path, dict config)
> > >
> > > Returns the object path for the new HDP session.
> > > The path parameter is the path of the remote object
> > > with the callbacks to nofity events (see
> > > org.bluez.HdpAgent at the end of this document)
> > > This petition starts an mcap session and also register
> > > in the SDP is needed
> > > Dict is defined as bellow:
> > > { "data_spec" : The data_spec is the data exchange
> > >
> > > specficication (see section 5.2.10 of
> > > the specification document),
> > > (optional)
> >
> > Would be nice to include a "survival kit" about this 5.2.10, for
> > completeness. Like (normally = 0x01 [IEEE xxxxx], 0x00 = reserved, 0x02 =
> > other -- )
>
> I think that you mean to document the possible values that can be used
> here. We think its a good Idea.
>
> > > "end_points" : [{ (optional)
> > >
> > > "mdepid" : uint8, (optional)
> > > "role" : uint8, (mandatory)
> >
> > We could use strings there, 'source' or 'sink'?
>
> Good idea, its clearer for the user this way.
>
> > > "specs" :[{ (mandatory)
> > >
> > > "dtype" : uint16, (mandatory)
> >
> > IMHO the key names may be more descriptive, like data_type. More about
> > this below.
>
> Ok with this too.
>
> > Another thing: as far as I understand, I may create a session, with
> > well-defined MDEP IDs, roles etc. but then choose not to publish a SDP
> > record. For example, I am an HDP source and want to have 5 MDEPs. An
> > additional bool dict key like 'export' or 'publish' (not sure about
> > correct BT nomenclature) would fit the bill.
> >
> > "Forcing" a source to specify the MDEP IDs here, even if not publishing
> > the record, makes checks easier further.
>
> Not sure about that. Note that when you don't publish a SDP record, nobody
> could connect to you, so you won't receive data channel connections
> request, so you don't need to check if the mdeps are in use or not.
>
> > > "description" : string, (optional)
> > >
> > > }]
> > >
> > > }]
> > >
> > > }
> > >
> > > if "data_spec" is not set, no SDP record will be
> > > registerd, so all the other data in the dictionary
> > > will be ignored
> >
> > See comments above
> >
> > > Session will be closed by the call or implicitly when
> > > the programs leaves the bus.
> > >
> > > Possible errors: org.bluez.Error.InvalidArguments
> > >
> > > void DeleteSession(object path)
> > >
> > > Delete the HDP session identified by the object path.
> > > Also session will be closed if the procces that started
> > > it is removed from the D-Bus.
> > >
> > > Possible errors: org.bluez.Error.InvalidArguments
> > >
> > > org.bluez.Error.NotFound
> > >
> > > array remote_session_properties GetRemotesSessions()
> >
> > typo
> >
> > > Returns an array with the remote session_properties
> > > of all the visible devices.
> > > remote_session_properties is a dictionary like:
> > > [{"session_id": a_session_identification (int or string,
> > >
> > > probably the SDP handler + btaddr)
> > >
> > > "data_spec" : the remote data spec,
> > >
> > > "end_points":
> > > ["mdepid": uint8,
> > >
> > > "role" : uint8,
> > > "specs" : [{
> > >
> > > "dtype" : uint16,
> > > "description" : string, (optional)
> > >
> > > }]
> > >
> > > ]
> > >
> > > }]
> > >
> > > Note that only remotes with a SDP record will be
> > > notified by this function.
> >
> > I don't get the concept of "remote sessions" of the current proposal. I
> > understand the HDP session as a kind of "context" which holds the rest of
> > HDP elements (published records, connections etc.)
> >
> > Perhaps you meant "SDP records of HDP devices"?
>
> Yes, but not only the record, also the session. This includes the mcl (mcap
> nomenclature) that can be connected to it and also all the data channel
> management.
>
> > If so, IMHO this method
> > should return just a list of device paths, which in turn would implement
> > a BlueZ HDP interface that supplies further information (like my API
> > proposal did).
>
> It's not a bad idea for requesting information, but we think that the
> connect method should be complicated. Note that the connections are
> performed between sessions, not between devices. So when you call the
> connect method, you will need to pass all this atributes:
>
> - Remote mdep_id
> - Configuration
> - Remote session_id
> - Local session
>
> > I see some spread between org.bluez.Hdp and org.bluez.HdpSession. IMHO
> > would be better to have just the context creation, as simple as possible,
> > in org.bluez.Hdp and have everything else in org.bluez.HdpSession. (I
> > still prefer the approach of "my" API, but I recognize that you are
> > accomodating the notion of multiple records per [process, device] tuple.)
>
> It could be a little bit estrange, but we think is necessary for the
> session support.
>
> > > -----------------------------------------------------------------------
> > > -- -------
> > >
> > > Service org.bluez
> > > Interface org.bluez.HdpSession
> > > Object path [variable prefix]/{hci0,hci1,...}/{hdp0,hdp1,...}
> > >
> > > object Connect(remote_session_id)
> > >
> > > Connects with the remote session and returns its object
> > > path.
> > >
> > > Possible errors: org.bluez.Error.InvalidArguments
> > >
> > > org.bluez.Error.HdpError
> > >
> > > void Disconnect(object device, boolean delete)
> > >
> > > Disconnect from the remote device. If delete is true, any
> > > status will also be deleted. Otherwise, the status will
> > > be keeped for allowing future reconnections.
> > >
> > > Possible errors: org.bluez.Error.InvalidArguments
> > >
> > > org.bluez.Error.NotFound
> > > org.bluez.Error.HdpError
> > >
> > > -----------------------------------------------------------------------
> > > -- -------
> > >
> > > Service org.bluez
> > > Interface org.bluez.HdpRemoteSession
> > > Object path [variable
> > > prefix]/{hci0,hci1,...}/{hdp0,hdp1,...}/rem_session_id
> >
> > IMHO "remote session" feels funny. "Device record" would sound better (it
> > is a device, so it is implied to be remote; and a record, which implies a
> > given SDP record).
>
> Yes, "remove session" is not a good name, but as we said above, the session
> is more than a device and a record. This class represent a connection
> between two session (the local and the remote) not just a remote device +
> SDP record. Imagine that a source without a SDP connects to a sink. The
> sink will need perform operations over data channels (except connect and
> reconnect because the sink don't know the remote psm's). So may be id
> should depend on the SDP id.
>
> > Also, I think that the device path (appended by an unique identifier of
> > the record) would be better. After all, that path already exists when
> > device is around.
>
> Using only the device path has a problem, the local session is not being
> taken in count. May be we could find a different representation of this,
> but we think that it should represent that this is a connection between
> two sessions, not between two devices or between a session and a device.
>
> > Perhaps you tried to accomodate the notion that a data channel ID
> > "survives" even if the device disappearrs for a short moment?
>
> Also this, remember that MCAP allow temporal disconnections to reestablish
> them in future connections to save state.
>
> > > boolean Echo(array{byte})
> > >
> > > Sends an echo petition to the remote session. Return True
> > > if response matches with the buffer sended. If some error
> > > is detected False value is returned and the associated
> > > MCL is closed.
> >
> > Ok
> >
> > > uint16 OpenDc(byte mdepid, byte config)
> >
> > Could be OpenDataChannel?
>
> Of course :). It's more clear
>
> > > Creates a new data channel with the indicated config
> > > to the remote MCAP Data End Point (MDEP).
> > > The configuration should indicate the channel quality of
> > > service.
> > > Returns the data channel id.
> > >
> > > Possible errors: org.bluez.Error.InvalidArguments
> > >
> > > org.bluez.Error.HdpError
> > >
> > > file_descriptor GetDcFd(uint16 mdlid)
> >
> > This FD should be delivered via HdpAgent exclusively. I have counted
> > three ways an application can receive an FD, IMHO there should be
> > exactly one.
>
> Yes, only one point sounds ok. Let's think about this. We think that first
> we should fixed the way the data will reach the l2cap socket from the
> application "crossing" dbus. We talked about fd-passing the l2cap socket
> but the pipe option may be also considered. Let's continue this in a
> different thread.
>
> > > Gets a file descriptor where data can be readed or
> > > writed for receive or sent by the data channel.
> > > Returns the file descriptor
> > >
> > > Possible errors: org.bluez.Error.InvalidArguments
> > >
> > > org.bluez.Error.NotFound
> > > org.bluez.Error.HdpError
> > >
> > > void DeleteDc(uint16 mdlid)
> >
> > DeleteDataChannel
>
> Ok
>
> > > Deletes a data channel so it will not be available for
> > > use.
> > >
> > > Possible errors: org.bluez.Error.InvalidArguments
> > >
> > > org.bluez.Error.NotFound
> > > org.bluez.Error.HdpError
> > >
> > > void DeleteAllDc()
> >
> > Could be overloaded with DeleteDataChannel with MDL ID = 0, perhaps, but
> > nothing incredibly important :)
>
> MDLID 0 is reserved in mcap. Could be 0xffff value, that is reserved in
> mcap for the delete all petition. But we think that using this we are
> passing mcap logic to the upper layer.
>
> > > Deletes all data channels so it will not be available
> > > for use. Typically this function is called when the
> > > connection with the remote device will be closed
> > > permanently
> > >
> > > Possible errors: org.bluez.Error.HdpError
> > >
> > > uint16 FirstRelDc()
> > >
> > > Returns the identificator of the first reliable data
> > > channel (ERTM) connected for this device.
> > >
> > > Possible errors: org.bluez.Error.HdpError
> > >
> > > uint16 GetBestEfforDc()
> > >
> > > Returns the id of a best effort (streamming) data
> > > channel if any.
> > >
> > > Possible errors: org.bluez.Error.NotFound
> >
> > An use case would be good. In my vision, the application should just have
> > one way to get the whole data connection list, and do whatever it wants,
> > and not one new method for each type. We can e.g. guarantee that such
> > list is in order, so the application can trust e.g. the first reliable
> > channel on list to be what FirstRelDc() meant to return. (HDP mandates
> > the first data channel to be reliable anyway.)
>
> You are ok with this. Santiago sent 1 or 2 emails yesterday with proposals
> about this.
I mean this messages:
http://www.spinics.net/lists/linux-bluetooth/msg05231.html
http://www.spinics.net/lists/linux-bluetooth/msg05244.html
> We think that the best approach is (like you suggested) one
> pettion that returns a dictionary of arrays sorted as you mentioned:
> { "reliable": [id1, id2,...], "best_effort": [id3, id4, ...] }
>
> In this case, the first reliable will be id1.
>
> > > array getStatus()
> > >
> > > Returns an array with all the data channels available
> > >
> > > returned array:
> > > [uint16, ...]
> > >
> > > Possible errors: org.bluez.Error.NotFound
> >
> > Available = connected, open (MDL ID has been created) or...?
>
> Available means all data channels that the user can use to send data.
> Connected or not (the applicaction does not know this status with implicit
> reconnections) where it can send data. We think that this petition can be
> removed and changed by the described above.
>
> > > HDPAgent hierarchy
> > > ==================
> > >
> > > (this object is implemented by the HDP client an receives
> > > notifications)
> > >
> > > Service unique name
> > > Interface org.bluez.HdpAgent
> > > Object path freely definable
> > >
> > > void DeviceConnected(object path)
> > >
> > > This method is called whenever a new device connection
> > > has been established over the control channel of the
> > > current HDP session. The objectpath contains the object
> > > path of the remote device.
> > >
> > > void DeviceDisconnected(object path)
> > >
> > > This method is called when a remote device is
> > > disconnected definitively. Any future reconnections
> > > will fail. Also all data channels associated to this
> > > device will be closed.
> >
> > Perfect up to this part.
> >
> > > void CreatedDc(object path, uint16 mdlid, filedescriptor fd)
> >
> > Could be "DataChannelCreated"?
>
> Ok
>
> > > This method is called when a new data channel is created
> > > The path contains the object path of the device whith
> > > the new connection is created, the mdlid the data
> > > channel identificator and the fd is the file descriptor
> > > where the data can be readed or writed.
> > >
> > > void DeletedDc(object path, uint16 mdlid)
> >
> > DataChannelDeleted?
>
> Ok
>
> > > This method is called when a data channel is closed.
> > > After this call the data channel will not be valid and
> > > can be reused for future created data channels.
> > >
> > > void DataReady(object path, uint16 mdlid, filedescriptor fd)
> > >
> > > This method is called when there is new data that can be
> > > readed in a data channel
> >
> > This one I don't understand. It seems to duplicate the function of
> > CreatedDc, even the prototype is exactly the same. Has this something to
> > have with reconnections? (Even so, CreatedDc could be overloaded with
> > this.)
>
> This is related with reconnections but from the other side. When the remote
> reconnects and send data. Nevertheless we should fix the way the data flows
> (as mentioned above) before discuss this API issues.
>
> > > void RemoteSession(dict remote_session_properties)
> > >
> > > This methos is called when a new session is discorevered
> > > in a remote device. See Hdp.GetRemotes to know how the
> > > dictionary is formed.
> >
> > Same comment about the concept of remote session.--
>
> Hope solved with the above comment.
>
> Regards
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth"
> in the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* Data transmission and reconnections in HDP
From: José Antonio Santos Cadenas @ 2010-05-07 11:02 UTC (permalink / raw)
To: linux-bluetooth@vger.kernel.org
Hi all,
I start this thread to discuss the alternatives to move the data from the
application to the l2cap socket in HDP. Till now we have the following
alternatives (please, add more if we missed something)
Reconnections options:
Option 1: Implicit reconnections: The application is not concern about the
disconnections or reconnections of the data channel until it is deleted.
We prefer this option because fixes more with a manager philosophy. A
20601 manager sould not perceive temporal disconnections because this way can
hold it state if it perceives a disconnection, next time it reconnects it will
need to exchange again apdus for association.
Option 2: Reconnections by the application. The applications are notified when
a data channel is disconnected and should perform a reconnection before using
it again.
Data transmission options:
Option 1: Fd_passing the l2cap socket of the data channel to the client. The
problem with this is that some data can be lost by d-bus if the channel is
disconnected. (We have to check how fd-passing works).
Option 2: Fd_passing a pipe and HDP will write the data in the l2cap data
chanel socket. The problem with this is that we need 2 pipes for each data
channel, but no data will be lost because HDP controls the data flow with the
sockets and resend data not correctly sent.
We think that the easier way for implicit reconnections is option 2.
Because the application can always write on the socket it have (the pipe).
Once written, the HDP layer tries to write it in the l2cap socket, if it
fails, perform a reconnection operation over the data channel.
Option 3: Transmiting the data by d-bus. We think that this option is bad for
d-bus, because of the overload of the system bus.
Option 4: Other IPC alternatives (more alternative here?)
Regards.
^ permalink raw reply
* Re: HDP proposed api (ver 0.2)
From: José Antonio Santos Cadenas @ 2010-05-07 11:24 UTC (permalink / raw)
To: Elvis Pfützenreuter; +Cc: linux-bluetooth
In-Reply-To: <201005071207.52723.jcaden@libresoft.es>
I cleaned up the API with the changes suggested in the thread. There are still
some parts that are being discussed.
BlueZ D-Bus HDP API description
***********************************
Authors:
Santiago Carot-Nemesio <sancane@gmail.com>
José Antonio Santos-Cadenas <santoscadenas@gmail.com>
Elvis Pfützenreuter <epx@signove.com>
Health Device Profile hierarchy
===============================
Service org.bluez
Interface org.bluez.Hdp
Object path [variable prefix]/{hci0,hci1,...}
Methods object CreateSession(object path, dict config)
Returns the object path for the new HDP session.
The path parameter is the path of the remote object
with the callbacks to notify events (see
org.bluez.HdpAgent at the end of this document)
This petition starts an mcap session and also register
in the SDP is needed
Dict is defined as bellow:
{ "data_spec" : The data_spec is the data exchange
specficication (see section 5.2.10 of
the specification document)
possible values:
0x00 = reserved,
0x01 [IEEE 11073-20601],
0x02..0xff reserved,
(optional)
"end_points" : [{ (optional)
"mdepid" : uint8, (optional)
"role" : ("source" or "sink"), (mandatory)
"specs" :[{ (mandatory)
"data_type" : uint16, (mandatory)
"description" : string, (optional)
}]
}]
}
if "data_spec" is not set, no SDP record will be
registered, so all the other data in the dictionary
will be ignored
Session will be closed by the call or implicitly when
the programs leaves the bus.
Possible errors: org.bluez.Error.InvalidArguments
void DeleteSession(object path)
Delete the HDP session identified by the object path.
Also session will be closed if the process that started
it is removed from the D-Bus.
Possible errors: org.bluez.Error.InvalidArguments
org.bluez.Error.NotFound
array remote_session_properties GetRemoteSessions()
Returns an array with the remote session_properties
of all the visible devices.
remote_session_properties is a dictionary like:
[{"session_id": a_session_identification (int or string,
probably the SDP handler + btaddr)
"data_spec" : the remote data spec,
"end_points":
["mdepid": uint8,
"role" : uint8,
"specs" : [{
"dtype" : uint16,
"description" : string, (optional)
}]
]
}]
Note that only remotes with a SDP record will be
notified by this function.
--------------------------------------------------------------------------------
Service org.bluez
Interface org.bluez.HdpSession
Object path [variable prefix]/{hci0,hci1,...}/{hdp0,hdp1,...}
object Connect(remote_session_id)
Connects with the remote session and returns its object
path.
Possible errors: org.bluez.Error.InvalidArguments
org.bluez.Error.HdpError
void Disconnect(object device, boolean delete)
Disconnect from the remote device. If delete is true, any
status will also be deleted. Otherwise, the status will
be kept for allowing future reconnections.
Possible errors: org.bluez.Error.InvalidArguments
org.bluez.Error.NotFound
org.bluez.Error.HdpError
--------------------------------------------------------------------------------
Service org.bluez
Interface org.bluez.HdpRemoteSession
Object path [variable prefix]/{hci0,hci1,...}/{hdp0,hdp1,...}/rem_session_id
boolean Echo(array{byte})
Sends an echo petition to the remote session. Return True
if response matches with the buffer sent. If some error
is detected False value is returned and the associated
MCL is closed.
uint16 OpenDataChannel(byte mdepid, byte config)
Creates a new data channel with the indicated config
to the remote MCAP Data End Point (MDEP).
The configuration should indicate the channel quality of
service.
Returns the data channel id.
Possible errors: org.bluez.Error.InvalidArguments
org.bluez.Error.HdpError
file_descriptor GetDcFd(uint16 mdlid)
Gets a file descriptor where data can be read or
written for receive or sent by the data channel.
Returns the file descriptor
Possible errors: org.bluez.Error.InvalidArguments
org.bluez.Error.NotFound
org.bluez.Error.HdpError
void DeleteDataChannel(uint16 mdlid)
Deletes a data channel so it will not be available for
use.
Possible errors: org.bluez.Error.InvalidArguments
org.bluez.Error.NotFound
org.bluez.Error.HdpError
void DeleteAllDataChannels()
Deletes all data channels so it will not be available
for use. Typically this function is called when the
connection with the remote device will be closed
permanently
Possible errors: org.bluez.Error.HdpError
dict GetDataChannelStatus()
Return a dictionary with all the data channels that
can be used to send data right now. The dictionary
is formed like follows:
{
"reliable": [id1, ..., idz],
"best_effort" : [idx, ..., idy]
}
The fist reliable data channel will always be the first
data channel in reliable array.
HDPAgent hierarchy
==================
(this object is implemented by the HDP client an receives notifications)
Service unique name
Interface org.bluez.HdpAgent
Object path freely definable
void DeviceConnected(object path)
This method is called whenever a new device connection
has been established over the control channel of the
current HDP session. The object path contains the object
path of the remote device.
void DeviceDisconnected(object path)
This method is called when a remote device is
disconnected definitively. Any future reconnections
will fail. Also all data channels associated to this
device will be closed.
void CreatedDataChannel(object path, uint16 mdlid,
filedescriptor fd)
This method is called when a new data channel is created
The path contains the object path of the device whith
the new connection is created, the mdlid the data
channel identificator and the fd is the file descriptor
where the data can be readed or writed.
void DeletedDataChannel(object path, uint16 mdlid)
This method is called when a data channel is closed.
After this call the data channel will not be valid and
can be reused for future created data channels.
void DataReady(object path, uint16 mdlid, filedescriptor fd)
This method is called when there is new data that can be
read in a data channel
void RemoteSession(dict remote_session_properties)
This method is called when a new session is discorevered
in a remote device. See Hdp.GetRemotes to know how the
dictionary is formed.
^ permalink raw reply
* Re: HDP proposed api (ver 0.2)
From: José Antonio Santos Cadenas @ 2010-05-07 11:26 UTC (permalink / raw)
To: Elvis Pfützenreuter; +Cc: linux-bluetooth
In-Reply-To: <201005071324.01531.jcaden@libresoft.es>
El Friday 07 May 2010 13:24:01 José Antonio Santos Cadenas escribió:
> I cleaned up the API with the changes suggested in the thread. There are still
> some parts that are being discussed.
>
>
> BlueZ D-Bus HDP API description
> ***********************************
>
> Authors:
>
> Santiago Carot-Nemesio <sancane@gmail.com>
> José Antonio Santos-Cadenas <santoscadenas@gmail.com>
> Elvis Pfützenreuter <epx@signove.com>
>
> Health Device Profile hierarchy
> ===============================
>
> Service org.bluez
> Interface org.bluez.Hdp
> Object path [variable prefix]/{hci0,hci1,...}
>
> Methods object CreateSession(object path, dict config)
>
> Returns the object path for the new HDP session.
> The path parameter is the path of the remote object
> with the callbacks to notify events (see
> org.bluez.HdpAgent at the end of this document)
> This petition starts an mcap session and also register
> in the SDP is needed
> Dict is defined as bellow:
> { "data_spec" : The data_spec is the data exchange
> specficication (see section 5.2.10 of
> the specification document)
> possible values:
> 0x00 = reserved,
> 0x01 [IEEE 11073-20601],
> 0x02..0xff reserved,
> (optional)
> "end_points" : [{ (optional)
> "mdepid" : uint8, (optional)
> "role" : ("source" or "sink"), (mandatory)
> "specs" :[{ (mandatory)
> "data_type" : uint16, (mandatory)
> "description" : string, (optional)
> }]
> }]
> }
>
> if "data_spec" is not set, no SDP record will be
> registered, so all the other data in the dictionary
> will be ignored
>
> Session will be closed by the call or implicitly when
> the programs leaves the bus.
>
> Possible errors: org.bluez.Error.InvalidArguments
>
> void DeleteSession(object path)
>
> Delete the HDP session identified by the object path.
> Also session will be closed if the process that started
> it is removed from the D-Bus.
>
> Possible errors: org.bluez.Error.InvalidArguments
> org.bluez.Error.NotFound
>
> array remote_session_properties GetRemoteSessions()
still being discussed
>
> Returns an array with the remote session_properties
> of all the visible devices.
> remote_session_properties is a dictionary like:
> [{"session_id": a_session_identification (int or string,
> probably the SDP handler + btaddr)
> "data_spec" : the remote data spec,
> "end_points":
> ["mdepid": uint8,
> "role" : uint8,
> "specs" : [{
> "dtype" : uint16,
> "description" : string, (optional)
> }]
> ]
> }]
>
> Note that only remotes with a SDP record will be
> notified by this function.
>
> --------------------------------------------------------------------------------
>
> Service org.bluez
> Interface org.bluez.HdpSession
> Object path [variable prefix]/{hci0,hci1,...}/{hdp0,hdp1,...}
>
> object Connect(remote_session_id)
>
> Connects with the remote session and returns its object
> path.
>
> Possible errors: org.bluez.Error.InvalidArguments
> org.bluez.Error.HdpError
>
> void Disconnect(object device, boolean delete)
>
> Disconnect from the remote device. If delete is true, any
> status will also be deleted. Otherwise, the status will
> be kept for allowing future reconnections.
>
> Possible errors: org.bluez.Error.InvalidArguments
> org.bluez.Error.NotFound
> org.bluez.Error.HdpError
>
> --------------------------------------------------------------------------------
>
> Service org.bluez
> Interface org.bluez.HdpRemoteSession
> Object path [variable prefix]/{hci0,hci1,...}/{hdp0,hdp1,...}/rem_session_id
>
> boolean Echo(array{byte})
>
> Sends an echo petition to the remote session. Return True
> if response matches with the buffer sent. If some error
> is detected False value is returned and the associated
> MCL is closed.
>
> uint16 OpenDataChannel(byte mdepid, byte config)
>
> Creates a new data channel with the indicated config
> to the remote MCAP Data End Point (MDEP).
> The configuration should indicate the channel quality of
> service.
> Returns the data channel id.
>
> Possible errors: org.bluez.Error.InvalidArguments
> org.bluez.Error.HdpError
>
> file_descriptor GetDcFd(uint16 mdlid)
Wait till transport/fd-passing discussion is solved
>
> Gets a file descriptor where data can be read or
> written for receive or sent by the data channel.
> Returns the file descriptor
>
> Possible errors: org.bluez.Error.InvalidArguments
> org.bluez.Error.NotFound
> org.bluez.Error.HdpError
>
> void DeleteDataChannel(uint16 mdlid)
>
> Deletes a data channel so it will not be available for
> use.
>
> Possible errors: org.bluez.Error.InvalidArguments
> org.bluez.Error.NotFound
> org.bluez.Error.HdpError
>
> void DeleteAllDataChannels()
still in discussion
>
> Deletes all data channels so it will not be available
> for use. Typically this function is called when the
> connection with the remote device will be closed
> permanently
>
> Possible errors: org.bluez.Error.HdpError
>
> dict GetDataChannelStatus()
>
> Return a dictionary with all the data channels that
> can be used to send data right now. The dictionary
> is formed like follows:
> {
> "reliable": [id1, ..., idz],
> "best_effort" : [idx, ..., idy]
> }
>
> The fist reliable data channel will always be the first
> data channel in reliable array.
>
> HDPAgent hierarchy
> ==================
>
> (this object is implemented by the HDP client an receives notifications)
>
> Service unique name
> Interface org.bluez.HdpAgent
> Object path freely definable
>
> void DeviceConnected(object path)
>
> This method is called whenever a new device connection
> has been established over the control channel of the
> current HDP session. The object path contains the object
> path of the remote device.
>
> void DeviceDisconnected(object path)
>
> This method is called when a remote device is
> disconnected definitively. Any future reconnections
> will fail. Also all data channels associated to this
> device will be closed.
>
> void CreatedDataChannel(object path, uint16 mdlid,
> filedescriptor fd)
>
> This method is called when a new data channel is created
> The path contains the object path of the device whith
> the new connection is created, the mdlid the data
> channel identificator and the fd is the file descriptor
> where the data can be readed or writed.
>
> void DeletedDataChannel(object path, uint16 mdlid)
>
> This method is called when a data channel is closed.
> After this call the data channel will not be valid and
> can be reused for future created data channels.
>
> void DataReady(object path, uint16 mdlid, filedescriptor fd)
probably it will disappear, depends on transport/fd-passing discussion
>
> This method is called when there is new data that can be
> read in a data channel
>
> void RemoteSession(dict remote_session_properties)
>
> This method is called when a new session is discorevered
> in a remote device. See Hdp.GetRemotes to know how the
> dictionary is formed.
> --
> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox