BLE protocol

edited April 13 in Python

Hi,

I was wondering if there is a documentation of the implemented BLE protocol.
I am struggling with the connection and streaming of several MMS sensors at once. It just won't get reliable enough.
There are always some "Segmentation Fault", "failed to write characteristic..." or just the good old " *** buffer overflow *** " errors.

So I am planning on implementing the communication for configuration of the MMS sensor for streaming Quat data in Python.
(using a different Bluetooth backend). This should give me the opportunity to manage the BLE interface and the errors better.

The steps I would need to configure:
1. Change Connection interval to 7.5ms --> should be something like that: 0x11 0x09 0x06 0x00 0x06 0x00 0x00 0x00 0x58 0x02 (MODULE_SETTINGS, CONNECTION_PARAMS, minInterval_low, minInterval_high, maxInterval_low, maxInterval_high, latency_low, latency_high, timeout_low, timeout_high)
2. Set fusion mode: NDOF
3. Set acc range: 8G or 4G
4. set gyro range 2000dps
5. enable fusion
6. start fusion

And afterwards for cleanup:
1. fusion stop
2. reset board

Is there any documentation or easy way to spit out the commands I need to send to the device?

Additonally: is there a way to reduce the quat datarate to just send each 3rd or 4th sample? Can I use the internal signal processor for that?

thanks
Alex

Comments

  • edited April 13

    The short answer is NO. The BLE protocol is very complicated but you could technical reverse engineer it from our C API if you wanted to.

    If you get a seg fault, it is because you have misused the APIs so there is an error in your code.
    You just have to be really careful.
    Typically working from the examples is the best way to go.
    You should also be very confident at programming in general.

    Additonally: is there a way to reduce the quat datarate to just send each 3rd or 4th sample? Can I use the internal signal processor for that?

    See this is just a general programing question. Not really related to our APIs. You just have to look at the data type of the incoming sensor data and split it into your desired data type.

  • Hi,
    for anyone who is interested in the messages needed to make this happen:

    configuration = [bytearray(b'\x19\x02\x01\x12'),    # sensor fusion
                     bytearray(b'\x03\x03\xa8\x02'),    # accelerometer range
                     bytearray(b'\x13\x03\x28\x00'),    # gyro range
                     bytearray(b'\x15\x01\x00'),        # mag
                     bytearray(b'\x15\x04\x04\x0e'),    # mag
                     bytearray(b'\x15\x03\x06'),        # mag ODR
                     bytearray(b'\x19\x07\x01')         # select quaternions
                     ]
    start_fusion = [bytearray(b'\x03\x02\x01\x00'),  # enable accelerometer
                    bytearray(b'\x13\x02\x01\x00'),  # enable gyro
                    bytearray(b'\x15\x02\x01\x00'),  # enable mag
                    bytearray(b'\x03\x01\x01'),  # start acc
                    bytearray(b'\x13\x01\x01'),  # start gyro
                    bytearray(b'\x15\x01\x01'),  # start mag
                    bytearray(b'\x19\x03\x08\x00'),  # Sensor Fusion output enable
                    bytearray(b'\x19\x01\x01')  # Enable Sensor Fusion
                    ]
    
    change_con_interval =  bytearray(b'\x11\x09\x06\x00\x06\x00\x00\x00\x58\x02')) # 7.5ms/6000ms
    
    stop_fusion = [bytearray(b'\x19\x07\x00'),  # Disable Sensor Fusion
                           bytearray(b'\xfe\x05')]  # reset after gc
    

    With this configuration the sensor is streaming 100Hz quat data.

    @Laura Can you provide information how the received data needs to be interpreted?
    The received data looks like: 1907d5b6503e94a5a7bd89bf79bf324da2ba
    where the first two bytes are the identifiers for 'Data Fusion' and 'Quaternions' respectively. How does the rest of it needs to be interpreted?

  • Oh boy you need to look at the CPP code for the logging module for that one. Part of it is the time counter.

Sign In or Register to comment.