Android Question BLE & ByteConverter problem

Discussion in 'Android Questions' started by wolvo66, Mar 27, 2015.

  1. wolvo66

    wolvo66 Member Licensed User

    I'm having problems decoding a string encoded in a byte array that I am reading from a BT-LE device.
    The input string is something like this ":12345678abcd"
    The raw data I get from reading the characteristic looks like this: [B@14db8bf7

    I have tried using the ByteConverter library, but it doesn't give the expected output, e.g.

    Code:
    Sub ble_CharacteristicChanged (Characteristic As BleCharacteristic)
      
    Log("Get string value: " & Characteristic.GetStringValue(0))
      
    Dim bc As ByteConverter
      
    Log("String from byte: " & bc.StringFromBytes(Characteristic.GetValue, "ASCII"))
    This gives the output
    Get string value: ���
    String from byte: ���

    I found a Java example, that seems exactly what I need, based on creating a new string e.g.
    String s = new String(bytes);
    http://www.mkyong.com/java/how-do-convert-byte-array-to-string-in-java/
    - but I'm not sure how to do this in B4A?
     
  2. wolvo66

    wolvo66 Member Licensed User

    SOLVED: I was reading from the wrong characteristic.
     
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