
feiyinziiu
New User
Oct 19, 2009, 3:46 AM
Post #1 of 3
(574 views)
|
Hello, 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:68:DB:2E:70"; 11 // allocate a socket 12 s = socket(AF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM); 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 } 28
|