Android Question howto get bluetooth LE scanresult

Discussion in 'Android Questions' started by analizer3816, Feb 7, 2015.

  1. analizer3816

    analizer3816 Member Licensed User

    I use Erel's blemanager library,on devicefound event can get devicename and macaddress.
    howto get rssi from scanresult without connect (this has getRssi () : https://developer.android.com/reference/android/bluetooth/le/ScanResult.html)

    **I try add this, it works for normal Bluetooth not Bluetooth LE**
    **add to manifest**
    AddReceiverText(BTService,
    <intent-filter>
    <action android:name="android.bluetooth.device.action.FOUND" />
    </intent-filter>)

    **and add to BTService**
    Sub Service_Start (StartingIntent AsIntent)
    If StartingIntent.Action = "android.bluetooth.device.action.FOUND"Then
    Dim RSSI AsString = StartingIntent.GetExtra("android.bluetooth.device.extra.RSSI")
    End If

    End Sub

    thanks
     
  2. analizer3816

    analizer3816 Member Licensed User

    I modified Erel's bleManager library and now I can read RSSI, scanRecord
    Battery,temperature and Humidity level on BLE HM-10 and HM-11 without connect

    :):)
     
  3. Tom Christman

    Tom Christman Active Member Licensed User

    Why not share your fix?
     
  4. analizer3816

    analizer3816 Member Licensed User

    **see example and use my library**
    ble 4.0 Battery,temperature and Humidity level see page 23 in http://www.jnhuamao.cn/bluetooth40_en.zip
    and use "AT+BATC1" command for enable battery monitor (one hour update once)

    Sub BLE_DeviceFound (Name As String, MacAddress As String,rssi As Int, scanRecord() As Byte)
    Dim i As Int
    Dim sBatt As String = "0", sTemp As String = "0", sHumidity As String = "0"
    For i = 0 To scanRecord.Length -1
    If (i+7 < scanRecord.Length) Then
    If (scanRecord(i) = 7 AND scanRecord(i+1) = 22 AND scanRecord(i+2) = 0AND scanRecord(i+3) = -80) Then
    sBatt = scanRecord(i+7)
    sHumidity = scanRecord(i+6)
    sTemp = scanRecord(i+5)
    EndIf
    EndIf
    Next
    ListView1.AddTwoLines2(Name,rssi & " dBm: batt " & sBatt & " %: temp " & sTemp & " c: humi " & sHumidity & " %", MacAddress)

    End Sub
     

    Attached Files:

    Artigala, Philip Prins and Erel like this.
  5. Tom Christman

    Tom Christman Active Member Licensed User

    Thanks. Are you using the new Beta 4.3 version?
     
    Last edited: Feb 8, 2015
  6. analizer3816

    analizer3816 Member Licensed User

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