Re: IOBluetooth questions
Re: IOBluetooth questions
- Subject: Re: IOBluetooth questions
- From: Yann Bizeul <email@hidden>
- Date: Thu, 22 Jul 2004 13:32:11 +0200
Hi,
You should take a look at IOBluetoothDevice documentation. There are
some methods like pairedDevices that will return an array of
IOBluetoothDevice which are paired.
Here is the code I use in BuddyPop to get an array of dictionaries
conatining HW address and device names according to a certain class of
services (use 0x400000 to get telephones)
+ (NSArray*)devicesWithService:(BluetoothClassOfDevice)service
{
IOBluetoothDevice *currentDevice;
NSArray *devices = [ IOBluetoothDevice pairedDevices];
NSEnumerator *e = [devices objectEnumerator ];
NSMutableArray *result = [NSMutableArray array];
while (currentDevice = [ e nextObject ])
{
//NSLog(@"%i : %@",[ device getClassOfDevice ], [ device getName ]);
//10100100000001000000100 T610
//00000000010010110000000 MX900
if ([ currentDevice getClassOfDevice ] & service)
[result addObject: [NSDictionary
dictionaryWithObjectsAndKeys:[currentDevice
getName],@"name",[currentDevice getAddressString],@"address",nil]];
}
return [[result copy]autorelease];
}
Le 21 juil. 04, ` 21:58, gnat a icrit :
>
Hello,
>
Anyone know of a good (or more than one) resource for how to use the
>
IOBluetooth API in Objective-C. The main thing i'm looking for is how
>
to find available devices without using the GUI functions (i.e. i'm
>
working on a command line tool).
>
In general I have an perl/Apple Script that does the following to get
>
info to my non-iSync compatible phone via the Bluetooth File Exchange
>
App. I want to move the functionality to a single non-UI binary so I
>
can cron it:
>
>
1) Check a local cache (want to read what's on the phone, but i'm
>
going for little steps) against my iCal and save each event that
>
hasn't already been sent to the phone as a separate file (the phone
>
doesn't seem to like calendar files with multiple entries) as well as
>
adjust the format.
>
2) Generate an apple script that:
>
a) Starts BT File Exchange
>
b) sends each file
>
c) quits BT File Exchange
>
>
Besides the taking over my UI issues, it also has some other issues
>
in regards to timing and not being able to catch errors properly. So I
>
want to write my own app to do it in the back ground. I have found
>
examples of sending/getting information once the connection is
>
established, but besides calls to the device chooser I haven't seen
>
how to get the devices in an Array/Dictionary/something else. I want
>
to do the following:
>
>
1) During setup, prompt the user to select a device(s) from those in
>
range and save the ID(s) to a config file.
>
2) During a run, startup and check to see if the selected devices are
>
in range.
>
a) If so, do work.
>
b) If not, quit.
>
>
Thanks,
>
-dave
>
_______________________________________________
>
cocoa-dev mailing list | email@hidden
>
Help/Unsubscribe/Archives:
>
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
>
Do not post admin requests to the list. They will be ignored.
>
>
>
--
Yann Bizeul - yann at tynsoe.org
http://projects.tynsoe.org/
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.