Loading apk_decompiled/AMBACommands +9 −7 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ int AMBA_CAMERA_TIMEOUT = 8000; MSGID_6156? = 6156 //MSGID_5121? = 5121; // repeat last command??? int AMBA_MSGID_RESET_VF = 259; int AMBA_MSGID_STOP_VF = 260; Loading @@ -23,7 +24,9 @@ int AMBA_MSGID_STOP_VF = 260; int AMBA_MSGID_UPDATE_HARDWARE = 8; int AMBA_MSGID_SET_CLNT_INFO = 261; int AMBA_MSGID_GET_MEDIA_INFO = 1026; int AMBA_MSGID_QUERY_SESSION_HOLDER = 1793; int AMBA_MSGID_START_LOOP_FAIL = 4626; int AMBA_MSGID_SET_GPS_INFO = 4917; int AMBA_MSGID_RTC_SYNC = 6147; Loading Loading @@ -75,14 +78,16 @@ int AMBA_MSGID_CD = 1283; /* SESSION */ int AMBA_MSGID_START_SESSION = 257; int AMBA_MSGID_STOP_SESSION = 258; int AMBA_MSGID_QUERY_SESSION_HOLDER = 1793; // <-- {"msg_id":1793} // hold session? // --> {"msg_id":1793,"token":token,"param":token} // yes, hold it /* WHITEBALANCE */ MSGID_SET_PHOTO_WHITEBALANCE = 5168; MSGID_SET_VIDEO_WHITEBALANCE = 5136; //int AMBA_MSGID_SET_WHITEBALANCE = 5121; // returns token ({"rval":0,"msg_id":257,"param":1) int AMBA_PARAM_WHITEBALANCE_AUTO = 0; int AMBA_PARAM_WHITEBALANCE_OUTDOOR = 1; Loading Loading @@ -122,7 +127,7 @@ int AMBA_MSGID_SET_PHOTO_INTERVAL_PARAM = 4929; param seconds (send string, receive int) int AMBA_MSGID_SET_PHOTO_BRACKETING_PARAM = 4918; param 0...6 ; 0EV...3EV param positive int ; 0.5EV, 1.0EV, 1.5EV... int AMBA_MSGID_SET_PHOTO_TIMING_PARAM = 4866; param seconds (send string, receive int) Loading Loading @@ -177,9 +182,6 @@ int AMBA_PARAM_BATTERY_CHARGE_FULL = 68; /* MODE */ int AMBA_MSGID_SET_PHOTO_MODE = 2307; int AMBA_MSGID_SET_VIDEO_MODE = 2308; int AMBA_MSGID_SET_CAMERA_MODE = 4611; int AMBA_PARAM_CAMERA_MODE_VIDEO = 0; int AMBA_PARAM_CAMERA_MODE_PHOTO = 1; Loading sdk/run.sh +1 −1 Original line number Diff line number Diff line Loading @@ -40,7 +40,7 @@ fi if [ "$run" = true ] ; then sleep 1 && nc 192.168.42.1 1234 -w2 <"$outfile" & sleep 1 && nc 192.168.42.1 1234 -w4 <"$outfile" & ./telnet.exp /tmp/"$outfile" fi sdk/src/codes.h +30 −8 Original line number Diff line number Diff line Loading @@ -2,6 +2,8 @@ #define CODES_H #include <string> #include <algorithm> #include <vector> class Codes { Loading @@ -10,14 +12,21 @@ public: { GetToken = 257, DropToken = 258, Shoot = 4864, ShootNormal = 4864, ShootBracketing = 5029, SetSpeed = 5171, SetISO = 5172, ImgCaptured = 8193, GetCameraState = 4362, SetCameraMode = 4611 //button press SetCameraMode = 4611, //button press ParamBracketing = 4918, }; enum class ParamCameraState Loading Loading @@ -95,12 +104,22 @@ public: S2 = 2, S4 = 4, S8 = 8, S12 = 12, //S12 = 12, S16 = 16, S20 = 20, S24 = 24, S28 = 28, S32 = 32 //S20 = 20, //S24 = 24, //S28 = 28, S32 = 32, }; enum class ParamBracketingBuiltIn { EV0_5 = 1, EV1 = 2, EV1_5 = 3, EV2 = 4, EV2_5 = 5, EV3 = 6 }; enum class ParamBattery Loading Loading @@ -174,6 +193,9 @@ public: return "invalid"; } } private: }; Loading sdk/src/commander.cpp +136 −22 Original line number Diff line number Diff line #include <cerrno> #include <climits> #include <unistd.h> #include "commander.h" #include <iostream> Loading Loading @@ -167,9 +169,13 @@ bool Commander::str2int (const char* s, int& i, int base) bool Commander::connect() { auto ret = _sock.connect("127.0.0.1", 7878); _sock.setTimeout(3); return ret; if (!_sock.connect("127.0.0.1", 7878) || !getToken()) return false; // TODO: get settings return true; } Loading @@ -179,7 +185,6 @@ bool Commander::getToken() return false; // Get response //DynamicJsonDocument json(JSON_OBJECT_SIZE(3) + 20); DynamicJsonDocument json(JSON_OBJECT_SIZE(5) + 50); if (!getJSON(json, Codes::MsgId::GetToken)) return false; Loading @@ -198,44 +203,97 @@ bool Commander::getToken() bool Commander::setISO(Codes::ISO iso) { if (_iso != iso){ if (!_sock.send(generateJSON(Codes::MsgId::SetISO, (int)iso))) return false; // Get response //DynamicJsonDocument json(JSON_OBJECT_SIZE(3) + 20); DynamicJsonDocument json(JSON_OBJECT_SIZE(5) + 50); if (!getJSON(json, Codes::MsgId::SetISO)) return false; _iso = iso; } return true; } bool Commander::setSpeed(Codes::Speed speed) { if (_speed != speed) { if (!_sock.send(generateJSON(Codes::MsgId::SetSpeed, (int)speed))) return false; // Get response //DynamicJsonDocument json(JSON_OBJECT_SIZE(3) + 20); DynamicJsonDocument json(JSON_OBJECT_SIZE(5) + 50); if (!getJSON(json, Codes::MsgId::SetSpeed)) return false; _speed = speed; } return true; } bool Commander::setBracketing(size_t evStep, size_t halfCount) { if (_bracketingStep != evStep || _bracketingHalfCount != halfCount) { if (_speed == Codes::Speed::Auto) { // TODO return false; } else { auto it = find(speedOrder.begin(), speedOrder.end(), _speed); vector<Codes::Speed> vect; auto first = it - halfCount * evStep; auto last = it + halfCount * evStep; // check if first & last are not out of range if (first < speedOrder.begin() || first >= speedOrder.end() || last < speedOrder.begin() || last >= speedOrder.end() ) return false; for (it = first; it <= last; it += evStep) vect.push_back(*it); _bracketingVector = vect; _bracketingStep = evStep; _bracketingHalfCount = 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; bool Commander::shoot() return true; } bool Commander::shootNormal() { if (!_sock.send(generateJSON(Codes::MsgId::Shoot))) if (!_sock.send(generateJSON(Codes::MsgId::ShootNormal))) return false; // await "capture was enqueued" //DynamicJsonDocument json(JSON_OBJECT_SIZE(2) + 20); DynamicJsonDocument json(JSON_OBJECT_SIZE(5) + 50); if (!getJSON(json, Codes::MsgId::Shoot)) if (!getJSON(json, Codes::MsgId::ShootNormal)) return false; // await "capture has finished" Loading @@ -255,6 +313,62 @@ bool Commander::shoot() return true; } bool Commander::shootBracketing() { auto s = _speed; // shoot bracketing for (auto&& s : _bracketingVector) { if (!setSpeed(s)) return false; if (!shootNormal()) return false; usleep(300000); //wait for 300ms } // set back shutter speed if (!setSpeed(s)) return false; return true; } bool Commander::shootBracketingBuiltIn() { if (!_sock.send(generateJSON(Codes::MsgId::ShootBracketing))) return false; // await "bracketing was enqueued" DynamicJsonDocument json(JSON_OBJECT_SIZE(5) + 50); if (!getJSON(json, Codes::MsgId::ShootBracketing)) 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)) return false; json = DynamicJsonDocument(JSON_OBJECT_SIZE(10) + 140); // await "capture has finished" if (!getJSON(json, Codes::MsgId::ImgCaptured, Codes::Rval::NotificationOk)) return false; if (!json.containsKey(key) || !json[key].is<string>()) { cerr << "Error: unexpected JSON response: \"" << key << "\" = " << json[key] << endl; return false; } cout << "Image captured: " << json[key] << endl; } return true; } void Commander::close() { Loading sdk/src/commander.h +47 −5 Original line number Diff line number Diff line Loading @@ -3,6 +3,7 @@ #include <map> #include <memory> #include <vector> #include <ArduinoJson.h> Loading @@ -11,23 +12,37 @@ #include "codes.h" class Commander { class Commander { public: Commander(); bool connect(); bool getToken(); bool setISO(Codes::ISO iso); bool setSpeed(Codes::Speed speed); bool shoot(); bool setBracketing(size_t evStep, size_t halfCount); bool setBracketingBuiltIn(Codes::ParamBracketingBuiltIn); bool shootNormal(); bool shootBracketing(); bool shootBracketingBuiltIn(); void close(); private: int _token; TcpSocket _sock; CustomReader _reader; Codes::ISO _iso; Codes::Speed _speed; size_t _bracketingStep; size_t _bracketingHalfCount; std::vector<Codes::Speed> _bracketingVector; bool getToken(); bool getJSON(DynamicJsonDocument& json, Codes::MsgId expected_msg_id, Codes::Rval expected_rval = Codes::Rval::CommandOk); void handleMsgId(DynamicJsonDocument& json); static bool str2int (const char* s, int& i, int base = 0); Loading @@ -37,8 +52,35 @@ private: template <typename T> std::string generateJSON(Codes::MsgId msg, T param); bool shootBracketing(const std::vector<Codes::Speed>& speeds); std::vector<Codes::Speed> speedOrder = { Codes::Speed::S1_6400, Codes::Speed::S1_3200, Codes::Speed::S1_2000, Codes::Speed::S1_1000, Codes::Speed::S1_500, Codes::Speed::S1_240, Codes::Speed::S1_120, Codes::Speed::S1_60, Codes::Speed::S1_30, Codes::Speed::S1_15, Codes::Speed::S1_8, Codes::Speed::S1_4, Codes::Speed::S1, Codes::Speed::S2, Codes::Speed::S4, Codes::Speed::S8, //Speed::S12, Codes::Speed::S16, //Speed::S20, //Speed::S24, //Speed::S28, Codes::Speed::S32, }; }; #endif /* COMMANDER_H */ Loading Loading
apk_decompiled/AMBACommands +9 −7 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ int AMBA_CAMERA_TIMEOUT = 8000; MSGID_6156? = 6156 //MSGID_5121? = 5121; // repeat last command??? int AMBA_MSGID_RESET_VF = 259; int AMBA_MSGID_STOP_VF = 260; Loading @@ -23,7 +24,9 @@ int AMBA_MSGID_STOP_VF = 260; int AMBA_MSGID_UPDATE_HARDWARE = 8; int AMBA_MSGID_SET_CLNT_INFO = 261; int AMBA_MSGID_GET_MEDIA_INFO = 1026; int AMBA_MSGID_QUERY_SESSION_HOLDER = 1793; int AMBA_MSGID_START_LOOP_FAIL = 4626; int AMBA_MSGID_SET_GPS_INFO = 4917; int AMBA_MSGID_RTC_SYNC = 6147; Loading Loading @@ -75,14 +78,16 @@ int AMBA_MSGID_CD = 1283; /* SESSION */ int AMBA_MSGID_START_SESSION = 257; int AMBA_MSGID_STOP_SESSION = 258; int AMBA_MSGID_QUERY_SESSION_HOLDER = 1793; // <-- {"msg_id":1793} // hold session? // --> {"msg_id":1793,"token":token,"param":token} // yes, hold it /* WHITEBALANCE */ MSGID_SET_PHOTO_WHITEBALANCE = 5168; MSGID_SET_VIDEO_WHITEBALANCE = 5136; //int AMBA_MSGID_SET_WHITEBALANCE = 5121; // returns token ({"rval":0,"msg_id":257,"param":1) int AMBA_PARAM_WHITEBALANCE_AUTO = 0; int AMBA_PARAM_WHITEBALANCE_OUTDOOR = 1; Loading Loading @@ -122,7 +127,7 @@ int AMBA_MSGID_SET_PHOTO_INTERVAL_PARAM = 4929; param seconds (send string, receive int) int AMBA_MSGID_SET_PHOTO_BRACKETING_PARAM = 4918; param 0...6 ; 0EV...3EV param positive int ; 0.5EV, 1.0EV, 1.5EV... int AMBA_MSGID_SET_PHOTO_TIMING_PARAM = 4866; param seconds (send string, receive int) Loading Loading @@ -177,9 +182,6 @@ int AMBA_PARAM_BATTERY_CHARGE_FULL = 68; /* MODE */ int AMBA_MSGID_SET_PHOTO_MODE = 2307; int AMBA_MSGID_SET_VIDEO_MODE = 2308; int AMBA_MSGID_SET_CAMERA_MODE = 4611; int AMBA_PARAM_CAMERA_MODE_VIDEO = 0; int AMBA_PARAM_CAMERA_MODE_PHOTO = 1; Loading
sdk/run.sh +1 −1 Original line number Diff line number Diff line Loading @@ -40,7 +40,7 @@ fi if [ "$run" = true ] ; then sleep 1 && nc 192.168.42.1 1234 -w2 <"$outfile" & sleep 1 && nc 192.168.42.1 1234 -w4 <"$outfile" & ./telnet.exp /tmp/"$outfile" fi
sdk/src/codes.h +30 −8 Original line number Diff line number Diff line Loading @@ -2,6 +2,8 @@ #define CODES_H #include <string> #include <algorithm> #include <vector> class Codes { Loading @@ -10,14 +12,21 @@ public: { GetToken = 257, DropToken = 258, Shoot = 4864, ShootNormal = 4864, ShootBracketing = 5029, SetSpeed = 5171, SetISO = 5172, ImgCaptured = 8193, GetCameraState = 4362, SetCameraMode = 4611 //button press SetCameraMode = 4611, //button press ParamBracketing = 4918, }; enum class ParamCameraState Loading Loading @@ -95,12 +104,22 @@ public: S2 = 2, S4 = 4, S8 = 8, S12 = 12, //S12 = 12, S16 = 16, S20 = 20, S24 = 24, S28 = 28, S32 = 32 //S20 = 20, //S24 = 24, //S28 = 28, S32 = 32, }; enum class ParamBracketingBuiltIn { EV0_5 = 1, EV1 = 2, EV1_5 = 3, EV2 = 4, EV2_5 = 5, EV3 = 6 }; enum class ParamBattery Loading Loading @@ -174,6 +193,9 @@ public: return "invalid"; } } private: }; Loading
sdk/src/commander.cpp +136 −22 Original line number Diff line number Diff line #include <cerrno> #include <climits> #include <unistd.h> #include "commander.h" #include <iostream> Loading Loading @@ -167,9 +169,13 @@ bool Commander::str2int (const char* s, int& i, int base) bool Commander::connect() { auto ret = _sock.connect("127.0.0.1", 7878); _sock.setTimeout(3); return ret; if (!_sock.connect("127.0.0.1", 7878) || !getToken()) return false; // TODO: get settings return true; } Loading @@ -179,7 +185,6 @@ bool Commander::getToken() return false; // Get response //DynamicJsonDocument json(JSON_OBJECT_SIZE(3) + 20); DynamicJsonDocument json(JSON_OBJECT_SIZE(5) + 50); if (!getJSON(json, Codes::MsgId::GetToken)) return false; Loading @@ -198,44 +203,97 @@ bool Commander::getToken() bool Commander::setISO(Codes::ISO iso) { if (_iso != iso){ if (!_sock.send(generateJSON(Codes::MsgId::SetISO, (int)iso))) return false; // Get response //DynamicJsonDocument json(JSON_OBJECT_SIZE(3) + 20); DynamicJsonDocument json(JSON_OBJECT_SIZE(5) + 50); if (!getJSON(json, Codes::MsgId::SetISO)) return false; _iso = iso; } return true; } bool Commander::setSpeed(Codes::Speed speed) { if (_speed != speed) { if (!_sock.send(generateJSON(Codes::MsgId::SetSpeed, (int)speed))) return false; // Get response //DynamicJsonDocument json(JSON_OBJECT_SIZE(3) + 20); DynamicJsonDocument json(JSON_OBJECT_SIZE(5) + 50); if (!getJSON(json, Codes::MsgId::SetSpeed)) return false; _speed = speed; } return true; } bool Commander::setBracketing(size_t evStep, size_t halfCount) { if (_bracketingStep != evStep || _bracketingHalfCount != halfCount) { if (_speed == Codes::Speed::Auto) { // TODO return false; } else { auto it = find(speedOrder.begin(), speedOrder.end(), _speed); vector<Codes::Speed> vect; auto first = it - halfCount * evStep; auto last = it + halfCount * evStep; // check if first & last are not out of range if (first < speedOrder.begin() || first >= speedOrder.end() || last < speedOrder.begin() || last >= speedOrder.end() ) return false; for (it = first; it <= last; it += evStep) vect.push_back(*it); _bracketingVector = vect; _bracketingStep = evStep; _bracketingHalfCount = 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; bool Commander::shoot() return true; } bool Commander::shootNormal() { if (!_sock.send(generateJSON(Codes::MsgId::Shoot))) if (!_sock.send(generateJSON(Codes::MsgId::ShootNormal))) return false; // await "capture was enqueued" //DynamicJsonDocument json(JSON_OBJECT_SIZE(2) + 20); DynamicJsonDocument json(JSON_OBJECT_SIZE(5) + 50); if (!getJSON(json, Codes::MsgId::Shoot)) if (!getJSON(json, Codes::MsgId::ShootNormal)) return false; // await "capture has finished" Loading @@ -255,6 +313,62 @@ bool Commander::shoot() return true; } bool Commander::shootBracketing() { auto s = _speed; // shoot bracketing for (auto&& s : _bracketingVector) { if (!setSpeed(s)) return false; if (!shootNormal()) return false; usleep(300000); //wait for 300ms } // set back shutter speed if (!setSpeed(s)) return false; return true; } bool Commander::shootBracketingBuiltIn() { if (!_sock.send(generateJSON(Codes::MsgId::ShootBracketing))) return false; // await "bracketing was enqueued" DynamicJsonDocument json(JSON_OBJECT_SIZE(5) + 50); if (!getJSON(json, Codes::MsgId::ShootBracketing)) 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)) return false; json = DynamicJsonDocument(JSON_OBJECT_SIZE(10) + 140); // await "capture has finished" if (!getJSON(json, Codes::MsgId::ImgCaptured, Codes::Rval::NotificationOk)) return false; if (!json.containsKey(key) || !json[key].is<string>()) { cerr << "Error: unexpected JSON response: \"" << key << "\" = " << json[key] << endl; return false; } cout << "Image captured: " << json[key] << endl; } return true; } void Commander::close() { Loading
sdk/src/commander.h +47 −5 Original line number Diff line number Diff line Loading @@ -3,6 +3,7 @@ #include <map> #include <memory> #include <vector> #include <ArduinoJson.h> Loading @@ -11,23 +12,37 @@ #include "codes.h" class Commander { class Commander { public: Commander(); bool connect(); bool getToken(); bool setISO(Codes::ISO iso); bool setSpeed(Codes::Speed speed); bool shoot(); bool setBracketing(size_t evStep, size_t halfCount); bool setBracketingBuiltIn(Codes::ParamBracketingBuiltIn); bool shootNormal(); bool shootBracketing(); bool shootBracketingBuiltIn(); void close(); private: int _token; TcpSocket _sock; CustomReader _reader; Codes::ISO _iso; Codes::Speed _speed; size_t _bracketingStep; size_t _bracketingHalfCount; std::vector<Codes::Speed> _bracketingVector; bool getToken(); bool getJSON(DynamicJsonDocument& json, Codes::MsgId expected_msg_id, Codes::Rval expected_rval = Codes::Rval::CommandOk); void handleMsgId(DynamicJsonDocument& json); static bool str2int (const char* s, int& i, int base = 0); Loading @@ -37,8 +52,35 @@ private: template <typename T> std::string generateJSON(Codes::MsgId msg, T param); bool shootBracketing(const std::vector<Codes::Speed>& speeds); std::vector<Codes::Speed> speedOrder = { Codes::Speed::S1_6400, Codes::Speed::S1_3200, Codes::Speed::S1_2000, Codes::Speed::S1_1000, Codes::Speed::S1_500, Codes::Speed::S1_240, Codes::Speed::S1_120, Codes::Speed::S1_60, Codes::Speed::S1_30, Codes::Speed::S1_15, Codes::Speed::S1_8, Codes::Speed::S1_4, Codes::Speed::S1, Codes::Speed::S2, Codes::Speed::S4, Codes::Speed::S8, //Speed::S12, Codes::Speed::S16, //Speed::S20, //Speed::S24, //Speed::S28, Codes::Speed::S32, }; }; #endif /* COMMANDER_H */ Loading