Return-Path: Message-ID: <94e407f00511090452m7f86753bq6f1ba05a8653379f@mail.gmail.com> From: Arpit Rai To: bluez-devel@lists.sourceforge.net Subject: Re: [Bluez-devel] C Program for Getting Link Quality In-Reply-To: <1131473837.5544.4.camel@blade> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_23466_26367994.1131540770623" References: <94e407f00511080131u11f01d79x65d05cfe47ccbb7@mail.gmail.com> <1131454195.5824.161.camel@blade> <94e407f00511080958j74841800k45532fdbd149e9cd@mail.gmail.com> <1131473837.5544.4.camel@blade> Sender: bluez-devel-admin@lists.sourceforge.net Errors-To: bluez-devel-admin@lists.sourceforge.net Reply-To: bluez-devel@lists.sourceforge.net List-Unsubscribe: , List-Id: BlueZ development List-Post: List-Help: List-Subscribe: , List-Archive: Date: Wed, 9 Nov 2005 20:52:50 +0800 ------=_Part_23466_26367994.1131540770623 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hi Marcel Yes, I forgot to include the icotl.h as well.Anyway, for I changed the definition of: cr =3D (hci_conn_info_req *)malloc(sizeof(*cr) + sizeof(stru= ct hci_conn_info)); to this: cr =3D (struct hci_conn_info_req*) malloc(sizeof(struct hci_conn_info_req) + sizeof(struct hci_conn_info)); . This doesn't give me the error any more. However, running the compiled program results in: Get connection info faile= d //Program for finding LQ #include #include #include #include #include #include #include #include #include #include #include #include #include #include int main(int argc, char **argv) { int dev_id; uint16_t *handle; struct hci_conn_info_req *cr=3D0; struct hci_request rq; read_link_quality_rp rp; bdaddr_t bdaddr; int dd; int err=3D0; char addr[18] =3D "00:10:60:B3:2C:F3"; printf("Link quality for %s: ", addr); //connecting int ptype; uint8_t role; role =3D 0; ptype =3D HCI_DM1 | HCI_DM3 | HCI_DM5 | HCI_DH1 | HCI_DH3 | HCI_DH5; str2ba(addr, &bdaddr); if(dev_id < 0) { dev_id =3D 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 =3D hci_open_dev(dev_id); if (dd < 0) { printf("HCI device open failed\n"); return 0; } //cr =3D (hci_conn_info_req *)malloc(sizeof(*cr) + sizeof(struct hci_conn_info)); cr =3D (struct hci_conn_info_req*) malloc(sizeof(struct hci_conn_info_req)= + sizeof(struct hci_conn_info)); if (!cr) { return 0; } bacpy(&cr->bdaddr, &bdaddr); cr->type =3D 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 =3D OGF_STATUS_PARAM; rq.ocf =3D OCF_READ_LINK_QUALITY; rq.cparam =3D &cr->conn_info->handle; rq.clen =3D 2; rq.rparam =3D &rp; rq.rlen =3D 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 =3D rp.link_quality; printf("Link quality for %s: %d", addr, link_quality); close(dd); free(cr); //return link_quality; } Any idea what might be wrong? Regards Arpit On 11/9/05, Marcel Holtmann wrote: > > Hi Arpit, > > > I did a yum update bluez*. > > > > The verion I'm using is: > > > > [root@174-15 bluetooth]# ls -l > > total 116 > > -rw-r--r-- 1 root root 3607 Mar 2 2005 bluetooth.h > > > > On including sys/socket.h..the error is the same: > > maybe is also missing. > > Regards > > Marcel > > > > > ------------------------------------------------------- > SF.Net email is sponsored by: > Tame your development challenges with Apache's Geronimo App Server. > Download > it for free - -and be entered to win a 42" plasma tv or your very own > Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php > _______________________________________________ > Bluez-devel mailing list > Bluez-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/bluez-devel > ------=_Part_23466_26367994.1131540770623 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hi Marcel

Yes, I forgot to include the icotl.h as well.Anyway, for I changed the defi= nition of: cr =3D (hci_conn_info_req *)= malloc(sizeof(*cr) + sizeof(struct hci_conn_info)); to this: cr =3D (struct hci_conn_info_req*) malloc(sizeof(struct hci_conn_info_req) = + sizeof(struct hci_conn_info)); . This doesn't give me the error an= y more.

However, running the compiled program results in:  Get connection info= failed

//Program for finding LQ
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <sys/ioctl.h><= br style=3D"color: rgb(255, 0, 0);"> #include <sys/socket.h>=
#include <sys/poll.h> #include <bluetooth/bluetooth.h&g= t;
#include <bluetooth/hci.h>
#include <bluetooth/l2cap.h>
#include <bluetooth/hci_lib.h>=
#include <bluetooth/rfcomm.h><= /span>
#include <bluetooth/sdp.h>
#include <bluetooth/sdp_lib.h>=

int main(int argc, char **argv)
{
    int dev_id;
    uint16_t *handle;=
    struct hci_conn_i= nfo_req *cr=3D0;
    struct hci_reques= t rq;
    read_link_quality= _rp rp;
    bdaddr_t bdaddr;<= /span>
    int dd;     int err=3D0;
    char addr[18] =3D= "00:10:60:B3:2C:F3";
   

    printf("Link= quality for %s: ", addr);

    //connecting
       = ; int ptype;
       = ; uint8_t role;

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

   
      =   if(dev_id < 0)
    {
       = ; dev_id =3D hci_get_route(&bdaddr);
       = ; if(dev_id < 0)
       = ; {
       = ;     printf("Cannot connect\n");
       = ;     return 0;
       = ; }
     }        = ;
      =   if(hci_create_connection(dd, &bdaddr, htobs(ptype), 0, role, han= dle,4000) < 0)
      =   {
      =   //printf("Cannot create connection\n");
    //return 0;
    }
   

    //get connection = links
    dd =3D hci_open_d= ev(dev_id);
    if (dd < 0) {<= /span>
       = ; printf("HCI device open failed\n");
       = ; return 0;
    }

    //cr =3D (hci_con= n_info_req *)malloc(sizeof(*cr) + sizeof(struct hci_conn_info));
        cr =3D (struct hci_conn_info_req*) malloc(sizeof(struct hci_conn_info_req) + sizeof(struct hci_conn_info));
    if (!cr)     {
       = ; return 0;
    }

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


    memset(&rq, 0= , sizeof(rq));
    rq.ogf  = ;  =3D OGF_STATUS_PARAM;
    rq.ocf  = ;  =3D OCF_READ_LINK_QUALITY;
    rq.cparam =3D &am= p;cr->conn_info->handle;
    rq.clen &nbs= p; =3D 2;
    rq.rparam =3D &am= p;rp;
    rq.rlen &nbs= p; =3D 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);<= br style=3D"color: rgb(255, 0, 0);">        = ; return 0;
    }
   
    int link_quality = =3D rp.link_quality;
    printf("Link= quality for %s: %d", addr, link_quality);
   
    close(dd);=
    free(cr);<= br style=3D"color: rgb(255, 0, 0);">

    //return link_qua= lity;
}

Any idea what might be wrong?

Regards
Arpit


On 11/9/05, Marcel Holtmann <marcel= @holtmann.org > wrote:
Hi Arpit,

> I did a yum update bluez*.
>
> The verion= I'm using is:
>
> [root@174-15 bluetooth]# ls -l
> total= 116
> -rw-r--r--  1 root root  3607 Mar &nb= sp;2  2005 bluetooth.h
>
> On including sys/socket.h..the error is the same:

maybe= <sys/ioctl.h> is also missing.

Regards

Marcel

<= br>

-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's G= eronimo App Server. Download
it for free - -and be entered to win a 42&q= uot; plasma tv or your very own
Sony(tm)PSP.  Click here to pl= ay: http://sourceforge.net/geronimo.php
________________________________= _______________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel

------=_Part_23466_26367994.1131540770623-- ------------------------------------------------------- SF.Net email is sponsored by: Tame your development challenges with Apache's Geronimo App Server. Download it for free - -and be entered to win a 42" plasma tv or your very own Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php _______________________________________________ Bluez-devel mailing list Bluez-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/bluez-devel