i'am test my bluetooth device connectting and data read.
but data read callback time is very slow. callback Interval time 100ms..
how can i read callback time fastest?
- (void)openSessionForProtocol
{
NSString *protocolString = @"com.company.datapath";
NSArray *accessories = [[EAAccessoryManager sharedAccessoryManager] connectedAccessories];
EAAccessory *accessory = nil;
for (EAAccessory *obj in accessories)
{
if ([[obj protocolStrings] containsObject:protocolString])
{
accessory = obj;
break;
}
}
NSLog(@"%@",accessory);
if (accessory)
{
m_session = [[EASession alloc] initWithAccessory:accessory
forProtocol:protocolString];
if (m_session)
{
[[m_session inputStream] setDelegate:self];
[[m_session inputStream] scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
[[m_session inputStream] open];
}
}
}
- (void)stream:(NSStream*)theStream handleEvent:(NSStreamEvent)streamEvent
{
switch (streamEvent)
{
case NSStreamEventHasBytesAvailable:
{
int len;
char buffer[1024];
while ([[m_session inputStream] hasBytesAvailable])
{
len = [[m_session inputStream] read:buffer maxLength:sizeof(buffer)];
}
}
}
}
i'm sorry. I can't speak English well. thank you