iOS Question BLE Chat Question

MrKim

Well-Known Member
Licensed User
Longtime User
So does it require TWO IOS devices? I need to be able to get 1 ios to connect to one Android.
I tried running ios Central and ios Peripheral on one device but everything just keeps saying "Trying to connect" (Android) or waiting for connection (iphone).
Everything is compiled - no debug.
 

MrKim

Well-Known Member
Licensed User
Longtime User
No.

You don't need the iOS_Central example. It just demonstrates how both iOS and Android devices can connect to the iOS peripheral.
HMMMM I compiled both the android and both ios programs and when I run them everything just spins - waiting to connect... can you point me at some things to look for? I made no changes. just compiled and ran. Iphone 6 running 12.4.5. Android pixel 3 with the latest updates.
Thanks
 
Upvote 0

MrKim

Well-Known Member
Licensed User
Longtime User
The Android project should probably be updated with the new location permission requirement.

Run this example: https://www.b4x.com/android/forum/threads/ble-2-bluetooth-low-energy.59937/#content

Does it find the peripheral device?
I am in awe of your ability to keep all these things straight in your head.
Well, progress of a sort. The Android will connect The iphone continued waiting. Since the Android said it was connected (to b4iPeripheral) I clciked on read Then both devices asked for permission to pair. Which I did. Now the Android is connected and reading data from the iphone (long GUID strings?) but the iphone still says waiting for connection.

Need to specify the device too. At one point the android connected to my watch.

Here is some of the log.
B4X:
** Activity (main) Resume **
Found: B4iPeripheral, 71:83:8C:40:51:AB, RSSI = -65, (MyMap) {1=[B@b192a95, 3=[B@8eeb7aa, 9=[B@1162f9b, 0=[B@5d5af38}
Discovering services.
Connected
(Intent) Intent { act=android.bluetooth.device.action.BOND_STATE_CHANGED flg=0x10 (has extras) }
Bundle[{android.bluetooth.device.extra.PREVIOUS_BOND_STATE=10, android.bluetooth.device.extra.DEVICE=71:83:8C:40:51:AB, android.bluetooth.device.extra.BOND_STATE=11}]
Disconnected
Disconnected
Found: B4iPeripheral, 71:83:8C:40:51:AB, RSSI = -64, (MyMap) {1=[B@227ceac, 3=[B@f39775, 9=[B@95b530a, 0=[B@2eb977b}
Found: , 19:30:D9:50:1B:6A, RSSI = -58, (MyMap) {-1=[B@a992998, 0=[B@17335f1}
Discovering services.
Connected
(Intent) Intent { act=android.bluetooth.device.action.BOND_STATE_CHANGED flg=0x10 (has extras) }
Bundle[{android.bluetooth.device.extra.PREVIOUS_BOND_STATE=11, android.bluetooth.device.extra.DEVICE=71:83:8C:40:51:AB, android.bluetooth.device.extra.BOND_STATE=10, android.bluetooth.device.extra.REASON=9}]
(Intent) Intent { act=android.bluetooth.device.action.BOND_STATE_CHANGED flg=0x10 (has extras) }
Bundle[{android.bluetooth.device.extra.PREVIOUS_BOND_STATE=10, android.bluetooth.device.extra.DEVICE=71:83:8C:40:51:AB, android.bluetooth.device.extra.BOND_STATE=11}]
Disconnected
Disconnected
Disconnected
** Activity (main) Pause, UserClosed = false **
** Activity (main) Resume **
(Intent) Intent { act=android.bluetooth.device.action.BOND_STATE_CHANGED flg=0x10 (has extras) }
Bundle[{android.bluetooth.device.extra.PREVIOUS_BOND_STATE=11, android.bluetooth.device.extra.DEVICE=71:83:8C:40:51:AB, android.bluetooth.device.extra.BOND_STATE=12}]
Found: , 19:30:D9:50:1B:6A, RSSI = -50, (MyMap) {-1=[B@eb2086, 0=[B@5a9dd47}
Found: B4iPeripheral, 71:83:8C:40:51:AB, RSSI = -67, (MyMap) {1=[B@a6fba5e, 3=[B@f0f2e3f, 9=[B@d48130c, 0=[B@4c5f455}
Discovering services.
Connected
(Intent) Intent { act=android.bluetooth.device.action.BOND_STATE_CHANGED flg=0x10 (has extras) }
Bundle[{android.bluetooth.device.extra.PREVIOUS_BOND_STATE=12, android.bluetooth.device.extra.DEVICE=71:83:8C:40:51:AB, android.bluetooth.device.extra.BOND_STATE=11}]
Disconnected
** Activity (main) Pause, UserClosed = false **
** Activity (main) Resume **
(Intent) Intent { act=android.bluetooth.device.action.BOND_STATE_CHANGED flg=0x10 (has extras) }
Bundle[{android.bluetooth.device.extra.PREVIOUS_BOND_STATE=11, android.bluetooth.device.extra.DEVICE=71:83:8C:40:51:AB, android.bluetooth.device.extra.BOND_STATE=12}]
Found: , 48:00:38:8C:6B:A7, RSSI = -74, (MyMap) {1=[B@2cd6ed3, 10=[B@36eaa10, -1=[B@64f7909, 0=[B@cad770e}
Discovering services.
Connected
 
Upvote 0

MrKim

Well-Known Member
Licensed User
Longtime User
The BLE example will not fully work. It was just a test to see that you can connect. You need to add the permission handling to the chat example.
I am confused. Permission handling to what? I am running the updated example you mentioned.
The android portion has
B4X:
Public Sub StartScan
    If manager.State <> manager.STATE_POWERED_ON Then
        Log("Not powered on.")
    Else If rp.Check(rp.PERMISSION_ACCESS_COARSE_LOCATION) = False Then
        Log("No location permission.")
    Else
        manager.Scan2(Null, False)
    End If
End Sub
Is there something else I need to do to the ios peripheral app?

I can get both devices to pair, the Android pairs the iphone as B4iperipheral, The iphone on the other hand, Pairs the Android as Pixel 3XL - and I can pair that twice so I am assuming one is through the app and one is through the pixel directly?
I have deleted the pairings and done hem again multiple times and at no time do any of the events fire in the iphone peripheral app.

Thanks again for your help.
 
Upvote 0

MrKim

Well-Known Member
Licensed User
Longtime User
Pairing is not relevant and not needed.

Lets start from the beginning. What is the problem?
As I wrote, you don't need to run B4i_Central at all. Run B4i_Peripheral and B4A_Central.
That is what I am doing. B4A central "Discovers" B4i_Peripheral and says connected, but nothing happens on the B4i_Peripheral side. No event on B4i_Peripheral ever fires.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
I've updated the two projects.

 
Upvote 0

MrKim

Well-Known Member
Licensed User
Longtime User
I've updated the two projects.

Worked like a charm 👍 👍 . You are a computer god. Marry me and bear my children:p.
 
Upvote 0
Top