2009-09-18 11:19:23

by Lorenzo Brito Morales

[permalink] [raw]
Subject: Help

Hi, im a beggineer in bluez and also in programming stuff, i have read
a coupble of things about bluez and programming, what i want to do is
a progran that send files to the phone is near by,,im trying to get
work these code, its compile, and conect to the phone , but in the
phone ask for a number security, ahta later i have to type in the
computer...... how can i send a file whitout asking a number? just
asking in the phone about aceptting the file
#include <stdio.h>
#include <unistd.h>
#include <sys/socket.h>
#include <bluetooth/bluetooth.h>
#include <bluetooth/rfcomm.h>

int main(int argc, char **argv)
{
struct sockaddr_rc addr = { 0 };
int s, status;
char dest[18] = "00:23:F1:CC:BF:10";

// allocate a socket
s = socket(AF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM);

// set the connection parameters (who to connect to)
addr.rc_family = AF_BLUETOOTH;
addr.rc_channel = 1;
str2ba( dest, &addr.rc_bdaddr );

// connect to server
status = connect(s, (struct sockaddr *)&addr, sizeof(addr));

// send a message
if( 0 == status ) {
status = send(s, "hello!", 6, 0);
}

if( status < 0 ) perror("uh oh");

close(s);
return 0;
}


2009-09-18 13:18:03

by Iain Hibbert

[permalink] [raw]
Subject: Re: Help

On Fri, 18 Sep 2009, Lorenzo Brito Morales wrote:

> Hi, im a beggineer in bluez and also in programming stuff, i have read
> a coupble of things about bluez and programming, what i want to do is
> a progran that send files to the phone is near by,,im trying to get
> work these code, its compile, and conect to the phone , but in the
> phone ask for a number security, ahta later i have to type in the
> computer...... how can i send a file whitout asking a number? just
> asking in the phone about aceptting the file

Well, in this case the phone requires authentication to connect to the
service on RFCOMM channel #1 so you are out of luck unless you can provide
the same PIN at both ends (or other pairing)

You need to investiage "OBEX Object Push". Sometimes you can send a text
file without authentication, but the person who owns the phone will
usually be required to authorise the connection (ie a message will appear,
asking if they wish to receive the file and they will need to approve)

It is a long way to do it yourself, look for "obexd" at http://www.bluez.org

iain