Sample applications


Movesense device library contains the following sample applications:


Accelerometer 16 bit

Description

Application that forwards the 32 bit floating point measurement values converted to 16 bit integer values. Adds a separate new yaml interface for the 16 bit data and wraps that over the standard 32 bit interface. Allows for higher sampling frequencies transfer over BLE or leaves more bandwidth for transferring other measurements.

Building

To build this sample application, specify its directory as the last argument to the build command:

cmake -G Ninja -DMOVESENSE_CORE_LIBRARY=../MovesenseCoreLib/ -DCMAKE_TOOLCHAIN_FILE=../MovesenseCoreLib/toolchain/gcc-nrf52.cmake -DCMAKE_BUILD_TYPE=Release ../samples/accel_int16_app

More details about the build process can be found here.

Details and usage

Sample API definition

To use the application, flash the Movesense sensor with the corresponding .hex file and access the app's service by entering the following command:

wbcmd --port COMx --path /Sample/IntAcc/{SampleRate} --op Subscribe
e.g.
wbcmd --port COM9 --path /Sample/IntAcc/416 --op Subscribe

where x stands for the COM port number.

Application response will be in the following format:

/net/184530000631/Sample/IntAcc/416::onSubscribeResult
  Subscribed and listening for notifications. Press ESC to stop:

  @144 { {"Timestamp": 88279, "ArrayAcc": [{"x": 28, "y": -45, "z": 4243}, {"x": 27, "y": -36, "z": 4256}, {"x": 27, "y": -41, "z": 4245}, {"x": 34, "y": -36, "z": 4253}, {"x": 26, "y": -39, "z": 4265}, {"x": 18, "y": -40, "z": 4265}, {"x": 19, "y": -30, "z": 4265}, {"x": 34, "y": -43, "z": 4265}]} }
  @165 { {"Timestamp": 88298, "ArrayAcc": [{"x": 23, "y": -37, "z": 4252}, {"x": 34, "y": -33, "z": 4249}, {"x": 35, "y": -30, "z": 4245}, {"x": 30, "y": -31, "z": 4244}, {"x": 36, "y": -35, "z": 4253}, {"x": 33, "y": -42, "z": 4254}, {"x": 33, "y": -44, "z": 4261}, {"x": 24, "y": -41, "z": 4265}]} }
  @183 { {"Timestamp": 88318, "ArrayAcc": [{"x": 23, "y": -38, "z": 4258}, {"x": 31, "y": -40, "z": 4254}, {"x": 22, "y": -33, "z": 4246}, {"x": 36, "y": -35, "z": 4250}, {"x": 31, "y": -36, "z": 4253}, {"x": 31, "y": -45, "z": 4253}, {"x": 26, "y": -49, "z": 4264}, {"x": 28, "y": -42, "z": 4264}]} }
  @207 { {"Timestamp": 88337, "ArrayAcc": [{"x": 23, "y": -44, "z": 4265}, {"x": 28, "y": -48, "z": 4261}, {"x": 32, "y": -40, "z": 4247}, {"x": 24, "y": -40, "z": 4240}, {"x": 32, "y": -43, "z": 4256}, {"x": 27, "y": -38, "z": 4259}, {"x": 27, "y": -36, "z": 4259}, {"x": 25, "y": -47, "z": 4266}]} }
/net/184530000631/Sample/IntAcc/416::onUnsubscribeResult: SUCCESS{
  "response": 200,
  "responsestring": "HTTP_CODE_OK",
  "operation": "subscribe",
  "querytimems": 533,
  "querytimens": 533154600
}

BLE Conformance Test

Description BLE testing via Nrf52 test modes.

Building To build this sample application, specify its directory as the last argument to the build command:

cmake -G Ninja -DMOVESENSE_CORE_LIBRARY=../MovesenseCoreLib/ -DCMAKE_TOOLCHAIN_FILE=../MovesenseCoreLib/toolchain/gcc-nrf52.cmake -DCMAKE_BUILD_TYPE=Release ../samples/ble_conformance_test_app

Details and usage

Sample API definition


BLE Standard Service

Description Provides the sensor internal heart rate measurement over the BLE standard heart rate service profile.

Building To build this sample application, specify its directory as the last argument to the build command:

cmake -G Ninja -DMOVESENSE_CORE_LIBRARY=../MovesenseCoreLib/ -DCMAKE_TOOLCHAIN_FILE=../MovesenseCoreLib/toolchain/gcc-nrf52.cmake -DCMAKE_BUILD_TYPE=Release ../samples/ble_std_services

More details about the build process can be found here.

Details and usage

N/A


Blinky

Description

This application can be used to periodically switch the LED on and off. It will make the LED blink with the period equal to 800 milliseconds.

Building

To build this sample application, specify its directory as the last argument to the build command:

cmake -G Ninja -DMOVESENSE_CORE_LIBRARY=../MovesenseCoreLib/ -DCMAKE_TOOLCHAIN_FILE=../MovesenseCoreLib/toolchain/gcc-nrf52.cmake -DCMAKE_BUILD_TYPE=Release ../samples/blinky_app

More details about the build process can be found here.

Details and usage

There's no API for the Blinky application. Once built and flashed into the device the application will start automatically.


Connection Reliability Test

Description BLE connection testing by sending large data packets 10 times a second.

Building To build this sample application, specify its directory as the last argument to the build command:

cmake -G Ninja -DMOVESENSE_CORE_LIBRARY=../MovesenseCoreLib/ -DCMAKE_TOOLCHAIN_FILE=../MovesenseCoreLib/toolchain/gcc-nrf52.cmake -DCMAKE_BUILD_TYPE=Release ../samples/connection_reliability_test_app

More details about the build process can be found here.

Details and usage

Sample API definition


Connection Scanner

Description Scan the one wire connection for connected device. Upon connection tries to detect heart rate measurement.

Building To build this sample application, specify its directory as the last argument to the build command:

cmake -G Ninja -DMOVESENSE_CORE_LIBRARY=../MovesenseCoreLib/ -DCMAKE_TOOLCHAIN_FILE=../MovesenseCoreLib/toolchain/gcc-nrf52.cmake -DCMAKE_BUILD_TYPE=Release ../samples/connection_scanner_app

More details about the build process can be found here.

Details and usage

N/A


Custom Ble Advertise

Description Configures custom BLE advertising via the Movesense core BLE advertise settings API.

Building To build this sample application, specify its directory as the last argument to the build command:

cmake -G Ninja -DMOVESENSE_CORE_LIBRARY=../MovesenseCoreLib/ -DCMAKE_TOOLCHAIN_FILE=../MovesenseCoreLib/toolchain/gcc-nrf52.cmake -DCMAKE_BUILD_TYPE=Release ../samples/custom_bleadv_app

More details about the build process can be found here.

Details and usage

N/A


Custom GATT Service

Description Uses the Movesense core BLE API to set up a custom GATT service.

Building To build this sample application, specify its directory as the last argument to the build command:

cmake -G Ninja -DMOVESENSE_CORE_LIBRARY=../MovesenseCoreLib/ -DCMAKE_TOOLCHAIN_FILE=../MovesenseCoreLib/toolchain/gcc-nrf52.cmake -DCMAKE_BUILD_TYPE=Release ../samples/custom_gattsvc_app

More details about the build process can be found here.

Details and usage

N/A


Dual BLE

Description Firmware configured to allow two simultaneous BLE connections.

Building To build this sample application, specify its directory as the last argument to the build command:

cmake -G Ninja -DMOVESENSE_CORE_LIBRARY=../MovesenseCoreLib/ -DCMAKE_TOOLCHAIN_FILE=../MovesenseCoreLib/toolchain/gcc-nrf52.cmake -DCMAKE_BUILD_TYPE=Release ../samples/dual_ble_app

More details about the build process can be found here.

Details and usage

Limitations (v. 2.2.1):


GATT SensorData

Description Uses the Movesense core BLE API to set up a custom GATT service that provides up-to 4 different datastreams as binary notifications. Implements a simple command/response protocol that can be used to subscribe or unsubscribe sensor datastreams and extended for your own applications:


// Simple command structure:
// - command [1 byte]
// - client reference [1 byte, not zero!]
// - Command specific data
//
// Result and data notifications are returned via dataCharacteristic in format
// - result type [1 byte]: (1= response to command, )2: data notification from subscription
// - client reference [1 byte]
// - data: (2 byte "HTTP result" for commands, sbem formatted binary for subscriptions)

// Command reference:
// HELLO (=0)
//   no data
//   responds with "Hello"
//
// SUBSCRIBE (=1)
//   data == WB Resource path as string (e.g. [1, 99, '/', 'M','e','a','s','/','a','c','c','/','1','3']
//
// UNSUBSCRIBE (=2)
//   no data
//   reference must match one given in SUBSCRIBE command

Includes a simple WebBLE-API client application as well as Python 3.6 client that can be used to access datastream (open index.html with Chrome browser, enable browser console view to see the data).

Building To build this sample application, specify its directory as the last argument to the build command:

cmake -G Ninja -DMOVESENSE_CORE_LIBRARY=../MovesenseCoreLib/ -DCMAKE_TOOLCHAIN_FILE=../MovesenseCoreLib/toolchain/gcc-nrf52.cmake -DCMAKE_BUILD_TYPE=Release ../samples/gatt_sensordata_app

More details about the build process can be found here.

Details and usage

N/A


Hello World

Description

This example prints the standard welcome message "Hello World!". Simple example of an resource provider that sends timed periodic notifications to subscribed clients.

Building

To build this sample application, specify its directory as the last argument to the build command:

cmake -G Ninja -DMOVESENSE_CORE_LIBRARY=../MovesenseCoreLib/ -DCMAKE_TOOLCHAIN_FILE=../MovesenseCoreLib/toolchain/gcc-nrf52.cmake -DCMAKE_BUILD_TYPE=Release ../samples/hello_world_app

More details about the build process can be found here.

Details and usage

Sample API definition

This application has two options:

Prints the "Hello World!" string only once when requested:

wbcmd --port COMx --path /Sample/HelloWorld --op GET

{
  "response": 200,
  "responsestring": "HTTP_CODE_OK",
  "operation": "get",
  "uri": "/net/ECKI6AF7F95A/Sample/HelloWorld",
  "content": {
    "Greeting": "Hello World!"
  },
  "querytimems": 28,
  "querytimens": 28776889
}

The second option is a continuous subcription to "Hello World #n!" string. It will periodically print the string with automatically increased n, for example:

wbcmd --port COMx --path /Sample/HelloWorld --op Subscribe
/net/ECKI6AF7F95A/Sample/HelloWorld::onSubscribeResult
  Subscribed and listening for notifications. Press ESC to stop:

  @1023 { {
  "Greeting": "Hello World #1!"
} }
  @2030 { {
  "Greeting": "Hello World #2!"
} }
  @3038 { {
  "Greeting": "Hello World #3!"
} }
  @4045 { {
  "Greeting": "Hello World #4!"
} }
  @5053 { {
  "Greeting": "Hello World #5!"
} }
  @6060 { {
  "Greeting": "Hello World #6!"
} }
/net/ECKI6AF7F95A/Sample/HelloWorld::onUnsubscribeResult: SUCCESS{
  "response": 200,
  "responsestring": "HTTP_CODE_OK",
  "operation": "subscribe",
  "querytimems": 6253,
  "querytimens": 6253077051
}

HR Wakeup

Description

This application is designed to set the device to sleep mode after a period of inactivity. Listens to incoming whiteboard connections for one minute. If no connection is made sets the HR measurement into wakeup mode and powers down. It can also detect when HR connectors L and R are short circuited which will wake the sensor up.

Building

To build this sample application, specify its directory as the last argument to the build command:

cmake -G Ninja -DMOVESENSE_CORE_LIBRARY=../MovesenseCoreLib/ -DCMAKE_TOOLCHAIN_FILE=../MovesenseCoreLib/toolchain/gcc-nrf52.cmake -DCMAKE_BUILD_TYPE=Release ../samples/hr_wakeup_app

More details about the build process can be found here.

Details and usage

This application doesn't require any command or request to be sent. Once the sensor is flashed with the application, it will start automatically, blink the LED periodically and remain active for 60 seconds. After that the device will go to sleep mode. Touching HR connector pins will reset the 60 seconds timer or wake up the sensor again.

If the sensor is placed in a programming jig, short circuiting can be done by connecting the Belt Contact pins (marked on be bottom of the jig board as J1).


Jumpmeter

Description

N/A

Building

To build this sample application, specify its directory as the last argument to the build command:

cmake -G Ninja -DMOVESENSE_CORE_LIBRARY=../MovesenseCoreLib/ -DCMAKE_TOOLCHAIN_FILE=../MovesenseCoreLib/toolchain/gcc-nrf52.cmake -DCMAKE_BUILD_TYPE=Release ../samples/jumpmeter_app

More details about the build process can be found here.

Details and usage

Sample API definition


One Wire

Description

This application provides no operation nor an API. It just demonstrates the use of the 1-Wire bus via Movesense API. Scanning and ScrathPad memory reading from connected device.

Building

To build this sample application, specify its directory as the last argument to the build command:

cmake -G Ninja -DMOVESENSE_CORE_LIBRARY=../MovesenseCoreLib/ -DCMAKE_TOOLCHAIN_FILE=../MovesenseCoreLib/toolchain/gcc-nrf52.cmake -DCMAKE_BUILD_TYPE=Release ../samples/1wire_app

More details about the build process can be found here.

Details and usage

N/A


One Wire Temperature

Description

Adds path /Sample/1WireTemp that supports get operation. The get operation will return a response of temperature(s) of any/all connetced external temperature sensors.

Building

To build this sample application, specify its directory as the last argument to the build command:

cmake -G Ninja -DMOVESENSE_CORE_LIBRARY=../MovesenseCoreLib/ -DCMAKE_TOOLCHAIN_FILE=../MovesenseCoreLib/toolchain/gcc-nrf52.cmake -DCMAKE_BUILD_TYPE=Release ../samples/1wire_temperature_app

More details about the build process can be found here.

Details and usage

Sample API definition To get temperature measurements use the command:

wbcmd --port COMx --path /Sample/1WireTemp --op GET

Jumpmeter

Description

Service that provides accelerometer based jump counting for suscribed clients. Counting starts from first subscription. Get and subsrciption provided for /Sample/JumpCounter/JumpCount and /Sample/JumpCounter/LastJumpHeight.

Building

To build this sample application, specify its directory as the last argument to the build command:

cmake -G Ninja -DMOVESENSE_CORE_LIBRARY=../MovesenseCoreLib/ -DCMAKE_TOOLCHAIN_FILE=../MovesenseCoreLib/toolchain/gcc-nrf52.cmake -DCMAKE_BUILD_TYPE=Release ../samples/jumpmeter_app

More details about the build process can be found here.

Details and usage

Sample API definition To get temperature measurements use the command:

wbcmd --port COMx --path /Sample/JumpCounter/JumpCount --op Subscribe

Movement Wakeup

Description

Listens to incoming whiteboard connections for one minute. If no connection is made sets the accelerometer measurement into wakeup mode and powers down.

Building

To build this sample application, specify its directory as the last argument to the build command:

cmake -G Ninja -DMOVESENSE_CORE_LIBRARY=../MovesenseCoreLib/ -DCMAKE_TOOLCHAIN_FILE=../MovesenseCoreLib/toolchain/gcc-nrf52.cmake -DCMAKE_BUILD_TYPE=Release ../samples/movement_wakeup_app

More details about the build process can be found here.

Details and usage

N/A


Offline GATT

Description

This sample app demonstrates the use of DataLogger and Logbook services in the sensor firmware. The firmware implements DataLogger backup of the streaming data over extended "gatt_sensordata_app" protocol (see: gatt_sensordata_app -sample). The inlcuded python client implements the client side of the operation by subscribing ECG data (200 Hz) and fetching the stored data in case disconnect happens during operation.


// Simple command structure:
// - command [1 byte]
// - client reference [1 byte, not zero!]
// - Command specific data
//
// Result and data notifications are returned via dataCharacteristic in format
// - result type [1 byte]: (1= response to command, )2: data notification from subscription
// - client reference [1 byte]
// - data: (2 byte "HTTP result" for commands, sbem formatted binary for subscriptions)

// Command reference:
// HELLO (=0)
//   no data
//   responds with "Hello"
//
// SUBSCRIBE (=1)
//   data == WB Resource path as string (e.g. [1, 99, '/', 'M','e','a','s','/','a','c','c','/','1','3']
//
// UNSUBSCRIBE (=2)
//   no data
//   reference must match one given in SUBSCRIBE command
//
// FETCH_OFFLINE_DATA (=3)
//   no data
//   reference must be different than the one given in SUBSCRIBE command
//   data is returned in DATA -reponses with the given reference, the format 
//   is the same as in notification (No SBEM wrapping!). All notifications are returend
//   with the same reference, so they must be distinguished by length

Includes a simple Python 3 client that can be used to fetch ECG data to CSV file, with storage to data memory if the BLE connection drops.

Building

To build this sample application, specify its directory as the last argument to the build command:

cmake -G Ninja -DMOVESENSE_CORE_LIBRARY=../MovesenseCoreLib/ -DCMAKE_TOOLCHAIN_FILE=../MovesenseCoreLib/toolchain/gcc-nrf52.cmake -DCMAKE_BUILD_TYPE=Release ../samples/gatt_sensordata_app

More details about the build process can be found here.

Details and usage

N/A


Plain

Description

This application provides no operation nor an API. It contains only a list of optional modules which are all enabled by default in the main App.cpp source file.

Building

To build this sample application, specify its directory as the last argument to the build command:

cmake -G Ninja -DMOVESENSE_CORE_LIBRARY=../MovesenseCoreLib/ -DCMAKE_TOOLCHAIN_FILE=../MovesenseCoreLib/toolchain/gcc-nrf52.cmake -DCMAKE_BUILD_TYPE=Release ../samples/plain_app

More details about the build process can be found here.

Details and usage

Plain application keeps the device in the idle mode with all of the optional core modules turned on. The optional core modules are:


Secure BLE

Description

Example of encryped data transfer over BLE, via device bonding.

Building

To build this sample application, specify its directory as the last argument to the build command:

cmake -G Ninja -DMOVESENSE_CORE_LIBRARY=../MovesenseCoreLib/ -DCMAKE_TOOLCHAIN_FILE=../MovesenseCoreLib/toolchain/gcc-nrf52.cmake -DCMAKE_BUILD_TYPE=Release ../samples/secure_ble_app

More details about the build process can be found here.

Details and usage

N/A


Sensor Output Test

Description

...

Building

To build this sample application, specify its directory as the last argument to the build command:

cmake -G Ninja -DMOVESENSE_CORE_LIBRARY=../MovesenseCoreLib/ -DCMAKE_TOOLCHAIN_FILE=../MovesenseCoreLib/toolchain/gcc-nrf52.cmake -DCMAKE_BUILD_TYPE=Release ../samples/sens_output_test_app

More details about the build process can be found here.

Details and usage

Sample API definition


Simple ECG Logger

Description

This firmware is created to simplify collecting ECG data from not "tech savvy" users. It demonstrates the use of DataLogger and Logbook services in the sensor firmware.

Building

To build this sample application, specify its directory as the last argument to the build command:

cmake -G Ninja -DMOVESENSE_CORE_LIBRARY=../MovesenseCoreLib/ -DCMAKE_TOOLCHAIN_FILE=../MovesenseCoreLib/toolchain/gcc-nrf52.cmake -DCMAKE_BUILD_TYPE=Release ../samples/simple_ecglogger_app

More details about the build process can be found here.

Details and usage

The sensor starts logging ECG data to the data memory on startup, if the data memory is empty. The recording will stop when the memory is full. To fetch the data, use the DataLoggerSample in the Movesense mobile library Android samples.