Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer
User Name
Linux - Embedded & Single-board computer This forum is for the discussion of Linux on both embedded devices and single-board computers (such as the Raspberry Pi, BeagleBoard and PandaBoard). Discussions involving Arduino, plug computers and other micro-controller like devices are also welcome.


  Search this Thread
Old 10-19-2009, 03:50 AM   #1
LQ Newbie
Registered: Oct 2009
Posts: 7

Rep: Reputation: 0
Red face how to programme with the bluetooth passcode?


I'm programming with bluez to use the
bluetooth dongle under linux to connect to
the remote bluetooth devices.But when the
my PC run the programme,and try to connect to the bluetooth of my cellphone,it ask for passcode.and I don't know how to deal with it.after I put in passcode, the bluetooth says :connect refused.

how to programm with the passcode?

thank you!

my bluetooth test is this:

1 #include <stdio.h>
2 #include <unistd.h>
3 #include <sys/socket.h>
4 #include <bluetooth/bluetooth.h>
5 #include <bluetooth/rfcomm.h>
6 int main(int argc, char **argv)
7 {
8 struct sockaddr_rc addr = { 0 };
9 int s, status;
10 char dest[18] = "00:26:68B:2E:70";
11 // allocate a socket
13 // set the connection parameters (who to connect to)
14 addr.rc_family = AF_BLUETOOTH;
15 addr.rc_channel = (uint8_t) 1;
16 str2ba( dest, &addr.rc_bdaddr );
17 // connect to server
18 status = connect(s, (struct sockaddr *)&addr, sizeof(addr));
19 printf("return\n");
20 // send a message
21 //if( status == 0 ) {
22 status = write(s, "hello!", 6);
23 //}
24 if( status < 0 ) perror("uh oh");
25 close(s);
26 return 0;
27 }
Old 10-20-2009, 02:28 PM   #2
LQ Guru
Registered: Jan 2004
Location: NJ, USA
Distribution: Slackware, Debian
Posts: 5,852

Rep: Reputation: 357Reputation: 357Reputation: 357Reputation: 357
So you are trying to specify the PIN in the running program, rather than using BlueZ's system-wide PIN settings?
Old 10-20-2009, 07:21 PM   #3
LQ Newbie
Registered: Oct 2009
Posts: 7

Original Poster
Rep: Reputation: 0
Red face

Originally Posted by MS3FGX View Post
So you are trying to specify the PIN in the running program, rather than using BlueZ's system-wide PIN settings?
Thanks for you reply.

en,yes.Because I find that my USB bluetooth dongle cannot connect to my nokia cellphone without the passcode.
I have searched the Interner.they told me to modify the hcid.conf and pin files.I did,however,I faided to connect my cellphone.
so I want to programm with the passcode.

my hcid.conf settings are like this:

# HCI daemon configuration file.

# HCId options
options {
# Automatically initialize new devices
autoinit yes;

# Security Manager mode
# none - Security manager disabled
# auto - Use local PIN for incoming connections
# user - Always ask user for a PIN
security auto;

# Pairing mode
# none - Pairing disabled
# multi - Allow pairing with already paired devices
# once - Pair once and deny successive attempts
pairing multi;

# Default PIN code for incoming connections
passkey "12345";

# Default settings for HCI devices
device {
# Local device name
# %d - device id
# %h - host name
name "BlueZ (%d)";

# Local device class
class 0x000100;

# Default packet type
#pkt_type DH1,DM1,HV1;

# Inquiry and Page scan
iscan enable; pscan enable;

# Default link mode
# none - no specific policy
# accept - always accept incoming connections
# master - become master on incoming connections,
# deny role switch on outgoing connections
lm accept;

# Default link policy
# none - no specific policy
# rswitch - allow role switch
# hold - allow hold mode
# sniff - allow sniff mode
# park - allow park mode
lp rswitch,hold,sniff,park;

with those settings,I still cannot connect to my cellphone successfully.

Last edited by feiyinziiu; 10-20-2009 at 07:27 PM.


bluetooth, passcode

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Bluetooth not working on FC6 with Targus USB bluetooth adapter mikevicious Linux - Software 1 12-11-2009 09:03 AM
Help retrieving current internet passcode... ladyigrainia Linux - Wireless Networking 5 08-27-2009 11:50 AM
best programme new.. elamina Linux - Software 1 05-14-2009 10:04 AM
problemn: nokia asks for passcode when connecting to airtel gps and fails to connect alokanand007 Linux - Mobile 6 12-27-2008 11:01 AM > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer

All times are GMT -5. The time now is 08:23 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration