![]() |
| | #1 |
| Registered User Join Date: May 2007
Posts: 5
| C / Bluetooth Question 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 |
| michaelmatthews is offline | |
| | #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 |
| Happy_Reaper is offline | |
| | #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 |
| michaelmatthews is offline | |
| | #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 |
| Happy_Reaper is offline | |
| | #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 |
| michaelmatthews is offline | |
| | #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 |
| michaelmatthews is offline | |
| | #7 |
| and the hat of vanishing Join Date: Aug 2001 Location: The edge of the known universe
Posts: 21,214
| s/!+/!/g
__________________ If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut. Up to 8Mb PlusNet broadband from only £5.99 a month! |
| Salem is offline | |
| | #8 |
| Registered User Join Date: May 2007
Posts: 5
| C / Bluetooth Okaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaay, Michael |
| michaelmatthews is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Bluetooth Questions | Tonto | Tech Board | 2 | 05-30-2009 02:41 AM |
| Bluetooth UART | ssharish2005 | Tech Board | 2 | 02-06-2008 06:31 AM |
| Bluetooth Audio Stream | Charmy | Windows Programming | 2 | 05-06-2006 12:10 AM |
| Alice.... | Lurker | General Discussions | 16 | 06-20-2005 02:51 PM |
| Question... | TechWins | A Brief History of Cprogramming.com | 16 | 07-28-2003 09:47 PM |