Search code examples
androidfluttermovesense

Movesense can't set DataLoggerConfig get error 400


I'm trying to set DataLogger Config to start measuring but get error 400. Don't have problems reading config or starting DataLogger. But since setting config doesn't work there is nothing to store. I'm using Flutter with native Java code to communicate with Movesens API. Please what is the issue here?

This package isn't used directly but this part is exactly from this package: https://gitlab.com/bluesquall/movesense_flutter

  static Future<String> setDataLoggerConfiguration(HRBandDevice device) async {
    const String configJsonString = '{"dataEntries": {"dataEntry": [{"path": "/Meas/Acc/13"}, {"path": "/Meas/Gyro/13"}]}}';

    final String response = await _wb.invokeMethod('put', {
      'path': 'suunto://${device.serial}/Mem/DataLogger/Config',
      'contract': configJsonString,
    });
    return response;
  }
                  String contract = call.argument("contract");
                                    Log.d(TAG, String.format("PUT %s : %s", path, contract));
                                    mMds.put(path, contract,
                                        new MdsResponseListener() {
                                            @Override
                                            public void onSuccess(String data) {
                                                Log.d(TAG, String.format("PUT received whiteboard response of type %s:", data.getClass().getName()));
                                                Log.d(TAG, data);
                                                result.success(data);
                                            }
                                            @Override
                                            public void onError(MdsException e) {
                                                Log.e(TAG, "PUT returned error:" + e);
                                                result.error(String.format("%d", e.getStatusCode()), "MdsException", e.getMessage() + String.format(", path: %s, contract: %s", path, contract));
                                            }
                                        } // MdsResponseListener
                                    ); // mds.put
                                    break;
D/MainActivity(19266): operation: put, path: suunto://204730000534/Mem/DataLogger/Config
D/MainActivity(19266): PUT suunto://204730000534/Mem/DataLogger/Config : {"dataEntries": {"dataEntry": [{"path": "/Meas/Acc/13"}, {"path": "/Meas/Gyro/13"}]}}
D/Mds     (19266): Mds put() uri: suunto://204730000534/Mem/DataLogger/Config contract: {"dataEntries": {"dataEntry": [{"path": "/Meas/Acc/13"}, {"path": "/Meas/Gyro/13"}]}}
I/Komposti(19266): [SDS REQUEST] type: PUT uri: suunto://204730000534/Mem/DataLogger/Config contract: {"dataEntries": {"dataEntry": [{"path": "/Meas/Acc/13"}, {"path": "/Meas/Gyro/13"}]}}
D/BleManager(19266): sendCb(1000000e), 13 bytes
D/BleManager(19266): Send complete
D/BleManager(19266): Received data: WB_DATAMSG_CLIENT_ON_PUT_RESULT, type: 7, direct msg, msgLen: 10, reqId: 5377, size: 16
E/Komposti(19266): [SDS RESPONSE] type: PUT status: BAD_REQUEST header: {"TaskId": 156, "Uri": "suunto://204730000534/Mem/DataLogger/Config", "Content-Length": 0, "Reason": "[wb] Operation failed", "Status": 400}
D/MdsOperationHandler(19266): SDSInternalCallback with call type: 4 header: {"TaskId": 156, "Uri": "suunto://204730000534/Mem/DataLogger/Config", "Content-Length": 0, "Reason": "[wb] Operation failed", "Status": 400}
E/MainActivity(19266): PUT returned error:com.movesense.mds.MdsException: Failed status: 400, reason: [wb] Operation failed
E/flutter (19266): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: PlatformException(400, MdsException, Failed status: 400, reason: [wb] Operation failed, path: suunto://204730000534/Mem/DataLogger/Config, contract: {"dataEntries": {"dataEntry": [{"path": "/Meas/Acc/13"}, {"path": "/Meas/Gyro/13"}]}}, null)

Solution

  • The config json object should look like this:

            '{ "config": { "dataEntries" : { "dataEntry" : [{ "path" : "/Meas/HR" }] }}}'
    

    or this for Acc and Gyro:

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