From: thanit sara <sara200t@uregina.ca>
To: BlueZ users <bluez-users@lists.sourceforge.net>
Subject: Re: [Bluez-users] Inquiry result with RSSI (From Newbie)
Date: Mon, 11 Aug 2008 16:46:03 -0500 [thread overview]
Message-ID: <BLU117-W15E187C73BF9CFCA61DDBBDF710@phx.gbl> (raw)
In-Reply-To: <d89ddf300808110209k46949860n3c525a7dd7e7b341@mail.gmail.com>
My hcidump seems to be running now, but still cannot read the rssi value. Anyone please tell me where can I read the RSSI from the inquiry result.
----------------------------------------
> From: sara200t@uregina.ca
> To: bluez-users@lists.sourceforge.net
> Subject: Inquiry result with RSSI (From Newbie)
> Date: Mon, 11 Aug 2008 16:24:17 -0500
>
>
> Dear all,
>
> Question from newbie. I am trying to send out the inquiry result format with RSSI.
> This is what I have done.
> My steps are
> 1.)open the BT device (open socket)
> 2.)set up event filters
> 3.)set the inquiry mode to be result format with RSSI
> "int set_Inquiring = hci_send_cmd(sock, OGF_HOST_CTL, OCF_WRITE_INQUIRY_MODE, WRITE_INQUIRY_MODE_RP_SIZE, &cpp);//set inquiry mode"
> 4.)send out an inquiry
> "int Inquiring = hci_send_cmd(sock, OGF_LINK_CTL,OCF_INQUIRY , INQUIRY_CP_SIZE, &cp);//do inquiry"
> 5.)try to read the rssi from "inquiry_info_with_rssi read_rssi"
> 6.)close socket
>
> Below is my code. Please advice me. Am I missing something here.
> /**************************************************************************************************
> //Open BT device
> //to retrieve the BT id of the local BT adaptor
> local_BT_id = hci_get_route(NULL); //NULL option = get teh first available BT adaptor
> //check for error
> if (local_BT_id < 0)
> {
> // printf(stderr, "error code %d: %s\n",errno, strerror(errno));
> perror("Fail to get BT adaptor id");
> exit(1);
> }
>
> //to open the socket of the local BT device
> sock = hci_open_dev( local_BT_id );
> // check for error
> if (local_BT_id < 0 || sock < 0)
> {
> perror("Fail to open device socket");
> exit(1);
> }
> //*****************************************************
> //Set up an event filter looking after the inquiry related events
> struct hci_filter InqFilter;
> hci_filter_clear(&InqFilter);
> hci_filter_set_ptype(HCI_EVENT_PKT, &InqFilter);
> hci_filter_set_event(EVT_INQUIRY_RESULT, &InqFilter);
> hci_filter_set_event(EVT_INQUIRY_RESULT, &InqFilter);
> hci_filter_set_event(EVT_INQUIRY_RESULT_WITH_RSSI, &InqFilter);
> hci_filter_set_event(EVT_INQUIRY_RESULT_WITH_RSSI, &InqFilter);
> hci_filter_set_event(EVT_INQUIRY_COMPLETE, &InqFilter);
> if (setsockopt(sock, SOL_HCI, HCI_FILTER, &InqFilter, sizeof(InqFilter)) < 0)
> {
> perror("Fail to setup filter!");
> exit(1);
> }
>
> //*****************************************************
> //inquiry with the RSSI result
> inquiry_info_with_rssi read_rssi;
>
> write_inquiry_mode_cp cpp;
> cpp.mode = 0x01;
> int set_Inquiring = hci_send_cmd(sock, OGF_HOST_CTL, OCF_WRITE_INQUIRY_MODE, WRITE_INQUIRY_MODE_RP_SIZE, &cpp);//set inquiry mode
>
> inquiry_cp cp;
> cp.lap[0] =0x33;
> cp.lap[1] =0x8b;
> cp.lap[2] =0x9e;
> cp.length = 4; //=4*1.28second = 5seconds
> cp.num_rsp =0;
>
> int Inquiring = hci_send_cmd(sock, OGF_LINK_CTL,OCF_INQUIRY , INQUIRY_CP_SIZE, &cp);//do inquiry
> if (Inquiring < 0)
> {
>
> printf("starting to inquire: %d\n",Inquiring);
> exit(1);
> }
> else
> printf ("Done inquiry with RSSI!\n");
>
> printf("rssi value = %d \n", read_rssi.rssi); //Try to print the RSSI value here.
> close( sock );//close socket
> return 0;
> }
> /***********************************************************************
>
>
> Beside my hcidump shows no event result format with RSSI.
>
> < HCI Command: Write Inquiry Mode (0x03|0x0045) plen 1
> 01
>> HCI Event: Command Complete (0x0e) plen 4
> 01 45 0C 00
> < HCI Command: Inquiry (0x01|0x0001) plen 5
> 33 8B 9E 04 00
>> HCI Event: Command Status (0x0f) plen 4
> 12 01 01 04
> /********************************************************************
>
> Your kindness is greatly appreciated. I use Fedora9, with BlueZ version 3.32. (I tried command hciconfig hci0 inqmode 1 and it works fine, so I think the problem might not be from my usb dongle.)
>
> Best regards,
> Sara
>
> _________________________________________________________________
>
_________________________________________________________________
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Bluez-users mailing list
Bluez-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-users
next prev parent reply other threads:[~2008-08-11 21:46 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-10 23:23 [Bluez-users] bluetooth tethering to at&t phone issues Jared Kidd
2008-08-11 9:09 ` Brad Midgley
2008-08-11 21:24 ` [Bluez-users] Inquiry result with RSSI (From Newbie) thanit sara
2008-08-11 21:46 ` thanit sara [this message]
2008-08-14 9:58 ` [Bluez-users] bluetooth tethering to at&t phone issues Xamindar
2008-08-15 18:14 ` Xamindar
2008-08-19 4:02 ` jayjwa
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=BLU117-W15E187C73BF9CFCA61DDBBDF710@phx.gbl \
--to=sara200t@uregina.ca \
--cc=bluez-users@lists.sourceforge.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox