2006-06-08 05:13:46

by Gloria Saripah Patara

[permalink] [raw]
Subject: [Bluez-devel] How to send file using File Transfer Protocol

Hello, guys. I want to ask you about the way to send file using File
Transfer Protocol.
Here my code :

int main(){
bdaddr_t src,dest;
uint8_t channel = 0;
int mode,od;
unsigned char *buf;
size_t len;


bacpy(&src,BDADDR_ANY);
str2ba("xx:xx:xx:xx:xx:xx",&dest); //xx is my bluetooth address

if((!channel)&&(!sdp_get_ftp_channel(&src,&dest,&channel))){
printf("Can't retrieve RFCOMM OBEX channel\n");
exit(1);
}

if((od=obex_open(&src,&dest,channel))<0){
perror("Can't establish OBEX connection\n");
exit(1);
}

mode = OBEX_FILE_TRANSFER;
obex_connect(od,mode);
printf("connected\n");

obex_setpath(od, "C:/", 0x03);
cmd_put(od,"gongli.jpeg");

obex_disconnect(od);
printf("disconnected\n");
obex_close(od);

return 0;

}

i have compiled this source code and success. no error. to compile it,
i using : gcc -o main main.c -lopenobex -lbluetooth.
And then, i want test it by running it using : run-standalone.sh ./main
But, the file didn't reach the phone's memory. i mean, there's a
confirmation that a message is coming but the confirmation will
disappear immediately. i have checked the inbox or file manager
(phone's memory), but there's none. There something error on my code?.

NB : The function used in main function has declared.

-------------------------------------------
Thanks in advance


_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel


2006-06-08 07:21:08

by Marcel Holtmann

[permalink] [raw]
Subject: Re: [Bluez-users] [Bluez-devel] How to send file using File Transfer Protocol

Hi Gloria,

> I want to ask you about the way to send file using File
> Transfer Protocol.
> Here my code :
>
> int main(){
> bdaddr_t src,dest;
> uint8_t channel = 0;
> int mode,od;
> unsigned char *buf;
> size_t len;
>
>
> bacpy(&src,BDADDR_ANY);
> str2ba("xx:xx:xx:xx:xx:xx",&dest); //xx is my bluetooth address
>
> if((!channel)&&(!sdp_get_ftp_channel(&src,&dest,&channel))){
> printf("Can't retrieve RFCOMM OBEX channel\n");
> exit(1);
> }
>
> if((od=obex_open(&src,&dest,channel))<0){
> perror("Can't establish OBEX connection\n");
> exit(1);
> }
>
> mode = OBEX_FILE_TRANSFER;
> obex_connect(od,mode);
> printf("connected\n");
>
> obex_setpath(od, "C:/", 0x03);

using the FTP profile you are not using Windows alike paths. This is not
how it works and all paths are mapped under a root directory. So leave
this command out and try again.

> NB : The function used in main function has declared.

And your code has do be licensed under GPL.

Regards

Marcel




_______________________________________________
Bluez-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-users