I want to do an application using openobex.
I want to use it for sending and receiving files. And I want to know the sender's or the receiver's bluetooth address. I have checked the openobex apidocs very detailed. But I didn't find some functions that I can get it. So who can help me?? Or give me some hint??:)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
It's been discussed on the list before. In summary:
use OBEX_GetFD() to get the socket, then getpeername() to retrieve the sockaddr.
HTH. Let me know if this solves the problem.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
It works.
But I have a new problem.
When a new connection is accepted, I use OBEX_GetFD and getpeername to retrieve the sockaddr. The sockaddr isn't exactly the real address It has some differences.
For example, the real address is '00:1A:16:C0:51:B4'. But the address in my program is '00:0A:00:1A:16:C0'. I don't know why? Can you help me??
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Sounds like you are programming a server. If you use this on a listening socket you'll get the address of your local hci. You need to call it on the established connection.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Yes, I am programming a server.
But I didn't use this on a listening socket. It's on the accepted socket.
And I use another method to solve this problem.
I want to do an application using openobex.
I want to use it for sending and receiving files. And I want to know the sender's or the receiver's bluetooth address. I have checked the openobex apidocs very detailed. But I didn't find some functions that I can get it. So who can help me?? Or give me some hint??:)
It's been discussed on the list before. In summary:
use OBEX_GetFD() to get the socket, then getpeername() to retrieve the sockaddr.
HTH. Let me know if this solves the problem.
It works.
But I have a new problem.
When a new connection is accepted, I use OBEX_GetFD and getpeername to retrieve the sockaddr. The sockaddr isn't exactly the real address It has some differences.
For example, the real address is '00:1A:16:C0:51:B4'. But the address in my program is '00:0A:00:1A:16:C0'. I don't know why? Can you help me??
Sounds like you are programming a server. If you use this on a listening socket you'll get the address of your local hci. You need to call it on the established connection.
Yes, I am programming a server.
But I didn't use this on a listening socket. It's on the accepted socket.
And I use another method to solve this problem.
int get_bdaddr(obex_t *handle, char *str) {
int fd;
unsigned char name[100];
int i;
fd = OBEX_GetFD(handle);
if( fd < 0 ){
return 0;
}
if( getpeername(fd, (struct sockaddr *)name, &len) ){
return 0;
}
sprintf(str,"%02X:%02X:%02X:%02X:%02X:%02X",name[7],name[6],name[5],name[4],name[3],name[2]);
//ba2str(&client_saddr.rc_bdaddr,str);
}
The bluetooth address is on the range 2-7 of the array name.