14 Replies Latest reply on Nov 4, 2014 2:43 PM by hk101

    Bluetooth server

    FlavioM

      Hi everybody,

      I am quite a beginner in the embedded development, please forgive me for any misunderstanding

       

      What I am trying to do is to create a bluetooth server on the Edison board, with a smartphone that is able to interact with it. I checked this forum and the web and, as far as I know, I found these options:

       

      • Flashing the Edison board with Debian, install python-bluez and develop it Debian on Edison
      • Building from scratch a custom image of yocto linux and try to add the proper libraries (but I am not sure that correct libraries exists)
      • Try to figure out how to use the Arduino IDE and develop a sketch with the bluetooth support (again, it's the first time that I am developing something for embedded systems).

       

      I have no preference for the programming language: C, C++, Java, Python are available options.

       

      Has  anyone ever had any experience with this kind of problem?

       

      Thank you

      Flavio

        • 1. Re: Bluetooth server
          mhahn

          why don't you work with BlueZ available on Edison? I suppose you should be able to just add python-bluez to it if you want to have python bindings. You'd probably have to manually install it

          • 2. Re: Bluetooth server
            AlexT_Intel

            ...or install pip and then install pybluez (which is what Debian calls python-bluez).

            • 3. Re: Bluetooth server
              FlavioM

              Thank you for your reply

               

              At this moment, I am trying the "Debian way". However, I am noticing a problem with the left space on the device.

              It seems that there is no space left for saving a a debian root directory (about 280 MB). I tried to flash the Edison a couple of times but the problem remains.

              I have not installed anything other than what there is from the beginning, of course.

               

              It is off topic for sure, but it is a little bit frustrating

               

              When I try to log in, I always receive these messages:

               

              [   69.967916] systemd-fsck[265]: /dev/mmcblk0p10: recovering journal

              [   70.018184] systemd-fsck[265]: /dev/mmcblk0p10: clean, 14/152608 files, 26869/610299 blocks

               

              EDIT:

              okok it is my fault

              I tried to save everything in a new directory in /

              With the df shell command I noted that most of the free space is in /home.

               

              I have just a doubt:

              Is there any differences between installing package with opkg and compiling the kernel image with new third-part libraries? I mean, why should I re-compile the kernel if I can use the package manager?

               

              Thank you very much.

               

              Flavio

              • 4. Re: Bluetooth server
                AlexT_Intel

                I mean, why should I re-compile the kernel if I can use the package manager?

                The only reason I can think of in this case is if you need a specific kernel option to be enabled/disabled.

                If you need just one or coupel things to be installed, it's much easier to either build from sources right on Edison or use the package repo. Rebuilding the whole image is only useful if you need to modify kernel or have some really custom build you want to use on several boards or continuously reflash on the same board, in which case installing the packages or from sources may be inconvenient (though could be scripted - many approaches are possible )

                • 5. Re: Bluetooth server
                  FlavioM

                  I have figured out how to write code for bluetooth applications. I hope it helps for those that want to develop bluetooth programs on Edison board.

                   

                   

                  Here the steps:

                  1. Configure the Edison board with the default image (kernel, Wifi, etc ...)
                  2. Choose a development strategyHelp with Cross Compiling . In my case I have preferred to develop code on my laptop a crosscompiling it with Eclipse.
                  3. Install Eclipse with both Intel Galileo and Edison support  Getting Started ‒ Installing Intel® IoT Developer Kit on Linux* .
                  4. Check if the Eclipse distro includes the requested libraries. At this moment, I am looking how to compile third-party libraries for Edison directly in Eclipse (any helps is welcome ) but we are lucky: the bluetooth library is included in the Eclipse package.
                  5. Look at the Ecplise example code: configure a new project with the proper configuration Help with Cross Compiling . In my case, I have also added a "-lmraa -lbluetooth" param to the crosslinker options.
                  6. Copy and paste the following C code: Bluetooth programming in C with BlueZ . The code is a bluetooth scanner (and not a server)

                   

                  Hope it helps

                  Flavio

                  • 6. Re: Bluetooth server
                    bentrevett

                    Hi FlavioM,

                     

                    In step 5, where did you find the crosslinker options to add the "-lmraa -lbluetooth"?

                     

                    Thanks.

                    • 7. Re: Bluetooth server
                      mhahn

                      it's in project properties -> settings -> Gross G++ Linker -> Libraries section (picture below showing "Miscelleneous" rather than "Libraries")

                      linker.png

                      • 8. Re: Bluetooth server
                        hk101

                        Hello,

                        I attempted to compile the C code: Bluetooth programming in C with BlueZ  with the

                        IoT eclipes :

                        Version: Kepler Service Release 2

                        Build id: 20140224-0627

                         

                        included the bluetooth include files and library and I get the following error:

                         

                        field 'bdaddr' could not be resolved on line 46

                        line 46:   ba2str(&(ii+i)->bdaddr, addr); in the for loop.

                         

                         

                        The "C" compiler is complaining that it cannot find the bd addr : of the variable inquiry_info *ii = NULL;

                        where the type inquiry_info is part of the include file as follows:

                        typedef struct {

                          bdaddr_t bdaddr;

                          uint8_t pscan_rep_mode;

                          uint8_t pscan_period_mode;

                          uint8_t pscan_mode;

                          uint8_t dev_class[3];

                          uint16_t clock_offset;

                        } __attribute__ ((packed)) inquiry_info;

                         

                        Why the error? thanks in advance

                        • 9. Re: Bluetooth server
                          hk101

                          OK, environment issue. Re-installed eclipse and problem of compile above went away.

                           

                          Note for all: Eclipse Kepler can be easily messed up by clicking on options etc

                          if you do not know what they do. Keep a copy (of your source and eclipse install zip folder)  handy to re-do setup

                           

                          Anyone see this error while trying to upload the above bluetooth C -- compiled file?

                          Error during file upload.

                          Missing element for : ''

                          Missing element for : ''

                          Missing element for : ''

                          • 10. Re: Bluetooth server
                            hk101

                            OK, able to solve above by setting correct path in run-configuration-path in eclipse environment,

                            next issue:

                            Failed to write to export

                            Intel Edison Failed to initialise Arduino board TriState,                         check i2c devices! FATAL

                            opening socket: No such device

                             

                            I am using mini breakout board without Arduino. The above code calls for -lmraa -lbluetooth set as stated above in post by

                             

                            However I understand that the -lmraa depends on Arduino to be present. Is this correct? If so will this be fixed, as many

                            people may not want to use an Arduino + Edison.

                             

                            If -lmraa is not the issue, please indicate how to fix,

                            thanks in advance

                            • 11. Re: Bluetooth server
                              mhahn

                              meanwhile the Arduino as well as the mini breakout board are supported by mraa.

                              Which version of libmraa do you use?

                              • 12. Re: Bluetooth server
                                hk101

                                I downloaded the iotdk-ide-win-1.7z from Edison - Software Downloads which shows a version number of "Arduino Software 1.5.3 - Intel 1.0.4"

                                and indicates for both Galileo & Edison. So what ever version of -lmraa was included is being used. How can I tell which lib version? I looked at the

                                IDE tree carefully and could only find an mraa.h file without any version number.

                                 

                                Thank you

                                • 13. Re: Bluetooth server
                                  mhahn

                                  the question is which version you have installed on your target as it's dynamically linked (hence the version on the IDE and on the target might differ).

                                  To also update the IDE with latest libmraa/UPM see my description on upgrading libmraa in iotdk

                                  • 14. Re: Bluetooth server
                                    hk101

                                    Thank you mhahn,

                                    upgrading the libmraa as in the link you provided fixed it.

                                     

                                    Now to "Boldly go where everyone has gone before :-) " ....