Search code examples
bluetooth-lowenergyuartmovesense

How to make use of BleNordicUART with Movesense


I want to make use of BLE UART (BleNordicUART module) with my custom firmware for printing simple debug outputs (I don't have a programming jig). I didn't find any information regarding BLE UART in the wiki or sources. I can find and connect to the BLE UART service from my Android device, but no data is received.

Can somebody help?

Thanks


Solution

  • Alternative to using the BLE Nordic UART is the DebugService which can provide you with live debug messages as well as store them to EEPROM for later retrieval.

    The documentation on that is still a bit sparse (see: debug.yaml in MovesenseCoreLib) but here's the short version:

    To write (info level) debug message in the code (see: DebugLogger.hpp for other levels):

    DebugLogger::info("stateChange DOUBLETAP: newState = %d", stateChange.newState);
    

    To get DebugMessages over BLE:

    • Subscribe to path /System/Debug/{Level} where {Level} is one of:

      • 'Fatal': 0
      • 'Error': 1
      • 'Warning': 2
      • 'Info': 3
      • 'Verbose': 4

    To store the debug messages to EEPROM you must define the memory area to use in App.cpp and make sure it does not overlap with Logbook memory. Example of definition (16kB for debug, rest for logbook):

    // Define 16kB DEBUG message area
    // NOTE: If building a simulator build, these macros are obligatory!
    DEBUGSERVICE_BUFFER_SIZE(6, 120); // 6 lines, 120 characters total
    DEBUG_EEPROM_MEMORY_AREA(true, 0, 16384)
    // Rest of the EEPROM is for Logbook 
    LOGBOOK_MEMORY_AREA(16384, (384 * 1024)-16384);
    

    ...and configure the minimum level to store to EEPROM with PUT on /System/Debug/Log/Config.

    To fetch entries from EEPROM, do GET on /System/Debug/Log with query object that contains the max timestamp ( in Movesense >=1.9 use "Id") to fetch (the GET returns max 4-6 entries at the time so you have to call it repeatedly to get all the entries).

    Full disclosure: I work for the Movesense team