Android Question BT discovery returns >80 same device on Chuwi android 8.1

MbedAndroid

Active Member
Licensed User
Longtime User
Using Erel's example of BT running it on the Chuwi, returns multiple same device. Around 80-100 it stops with the list found devices (all the same, all same MAC). Never seen this on any other device. Is this something new in android 8+?
code used for test/example
https://www.b4x.com/android/forum/threads/android-bluetooth-bluetoothadmin-tutorial.14768

bluetooth device is a HC05, but that doesnt matter with this example. This problem comes up also with the app which was build for the gps


/#content
Logger connected to: joyar Hi8SE
--------- beginning of main
Logger connected to: joyar Hi8SE
--------- beginning of main
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
GPS:98:D3:37:90:CE:79
GPS:98:D3:37:90:CE:79
GPS:98:D3:37:90:CE:79
GPS:98:D3:37:90:CE:79
GPS:98:D3:37:90:CE:79
GPS:98:D3:37:90:CE:79
GPS:98:D3:37:90:CE:79
GPS:98:D3:37:90:CE:79
GPS:98:D3:37:90:CE:79
GPS:98:D3:37:90:CE:79
GPS:98:D3:37:90:CE:79
GPS:98:D3:37:90:CE:79
GPS:98:D3:37:90:CE:79
GPS:98:D3:37:90:CE:79
GPS:98:D3:37:90:CE:79
GPS:98:D3:37:90:CE:79
GPS:98:D3:37:90:CE:79
GPS:98:D3:37:90:CE:79
GPS:98:D3:37:90:CE:79
GPS:98:D3:37:90:CE:79
GPS:98:D3:37:90:CE:79
GPS:98:D3:37:90:CE:79
GPS:98:D3:37:90:CE:79
GPS:98:D3:37:90:CE:79
GPS:98:D3:37:90:CE:79
GPS:98:D3:37:90:CE:79
GPS:98:D3:37:90:CE:79
GPS:98:D3:37:90:CE:79
GPS:98:D3:37:90:CE:79
GPS:98:D3:37:90:CE:79
GPS:98:D3:37:90:CE:79
GPS:98:D3:37:90:CE:79
GPS:98:D3:37:90:CE:79
GPS:98:D3:37:90:CE:79
GPS:98:D3:37:90:CE:79
GPS:98:D3:37:90:CE:79
GPS:98:D3:37:90:CE:79
GPS:98:D3:37:90:CE:79
GPS:98:D3:37:90:CE:79
GPS:98:D3:37:90:CE:79
GPS:98:D3:37:90:CE:79
GPS:98:D3:37:90:CE:79
GPS:98:D3:37:90:CE:79
GPS:98:D3:37:90:CE:79
GPS:98:D3:37:90:CE:79
etc....

** Activity (main) Pause, UserClosed = false **
 

DonManfred

Expert
Licensed User
Longtime User
It is not an other Device but the same device over and over. Probably advertising something?
Use a Map to get control over it. Add the Device using its mac as key to your map. You map should have only one Item...
 
Upvote 0

MbedAndroid

Active Member
Licensed User
Longtime User
here the code with maps to solve this issue

B4X:
Private Sub Admin_DeviceFound (Name As String, MacAddress As String)
    Log(Name & ":" & MacAddress)
    If foundDevices.ContainsKey(MacAddress) Then
    Else
        foundDevices.Put(MacAddress, Name)
        ProgressDialogShow(ResourceStrings.Get("SEARCHDEVICE") & " (~ device found)...".Replace("~", foundDevices.Size))
    End If
End Sub
Sub Admin_DiscoveryFinished
    ProgressDialogHide

    Private i As Int
    If foundDevices.Size = 0 Then
        ToastMessageShow(ResourceStrings.Get("NODEVICE"), True)
    Else
        Dim l As List
        l.Initialize
        For i=0 To foundDevices.Size-1
                    l.Add(foundDevices.GetValueAt(i))
        Next
        InputListAsync(l, ResourceStrings.Get("DEVICECONNECT"), -1, True)
        Wait For InputList_Result (Index As Int)
        If Index <> DialogResponse.CANCEL Then
            ProgressDialogShow(ResourceStrings.Get("TRYCONNECT") & foundDevices.GetValueAt(Index) & " (" & foundDevices.GetkeyAt(Index) & ")")
            Serial1.Connect(foundDevices.GetkeyAt(Index))
        End If
    End If
End Sub
 
Upvote 0
Top