Loading apk_decompiled/AMBACommands +1 −0 Original line number Diff line number Diff line Loading @@ -59,6 +59,7 @@ int AMBA_RVAL_ERROR_SDCARD_FULL = -17; int AMBA_RVAL_ERROR_SDCARD_SLOWLY = -61; int AMBA_RVAL_ERROR_WRONG_MODE = -56; int AMBA_RVAL_START_SESSION_DENIED = -3; INVALID_MSGID? = -23 Loading sdk/src/codes.h +12 −10 Original line number Diff line number Diff line Loading @@ -16,16 +16,15 @@ public: ShootNormal = 4864, ShootBracketing = 5029, SetSpeed = 5171, SetISO = 5172, GetSetSpeed = 5171, GetSetISO = 5172, GetSetBracketingBuiltIn = 4918, GetSetMode = 4611, //button press ImgCaptured = 8193, GetCameraSettings = 4364, GetCameraState = 4362, SetCameraMode = 4611, //button press ParamBracketing = 4918, }; Loading Loading @@ -58,10 +57,12 @@ public: { CommandOk = 0, NotificationOk = 128, ErrorBusy = -21, ErrorInvalidToken = -4, ErrorInvalidFilePath = -26, ErrorInvalidOperation = -14, ErrorInvalidToken = -4, ErrorInvalidMsgId = -23, ErrorLowBattery = -58, ErrorNoFirmware = -57, ErrorNoSdcard = -50, Loading @@ -69,12 +70,13 @@ public: ErrorScardFull = -17, ErrorSdcardSlowly = -61, ErrorWrongMode = -56, StartSessionDenied = -3 StartSessionDenied = -3, }; enum class ISO { Auto = 0, I50 = 50, I100 = 100, I200 = 200, Loading sdk/src/commander.cpp +212 −48 Original line number Diff line number Diff line Loading @@ -8,8 +8,18 @@ using namespace std; Commander::Commander() : _token(0), _sock(TcpSocket()), _reader(CustomReader(&_sock)) {}; _token(0), _sock(TcpSocket()), _reader(CustomReader(&_sock)), _iso((Codes::ISO)-1), _speed((Codes::Speed)-1), _bracketingStep(1), _bracketingHalfCount(1), _bracketingBuiltIn((Codes::ParamBracketingBuiltIn)-1) {}; string Commander::generateJSON(Codes::MsgId msg) { Loading Loading @@ -70,7 +80,7 @@ void Commander::handleMsgId(DynamicJsonDocument& json) break; } case (int)Codes::MsgId::SetCameraMode: case (int)Codes::MsgId::GetSetMode: { cout << "Camera mode set to: "; string key = "param"; Loading @@ -88,7 +98,7 @@ void Commander::handleMsgId(DynamicJsonDocument& json) } bool Commander::getJSON(DynamicJsonDocument& json, Codes::MsgId expected_msg_id, Codes::Rval expected_rval) bool Commander::getJSON(DynamicJsonDocument& json, int& rval, Codes::MsgId expected_msg_id) { // Get response for (int i = 0; i < 3; ++i) // make 3 attempts to receive json Loading @@ -111,7 +121,7 @@ bool Commander::getJSON(DynamicJsonDocument& json, Codes::MsgId expected_msg_id, case DeserializationError::NoMemory: //TODO cerr << "Error: couldn't parse JSON (" << err.c_str() << "): " << _reader.history << endl; break; return false; //these shouldn't happen case DeserializationError::InvalidInput: Loading @@ -121,9 +131,10 @@ bool Commander::getJSON(DynamicJsonDocument& json, Codes::MsgId expected_msg_id, cerr << "Error: couldn't parse JSON (" << err.c_str() << "): " << _reader.history << endl; cerr << "Restarting socket..."; _sock.close(); close(); connect(); //TODO: try again break; //TODO: try again? return false; } string key = "msg_id"; Loading @@ -139,14 +150,14 @@ bool Commander::getJSON(DynamicJsonDocument& json, Codes::MsgId expected_msg_id, } key = "rval"; if (!json.containsKey(key) || !json[key].is<int>() || json[key] != (int)expected_rval) if (!json.containsKey(key) || !json[key].is<int>()) { //TODO: Handle invalid rval //handleRval(json); //TODO: Handle message without rval cerr << "Error: unexpected rval (\"" << key << "\" = " << json[key] << ")" << endl; break; } rval = json[key]; return true; } return false; Loading @@ -171,10 +182,11 @@ bool Commander::connect() { _sock.setTimeout(3); if (!_sock.connect("127.0.0.1", 7878) || !getToken()) if (!_sock.connect("127.0.0.1", 7878) || !getToken() || !getCameraSettings()) return false; // TODO: get settings return true; } Loading @@ -185,9 +197,19 @@ bool Commander::getToken() return false; // Get response DynamicJsonDocument json(JSON_OBJECT_SIZE(5) + 50); if (!getJSON(json, Codes::MsgId::GetToken)) DynamicJsonDocument json(minCapacity); int rval; if (!getJSON(json, rval, Codes::MsgId::GetToken)) return false; switch(rval) { case (int)Codes::Rval::CommandOk: break; default: return false; } string key = "param"; if (!json.containsKey(key) || !json[key].is<int>() || json[key] == 0) Loading @@ -200,19 +222,53 @@ bool Commander::getToken() return true; } bool Commander::getCameraSettings() { if (!_sock.send(generateJSON(Codes::MsgId::GetCameraSettings))) return false; DynamicJsonDocument json(JSON_OBJECT_SIZE(26) + 370); int rval; if (!getJSON(json, rval, Codes::MsgId::GetCameraSettings)) return false; bool Commander::setISO(Codes::ISO iso) switch(rval) { if (_iso != iso){ if (!_sock.send(generateJSON(Codes::MsgId::SetISO, (int)iso))) case (int)Codes::Rval::CommandOk: break; default: return false; } // Get response DynamicJsonDocument json(JSON_OBJECT_SIZE(5) + 50); if (!getJSON(json, Codes::MsgId::SetISO)) string key = "still_iso"; if (!json.containsKey(key) || !json[key].is<int>()) { cerr << "Error: unexpected JSON response: \"" << key << "\" = " << json[key] << endl; return false; } _iso = (Codes::ISO)(int)json[key]; key = "still_shutter"; if (!json.containsKey(key) || !json[key].is<int>()) { cerr << "Error: unexpected JSON response: \"" << key << "\" = " << json[key] << endl; return false; } _speed = (Codes::Speed)(int)json[key]; return true; } bool Commander::setISO(Codes::ISO iso) { if (_iso != iso) { if (setParam(Codes::MsgId::GetSetISO, iso)) _iso = iso; else return false; } return true; } Loading @@ -222,19 +278,95 @@ bool Commander::setSpeed(Codes::Speed speed) { if (_speed != speed) { if (!_sock.send(generateJSON(Codes::MsgId::SetSpeed, (int)speed))) if (setParam(Codes::MsgId::GetSetSpeed, speed)) _speed = speed; else return false; } return true; } bool Commander::setBracketingBuiltIn(Codes::ParamBracketingBuiltIn bracketing) { if (_bracketingBuiltIn != bracketing) { if (setParam(Codes::MsgId::GetSetBracketingBuiltIn, bracketing)) _bracketingBuiltIn = bracketing; else return false; } return true; } template <typename T> bool Commander::setParam(Codes::MsgId msgid, T param) { if (!_sock.send(generateJSON(msgid, (int)param))) return false; // Get response DynamicJsonDocument json(JSON_OBJECT_SIZE(5) + 50); if (!getJSON(json, Codes::MsgId::SetSpeed)) DynamicJsonDocument json(minCapacity); int rval; if (!getJSON(json, rval, msgid)) return false; _speed = speed; switch(rval) { case (int)Codes::Rval::CommandOk: break; default: return false; } return true; } template <typename T> bool Commander::getParam(Codes::MsgId msgid, T& param_out) { if (!_sock.send(generateJSON(msgid))) return false; // Get response DynamicJsonDocument json(minCapacity); int rval; if (!getJSON(json, rval, msgid)) return false; switch(rval) { case (int)Codes::Rval::CommandOk: break; default: return false; } string key = "param"; if (!json.containsKey(key) || !json[key].is<T>()) { cerr << "Error: unexpected JSON response: \"" << key << "\" = " << json[key] << endl; return false; } param_out = json[key]; return true; } /** * Set commander's bracketing settings - * * Computes and saves 'halfCount' shutter speeds above and below currently set * shutter speed, so each two 'adjecent' speeds differ !APPROXIMATELY! by 'evStep' EV * (shutter speeds supported by camera does not always differ exactly by 1EV, * e.g. ... 1/3200s,1/2000s,1/1000s ... 1/4s,1s,2s ...) * * @param evStep number of exposure steps between two images * @param halfCount number of pictures to be taken above and below currently set exposure * @return true if setting was successful, otherwise false */ bool Commander::setBracketing(size_t evStep, size_t halfCount) { if (_bracketingStep != evStep || _bracketingHalfCount != halfCount) Loading Loading @@ -272,18 +404,8 @@ bool Commander::setBracketing(size_t evStep, size_t halfCount) return true; } bool Commander::setBracketingBuiltIn(Codes::ParamBracketingBuiltIn) { if (!_sock.send(generateJSON(Codes::MsgId::ParamBracketing, (int)Codes::ParamBracketingBuiltIn::EV2))) return false; // Get response DynamicJsonDocument json(JSON_OBJECT_SIZE(5) + 50); if (!getJSON(json, Codes::MsgId::ParamBracketing)) return false; return true; } bool Commander::shootNormal() { Loading @@ -292,14 +414,31 @@ bool Commander::shootNormal() // await "capture was enqueued" DynamicJsonDocument json(JSON_OBJECT_SIZE(5) + 50); if (!getJSON(json, Codes::MsgId::ShootNormal)) DynamicJsonDocument json(minCapacity); int rval; if (!getJSON(json, rval, Codes::MsgId::ShootNormal)) return false; switch(rval) { case (int)Codes::Rval::CommandOk: break; default: return false; } // await "capture has finished" json = DynamicJsonDocument(JSON_OBJECT_SIZE(9) + 140); if (!getJSON(json, Codes::MsgId::ImgCaptured, Codes::Rval::NotificationOk)) if (!getJSON(json, rval, Codes::MsgId::ImgCaptured)) return false; switch(rval) { case (int)Codes::Rval::NotificationOk: break; default: return false; } string key = "param"; if (!json.containsKey(key) || !json[key].is<string>()) Loading Loading @@ -341,22 +480,47 @@ bool Commander::shootBracketingBuiltIn() return false; // await "bracketing was enqueued" DynamicJsonDocument json(JSON_OBJECT_SIZE(5) + 50); if (!getJSON(json, Codes::MsgId::ShootBracketing)) DynamicJsonDocument json(minCapacity); int rval; if (!getJSON(json, rval, Codes::MsgId::ShootBracketing)) return false; switch(rval) { case (int)Codes::Rval::CommandOk: break; default: return false; } string key = "param"; for (int i = 0; i < 3; ++i) { json = DynamicJsonDocument(JSON_OBJECT_SIZE(5) + 50); if (!getJSON(json, Codes::MsgId::ShootBracketing, Codes::Rval::NotificationOk)) json = DynamicJsonDocument(minCapacity); if (!getJSON(json, rval, Codes::MsgId::ShootBracketing)) return false; switch(rval) { case (int)Codes::Rval::NotificationOk: break; default: return false; } json = DynamicJsonDocument(JSON_OBJECT_SIZE(10) + 140); // await "capture has finished" if (!getJSON(json, Codes::MsgId::ImgCaptured, Codes::Rval::NotificationOk)) if (!getJSON(json, rval, Codes::MsgId::ImgCaptured)) return false; switch(rval) { case (int)Codes::Rval::NotificationOk: break; default: return false; } if (!json.containsKey(key) || !json[key].is<string>()) { cerr << "Error: unexpected JSON response: \"" << key << "\" = " << json[key] << endl; Loading sdk/src/commander.h +12 −4 Original line number Diff line number Diff line Loading @@ -20,9 +20,13 @@ public: bool setISO(Codes::ISO iso); bool setSpeed(Codes::Speed speed); bool setBracketing(size_t evStep, size_t halfCount); bool setBracketingBuiltIn(Codes::ParamBracketingBuiltIn); template <typename T> bool setParam(Codes::MsgId msgid, T param); template <typename T> bool getParam(Codes::MsgId msgid, T& param_out); bool setBracketing(size_t evStep, size_t halfCount); bool shootNormal(); bool shootBracketing(); bool shootBracketingBuiltIn(); Loading @@ -31,20 +35,24 @@ public: private: const int minCapacity = (JSON_OBJECT_SIZE(5) + 50); int _token; TcpSocket _sock; CustomReader _reader; Codes::ISO _iso; Codes::Speed _speed; size_t _bracketingStep; size_t _bracketingHalfCount; std::vector<Codes::Speed> _bracketingVector; Codes::ParamBracketingBuiltIn _bracketingBuiltIn; bool getToken(); bool getJSON(DynamicJsonDocument& json, Codes::MsgId expected_msg_id, Codes::Rval expected_rval = Codes::Rval::CommandOk); bool getCameraSettings(); bool getJSON(DynamicJsonDocument& json, int& rval, Codes::MsgId expected_msg_id); void handleMsgId(DynamicJsonDocument& json); static bool str2int (const char* s, int& i, int base = 0); std::string generateJSON(Codes::MsgId msg); Loading sdk/src/main.cpp +4 −3 Original line number Diff line number Diff line Loading @@ -3,10 +3,11 @@ using namespace std; #include <vector> #include <algorithm> int main(int argc , char *argv[]) { Commander comm; comm.connect() Loading Loading
apk_decompiled/AMBACommands +1 −0 Original line number Diff line number Diff line Loading @@ -59,6 +59,7 @@ int AMBA_RVAL_ERROR_SDCARD_FULL = -17; int AMBA_RVAL_ERROR_SDCARD_SLOWLY = -61; int AMBA_RVAL_ERROR_WRONG_MODE = -56; int AMBA_RVAL_START_SESSION_DENIED = -3; INVALID_MSGID? = -23 Loading
sdk/src/codes.h +12 −10 Original line number Diff line number Diff line Loading @@ -16,16 +16,15 @@ public: ShootNormal = 4864, ShootBracketing = 5029, SetSpeed = 5171, SetISO = 5172, GetSetSpeed = 5171, GetSetISO = 5172, GetSetBracketingBuiltIn = 4918, GetSetMode = 4611, //button press ImgCaptured = 8193, GetCameraSettings = 4364, GetCameraState = 4362, SetCameraMode = 4611, //button press ParamBracketing = 4918, }; Loading Loading @@ -58,10 +57,12 @@ public: { CommandOk = 0, NotificationOk = 128, ErrorBusy = -21, ErrorInvalidToken = -4, ErrorInvalidFilePath = -26, ErrorInvalidOperation = -14, ErrorInvalidToken = -4, ErrorInvalidMsgId = -23, ErrorLowBattery = -58, ErrorNoFirmware = -57, ErrorNoSdcard = -50, Loading @@ -69,12 +70,13 @@ public: ErrorScardFull = -17, ErrorSdcardSlowly = -61, ErrorWrongMode = -56, StartSessionDenied = -3 StartSessionDenied = -3, }; enum class ISO { Auto = 0, I50 = 50, I100 = 100, I200 = 200, Loading
sdk/src/commander.cpp +212 −48 Original line number Diff line number Diff line Loading @@ -8,8 +8,18 @@ using namespace std; Commander::Commander() : _token(0), _sock(TcpSocket()), _reader(CustomReader(&_sock)) {}; _token(0), _sock(TcpSocket()), _reader(CustomReader(&_sock)), _iso((Codes::ISO)-1), _speed((Codes::Speed)-1), _bracketingStep(1), _bracketingHalfCount(1), _bracketingBuiltIn((Codes::ParamBracketingBuiltIn)-1) {}; string Commander::generateJSON(Codes::MsgId msg) { Loading Loading @@ -70,7 +80,7 @@ void Commander::handleMsgId(DynamicJsonDocument& json) break; } case (int)Codes::MsgId::SetCameraMode: case (int)Codes::MsgId::GetSetMode: { cout << "Camera mode set to: "; string key = "param"; Loading @@ -88,7 +98,7 @@ void Commander::handleMsgId(DynamicJsonDocument& json) } bool Commander::getJSON(DynamicJsonDocument& json, Codes::MsgId expected_msg_id, Codes::Rval expected_rval) bool Commander::getJSON(DynamicJsonDocument& json, int& rval, Codes::MsgId expected_msg_id) { // Get response for (int i = 0; i < 3; ++i) // make 3 attempts to receive json Loading @@ -111,7 +121,7 @@ bool Commander::getJSON(DynamicJsonDocument& json, Codes::MsgId expected_msg_id, case DeserializationError::NoMemory: //TODO cerr << "Error: couldn't parse JSON (" << err.c_str() << "): " << _reader.history << endl; break; return false; //these shouldn't happen case DeserializationError::InvalidInput: Loading @@ -121,9 +131,10 @@ bool Commander::getJSON(DynamicJsonDocument& json, Codes::MsgId expected_msg_id, cerr << "Error: couldn't parse JSON (" << err.c_str() << "): " << _reader.history << endl; cerr << "Restarting socket..."; _sock.close(); close(); connect(); //TODO: try again break; //TODO: try again? return false; } string key = "msg_id"; Loading @@ -139,14 +150,14 @@ bool Commander::getJSON(DynamicJsonDocument& json, Codes::MsgId expected_msg_id, } key = "rval"; if (!json.containsKey(key) || !json[key].is<int>() || json[key] != (int)expected_rval) if (!json.containsKey(key) || !json[key].is<int>()) { //TODO: Handle invalid rval //handleRval(json); //TODO: Handle message without rval cerr << "Error: unexpected rval (\"" << key << "\" = " << json[key] << ")" << endl; break; } rval = json[key]; return true; } return false; Loading @@ -171,10 +182,11 @@ bool Commander::connect() { _sock.setTimeout(3); if (!_sock.connect("127.0.0.1", 7878) || !getToken()) if (!_sock.connect("127.0.0.1", 7878) || !getToken() || !getCameraSettings()) return false; // TODO: get settings return true; } Loading @@ -185,9 +197,19 @@ bool Commander::getToken() return false; // Get response DynamicJsonDocument json(JSON_OBJECT_SIZE(5) + 50); if (!getJSON(json, Codes::MsgId::GetToken)) DynamicJsonDocument json(minCapacity); int rval; if (!getJSON(json, rval, Codes::MsgId::GetToken)) return false; switch(rval) { case (int)Codes::Rval::CommandOk: break; default: return false; } string key = "param"; if (!json.containsKey(key) || !json[key].is<int>() || json[key] == 0) Loading @@ -200,19 +222,53 @@ bool Commander::getToken() return true; } bool Commander::getCameraSettings() { if (!_sock.send(generateJSON(Codes::MsgId::GetCameraSettings))) return false; DynamicJsonDocument json(JSON_OBJECT_SIZE(26) + 370); int rval; if (!getJSON(json, rval, Codes::MsgId::GetCameraSettings)) return false; bool Commander::setISO(Codes::ISO iso) switch(rval) { if (_iso != iso){ if (!_sock.send(generateJSON(Codes::MsgId::SetISO, (int)iso))) case (int)Codes::Rval::CommandOk: break; default: return false; } // Get response DynamicJsonDocument json(JSON_OBJECT_SIZE(5) + 50); if (!getJSON(json, Codes::MsgId::SetISO)) string key = "still_iso"; if (!json.containsKey(key) || !json[key].is<int>()) { cerr << "Error: unexpected JSON response: \"" << key << "\" = " << json[key] << endl; return false; } _iso = (Codes::ISO)(int)json[key]; key = "still_shutter"; if (!json.containsKey(key) || !json[key].is<int>()) { cerr << "Error: unexpected JSON response: \"" << key << "\" = " << json[key] << endl; return false; } _speed = (Codes::Speed)(int)json[key]; return true; } bool Commander::setISO(Codes::ISO iso) { if (_iso != iso) { if (setParam(Codes::MsgId::GetSetISO, iso)) _iso = iso; else return false; } return true; } Loading @@ -222,19 +278,95 @@ bool Commander::setSpeed(Codes::Speed speed) { if (_speed != speed) { if (!_sock.send(generateJSON(Codes::MsgId::SetSpeed, (int)speed))) if (setParam(Codes::MsgId::GetSetSpeed, speed)) _speed = speed; else return false; } return true; } bool Commander::setBracketingBuiltIn(Codes::ParamBracketingBuiltIn bracketing) { if (_bracketingBuiltIn != bracketing) { if (setParam(Codes::MsgId::GetSetBracketingBuiltIn, bracketing)) _bracketingBuiltIn = bracketing; else return false; } return true; } template <typename T> bool Commander::setParam(Codes::MsgId msgid, T param) { if (!_sock.send(generateJSON(msgid, (int)param))) return false; // Get response DynamicJsonDocument json(JSON_OBJECT_SIZE(5) + 50); if (!getJSON(json, Codes::MsgId::SetSpeed)) DynamicJsonDocument json(minCapacity); int rval; if (!getJSON(json, rval, msgid)) return false; _speed = speed; switch(rval) { case (int)Codes::Rval::CommandOk: break; default: return false; } return true; } template <typename T> bool Commander::getParam(Codes::MsgId msgid, T& param_out) { if (!_sock.send(generateJSON(msgid))) return false; // Get response DynamicJsonDocument json(minCapacity); int rval; if (!getJSON(json, rval, msgid)) return false; switch(rval) { case (int)Codes::Rval::CommandOk: break; default: return false; } string key = "param"; if (!json.containsKey(key) || !json[key].is<T>()) { cerr << "Error: unexpected JSON response: \"" << key << "\" = " << json[key] << endl; return false; } param_out = json[key]; return true; } /** * Set commander's bracketing settings - * * Computes and saves 'halfCount' shutter speeds above and below currently set * shutter speed, so each two 'adjecent' speeds differ !APPROXIMATELY! by 'evStep' EV * (shutter speeds supported by camera does not always differ exactly by 1EV, * e.g. ... 1/3200s,1/2000s,1/1000s ... 1/4s,1s,2s ...) * * @param evStep number of exposure steps between two images * @param halfCount number of pictures to be taken above and below currently set exposure * @return true if setting was successful, otherwise false */ bool Commander::setBracketing(size_t evStep, size_t halfCount) { if (_bracketingStep != evStep || _bracketingHalfCount != halfCount) Loading Loading @@ -272,18 +404,8 @@ bool Commander::setBracketing(size_t evStep, size_t halfCount) return true; } bool Commander::setBracketingBuiltIn(Codes::ParamBracketingBuiltIn) { if (!_sock.send(generateJSON(Codes::MsgId::ParamBracketing, (int)Codes::ParamBracketingBuiltIn::EV2))) return false; // Get response DynamicJsonDocument json(JSON_OBJECT_SIZE(5) + 50); if (!getJSON(json, Codes::MsgId::ParamBracketing)) return false; return true; } bool Commander::shootNormal() { Loading @@ -292,14 +414,31 @@ bool Commander::shootNormal() // await "capture was enqueued" DynamicJsonDocument json(JSON_OBJECT_SIZE(5) + 50); if (!getJSON(json, Codes::MsgId::ShootNormal)) DynamicJsonDocument json(minCapacity); int rval; if (!getJSON(json, rval, Codes::MsgId::ShootNormal)) return false; switch(rval) { case (int)Codes::Rval::CommandOk: break; default: return false; } // await "capture has finished" json = DynamicJsonDocument(JSON_OBJECT_SIZE(9) + 140); if (!getJSON(json, Codes::MsgId::ImgCaptured, Codes::Rval::NotificationOk)) if (!getJSON(json, rval, Codes::MsgId::ImgCaptured)) return false; switch(rval) { case (int)Codes::Rval::NotificationOk: break; default: return false; } string key = "param"; if (!json.containsKey(key) || !json[key].is<string>()) Loading Loading @@ -341,22 +480,47 @@ bool Commander::shootBracketingBuiltIn() return false; // await "bracketing was enqueued" DynamicJsonDocument json(JSON_OBJECT_SIZE(5) + 50); if (!getJSON(json, Codes::MsgId::ShootBracketing)) DynamicJsonDocument json(minCapacity); int rval; if (!getJSON(json, rval, Codes::MsgId::ShootBracketing)) return false; switch(rval) { case (int)Codes::Rval::CommandOk: break; default: return false; } string key = "param"; for (int i = 0; i < 3; ++i) { json = DynamicJsonDocument(JSON_OBJECT_SIZE(5) + 50); if (!getJSON(json, Codes::MsgId::ShootBracketing, Codes::Rval::NotificationOk)) json = DynamicJsonDocument(minCapacity); if (!getJSON(json, rval, Codes::MsgId::ShootBracketing)) return false; switch(rval) { case (int)Codes::Rval::NotificationOk: break; default: return false; } json = DynamicJsonDocument(JSON_OBJECT_SIZE(10) + 140); // await "capture has finished" if (!getJSON(json, Codes::MsgId::ImgCaptured, Codes::Rval::NotificationOk)) if (!getJSON(json, rval, Codes::MsgId::ImgCaptured)) return false; switch(rval) { case (int)Codes::Rval::NotificationOk: break; default: return false; } if (!json.containsKey(key) || !json[key].is<string>()) { cerr << "Error: unexpected JSON response: \"" << key << "\" = " << json[key] << endl; Loading
sdk/src/commander.h +12 −4 Original line number Diff line number Diff line Loading @@ -20,9 +20,13 @@ public: bool setISO(Codes::ISO iso); bool setSpeed(Codes::Speed speed); bool setBracketing(size_t evStep, size_t halfCount); bool setBracketingBuiltIn(Codes::ParamBracketingBuiltIn); template <typename T> bool setParam(Codes::MsgId msgid, T param); template <typename T> bool getParam(Codes::MsgId msgid, T& param_out); bool setBracketing(size_t evStep, size_t halfCount); bool shootNormal(); bool shootBracketing(); bool shootBracketingBuiltIn(); Loading @@ -31,20 +35,24 @@ public: private: const int minCapacity = (JSON_OBJECT_SIZE(5) + 50); int _token; TcpSocket _sock; CustomReader _reader; Codes::ISO _iso; Codes::Speed _speed; size_t _bracketingStep; size_t _bracketingHalfCount; std::vector<Codes::Speed> _bracketingVector; Codes::ParamBracketingBuiltIn _bracketingBuiltIn; bool getToken(); bool getJSON(DynamicJsonDocument& json, Codes::MsgId expected_msg_id, Codes::Rval expected_rval = Codes::Rval::CommandOk); bool getCameraSettings(); bool getJSON(DynamicJsonDocument& json, int& rval, Codes::MsgId expected_msg_id); void handleMsgId(DynamicJsonDocument& json); static bool str2int (const char* s, int& i, int base = 0); std::string generateJSON(Codes::MsgId msg); Loading
sdk/src/main.cpp +4 −3 Original line number Diff line number Diff line Loading @@ -3,10 +3,11 @@ using namespace std; #include <vector> #include <algorithm> int main(int argc , char *argv[]) { Commander comm; comm.connect() Loading