Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
1,032 Views

Bluetooth connecting

Hi everyone. I have a problem with connecting Bluetooth.

I am using intel centrino wireless-N 135. I read a lot of post about bluetooth connecting to iphone 4. but still haven't found solution.

I am getting blocked at input pin code. When i was using and waiting for signal. Iphone4 poped up a message for input pin code I tried 0000,1111,1234..etc..

This is what i typed.

root@clanton~:rfcomm /dev/rfcomm0 1 or 1&.

(i already set up hciconfig hci0 up.)

I don't know where i can set my pin code. I tried sspmode; but not working.

I really need help. thank you and sorry for my bad english.

0 Kudos
5 Replies
Highlighted
2 Views

Re: Bluetooth connecting

This post might give a clue:

http://forums.gentoo.org/viewtopic-t-797762-start-4.html http://forums.gentoo.org/viewtopic-t-797762-start-4.html

In that case, pincodes for specific device pairs are stored in a pincodes file. Maybe there is a way to set a generic PIN there for any device pairs?

Highlighted
Beginner
2 Views

Re: Bluetooth connecting

Thank you , but actually i tried this already and it didn't work well.. because i think that pincodes file didn't exist at there.And i manually made a hcid.conf file. but don't know how to fit it in to mine.

It is really annoying.. i spent too long time.

Any suggestion for me?

Highlighted
Novice
2 Views

Re: Bluetooth connecting

actually pincodes does not help for galileo.

i use 135 ,and follow these commands can connect my iphone yesterday ,but not today(pincode issue i do not know why),

# rfcomm bind /dev/rfcomm0 xx:xx:xx:xx:xx:xx(other bluetooth device mac)

# cat >/dev/rfcomm0

you can try these commands, may you success.

after all of this i prepare to write c programme to communicate with control another bluetooth device like a single chip something on l2 raw data packets.

waiting for some help too.

thank u.

0 Kudos
Highlighted
New Contributor II
2 Views

Re: Bluetooth connecting

Just for the record: Distribution specific help pages may not always help, because they often use distribution specific tools. So you should check help pages of other linux distributions too. Also there are different versions of BlueZ in the wild, which behave different (including but not limited to config file and binary locations, and also tools).

To disable the pincode request, you can try:

hciconfig hci0 sspmode 1

SSP = Simple Pairing, doesn't require a pin.

Highlighted
Novice
2 Views

Re: Bluetooth connecting

now i can send bluetooth messages from linux to galileo.

  1. follow the steps https://github.com/tokoro10g/galileo-makefile https://github.com/tokoro10g/galileo-makefile, then you can compile c programme without compile

the yoto damn thing or cross compiler.

2. the server run on galileo.(need some of bluez include file bluetooth.h l2cap.h)

server.c

# include

# include

# include

# include

# include

# include

# include

# include

# include

# include

# include

# include

# define RWRR (S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH)

# define BUFFSIZE 1024

void puintobg(){

/* Our process ID and Session ID */

pid_t pid, sid;

/* Fork off the parent process */

pid = fork();

if (pid < 0)

exit(EXIT_FAILURE);

/* If we got a good PID, then

we can exit the parent process. */

if (pid > 0)

exit(EXIT_SUCCESS);

/* Change the file mode mask */

umask(0);

/* Create a new SID for the child process */

sid = setsid();

if (sid < 0)

exit(EXIT_FAILURE);

/* Change the current working directory */

if ((chdir("/")) < 0)

exit(EXIT_FAILURE);

/* Close out the standard file descriptors */

close(STDIN_FILENO);

close(STDOUT_FILENO);

close(STDERR_FILENO);

}

int main(int argc, char **argv)

{

puintobg();

time_t timep;

struct sockaddr_l2 loc_addr = { 0 }, rem_addr = { 0 };

struct sockaddr_l2 addr;

socklen_t optlen;

char buf[BUFFSIZE] = { 0 };

char buftmp[BUFFSIZE]={0};

char str[18];

int s, client, bytes_read;

socklen_t opt = sizeof(rem_addr);

// allocate socket

s = socket(AF_BLUETOOTH, SOCK_SEQPACKET, BTPROTO_L2CAP);

// bind socket to port 0x1001 of the first available

// bluetooth adapter

loc_addr.l2_family = AF_BLUETOOTH;

loc_addr.l2_bdaddr = *BDADDR_ANY;

loc_addr.l2_psm = htobs(0x1001);

if (bind(s, (struct sockaddr *)&loc_addr, sizeof(loc_addr)) < 0) {

//perror("Can't bind socket");

goto error;

}

/* Get local address */

memset(&addr, 0, sizeof(addr));

optlen = sizeof(addr);

if (getsockname(s, (struct sockaddr *) &addr, &optlen) < 0) {

//perror("Can't get local address");

goto error;

}

ba2str(&addr.l2_bdaddr, str);

//printf("localaddr %s ...\n", str);

// put socket into listening mode

listen(s, 1);

while(1){

// accept one connection

client = accept(s, (struct sockaddr *)&rem_addr, &opt);

ba2str( &rem_addr.l2_bdaddr, buf );

sprintf(buftmp, "accepted connection from %s ", buf);

memset(buf, 0, sizeof(buf));

// read data from the client

bytes_read = read(client, buf, sizeof(buf));

if( bytes_read > 0 ) {

int fd=0;;

//printf("received [%s]\n", buf);

if((fd = open("btContent.log", O_WRONLY | O_CREAT | O_APPEND, RWRR)) < 0)

goto error;

write(fd,buftmp,strlen(buftmp));

write(fd, "[",1);

write(fd, buf, bytes_read);

write(fd, "]",1);

time(&timep);

write(fd,ctime(&timep),24);

write(fd, "\n",1);

//goto error;

close(fd);

}

close(client);

}

error:

close(client);

close(s);

exit(1);

}

3.client.c runs on linux with usb bluetooth device

# include

# include

# include

# include "bluetooth.h"

# include "l2cap.h"

int main(int argc, char **argv)

{

struct sockaddr_l2 addr = { 0 };

int s, status;

char *message;

char dest[18];

if(argc < 2)

{

fprintf(stderr, "usage: %s \n", argv[0]);

exit(2);

}

if(argc==3){

strncpy(dest, argv[1], 18);

message=argv[2];

}

else{

strncpy(dest,"00:15:00:96:7F:93",18);

message=argv[1];

}

// allocate a socket

s = socket(AF_BLUETOOTH, SOCK_SEQPACKET, BTPROTO_L2CAP);

// set the connection parameters (who to connect to)

addr.l2_family = AF_BLUETOOTH;

addr.l2_psm = htobs(0x1001);

str2ba( dest, &addr.l2_bdaddr );

// connect to server

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

// send a message

if( status == 0 ) {

status = write(s, message, strlen(message));

}

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

close(s);

}

4.of course do not forget run :

hciconfig hci0 up

hciconfig hci0 piscan

on galileo.