Closed MartinNievas closed 3 years ago
Thanks for the reminder, this is actually not yet supported in the CLI or GUI, but only available locally for now until I can finish this.
For now you can apply the following patch to write the current settings and apps to JSON files as part of regular syncing in CLI or GUI.
Maybe you can come up with changes which add a GUI-setting/commandline-parameter for this and store the file in the configuration-directory instead of the current directory?
Index: src/movescount/movescount.cpp
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/movescount/movescount.cpp (revision 3c70c4b5e4c03933af57ef7a48031ccf4d491200)
+++ src/movescount/movescount.cpp (revision e6a3a4cb037ac60a272a78c5625b52f35ad08094)
@@ -27,6 +27,8 @@
#include <QEventLoop>
#include <QMutex>
#include <QDebug>
+#include <QDir>
+#include <QJsonDocument>
#include "logstore.h"
@@ -471,6 +473,20 @@
}
}
+void writeJson(QByteArray _data, const char* name) {
+ QFile logfile(name);
+ logfile.open(QIODevice::WriteOnly | QIODevice::Truncate);
+
+ // pretty print JSON
+ QJsonDocument doc = QJsonDocument::fromJson(_data);
+ QString formattedJsonString = doc.toJson(QJsonDocument::Indented);
+
+ //formattedJsonString.replace("", "");
+
+ logfile.write(formattedJsonString.toUtf8());
+ logfile.close();
+}
+
int MovesCount::getCustomModeDataInThread(ambit_sport_mode_device_settings_t *ambitSettings)
{
int ret = -1;
@@ -482,6 +498,8 @@
QByteArray _data = reply->readAll();
MovescountSettings settings = MovescountSettings();
+ writeJson(_data, "settings.json");
+
if (jsonParser.parseDeviceSettingsReply(_data, settings) == 0) {
settings.toAmbitData(ambitSettings);
ret = 0;
@@ -501,6 +519,8 @@
if (checkReplyAuthorization(reply)) {
QByteArray _data = reply->readAll();
+ writeJson(_data, "apprules.json");
+
if (jsonParser.parseAppRulesReply(_data, ambitApps) == 0) {
ret = 0;
}
Hi, thanks for the reply.
I successfully apply the patch, but I was getting problems connecting, mainly because I don't understand what username
and userkey
was.
Reading this comment I understood that APPKEY
is also device/account specific. All these values can be found in the file %AppData%\Roaming\Suunto\Moveslink2\Settings.xml
on windows. After that, I was able to download the json files (apprules and settings) with openambit-cli.
Is there any other way to get those values? (APPKEY
, username
and userkey
)
Writing the json-config to json-files is now available in the UI via #258 and in the command-line application via https://github.com/openambitproject/openambit/commit/6c3c781cfdfdd8587f6ed2876f3db631e67bb132
Hi. I saw that in #243 the tool for the command line was introduced. But I can't find how to set the option:
In #190 there is an example of the JSON file, but I guess there is a way to generate it. Could someone tell me the steps to create it? or from where can I find the format to create the file?