Android Question BLE Peripheral - advertising data

Discussion in 'Android Questions' started by jvetterli, Apr 13, 2018.

Tags:
  1. jvetterli

    jvetterli Member Licensed User

    Playing around with the BLE peripheral library, I'm wondering if it's possible to change the advertising data. When doing a BLE scan with a RedBear Duo, it shows me:

    reportCallback:
    The advEventType: 0
    The peerAddrType: 1
    The peerAddr: 64 D6 55 74 E2 D9
    The rssi: -55
    The advertising data: 2 1 1A E 9 42 34 41 50 65 72 69 70 68 65 72 61 6C 2 A F9 3 3 1 0
    The length of Complete Local Name : D
    The Complete Local Name is : B4APeripheral

    Local name can be changed, but the advertising data stays the same with different phones.
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    It is currently not possible to change it.

    It will be simple to add an option for manufacturer specific data if anyone needs it.
     
  3. jvetterli

    jvetterli Member Licensed User

    Thanks for your quick reply Erel, I would be thankful if you could add such an option
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    I've sent you a new version (v1.10). Please try it.

    You can set the manufacturer data with:
    Code:
    BlePeripheral2.ManufacturerData = CreateMap(123"this is my data".GetBytes("utf8"), 124Array As Byte(1234))
    You need to set it before you call Start.
     
  5. jvetterli

    jvetterli Member Licensed User

    Hi Erel, I'm sorry for the late reply, thanks for the new version, didn't have a chance to try until today.
    Unfortunately it doesn't work, if I set the manufacturer data, BLEperipheral2 doesn't seem to work anymore (without showing any errors in the log view), as the two phones I'm testing with, aren't showing up anymore.
     
  6. Erel

    Erel Administrator Staff Member Licensed User

    Are there any messages in the unfiltered logs?

    Can you post the code?
     
  7. jvetterli

    jvetterli Member Licensed User

    I don't see any abnormalities in the log, I've attached them, BLEnew.txt for the version including the manufacturer-date.

    I'm using your BlePeripheral sample and only changed Manager_StateChanged with two variations:

    Code:
    Private Sub Manager_StateChanged (State As Int)
        
    If State <> manager.STATE_POWERED_ON Then
            
    ToastMessageShow("Please enable Bluetooth"True)
            NotAvailable = 
    True
        
    Else
            peripheral.Initialize(
    "peripheral", manager)
            
            
    'peripheral.ManufacturerData = CreateMap(123: "this is my data".GetBytes("utf8"))
            peripheral.ManufacturerData = CreateMap(123"this is my data".GetBytes("utf8"), 124Array As Byte(1234))
            
            
    If peripheral.IsPeripheralSupported = False Then
                
    ToastMessageShow("Peripheral mode not supported."True)
                NotAvailable = 
    True
            
    Else
                peripheral.Start(
    "B4APeripheral")
                
    Wait For Peripheral_Start (Success As Boolean)
                
    Log("Peripheral started successfully? " & Success)
            
    End If
        
    End If
        SetState(
    False)
    End Sub
     

    Attached Files:

  8. Erel

    Erel Administrator Staff Member Licensed User

    The problem is with the id that is probably reserved.

    This works:
    Code:
    per.ManufacturerData = CreateMap(0x0700"abc".GetBytes("utf8"))
     
  9. jvetterli

    jvetterli Member Licensed User

    Don't know what I do wrong, but it still doesn't show up, I've attached the unfiltered log, maybe it will help.
     

    Attached Files:

  10. Erel

    Erel Administrator Staff Member Licensed User

    The above code worked for me in a small example. I've tested it on Nexus 5X. I used an iPhone app to scan for BLE and read the advertising data.
     
  11. jvetterli

    jvetterli Member Licensed User

    Pretty strange, I've tested with a Samsung Note4 and Blackview A7 without success. As soon as I comment the ManufacturerData out, the phone will show up on BLEscanner
     
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