Ok, the if mystring contains part does not work with whatever I try. Also, it does not seem to work at all with the idle part. But if you need what I get out of the system_profiler for Devices, it is this:
Devices (Paired, Favorites, etc):
Device:
Name: LGEnv2
Address: 00-1f-6b-5d-cc-c6
Type: Mobile Phone
Services: Service Discovery Server, OBEX Object Push, OBEX File Transfer, AV Audio Source, AV Remote Control Target, AV Remote Control, Phonebook Access PSE, Voice Gateway, Voice Gateway, BT DIAG, Bluetooth Modem
Paired: No
Favorite: Yes
Connected: No
Device:
Name: W580i
Address: 00-1e-dc-48-27-7e
Type: Mobile Phone
Services:
Paired: No
Favorite: Yes
Connected: No
Device:
Name: SCH-u740
Address: 00-1a-8a-a4-93-04
Type: Mobile Phone
Services: QC Voice Gateway, Dial-up Networking, Phonebook Sync, OPP server, QC Voice Gateway
Paired: No
Favorite: Yes
Connected: No
Device:
Name: SCH-U540
Address: 00-1b-98-70-7e-e1
Type: Mobile Phone
Services: QC Voice Gateway, OPP server, Phonebook Sync, Dial-up Networking, QC Voice Gateway
Paired: No
Favorite: Yes
Connected: No
Device:
Name: MotorolaQ
Address: 00-19-2c-de-9a-dd
Type: Smartphone
Services: Network Access, Network Access, Generic Serial, Dial-up Networking, Audio Gateway, Audio Gateway, OBEX Object Push, OBEX File Transfer
Paired: No
Favorite: Yes
Connected: No
Device:
Name: LGVX9700
Address: 00-21-fb-64-e7-9e
Type: Mobile Phone
Firmware Version: 0000
Services: OBEX File Transfer, Phonebook Access PSE, Object Push, HSP Service, HFP Service, Dial-up Networking, Serial Port
Paired: No
Favorite: Yes
Connected: No
Manufacturer: Broadcom (0x4, 0x420e)
Vendor ID: 0x0f
Product ID: 0000
Device:
Name: Jonathan'sIpod
Address: 00-25-00-25-59-7f
Type: Portable
Firmware Version: 0x300
Services: AVRCP Device, Wireless iAP, Audio Source
Paired: No
Favorite: Yes
Connected: No
Manufacturer: Broadcom (0x4, 0x8107)
Vendor ID: 0x5ac
Product ID: 0x1293
Device:
Name: 3XXPlantronics
Address: 00-19-7f-23-2f-80
Type: Headset
Services: HF-Audio, HS-Audio
Paired: No
Favorite: Yes
Connected: No
Manufacturer: Cambridge Silicon Radio (0x2, 0x8d1)
Device:
Name: LGGR500
Address: 00-22-a9-56-2c-74
Type: Mobile Phone
Firmware Version: 0000
Services: Serial Port 1, HS Voice Gateway, HF Voice Gateway, LG Bluetooth A2DP, Dial-up Networking, OBEX File Transfer, OBEX Object Push, LG Bluetooth AVRCP Target
Paired: No
Favorite: Yes
Connected: No
Manufacturer: Unknown (0x4, 0xf1)
Vendor ID: 0000
Product ID: 0x35
Device:
Name: Archos5
Address: 00-23-d4-50-0b-82
Type: Smartphone
Services: Voice Gateway, Voice Gateway, Audio Source, AVRCP TG
Paired: No
Favorite: Yes
Connected: No
Manufacturer: Unknown (0x4, 0x1d1f)
Device:
Name: SCH-u410
Address: 00-1e-7d-e6-28-bd
Type: Mobile Phone
Services: OBEX Object Push, Phonebook Access PSE, AUDIO Gateway, Serial Port, Voice Gateway, Dial-up Networking
Paired: No
Favorite: Yes
Connected: No
Manufacturer: Unknown (0x3, 0xe1b)
Device:
Name: LGVX9700
Address: 00-1f-e3-ea-96-b1
Type: Mobile Phone
Firmware Version: 0000
Services: OBEX File Transfer, Phonebook Access PSE, Object Push, HSP Service, HFP Service, Dial-up Networking, Serial Port
Paired: No
Favorite: Yes
Connected: No
Manufacturer: Broadcom (0x4, 0x420e)
Vendor ID: 0x0f
Product ID: 0000
Device:
Name: DR-BT101
Address: 00-1f-82-36-38-01
Type: Handsfree
Services: Headset, Hands-Free unit
Paired: Yes
Favorite: Yes
Connected: No
Manufacturer: Cambridge Silicon Radio (0x4, 0x14f3)
Device:
Name: LGVX11000
Address: 00-26-e2-67-9d-7e
Type: Mobile Phone
Firmware Version: 0000
Services: Serial Port, OBEX File Transfer, Phonebook Access PSE, Object Push, BIP Responder, Dialup Networking, HSP Audio Gateway, Advanced audio source, HFP Audio Gateway
Paired: No
Favorite: Yes
Connected: No
Manufacturer: Broadcom (0x4, 0x420e)
Vendor ID: 0x0f
Product ID: 0000
Device:
Name: DROIDX
Address: d0-37-61-46-56-8a
Type: Smartphone
Firmware Version: 0000
Services: AVRCP TG, AVRCP CT, Audio Source, Dialup Networking, OBEX Object Push, MAP MASname, OBEX Phonebook Access Server, Voice Gateway, Voice Gateway, Network Access Point Service
Paired: No
Favorite: Yes
Connected: No
Manufacturer: Unknown (0x4, 0x1d1f)
Vendor ID: 0x0a
Product ID: 0000
Incoming Serial Ports:
Serial Port 1:
Name: Bluetooth-PDA-Sync
RFCOMM Channel: 3
Requires Authentication: Yes
I need headset DR-BT101 to be tested if connected. I think simply if you just display the info for One Device you could say if it contains "name" & "connected" & "yes".
Or something similar to that.
Hope this answers your question.