Android Question About bluetooth bandwidth isuue

vincentehsu

Member
Licensed User
Dear Sir:
I have a bluetooth project,and it has two function.the first is get BT device's info and another one is download config file from web service,the first one jsut a 4 byte command and then i can get response from BT device info,but the second command is a big size command about 10507 bytes, when i send the command,the BT device can't get any response,When i told the problem to our BT device engineer and check the command is correct,we found the problem may cause of the BT bandwidth.I wanna prove it,so i used the frist command to test as followed
B4X:
Dim TriggerPayment() As Byte = Array As Byte(0x00, 0x02, 0xF2, 0xF2)
AStream.Write(TriggerPayment)
Above is the code work fine,I can get the BT info,Next i wanna separate the command to test
B4X:
Dim TriggerPayment() As Byte=Array As Byte(0x00, 0x02, 0xF2, 0xF2)
    Dim BufferSizeMax As Int = 2
      Dim BufferSize As Int
   
       For i = 0 To TriggerPayment.Length -1 Step BufferSizeMax
      BufferSize = TriggerPayment.Length - 1
      If (i + BufferSizeMax) > (TriggerPayment.Length - 1) Then
         BufferSize = TriggerPayment.Length Mod BufferSizeMax
      Else
         BufferSize = BufferSizeMax
      End If
     Log(i & ":" & BufferSize)
      AStream.Write2(TriggerPayment, i, BufferSize)
   Next
i get the BT device response:timeout

where am i wrong?or is there have another way the separate the command?
 

vincentehsu

Member
Licensed User
Yse,I'm sure the initialize AsyncStreams in non-prefix mode as below
B4X:
Sub Activity_Create(FirstTime As Boolean)
    If FirstTime=True Then
        Activity.LoadLayout("Command")
        'Timer1.Initialize("Timer1",100)
        timecnt=0
    End If
    If AStream.IsInitialized = False Then
        AStream.Initialize(Main.serial1.InputStream, Main.serial1.OutputStream, "AStream")
    End If
End Sub
 
Top