Thread: C / Bluetooth Question

  1. #1
    Registered User
    Join Date
    May 2007
    Posts
    5

    C / Bluetooth Question

    Hello All Forum Goers,
    I am a programmer at an intermediate level. I am at the moment developing an application that is going to be used in a Bluetooth busy environment.

    I am wondering if it is possible to narrow down what a BT Devices searches for in a Bluetooth busy environment.

    Is it possible to distinguish BT enabled phone device from a BT enabled GPS when scanning (Discovering).

    I have being investigating this myself and I have come across one possible solution of checking the Device Class Attribute and coupling this attribute with Bluetooth Assigned Numbers(https://programs.bluetooth.org/apps/...?doc_id=49709). I have found this code in java which is below but was wndering if this is possible with an non OO language i.e. C :,

    ---------------------------------------------------------------------------------------------------
    Code:
    public void deviceDiscovered(RemoteDevice btDevice, DeviceClass cod) {
    System.out.println("Found device = " + btDevice.getBluetoothAddress());
    
            /*
             * Since service search takes time and we are already forced to
             * complete an inquiry, we will not do a service
             * search on any device that is not an Imaging device.
             * The device class of 0x600 is Imaging as
             * defined in the Bluetooth Assigned Numbers document.
             */
    //        if (cod.getMajorDeviceClass() == 0x600) {
                /*
                 * Imaging devices could be a display, camera, scanner, or
                 * printer. If the imaging device is a printer,
                 * then bit 7 should be set from its minor device
                 * class according to the Bluetooth Assigned
                 * Numbers document.
                 */
    //            if ((cod.getMinorDeviceClass() & 0x80) != 0) {
                    /*
                     * Now we know that it is a printer.  Now we will verify that
                     * it has a rendering service on it.  A rendering service may
                     * allow us to print.  We will have to do a service search to
                     * get more information if a rendering service exists. If this
                     * device has a rendering service then bit 18 will be set in
                     * the major service classes.
                     */
    //                if ((cod.getServiceClasses() & 0x40000) != 0) {
                        deviceList.addElement(btDevice);
    //                }
    //            }
    //        }
        }
    ----------------------------------------------------------------------------------------------------



    Thanks,
    Michael

  2. #2
    Fear the Reaper...
    Join Date
    Aug 2005
    Location
    Toronto, Ontario, Canada
    Posts
    625
    Quite nearly everything you can do in OO you can do in C, the question is how much harder it would be.

    In your case, the body of the method seems like it could almost be ported as is, but instead as receiving an object as a parameter, you'd have to receive a majorDeviceClass, a minorDeviceClass and a serviceClasses (which all appear to be integers).

    With that being said, I don't know what additional info is contained in the btDevice and the DeviceClass classes, so it could make the problem a little more difficult.
    Teacher: "You connect with Internet Explorer, but what is your browser? You know, Yahoo, Webcrawler...?" It's great to see the educational system moving in the right direction

  3. #3
    Registered User
    Join Date
    May 2007
    Posts
    5

    C / Bluetooth Question

    Thanks a million,
    Just as it happens C is my third language so not really up on the Bluetooth Libraries etc. I have taken this job just to get my foot in the door as i really like the C language. Could you lead me to any bluetooth Libraries where i could get more info on this "Device Class Attribute". This would be much easier in an OO language but execution time is extremly important here so C is my choice,

    Thanks for your speedy reply,
    Michael

  4. #4
    Fear the Reaper...
    Join Date
    Aug 2005
    Location
    Toronto, Ontario, Canada
    Posts
    625
    Here's an open source, C Bluetooth library for linux. I don't know if that'll help you out, but the rest you'll have to google and find on your own.
    Teacher: "You connect with Internet Explorer, but what is your browser? You know, Yahoo, Webcrawler...?" It's great to see the educational system moving in the right direction

  5. #5
    Registered User
    Join Date
    May 2007
    Posts
    5

    C / Bluetooth Question

    Thanks a Million for your replies,
    I will have a look through this. I have being "Googling" this alot but not much seems to be popping up. Any else that has a comment to make or any sample code that i could start off with would help me out big time,

    Thanks for yer time,
    Michael

  6. #6
    Registered User
    Join Date
    May 2007
    Posts
    5

    C / Bluetooth Question

    Before this message leaves the main page and never seen again!!!!!!!!!!!!!!,

    Could anyone provide some pseudocode that i could use to start me off!!!


    Thanks,
    Michael

  7. #7
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    s/!+/!/g
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  8. #8
    Registered User
    Join Date
    May 2007
    Posts
    5

    C / Bluetooth

    Okaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaay,


    Michael

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Bluetooth Questions
    By Tonto in forum Tech Board
    Replies: 2
    Last Post: 05-30-2009, 02:41 AM
  2. Bluetooth UART
    By ssharish2005 in forum Tech Board
    Replies: 2
    Last Post: 02-06-2008, 06:31 AM
  3. Bluetooth Audio Stream
    By Charmy in forum Windows Programming
    Replies: 2
    Last Post: 05-06-2006, 12:10 AM
  4. Alice....
    By Lurker in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 06-20-2005, 02:51 PM
  5. Question...
    By TechWins in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 07-28-2003, 09:47 PM