iOS Question iExternalAccessory ReadData

mrossen

Active Member
Licensed User
Hi,

You can send data in text and hex format, but only recieve in hex format.

Is it possible to recieve in text format?

Thanks
Mogens
 

mrossen

Active Member
Licensed User
Hi Alberto,

Thank you for the nice gift :)

I used this code example and it Work very nice :)

B4X:
Sub objEA_ReadData3(DecReceived() As String)
  
    Dim strDec As String
    For a = 0 To DecReceived.Length-1
       strDec = DecReceived(a)
        LogColor("strDec=" & strDec,Colors.Blue)
    Next

End Sub

My question now is when is the DecRecieved array cleared og how can I clear it.

In the start of my com withe my device I expect to see "lppp" and then I get the next data, but when I get my my second data I still have "lppp" in the beging of the dataset

Mogens
 
Upvote 0

mrossen

Active Member
Licensed User
Hey Alberto,

How are you connecting to you bluetooth device?

Are you using the setup/bluetooth to connect before you open you app?

It would be nice to be able to connect inside the app,

I have made this example a while ago. I don't know if you can use some of it, or maybe add it too your liberary

Mogens
 

Attachments

  • bluetooth_spp.zip
    2.8 KB · Views: 140
Upvote 0

mrossen

Active Member
Licensed User
Hey Alberto,

The scan thing Works like a charm :)

But nothing happens with the event _onEAScan

Have I done something wrong?

B4X:
Sub objEA_onEAScan
    Log("[objEA_onEAScan]")
End Sub

I can se in the debug window that this line : "connectedAccessories:x" changes if connected or not

Mogens
 
Upvote 0

Alberto Iglesias

Well-Known Member
Licensed User
Look the method:

The event fire only is if ([mgr.connectedAccessoriescount])

If you need to change something, tell me....

B4X:
-(void)EAScan {
  
  if(_DebugMode) NSLog(@"%s", __FUNCTION__);
  
  mgr = [EAAccessoryManager sharedAccessoryManager];
  
  NSOutputStream *os = session.outputStream;
  
  if(_DebugMode) NSLog(@"connectedAccessories:%lu",(unsigned long)[mgr.connectedAccessories count]);
  
  if ([mgr.connectedAccessories count])
  {
  
  if (os.hasSpaceAvailable)
  {
  if(_DebugMode) NSLog(@"hasSpaceAvailable");
  
  [B4IObjectWrapper raiseEventFromDifferentThread:self :@"_oneascan:" :@[@"Device are already connected"]];
  /*
  UIAlertView *alert = [[UIAlertView alloc]
  initWithTitle: @"Warning !!!"
  message: @"Device are already connected"
  delegate: nil
  cancelButtonTitle:@"OK"
  otherButtonTitles:nil]; [alert show];
  
  [alert show];*/
  }
  else
  {
  [B4IObjectWrapper raiseEventFromDifferentThread:self :@"_oneascan:" :@[@"OK"]];
  /*[self connectBT];*/
  
  
  }
  }
  else
  {
  if(_DebugMode) NSLog(@"showBluetoothAccessoryPickerWithNameFilter");
  [mgr showBluetoothAccessoryPickerWithNameFilter:nil completion:^(NSError *error){ NSLog(@"%@", [error localizedDescription]);}];
  }
  
}
 
Upvote 0
Top