API for plug device on iPhone
What the API uses for work with plug devices, something like this app: square iphone scanner ?CocoaTouch, some from Foundat开发者_如何学Cion?
Square works through the headphone jack, so it doesn't use the External Accessory framework. External accessories on the iPhone are notoriously difficult to do, which is why barely any manufacturers are creating products.
http://www.wired.com/gadgetlab/2010/01/wither-the-dongleware
I can count on one finger the number of third party devices I've seen that communicate through the dock connector on the iPhone.
ExternalAccessory.framework.
Oops. Square doesn't use ExternalAccessory, but some kind of custom interface through the headphone jack, as explained by @kubi.
The relevant interface looks like this:
__attribute__((visibility("hidden")))
@interface SKSquareInterface : NSObject {
@private
? delegate;
? queue;
? state;
}
@property(assign) ? XXEncryptedProperty_6b644;
@property(assign) ? XXEncryptedProperty_6a1bc;
@property(assign) ? XXEncryptedProperty_77a22;
@property(assign) ? XXEncryptedProperty_77a39;
@property(assign) ? XXEncryptedProperty_77a60;
@property(assign) ? XXEncryptedProperty_77800;
@property(assign) ? XXEncryptedProperty_7780c;
+(?)sharedInstance;
-(?)init;
-(?)dealloc;
-(?)parseState;
-(?)triggered;
-(?)dcOffset;
-(?)shouldStartWhenCapable;
-(?)setShouldStartWhenCapable:(?)startWhenCapable;
-(?)start;
-(?)stop;
-(?)isAttached;
-(?)_reset;
-(?)_stop;
-(?)_initializeQueues;
-(?)_isAudioQueueRunning;
-(?)_listenForSwipe:(?)swipe numSamps:(?)samps;
-(?)_tryToStartAudioInterface;
-(?)_tryToStopAudioInterface;
-(?)_notifyDelegateDidBeginSwipe;
-(?)_notifyDelegateSwipeFailed;
-(?)_notifyDelegateOfRawData:(?)rawData;
-(?)_notifyDelegateOfRawDataOnMainThread:(?)rawDataOnMainThread;
-(?)_notifyDelegateSwipedPaymentCard:(?)card;
-(?)_notifyDelegateSwipedPaymentCardOnMainThread:(?)thread;
-(?)state;
-(?)delegate;
-(?)setDelegate:(?)delegate;
@end
which suggest it directly parse the input from AudioQueue.
精彩评论