B4R Library rESP32SimpleBLE - ESP32 BLE

Discussion in 'B4R Libraries' started by Erel, May 22, 2018.

  1. Erel

    Erel Administrator Staff Member Licensed User

    This library makes it very simple to advertise data through BLE. You just need to call ble.Advertise with the string that you want to advertise as the device name.

    Note that it doesn't support making connections.


    Usage example:

    Code:
    #StackBufferSize: 600
    Sub Process_Globals
       
    Public Serial1 As Serial
       
    Private ble As ESP32SimpleBLE
       
    Private timer1 As Timer
    End Sub

    Private Sub AppStart
       Serial1.Initialize(
    115200)
       
    Log("AppStart")
       timer1.Initialize(
    "timer1_Tick"500)
       timer1.Enabled = 
    True
    End Sub

    Private Sub Timer1_Tick
       
    Dim data As String = JoinStrings(Array As String("B4RTime: "NumberFormat(Millis, 00)))
       
    If ble.Advertise(data) = False Then
           
    Log("failed to set name.")
       
    End If
    End Sub
    iOS app:
    [​IMG]

    The clients need to scan for near by devices and check the device name.
    B4i and B4A clients examples are attached.

    On Android the name is cached so we need to get it from the advertising data map.
    On iOS it stops scanning after a while so we restart the scanning process every 10 seconds.
     

    Attached Files:

    Hypnos, rwblinn, rbghongade and 3 others like this.
  2. Johan Hormaza

    Johan Hormaza Active Member Licensed User

    OOOHHH! Excellent EREL !!!:):):):)
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice