将加速度计范围更改为 16G

Change Accelerometer Range to 16G

谁能帮忙啊! 我正在尝试将 Android Studio 中 Movesense 传感器的加速度计范围从标准 8G 更改为 16G。

我一直收到 'Bad Request' 错误。我对其他事情使用 PUT 请求没有问题(例如切换 LED on/off),但由于某种原因我无法更改加速度计范围。我尝试更改请求的合同部分的格式,但这并没有解决问题。我是 Movesense 编程的新手。谢谢。

我的代码是:

private final String LINEAR_CONFIG_PATH = "/Meas/Acc/Config";
private final String range = "{\"GRange\":";
private final String rangeValue = "16";

Mds.builder().build(this).put(MdsRx.SCHEME_PREFIX +  
MovesenseConnectedDevices.getConnectedDevice(0).getSerial()+
LINEAR_CONFIG_PATH , range + rangeValue +"}", new  
MdsResponseListener() {

API /Meas/Acc/Config 的 API (yaml) 文档指出:

put:
  description: |
    Set linear acceleration measurement configuration.
  parameters:
    - name: config
      in: body
      description: New configurations for the accelerometer.
      required: true
      schema:
        $ref: '#/definitions/AccConfig'

参数名称是"config"。所以你向请求提出的 JSON 应该是:

{
  "config":{"GRange":16}
}

即它必须被包裹到一个 属性 与 put 参数的名称(在某些 API 中有多个参数,所以这是设置它们的方法)。

完全披露:我在 Movesense 团队工作