Good day to all.
Can anybody help me figure out why the bluetooth address I am getting is
not right?
What I am trying to do is get the bluetooth address of the sender/peer
to my obex server.
Here are the obex calls I made:
--------
handle = OBEX_Init(OBEX_TRANS_BLUETOOTH, obex_event, 0);
BtOBEX_ServerRegister(handle, NULL, OBEX_PUSH_HANDLE);
btobex_accept(handle);
OBEX_HandleInput(handle, 1);
//get addresss
fd = OBEX_GetFD(handle);
if( fd < 0 )
return 0;
getpeername(fd,(struct sockaddr *)&sa,&len)
return 0;
baswap(&bdaddr, &sa.rc_bdaddr);
printf("\tADDRESS: %s\n", batostr(&bdaddr));
--------
when i run the program, i was able to get the following:
channel: 10
family: 31
ADDRESS 2: 00:0A:00:02:EE:69 -> this is not the bluetooth
address of the sender!!! Its address is 00:02:EE:69:E1:88. The last for
digits displayed are the 1st four digits of the device's real address. I
tried it with another device and the result is the same, from the
original address (00:E0:03:74:38:8E) to 00:0A:00:E0:03:74.
Bdw, I am using openobex.
Any help would be appreciated.
Thanks :)
Also, thanks to Marcel for replying to my first email: Getting remote
device address & name using obex commands
--
~jan
-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
_______________________________________________
Bluez-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-users
Hi to all :)
Here is the complete code of the server I am working on. The server code
is from http://www.frasunek.com/sources/unix/obexserver.c.
/* Simple OpenOBEX server for Bluez+OpenOBEX */
/* link with libmisc.a from OPENObex-apps and libopenobex from OpenOBEX
*/
/* [email protected] */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <openobex/obex.h>
#include "obex_io.c"
#include "obex_put_common.c"
#include <bluetooth/rfcomm.h>
#define OBEX_PUSH_HANDLE 10
volatile int finished = 0;
obex_t *handle = NULL;
int Get_handle_bdaddr(obex_t *handle, char *str);
void obex_event(obex_t *handle, obex_object_t *object, int mode, int
event, int obex_cmd, int obex_rsp);
int main(int argc, char **argv)
{
char str[256];
int get;
obex_object_t *object;
handle = OBEX_Init(OBEX_TRANS_BLUETOOTH, obex_event, 0);
if (argc == 1)
{
BtOBEX_ServerRegister(handle, NULL, OBEX_PUSH_HANDLE);
printf("Waiting for connection...\n");
btobex_accept(handle);
while (!finished)
{
OBEX_HandleInput(handle, 1);
}
get=get_bdaddr(handle,str);
}
}
/*
* int get_bdaddr(obex_t *handle, char *str)
* I've added this function
*
*/
int get_bdaddr(obex_t *handle, char *str)
{
int fd;
struct sockaddr_rc sa;
socklen_t len = sizeof(sa);
if( (fd = OBEX_GetFD(handle)) < 0 )
return 0;
if( getpeername(fd,(struct sockaddr *)&sa,&len) < 0 )
return 0;
ba2str(&sa.rc_bdaddr,str);
printf("\n\tADDRESS: %s\n", str);
printf("\tchannel: %d\n", sa.rc_channel);
printf("\tfamily: %d\n", sa.rc_family);
return 1;
}
------------
I saved it inside the openobex-apps/src folder and compiled it using
gcc -o obexserver_temp obexserver_temp.c -lopenobex -lbluetooth
Thanks :)
On Tue, 2004-02-03 at 19:30, Marcel Holtmann wrote:
> Hi Jan,
>
> > I have already inserted a len=sizeof(sa) before calling getpeername but
> > the result is still the same.
>
> show us the complete code.
>
> Regards
>
> Marcel
>
-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
_______________________________________________
Bluez-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-users
Hi Jan,
> I have already inserted a len=sizeof(sa) before calling getpeername but
> the result is still the same.
show us the complete code.
Regards
Marcel
-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
_______________________________________________
Bluez-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-users
Thanks Marcel.
I have already inserted a len=sizeof(sa) before calling getpeername but
the result is still the same.
On Mon, 2004-02-02 at 19:55, Marcel Holtmann wrote:
> Hi Jan,
>
> > Can anybody help me figure out why the bluetooth address I am getting is
> > not right?
> >
> > What I am trying to do is get the bluetooth address of the sender/peer
> > to my obex server.
> >
> > Here are the obex calls I made:
> > --------
> > handle = OBEX_Init(OBEX_TRANS_BLUETOOTH, obex_event, 0);
> >
> > BtOBEX_ServerRegister(handle, NULL, OBEX_PUSH_HANDLE);
> >
> > btobex_accept(handle);
> >
> > OBEX_HandleInput(handle, 1);
> >
> > //get addresss
> >
> > fd = OBEX_GetFD(handle);
> > if( fd < 0 )
> > return 0;
> >
> > getpeername(fd,(struct sockaddr *)&sa,&len)
> > return 0;
> >
> > baswap(&bdaddr, &sa.rc_bdaddr);
> > printf("\tADDRESS: %s\n", batostr(&bdaddr));
> > --------
> >
> >
> > when i run the program, i was able to get the following:
> > channel: 10
> > family: 31
> > ADDRESS 2: 00:0A:00:02:EE:69 -> this is not the bluetooth
> > address of the sender!!! Its address is 00:02:EE:69:E1:88. The last for
> > digits displayed are the 1st four digits of the device's real address. I
> > tried it with another device and the result is the same, from the
> > original address (00:E0:03:74:38:8E) to 00:0A:00:E0:03:74.
>
> insert a "len = sizeof(sa)" before you call getpeername().
>
> Regards
>
> Marcel
>
Hi Jan,
> Can anybody help me figure out why the bluetooth address I am getting is
> not right?
>
> What I am trying to do is get the bluetooth address of the sender/peer
> to my obex server.
>
> Here are the obex calls I made:
> --------
> handle = OBEX_Init(OBEX_TRANS_BLUETOOTH, obex_event, 0);
>
> BtOBEX_ServerRegister(handle, NULL, OBEX_PUSH_HANDLE);
>
> btobex_accept(handle);
>
> OBEX_HandleInput(handle, 1);
>
> //get addresss
>
> fd = OBEX_GetFD(handle);
> if( fd < 0 )
> return 0;
>
> getpeername(fd,(struct sockaddr *)&sa,&len)
> return 0;
>
> baswap(&bdaddr, &sa.rc_bdaddr);
> printf("\tADDRESS: %s\n", batostr(&bdaddr));
> --------
>
>
> when i run the program, i was able to get the following:
> channel: 10
> family: 31
> ADDRESS 2: 00:0A:00:02:EE:69 -> this is not the bluetooth
> address of the sender!!! Its address is 00:02:EE:69:E1:88. The last for
> digits displayed are the 1st four digits of the device's real address. I
> tried it with another device and the result is the same, from the
> original address (00:E0:03:74:38:8E) to 00:0A:00:E0:03:74.
insert a "len = sizeof(sa)" before you call getpeername().
Regards
Marcel
-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
_______________________________________________
Bluez-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-users