2

We are working on an app for the MoveSense that tracks the users movement in some particular cases. However due to our environment the Bluetooth connection can drop out intermittently. To not have any data loss we want to store the sensor data on the MoveSense and read it once the connection is back. In the documentation we found the DataLogger interface, but we are having issues getting it to work.

In our Android app we first subscribe to the sensor we want (for now only the gyro, but we will expand to include the accelerometer once we have the gyro up and running). To do this we execute a put command:

Mds put() uri: suunto://<SERIAL>/Mem/DataLogger/Config contract: {"config": { "dataEntries": {"dataEntry": [{"path": "/Meas/Gyro/13"}]}}}

This command is accepted with a '200' code (figuring out the right JSON also took some time as the documentation lacks the 'config' part and uses a completely different path).

After this we try to activate the logger:

Mds put() uri: suunto://<SERIAL>/Mem/DataLogger/State contract: {"newState": 5}

But on this command we get a '403' (FORBIDDEN) error back:

[SDS RESPONSE] type: PUT status: FORBIDDEN header: {"Status": 403, "TaskId": 28, "Reason": "FORBIDDEN", "Uri": "suunto://<SERIAL>/Mem/DataLogger/State", "Content-Length": 0}

What are we doing wrong here? Is there an error in the config? Of are we forgetting some other action?

Note that we made sure to flash an app on the MoveSense that has the DataLoger and Logbook modules enabled.

1 Answers1

1

First step before we can start logging we need to create DataLogger config. Example for config with Accelerometer and Gyroscope logs.

{
    "dataEntries" : {
        "dataEntry" : [{
                "path" : "/Meas/Acc/13"
            }, {
                "path" : "/Meas/Gyro/13"
            }
        ]
    }
}

Creating config in Android example:

PATH: {serial}/Mem/DataLogger/Config/ REQUEST: PUT

 Mds.builder().build(context).put("suunto://" + movesenseSerial + "/Mem/DataLogger/Config/",
                jsonConfig, new MdsResponseListener() {
                    @Override
                    public void onSuccess(String s) {
                    }

                    @Override
                    public void onError(MdsException e) {
                    }
                });

EXAMPLE RESPONSE:

{"Content": {"dataEntries": {"dataEntry": [{"path": "/Meas/Acc/13"}, {"path": "/Meas/Gyro/13"}]}}}

When config is ready we can start logging. To start logging, PUT value DATALOGGER_LOGGING (=3) to Mem/DataLogger/State resource Android start logging example:

PATH: {serial}/Mem/DataLogger/State/ REQUEST: PUT

Mds.builder().build(context).put("suunto://" + movesenseSerial + /Mem/DataLogger/State/,
                "{\"newState\":3}", new MdsResponseListener() {
                    @Override
                    public void onSuccess(String data) {
                    }
                    @Override
                    public void onError(MdsException error) {
                    }
                });

EXAMPLE RESPONSE:

{"Content": 3}

To stop logging, PUT value DATALOGGER_READY (=2) to Mem/DataLogger/State resource Android stop logging example:

PATH: {serial}/Mem/DataLogger/State/ REQUEST: PUT

Mds.builder().build(context).put("suunto://" + movesenseSerial + /Mem/DataLogger/State/,
                "{\"newState\":2}", new MdsResponseListener() {
                    @Override
                    public void onSuccess(String data) {
                    }
                    @Override
                    public void onError(MdsException error) {
                    }
                });

EXAMPLE RESPONSE:

{"Content": 2}

After log file is created we can get all entries / logs from the device:

PATH: /MDS/Logbook/{serial}/Entries REQUEST: GET

Mds.builder().build(context).get("suunto://" + movesenseSerial + "/Mem/Logbook/Entries/",
                        null, new MdsResponseListener() {
                            @Override
                            public void onSuccess(String data) {
                            }

                            @Override
                            public void onError(MdsException error) {
                            }
                        });

EXAMPLE RESPONSE:

{"elements": [{"Id": 1, "ModificationTimestamp": 536927972, "Size": null}, {"Id": 5, "ModificationTimestamp": 4446227, "Size": null}]}

When we have Entries we can read them

PATH: /MDS/Logbook/{serial}/byId/{LogId}/Summary REQUEST: GET

Mds.builder().build(context).get("suunto://MDS/Logbook/" + movesenseSerial + "/byId/" + entryId + "/Data",
                        null, new MdsResponseListener() {
                            @Override
                            public void onSuccess(String data) {
                            }

                            @Override
                            public void onError(MdsException error) {
                            }
                        });
Esperanz0
  • 1,524
  • 13
  • 35
  • 2
    Your description has a minor error: The configuration json should be wrapped by a "config" block: `{"config": }`. I also figured out what I apparently did wrong: I was doing the PUT for the updated state inside the 'onSuccess' callback of the configuration PUT. Apparently the API cannot handle this. By pulling it out to a separate call it is now working. Thanks! – Jeroen Bogers Jan 18 '18 at 15:01
  • Still, almost three years later the documentation hasn't been fixed. Spent so much time figuring out why my config wasn't being accepted... – Quartal Oct 10 '20 at 10:16