List Info

Thread: problem reading rssi




problem reading rssi
user name
2007-03-29 22:18:01
Hi,

I am having some headache for reading the rssi of a remote device. The code bellow insists in returning 0 to the "rssi" variable when I try to read the rssi of a connected Nokia 770. If I run the same code for a connected desktop, then a non zero value is returned. For complicating even more, if I run "hcitool clkoff <addr&gt;" when connected to the 770, then a non zero value is also returned.

 &nbsp;  struct hci_conn_info_req* cr;
   ; bdaddr_t bdaddr;
&nbsp; &nbsp; int8_t rssi;
&nbsp; &nbsp;
 &nbsp;  char* addr = device->;client->;getClientAddressAsString();
&nbsp; &nbsp; int sockId = device->;dongle->;getSocketId();

&nbsp; &nbsp; str2ba( addr, &bdaddr );

   ; cr = (hci_conn_info_req*)malloc(sizeof(*cr) + sizeof(struct hci_conn_info));
&nbsp; &nbsp; if( !cr ) {
 &nbsp;   &nbsp;  perror( "Can&#39;t allocate memory&quot; );
 &nbsp;   &nbsp;  exit( 1 );
 ; &nbsp; }

 &nbsp;  bacpy(&;cr->bdaddr, &bdaddr);
 &nbsp;  cr->type = ACL_LINK;
  ;  if( ioctl( sockId, HCIGETCONNINFO, (unsigned long) cr ) < 0 ) {
 &nbsp;   &nbsp;  perror(&quot;Get connection info failed&quot;);
&nbsp; &nbsp;  &nbsp;  exit(1);
&nbsp;   }

 &nbsp;  if( hci_read_rssi(sockId, htobs(cr-&gt;conn_info->handle), &rssi, 1000) < 0 ) {
 &nbsp;   &nbsp;  perror(&quot;Read RSSI failed&quot;);
   ;  &nbsp;  exit(1);
&nbsp;   }

 &nbsp;  printf(&quot;RSSI return value: %dn", rssi);

  ;  free(cr);
  ;  return (int)rssi;

Does anyone have some idea about what is going wrong here?

Loreno
Re: problem reading rssi
country flaguser name
Germany
2007-03-31 08:48:55
Hi Loreno,

> I am having some headache for reading the rssi of a
remote device. The
> code bellow insists in returning 0 to the
"rssi" variable when I try
> to read the rssi of a connected Nokia 770. If I run the
same code for
> a connected desktop, then a non zero value is returned.
For
> complicating even more, if I run "hcitool clkoff
<addr>" when
> connected to the 770, then a non zero value is also
returned. 

it depends on the local adapter you use and the Bluetooth
chip in the
remote device. Some devices don't report the correct RSSI
value. It
seems they always return 0.

Regards

Marcel



------------------------------------------------------------
-------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the
chance to share your
opinions on IT & business topics through brief
surveys-and earn cash
http://www.techsay.com/default.
php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Bluez-users mailing list
Bluez-userslists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-users


Re: problem reading rssi
user name
2007-03-31 11:28:20
Thanks for answer Marcel.

However, i think this is not the case. In some test I have made, I put two scripts to run at the same time. The first one used hcitool for getting the RSSI, the second one used my program to get the RSSI. Looking to the prints on the terminal window, my program returned zero for the RSSI value while hcitool returned a non zero value...

I am quite confused with this result. The code I am using for getting the rssi is the same as the code hcitool uses. As far as a saw, the whole code necessary for measuring rssi through hcitool is within the "cmd_rssi" function. Is that right or there is some state outside cmd_rssi that impacts in the correctness of the measurement?

Thanks again,

Loreno

On 3/31/07, Marcel Holtmann < marcelholtmann.org">marcelholtmann.org> wrote:
Hi Loreno,

&gt; I am having some headache for reading the rssi of a remote device. The
> code bellow insists in returning 0 to the "rssi" variable when I try
> to read the rssi of a connected Nokia 770. If I run the same code for
> a connected desktop, then a non zero value is returned. For
> complicating even more, if I run "hcitool clkoff <addr&gt;" when
> connected to the 770, then a non zero value is also returned.

it depends on the local adapter you use and the Bluetooth chip in the
remote device. Some devices don't report the correct RSSI value. It
seems they always return 0.

Regards

Marcel



-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Bluez-users mailing list
Bluez-userslists.sourceforge.net">Bluez-userslists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-users

[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )