• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Using CoreBluetooth from Command Line Tool
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Using CoreBluetooth from Command Line Tool


  • Subject: Re: Using CoreBluetooth from Command Line Tool
  • From: András Kövi <email@hidden>
  • Date: Fri, 05 Apr 2013 22:54:58 +0200

I start with scanning, then insert the UUID that's printed out and use that in the next round. Everything works fine on my Mac mini.

I suppose you use notifications for sending the data update. Notifications are not acknowledged by the peer. 

There have been several discussions on this list about strategies for creating data streams. Etan Kissling is a "master" of this topic. :) The basic idea when using notifications is to have two characteristics. One is the outgoing data, the other is the acknowledgement indicator. You update the data characteristic and then wait until the acknowledgement characteristic is written by the peer. You may fine tune the process, of course, to increase the bandwidth. The other solution is to change to indications to ensure consistency. There can be only one indication at a time so you will not be able to send data until the update is processed.

A third solution I can think of is implementing the peripheral role in the i* device and writing the data characteristic on that from the real peripheral. This scheme is used in the Alert Notification Service.

I never needed high speed data transfer but I'd be interested in whether these solve your issues.

Andras


2013/4/5 <email@hidden>
András,  

If you change line 40 in WirelessBandManager.m to have a UUID of your peripheral, are you still able to get all the way through the didConnectPeripheral delegate?  It doesn't work for me, I never get connected.

If I use the scanning method, I can find my peripheral and connect, including getting the didConnectPeripheral delegate called.  However once I get my characteristics and start receiving data, I get corrupted/duplicated data (If my peripheral sends two segments of data on two connection intervals, I get the second data segment duplicated on both calls to didUpdateValueForCharacteristic).

Thanks for your help - I'm sure it is something stupid I'm doing, I just wish I knew what!

-- dave


On Apr 5, 2013, at 11:27 AM, András Kövi <email@hidden> wrote:

I'm not sure either but it works for me pretty well. Though, I haven't tried to read or write characteristics. Do you have any clues why you would need the CFRunLoop? The reference says:


The main queue is automatically created by the system and associated with your application’s main thread. Your application uses one (and only one) of the following three approaches to invoke blocks submitted to the main queue:
  • Calling dispatch_main
  • Calling UIApplicationMain (iOS) or NSApplicationMain (OS X)
  • Using a CFRunLoopRef on the main thread
If the main thread is used, then any of these should suffice and the same should be enough when a different queue is used as those are mapped to a thread pool and fully managed by the system.

Andras


2013/4/5 Dave Camp <email@hidden>
Not sure, but dispatch_main() might not be enough. You might have to actually run the runloop with CFRunLoopRun or something similar. I know that works because I've written a CoreBluetooth command line tool and it works fine.

Dave

On Apr 4, 2013, at 1:40 PM, email@hidden wrote:

> Hi,
>
> I'm trying to write a simple command line app that uses CoreBluetooth on an BLE capable mac book (OSX v10.8.3).
>
> If I use the retrievePeripherals I get the delegate didRetrievePeripherals to fire.  If I then try to connect to the found peripheral, the didConnectPeripheral delegate never fires.
>
> However, if I scan for peripherals and get the delegate didDiscoverPeripheral to fire.  I can then connect and connect succeeds.  However, once I'm connected and have my characteristics, the data I receive from my peripheral is not reliably received.
>
> Using similar code in a GUI application works perfect.
>
> Has anyone else been successful running the CoreBluetooth stack from within a command line app?
>
> In my main I essentially create a dispatch_queue and let it run my operations via dispatch_async.  Meanwhile, I let main just call dispatch_main().
>
> -- dave
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Bluetooth-dev mailing list      (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Bluetooth-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden



 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Bluetooth-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Using CoreBluetooth from Command Line Tool (From: email@hidden)
 >Re: Using CoreBluetooth from Command Line Tool (From: Dave Camp <email@hidden>)
 >Re: Using CoreBluetooth from Command Line Tool (From: András Kövi <email@hidden>)
 >Re: Using CoreBluetooth from Command Line Tool (From: email@hidden)

  • Prev by Date: Re: Using CoreBluetooth from Command Line Tool
  • Next by Date: Connect immediately with peripheral in standby mode(Background mode)
  • Previous by thread: Re: Using CoreBluetooth from Command Line Tool
  • Next by thread: Built in support for BTLE HID profile
  • Index(es):
    • Date
    • Thread