diff options
author | Armando Visconti <armando.visconti@st.com> | 2017-06-19 20:49:24 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2017-06-19 20:49:24 +0000 |
commit | 5f58ae9261504268a4ad991479da82e50837e6b7 (patch) | |
tree | 8ac9b420ae7fdd5226215820d5ed38157a6ea881 | |
parent | e5184bf65d09fab904f4107f5f8be8c7a4c97350 (diff) | |
parent | f26c26e4ab203e2e436bc32fd164c94a48d26859 (diff) | |
download | contexthub-5f58ae9261504268a4ad991479da82e50837e6b7.tar.gz |
nanotool: Add the capability to retrieve/send saved mag calibration data am: 0607403836 am: 439ef2d92c am: 4a4de94a82
am: f26c26e4ab
Change-Id: Iddb5aa0603baa360bfb409c9796661c3b2613d8c
-rw-r--r-- | util/nanotool/androidcontexthub.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/util/nanotool/androidcontexthub.cpp b/util/nanotool/androidcontexthub.cpp index ba872038..44af1b4d 100644 --- a/util/nanotool/androidcontexthub.cpp +++ b/util/nanotool/androidcontexthub.cpp @@ -50,6 +50,7 @@ constexpr int kPollNoTimeout = -1; static const std::vector<std::tuple<const char *, SensorType>> kCalibrationKeys = { std::make_tuple("accel", SensorType::Accel), std::make_tuple("gyro", SensorType::Gyro), + std::make_tuple("mag", SensorType::Magnetometer), std::make_tuple("proximity", SensorType::Proximity), std::make_tuple("barometer", SensorType::Barometer), std::make_tuple("light", SensorType::AmbientLightSensor), @@ -77,6 +78,21 @@ static bool CopyInt32Array(const char *key, return false; } +static bool CopyFloatArray(const char *key, + sp<JSONObject> json, std::vector<uint8_t>& bytes) { + sp<JSONArray> array; + if (json->getArray(key, &array)) { + for (size_t i = 0; i < array->size(); i++) { + float val = 0; + array->getFloat(i, &val); + AppendBytes(&val, sizeof(float), bytes); + } + + return true; + } + return false; +} + static bool GetCalibrationBytes(const char *key, SensorType sensor_type, std::vector<uint8_t>& bytes) { bool success = true; @@ -92,6 +108,10 @@ static bool GetCalibrationBytes(const char *key, SensorType sensor_type, success = CopyInt32Array(key, json, bytes); break; + case SensorType::Magnetometer: + success = CopyFloatArray(key, json, bytes); + break; + case SensorType::AmbientLightSensor: case SensorType::Barometer: { float value = 0; |