All of lore.kernel.org
 help / color / mirror / Atom feed
* [Bluez-devel] C Program for Getting Link Quality
@ 2005-11-08  9:31 Arpit Rai
  2005-11-08  9:46 ` Collin R. Mulliner
  2005-11-08 12:49 ` Marcel Holtmann
  0 siblings, 2 replies; 7+ messages in thread
From: Arpit Rai @ 2005-11-08  9:31 UTC (permalink / raw)
  To: bluez-devel

[-- Attachment #1: Type: text/plain, Size: 3583 bytes --]

Hi

I've written a C program to help me get the link quality between two
bluetooth dongles. But, on compilation there are problems with the
definition:

cr = (hci_conn_info_req *)malloc(sizeof(*cr) + sizeof(struct
hci_conn_info)); (Error: 'hci_conn_info_req' undeclared)

This the program I'm running:

//Program for finding LQ
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <bluetooth/bluetooth.h>
#include <bluetooth/hci.h>
#include <bluetooth/hci_lib.h>

int main(int argc, char **argv)
{
int dev_id = -1;
uint16_t *handle;
struct hci_conn_info_req *cr;
struct hci_request rq;
read_link_quality_rp rp;
bdaddr_t bdaddr;
int dd;
char addr[18] = "00:10:60:B3:2C:F8";

//connecting
int ptype;
uint8_t role;

role = 0;
ptype = HCI_DM1 | HCI_DM3 | HCI_DM5 | HCI_DH1 | HCI_DH3 | HCI_DH5;
str2ba(addr, &bdaddr);


if(dev_id < 0)
{
dev_id = hci_get_route(&bdaddr);
if(dev_id < 0)
{
printf("Cannot connect\n");
return 0;
}
}

if(hci_create_connection(dd, &bdaddr, htobs(ptype), 0, role, handle,4000) <
0)
{
//printf("Cannot create connection\n");
//return 0;
}


//get connection links
dd = hci_open_dev(dev_id);
if (dd < 0)
{
printf("HCI device open failed\n");
return 0;
}

cr = (hci_conn_info_req *)malloc(sizeof(*cr) + sizeof(struct
hci_conn_info));
if (!cr)
return 0;

bacpy(&cr->bdaddr, &bdaddr);
cr->type = ACL_LINK;
if (ioctl(dd, HCIGETCONNINFO, (unsigned long) cr) < 0)
{
printf("Get connection info failed\n");
return 0;
}

memset(&rq, 0, sizeof(rq));
rq.ogf = OGF_STATUS_PARAM;
rq.ocf = OCF_READ_LINK_QUALITY;
rq.cparam = &cr->conn_info->handle;
rq.clen = 2;
rq.rparam = &rp;
rq.rlen = READ_LINK_QUALITY_RP_SIZE;

if (hci_send_req(dd, &rq, 100) < 0)
{
printf("HCI get_link_quality request failed\n");
return 0;
}

if (rp.status)
{
printf("HCI get_link_quality cmd failed\n", rp.status);
return 0;
}

int link_quality = rp.link_quality;
printf("Link quality for %s: %d", addr, link_quality);

close(dd);
free(cr);

//return link_quality;
}

On compilation, I get the following errors:

In file included from getlq.c:6:
/usr/include/bluetooth/hci.h:1113: error: syntax error before 'sa_family_t'
/usr/include/bluetooth/hci.h:1115: error: syntax error before '}' token
getlq.c: In function 'main':
getlq.c:53: error: 'hci_conn_info_req' undeclared (first use in this
function)
getlq.c:53: error: (Each undeclared identifier is reported only once
getlq.c:53: error: for each function it appears in.)
getlq.c:53: error: syntax error before ')' token
getlq.c:59: error: syntax error before 'int'
getlq.c: At top level:
getlq.c:65: error: syntax error before '&' token
getlq.c:85: error: 'rp' undeclared here (not in a function)
getlq.c:86: error: syntax error before string constant
getlq.c:86: error: conflicting types for 'printf'
getlq.c:86: note: a parameter list with an ellipsis can't match an empty
parameter name list declaration
getlq.c:86: warning: data definition has no type or storage class
getlq.c:88: warning: parameter names (without types) in function declaration
getlq.c:88: warning: data definition has no type or storage class
getlq.c:89: warning: parameter names (without types) in function declaration
getlq.c:89: error: conflicting types for 'free'
/usr/include/stdlib.h:601: error: previous declaration of 'free' was here
getlq.c:89: warning: data definition has no type or storage class
getlq.c:92: error: syntax error before '}' token

Any idea why I'm getting the compilation error?

Regards
Arpit

[-- Attachment #2: Type: text/html, Size: 7896 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2005-11-09 14:02 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-11-08  9:31 [Bluez-devel] C Program for Getting Link Quality Arpit Rai
2005-11-08  9:46 ` Collin R. Mulliner
2005-11-08 12:49 ` Marcel Holtmann
2005-11-08 17:58   ` Arpit Rai
2005-11-08 18:17     ` Marcel Holtmann
2005-11-09 12:52       ` Arpit Rai
2005-11-09 14:02         ` Marcel Holtmann

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.