13 Replies Latest reply on Feb 19, 2015 12:37 AM by kganesh

    intel Edison Bluetooth connection refuse

    kganesh

      Hi,

       

      I am trying bluetooth communication using rfcomm. For this, I am referring this link Communicating with RFCOMM

       

      When I run rfcomm-client.py service on intel edison and rfcomm-client.py on other bluetooth enabled device. These both communicating without any problems. When I tries to run rfcomm-server.py in intel edison and rfcomm-client.py on other device, the connection getting terminated at client side with the following errors

      Traceback (most recent call last):

        File "rfcomm-client.py", line 5, in <module>

          client_socket.connect(("<bluetooth_device_address>",port))

        File "<string>", line 5, in connect

      bluetooth.btcommon.BluetoothError: (13, 'Permission denied')

       

      When I tried these type of communications among other bluetooth devices, they are working very good.

       

      I found same case in this forum at this link Bluetooth communication Edison/phone. But, I didn't get expected answer from that post. I wanted rfcomm-server.py running on intel edison, should receive message from other bluetooth rfcomm clients.

       

      I am suspecting, there is hidden issue/secret in intel edison. Hope intel edison makers can respond with good solution.

       

      Thanks

      Ganesh

       

       

        • 1. Re: intel Edison Bluetooth connection refuse
          Intel_Alvarado

          Hi kganesh,

           

          Have you already enabled Bluetooth on the board? To enable Bluetooth run the command root@edison:~# rfkill unblock Bluetooth. After Bluetooth is enabled you can see the available interfaces you can connect to using rfkill list. You can see more information about pairing devices here https://communities.intel.com/docs/DOC-23618 .

           

          Regards

          Sergio

          • 2. Re: intel Edison Bluetooth connection refuse
            kganesh

            Hi Sergio,

             

            This Intel® Edison Bluetooth Guide is quite useful to work with intel Edison, absolutely No doubt in that.

             

            But, My idea is to use bluetooth rfcomm protocol to communicate with other device. I found some useful link Communicating with RFCOMM. This helps me to automate the process of bluetooth communication with other device. Where as, if I go with bluetoothctl tool I should definitely with interactive process. I thought rfcomm-server and rfcomm-client process would be the best choice.

             

            If my idea is not good, Can you suggest any other way to automate the bluetooth communication procedure between Intel Edison and Ubuntu PC.? May be intel Edison can support any of such bluetooth communication tools.? Hope you get my Question.?

             

            Thanks

            Ganesh

            • 3. Re: intel Edison Bluetooth connection refuse
              Intel_Alvarado

              Hi kganesh,

               

              According to the error message, you are getting it from the rfcomm-client.py.

              Make sure you are not using the bd_addr address given in that example but the one of your device.

               

              Regards

              Sergio

              • 4. Re: intel Edison Bluetooth connection refuse
                kganesh

                Hi Sergio,

                 

                In the rfcomm-server.py, no specific bd_addr is required (You can check from the source). In rfcomm-client.py, I mentioned correct bd_addr of intel Edison and matching port number as well. As I said in earlier message rfcomm-client.py is working in Intel Edison well. It looks rfcomm-server.py running in intel Edison deny the permissions to give access for rfcomm-client.py. I am not sure that my doubt is correct. I can't say, this issue is only from intel Edison side, It may be issue of bluetooth profiles as well. Sometimes in raspberry pi also, We detected this problem. When Raspberry get rebooted, it works well. But, Intel Edison situation is quite different.

                 

                I don't have another intel Edison to check this scenario. So, I am relied in this community answers to get the solution. Hope it can be useful to other users as well.

                 

                Thanks,

                Ganesh

                • 5. Re: intel Edison Bluetooth connection refuse
                  Intel_Alvarado

                  Hi kganesh,

                   

                  Have you already tried to run this using the new software release? You can download it here Intel® Edison Boards and Compute Modules — Software Downloads . As stated in the R2 release notes Intel® Edison Boards and Compute Modules — Support Package Release Notes there is a resolved issue of rfcomm. Try downloading the new image and let us know your results.

                   

                  Regards

                  Sergio

                  • 6. Re: intel Edison Bluetooth connection refuse
                    kganesh

                    Hi Sergio,

                     

                    I tried this latest yocto source http://downloadmirror.intel.com/24698/eng/edison-image-ww05-15.zip. Still, I didn't find solution for What I am looking for. If anyone trying my case at their end, they can understand about the issue clearly.

                     

                    Thanks,
                    Ganesh

                    • 7. Re: intel Edison Bluetooth connection refuse
                      Frederick Blais

                      Hello kganesh,

                       

                      I fiddled with pybluez with the Edison and my Ubuntu computer a couple weeks ago. I would like to help you but I'm away from home until Feb 20. I'll take a look into this when I'll be back.

                      Could you try enable page and inquiry scan on both devices? It helped me resolve some connection issues :

                       

                      hciconfig hci0 piscan

                      (change hci0 for the correct Bluetooth adapter)

                      • 8. Re: intel Edison Bluetooth connection refuse
                        kganesh

                        Hi,

                         

                        I could list you the commands trying. In intel Edison, I am giving the following commands to work with bluetooth.

                         

                        1. rfkill unblock bluetooth

                        2. hciconfig hci0 up

                        3. hciconfig hci0 piscan (as you said)

                         

                        Now, Running rfcomm-server.py on port number 1

                         

                        And, Ubuntu PC side

                        1. hciconfig hci0 up

                         

                        Here, Running rfcomm-client.py on port number 1 with intel Edison bluetooth address to point. Even though, it is giving "Connection refuse" error.

                        • 9. Re: intel Edison Bluetooth connection refuse
                          Thror

                          Hi kganesh,

                           

                          I'm stuck on the same problems, even if my code is in C++ .

                           

                          I have add some checks on RFCOMM sockets examples. I discover that the bind function on server side fails. Tomorrow I'll do ore tests.

                           

                          As soon as I find the solution, I publish it.

                           

                          I hope you do the same,

                           

                          Best Regards,

                           

                          Thror

                          • 10. Re: intel Edison Bluetooth connection refuse
                            kganesh

                            Hi Thror,

                             

                            I will also look into that in parallel. When you get appropriate solution, Please post to me. I will also try to resolve issue at my end.

                             

                            Thanks,

                            Ganesh

                            • 11. Re: intel Edison Bluetooth connection refuse
                              Thror

                              Hi Ganesh,

                               

                              I test again the C/C++ software

                               

                              This is the server.cpp:

                               

                              #include <stdio.h>

                              #include <unistd.h>

                              #include <sys/socket.h>

                              #include <bluetooth/bluetooth.h>

                              #include <bluetooth/rfcomm.h>

                               

                               

                              int main(int argc, char **argv)

                              {

                               

                               

                                printf("qui\n");

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

                                  char buf[1024] = { 0 };

                                  char dest[18]="98:4F:EE:03:0B:AC";

                                  int s, client, bytes_read;

                                  socklen_t opt = sizeof(rem_addr);

                               

                               

                                  // allocate socket

                                  s = socket(AF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM);

                                  printf("s: %d\n", s);

                                  // bind socket to port 1 of the first available

                                  // local bluetooth adapter

                                  loc_addr.rc_family = AF_BLUETOOTH;

                                  loc_addr.rc_channel = (uint8_t) 1;

                                  str2ba(dest, &loc_addr.rc_bdaddr);

                               

                               

                                  bind(s, (struct sockaddr *)&loc_addr, sizeof(loc_addr));

                               

                               

                                  // put socket into listening mode

                                  listen(s, 1);

                               

                               

                                  // accept one connection

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

                               

                               

                                  ba2str( &rem_addr.rc_bdaddr, buf );

                                  fprintf(stderr, "accepted connection from %s\n", buf);

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

                               

                               

                                  // read data from the client

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

                                  if( bytes_read > 0 ) {

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

                                  }

                               

                               

                                  // close connection

                                  close(client);

                                  close(s);

                                  return 0;

                              }

                               

                              This is the client.cpp:

                              #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]="98:4F:EE:03:0B:AC";

                                  // allocate a socket

                                  s = socket(AF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM);

                                  printf("s:%d\n", s);

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

                                  addr.rc_family = AF_BLUETOOTH;

                                  addr.rc_channel = (uint8_t) 1;

                                  str2ba( dest, &addr.rc_bdaddr );

                               

                               

                                  // connect to server

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

                               

                               

                                  // send a message

                                  if( status == 0 ) {

                                      status = write(s, "hello!", 6);

                                  }

                               

                               

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

                               

                               

                                  close(s);

                                  return 0;

                              }

                              • 12. Re: intel Edison Bluetooth connection refuse
                                Thror

                                I'm sorry for the double message!

                                 

                                Testing again the software, you can find it in the previous message, I succeeded in sending message between two Edison device!

                                 

                                I did not understand why today I succeeded. I setup again the pairing and connection between Edison with bluetoothctl service.

                                 

                                If you need help or have some questions, I'll try to respond you,

                                 

                                See you

                                Thror

                                • 13. Re: intel Edison Bluetooth connection refuse
                                  kganesh

                                  Hi Thror,

                                   

                                  Happy to hear working on your end. For the first time, I tried to communicate, It worked for me also. After that, Several times I tried to do this. But, In the all cases I failed to communicate except first time.

                                   

                                  Any how, I will try again to see the result of fresh communication.

                                   

                                  Thanks,

                                  Ganesh