vincentehsu Member Licensed User Longtime User Dec 12, 2014 #1 Dear Sir: I used the sample code from https://www.b4x.com/android/forum/threads/new-serial-library-bluetooth-communication.6910/ but i don't how to get response from bt device
Dear Sir: I used the sample code from https://www.b4x.com/android/forum/threads/new-serial-library-bluetooth-communication.6910/ but i don't how to get response from bt device
Erel B4X founder Staff member Licensed User Longtime User Dec 12, 2014 #2 You should use AsyncStreams: AsyncStreams Tutorial [URL='https://www.b4x.com/android/forum/threads/14768/#content']Android Bluetooth / BluetoothAdmin Tutorial [/URL] Upvote 0
You should use AsyncStreams: AsyncStreams Tutorial [URL='https://www.b4x.com/android/forum/threads/14768/#content']Android Bluetooth / BluetoothAdmin Tutorial [/URL]
vincentehsu Member Licensed User Longtime User Dec 12, 2014 #3 so,I can get the bt device response data in below section? Code: Sub AStream_NewData (Buffer() As Byte) 'LogMessage("You", BytesToString(Buffer, 0, Buffer.Length, "UTF8")) txtLog.Text =BytesToString(Buffer, 0, Buffer.Length, "UTF8") End Sub Upvote 0
so,I can get the bt device response data in below section? Code: Sub AStream_NewData (Buffer() As Byte) 'LogMessage("You", BytesToString(Buffer, 0, Buffer.Length, "UTF8")) txtLog.Text =BytesToString(Buffer, 0, Buffer.Length, "UTF8") End Sub
vincentehsu Member Licensed User Longtime User Dec 13, 2014 #4 Dear Sir: I can't get any response from my BT device via Code: Sub AStream_NewData (Buffer() As Byte) Dim i As Int For i= 0 To Buffer.Length-1 Log(Buffer(i)) Next End Sub Upvote 0
Dear Sir: I can't get any response from my BT device via Code: Sub AStream_NewData (Buffer() As Byte) Dim i As Int For i= 0 To Buffer.Length-1 Log(Buffer(i)) Next End Sub
raphael75 Active Member Licensed User Longtime User Dec 13, 2014 #5 Does the BT device receive bytes from your Android device when you use the Write command in your B4A app? Upvote 0
Does the BT device receive bytes from your Android device when you use the Write command in your B4A app?
vincentehsu Member Licensed User Longtime User Dec 13, 2014 #6 Yes,the same command used in IOS is work,but it's not in B4i Upvote 0
raphael75 Active Member Licensed User Longtime User Dec 13, 2014 #7 I'm not sure if there is a misunderstanding. Do you use B4A or B4i? Upvote 0
vincentehsu Member Licensed User Longtime User Dec 14, 2014 #8 I have an Xcode project.i wanna write an android version via b4a.I used the same command in my Xcode project and it's worked fine Upvote 0
I have an Xcode project.i wanna write an android version via b4a.I used the same command in my Xcode project and it's worked fine
vincentehsu Member Licensed User Longtime User Dec 14, 2014 #9 It's maybe still not so clear,let me upload my source code and explain that. I have an Xcode project.i wanna write an android version via b4a.I used the same command as below in my Xcode project and it's worked fine Code: (void)getDeviceSN{ NSLog(@"getSN"); self.status=MPAGetSN; Byte cmd0[0x04] = {0x00,0x02,0xF2, 0xF2}; [self send:cmd0 andLength: sizeof(cmd0)]; } in my b4a project ,I used the same command but i can't get any response from bt device Code: Sub btnSend_Click Dim TriggerPayment() As Byte = Array As Byte(0x00,0x02,0xf2, 0xf2) AStream.Write(TriggerPayment) End Sub attachment is my b4a project,could anybody tell me what event can i get the response from bt device Attachments Bluetooth.zip Bluetooth.zip 422 KB · Views: 321 Upvote 0
It's maybe still not so clear,let me upload my source code and explain that. I have an Xcode project.i wanna write an android version via b4a.I used the same command as below in my Xcode project and it's worked fine Code: (void)getDeviceSN{ NSLog(@"getSN"); self.status=MPAGetSN; Byte cmd0[0x04] = {0x00,0x02,0xF2, 0xF2}; [self send:cmd0 andLength: sizeof(cmd0)]; } in my b4a project ,I used the same command but i can't get any response from bt device Code: Sub btnSend_Click Dim TriggerPayment() As Byte = Array As Byte(0x00,0x02,0xf2, 0xf2) AStream.Write(TriggerPayment) End Sub attachment is my b4a project,could anybody tell me what event can i get the response from bt device
Erel B4X founder Staff member Licensed User Longtime User Dec 14, 2014 #10 Go over AsyncStreams tutorial: AsyncStreams Tutorial You should not use prefix mode in this case. Upvote 0