S scarr Member Licensed User Longtime User Jul 15, 2016 #1 Hi All, OK, I have a HC-05 module, when I search for the HC-05 using the phones built in bluetooth pairing it see it and I can pair with it, I can also see another nearby mobile phone however when I run my app and search for the HC-05 it fails to see it or the other phone! If I have already paired with the HC-05 I can select it from the paired list in my app and it works fine! I do not move phone or HC-05 during either test. Any ideas anyone? Code: Sub btnSearchForDevices_Click Dim PairedDevices As Map PairedDevices = serial1.GetPairedDevices Dim l As List l.Initialize For i = 0 To PairedDevices.Size - 1 l.Add(PairedDevices.GetKeyAt(i)) Next If l.Size > 0 Then Dim res As Int res = InputList(l, "Choose device", -1) 'show list with paired devices If res <> DialogResponse.CANCEL Then serial1.Connect(PairedDevices.Get(l.Get(res))) 'convert the name to mac address and connect Else foundDevices.Initialize If Admin.StartDiscovery = False Then ToastMessageShow("Error starting discovery process.", True) Else ProgressDialogShow("Searching for devices...") End If End If Else foundDevices.Initialize If Admin.StartDiscovery = False Then ToastMessageShow("Error starting discovery process.", True) Else ProgressDialogShow("Searching for devices...") End If End If End Sub Last edited: Jul 15, 2016
Hi All, OK, I have a HC-05 module, when I search for the HC-05 using the phones built in bluetooth pairing it see it and I can pair with it, I can also see another nearby mobile phone however when I run my app and search for the HC-05 it fails to see it or the other phone! If I have already paired with the HC-05 I can select it from the paired list in my app and it works fine! I do not move phone or HC-05 during either test. Any ideas anyone? Code: Sub btnSearchForDevices_Click Dim PairedDevices As Map PairedDevices = serial1.GetPairedDevices Dim l As List l.Initialize For i = 0 To PairedDevices.Size - 1 l.Add(PairedDevices.GetKeyAt(i)) Next If l.Size > 0 Then Dim res As Int res = InputList(l, "Choose device", -1) 'show list with paired devices If res <> DialogResponse.CANCEL Then serial1.Connect(PairedDevices.Get(l.Get(res))) 'convert the name to mac address and connect Else foundDevices.Initialize If Admin.StartDiscovery = False Then ToastMessageShow("Error starting discovery process.", True) Else ProgressDialogShow("Searching for devices...") End If End If Else foundDevices.Initialize If Admin.StartDiscovery = False Then ToastMessageShow("Error starting discovery process.", True) Else ProgressDialogShow("Searching for devices...") End If End If End Sub
S scarr Member Licensed User Longtime User Jul 16, 2016 #2 Hmmm, am I asking a stupid question or is this something that nobody has any ideas how to solve? Steve Upvote 0
Hmmm, am I asking a stupid question or is this something that nobody has any ideas how to solve? Steve
GMan Well-Known Member Licensed User Longtime User Jul 16, 2016 #3 I am using also HC-05's and HC-06's - but am not at home in the moment to look @ my code. Tomorrow i can send you my code part which works perfectly. P.S.: there are mostly no stupid questions, only stupid answers Upvote 0
I am using also HC-05's and HC-06's - but am not at home in the moment to look @ my code. Tomorrow i can send you my code part which works perfectly. P.S.: there are mostly no stupid questions, only stupid answers
Erel B4X founder Staff member Licensed User Longtime User Jul 17, 2016 #4 Have you seen this example: https://www.b4x.com/android/forum/threads/hc-05-classic-bluetooth.66677/#content ? Upvote 0
Have you seen this example: https://www.b4x.com/android/forum/threads/hc-05-classic-bluetooth.66677/#content ?
S scarr Member Licensed User Longtime User Jul 17, 2016 #5 GMan said: I am using also HC-05's and HC-06's - but am not at home in the moment to look @ my code. Tomorrow i can send you my code part which works perfectly. P.S.: there are mostly no stupid questions, only stupid answers Click to expand... Thanks GMan, that would help a lot. Upvote 0
GMan said: I am using also HC-05's and HC-06's - but am not at home in the moment to look @ my code. Tomorrow i can send you my code part which works perfectly. P.S.: there are mostly no stupid questions, only stupid answers Click to expand... Thanks GMan, that would help a lot.
S scarr Member Licensed User Longtime User Jul 18, 2016 #6 Been playing whilst I wait for Gman's reply and I am beginning to think it's the phone (S5), I have another cheap phone and using this phone I test the Bluetooth example from here:- https://www.b4x.com/android/forum/threads/android-bluetooth-bluetoothadmin-tutorial.14768/ it see's the HC-05, but the same example on my S5 fails to see it!!! What could possibly cause this, keeping in mind that on the S5 when I go to the phones "Bluetooth search" I can see the HC-05 and even pair with it! Thanks Steve Upvote 0
Been playing whilst I wait for Gman's reply and I am beginning to think it's the phone (S5), I have another cheap phone and using this phone I test the Bluetooth example from here:- https://www.b4x.com/android/forum/threads/android-bluetooth-bluetoothadmin-tutorial.14768/ it see's the HC-05, but the same example on my S5 fails to see it!!! What could possibly cause this, keeping in mind that on the S5 when I go to the phones "Bluetooth search" I can see the HC-05 and even pair with it! Thanks Steve
Erel B4X founder Staff member Licensed User Longtime User Jul 18, 2016 #7 Which version of the Serial library are you using? If it is lower than 1.26 then try to add this line to the manifest editor: Code: AddPermission("android.permission.ACCESS_COARSE_LOCATION") Upvote 0
Which version of the Serial library are you using? If it is lower than 1.26 then try to add this line to the manifest editor: Code: AddPermission("android.permission.ACCESS_COARSE_LOCATION")
S scarr Member Licensed User Longtime User Jul 18, 2016 #8 Erel said: Which version of the Serial library are you using? If it is lower than 1.26 then try to add this line to the manifest editor: Code: AddPermission("android.permission.ACCESS_COARSE_LOCATION") Click to expand... Erel you are the man now working fine, thanks Upvote 0
Erel said: Which version of the Serial library are you using? If it is lower than 1.26 then try to add this line to the manifest editor: Code: AddPermission("android.permission.ACCESS_COARSE_LOCATION") Click to expand... Erel you are the man now working fine, thanks
W wigigo Member Licensed User Longtime User Jan 5, 2017 #9 I'm using serial 1.26. I add the permission access_coarse_location. i'm running b4a 6.5 the discovery process fires the start and finished event, but never the devicefound event the serial getpaireddevices show all possible devices, but serial.connect dosn't connect to the choosen device. manually i can choose the device, it's working fine. Upvote 0
I'm using serial 1.26. I add the permission access_coarse_location. i'm running b4a 6.5 the discovery process fires the start and finished event, but never the devicefound event the serial getpaireddevices show all possible devices, but serial.connect dosn't connect to the choosen device. manually i can choose the device, it's working fine.
Erel B4X founder Staff member Licensed User Longtime User Jan 6, 2017 #10 Please start a new thread for this question. Upvote 0