File indexing completed on 2024-12-22 05:29:17

0001 /*
0002  * Copyright 2019 Eike Hein <hein@kde.org>
0003  *
0004  * This library is free software; you can redistribute it and/or
0005  * modify it under the terms of the GNU Lesser General Public
0006  * License as published by the Free Software Foundation; either
0007  * version 2.1 of the License, or (at your option) version 3, or any
0008  * later version accepted by the membership of KDE e.V. (or its
0009  * successor approved by the membership of KDE e.V.), which shall
0010  * act as a proxy defined in Section 6 of version 3 of the license.
0011  *
0012  * This library is distributed in the hope that it will be useful,
0013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0015  * Lesser General Public License for more details.
0016  *
0017  * You should have received a copy of the GNU Lesser General Public
0018  * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
0019  */
0020 
0021 #include "parrotprotocol.h"
0022 #include "debug.h"
0023 
0024 #include <QDataStream>
0025 
0026 QHash<ParrotCommand::Tuple, Parrot::Command> initCommandForTuple()
0027 {
0028     return {{{0, 1, 0}, Parrot::CommonNetworkEventDisconnection},
0029             {{0, 2, 0}, Parrot::CommonSettingsAllSettings},
0030             {{0, 2, 1}, Parrot::CommonSettingsReset},
0031             {{0, 2, 2}, Parrot::CommonSettingsProductName},
0032             {{0, 2, 3}, Parrot::CommonSettingsCountry},
0033             {{0, 2, 4}, Parrot::CommonSettingsAutoCountry},
0034             {{0, 3, 0}, Parrot::CommonSettingsStateAllSettingsChanged},
0035             {{0, 3, 1}, Parrot::CommonSettingsStateResetChanged},
0036             {{0, 3, 2}, Parrot::CommonSettingsStateProductNameChanged},
0037             {{0, 3, 3}, Parrot::CommonSettingsStateProductVersionChanged},
0038             {{0, 3, 4}, Parrot::CommonSettingsStateProductSerialHighChanged},
0039             {{0, 3, 5}, Parrot::CommonSettingsStateProductSerialLowChanged},
0040             {{0, 3, 6}, Parrot::CommonSettingsStateCountryChanged},
0041             {{0, 3, 7}, Parrot::CommonSettingsStateAutoCountryChanged},
0042             {{0, 4, 0}, Parrot::CommonCommonAllStates},
0043             {{0, 4, 1}, Parrot::CommonCommonCurrentDate},
0044             {{0, 4, 2}, Parrot::CommonCommonCurrentTime},
0045             {{0, 4, 3}, Parrot::CommonCommonReboot},
0046             {{0, 5, 0}, Parrot::CommonCommonStateAllStatesChanged},
0047             {{0, 5, 1}, Parrot::CommonCommonStateBatteryStateChanged},
0048             {{0, 5, 2}, Parrot::CommonCommonStateMassStorageStateListChanged},
0049             {{0, 5, 3}, Parrot::CommonCommonStateMassStorageInfoStateListChanged},
0050             {{0, 5, 4}, Parrot::CommonCommonStateCurrentDateChanged},
0051             {{0, 5, 5}, Parrot::CommonCommonStateCurrentTimeChanged},
0052             {{0, 5, 7}, Parrot::CommonCommonStateWifiSignalChanged},
0053             {{0, 5, 8}, Parrot::CommonCommonStateSensorsStatesListChanged},
0054             {{0, 5, 12}, Parrot::CommonCommonStateMassStorageContent},
0055             {{0, 5, 13}, Parrot::CommonCommonStateMassStorageContentForCurrentRun},
0056             {{0, 5, 14}, Parrot::CommonCommonStateVideoRecordingTimestamp},
0057             {{0, 7, 1}, Parrot::CommonOverHeatStateOverHeatRegulationChanged},
0058             {{0, 8, 0}, Parrot::CommonControllerisPiloting},
0059             {{0, 9, 0}, Parrot::CommonWifiSettingsOutdoorSetting},
0060             {{0, 10, 0}, Parrot::CommonWifiSettingsStateoutdoorSettingsChanged},
0061             {{0, 11, 0}, Parrot::CommonMavlinkStart},
0062             {{0, 11, 1}, Parrot::CommonMavlinkPause},
0063             {{0, 11, 2}, Parrot::CommonMavlinkStop},
0064             {{0, 12, 0}, Parrot::CommonMavlinkStateMavlinkFilePlayingStateChanged},
0065             {{0, 12, 2}, Parrot::CommonMavlinkStateMissionItemExecuted},
0066             {{0, 32, 0}, Parrot::CommonFlightPlanSettingsReturnHomeOnDisconnect},
0067             {{0, 33, 0}, Parrot::CommonFlightPlanSettingsStateReturnHomeOnDisconnectChanged},
0068             {{0, 13, 0}, Parrot::CommonCalibrationMagnetoCalibration},
0069             {{0, 14, 0}, Parrot::CommonCalibrationStateMagnetoCalibrationStateChanged},
0070             {{0, 14, 1}, Parrot::CommonCalibrationStateMagnetoCalibrationRequiredState},
0071             {{0, 14, 2}, Parrot::CommonCalibrationStateMagnetoCalibrationAxisToCalibrateChanged},
0072             {{0, 14, 3}, Parrot::CommonCalibrationStateMagnetoCalibrationStartedChanged},
0073             {{0, 14, 4}, Parrot::CommonCalibrationStatePitotCalibrationStateChanged},
0074             {{0, 15, 0}, Parrot::CommonCameraSettingsStateCameraSettingsChanged},
0075             {{0, 17, 0}, Parrot::CommonFlightPlanStateAvailabilityStateChanged},
0076             {{0, 17, 1}, Parrot::CommonFlightPlanStateComponentStateListChanged},
0077             {{0, 17, 2}, Parrot::CommonFlightPlanStateLockStateChanged},
0078             {{0, 19, 0}, Parrot::CommonFlightPlanEventStartingErrorEvent},
0079             {{0, 19, 1}, Parrot::CommonFlightPlanEventSpeedBridleEvent},
0080             {{0, 18, 0}, Parrot::CommonARLibsVersionsStateControllerLibARCommandsVersion},
0081             {{0, 18, 1}, Parrot::CommonARLibsVersionsStateSkyControllerLibARCommandsVersion},
0082             {{0, 18, 2}, Parrot::CommonARLibsVersionsStateDeviceLibARCommandsVersion},
0083             {{0, 30, 0}, Parrot::CommonRunStateRunIdChanged},
0084             {{0, 31, 0}, Parrot::CommonFactoryReset},
0085             {{1, 0, 0}, Parrot::Ardrone3PilotingFlatTrim},
0086             {{1, 0, 1}, Parrot::Ardrone3PilotingTakeOff},
0087             {{1, 0, 2}, Parrot::Ardrone3PilotingPCMD},
0088             {{1, 0, 3}, Parrot::Ardrone3PilotingLanding},
0089             {{1, 0, 4}, Parrot::Ardrone3PilotingEmergency},
0090             {{1, 0, 5}, Parrot::Ardrone3PilotingNavigateHome},
0091             {{1, 0, 7}, Parrot::Ardrone3PilotingmoveBy},
0092             {{1, 0, 8}, Parrot::Ardrone3PilotingUserTakeOff},
0093             {{1, 0, 10}, Parrot::Ardrone3PilotingmoveTo},
0094             {{1, 0, 11}, Parrot::Ardrone3PilotingCancelMoveTo},
0095             {{1, 0, 12}, Parrot::Ardrone3PilotingStartPilotedPOI},
0096             {{1, 0, 13}, Parrot::Ardrone3PilotingStopPilotedPOI},
0097             {{1, 5, 0}, Parrot::Ardrone3AnimationsFlip},
0098             {{1, 1, 1}, Parrot::Ardrone3CameraOrientationV2},
0099             {{1, 1, 2}, Parrot::Ardrone3CameraVelocity},
0100             {{1, 7, 2}, Parrot::Ardrone3MediaRecordPictureV2},
0101             {{1, 7, 3}, Parrot::Ardrone3MediaRecordVideoV2},
0102             {{1, 8, 2}, Parrot::Ardrone3MediaRecordStatePictureStateChangedV2},
0103             {{1, 8, 3}, Parrot::Ardrone3MediaRecordStateVideoStateChangedV2},
0104             {{1, 3, 0}, Parrot::Ardrone3MediaRecordEventPictureEventChanged},
0105             {{1, 3, 1}, Parrot::Ardrone3MediaRecordEventVideoEventChanged},
0106             {{1, 4, 0}, Parrot::Ardrone3PilotingStateFlatTrimChanged},
0107             {{1, 4, 1}, Parrot::Ardrone3PilotingStateFlyingStateChanged},
0108             {{1, 4, 2}, Parrot::Ardrone3PilotingStateAlertStateChanged},
0109             {{1, 4, 3}, Parrot::Ardrone3PilotingStateNavigateHomeStateChanged},
0110             {{1, 4, 4}, Parrot::Ardrone3PilotingStatePositionChanged},
0111             {{1, 4, 5}, Parrot::Ardrone3PilotingStateSpeedChanged},
0112             {{1, 4, 6}, Parrot::Ardrone3PilotingStateAttitudeChanged},
0113             {{1, 4, 8}, Parrot::Ardrone3PilotingStateAltitudeChanged},
0114             {{1, 4, 9}, Parrot::Ardrone3PilotingStateGpsLocationChanged},
0115             {{1, 4, 12}, Parrot::Ardrone3PilotingStatemoveToChanged},
0116             {{1, 4, 13}, Parrot::Ardrone3PilotingStateMotionState},
0117             {{1, 4, 14}, Parrot::Ardrone3PilotingStatePilotedPOI},
0118             {{1, 4, 15}, Parrot::Ardrone3PilotingStateReturnHomeBatteryCapacity},
0119             {{1, 34, 0}, Parrot::Ardrone3PilotingEventmoveByEnd},
0120             {{1, 13, 0}, Parrot::Ardrone3NetworkWifiScan},
0121             {{1, 13, 1}, Parrot::Ardrone3NetworkWifiAuthChannel},
0122             {{1, 14, 0}, Parrot::Ardrone3NetworkStateWifiScanListChanged},
0123             {{1, 14, 1}, Parrot::Ardrone3NetworkStateAllWifiScanChanged},
0124             {{1, 14, 2}, Parrot::Ardrone3NetworkStateWifiAuthChannelListChanged},
0125             {{1, 14, 3}, Parrot::Ardrone3NetworkStateAllWifiAuthChannelChanged},
0126             {{1, 2, 0}, Parrot::Ardrone3PilotingSettingsMaxAltitude},
0127             {{1, 2, 1}, Parrot::Ardrone3PilotingSettingsMaxTilt},
0128             {{1, 2, 3}, Parrot::Ardrone3PilotingSettingsMaxDistance},
0129             {{1, 2, 4}, Parrot::Ardrone3PilotingSettingsNoFlyOverMaxDistance},
0130             {{1, 2, 5}, Parrot::Ardrone3PilotingSettingssetAutonomousFlightMaxHorizontalSpeed},
0131             {{1, 2, 6}, Parrot::Ardrone3PilotingSettingssetAutonomousFlightMaxVerticalSpeed},
0132             {{1, 2, 7}, Parrot::Ardrone3PilotingSettingssetAutonomousFlightMaxHorizontalAcceleration},
0133             {{1, 2, 8}, Parrot::Ardrone3PilotingSettingssetAutonomousFlightMaxVerticalAcceleration},
0134             {{1, 2, 9}, Parrot::Ardrone3PilotingSettingssetAutonomousFlightMaxRotationSpeed},
0135             {{1, 2, 10}, Parrot::Ardrone3PilotingSettingsBankedTurn},
0136             {{1, 2, 16}, Parrot::Ardrone3PilotingSettingsSetMotionDetectionMode},
0137             {{1, 6, 0}, Parrot::Ardrone3PilotingSettingsStateMaxAltitudeChanged},
0138             {{1, 6, 1}, Parrot::Ardrone3PilotingSettingsStateMaxTiltChanged},
0139             {{1, 6, 3}, Parrot::Ardrone3PilotingSettingsStateMaxDistanceChanged},
0140             {{1, 6, 4}, Parrot::Ardrone3PilotingSettingsStateNoFlyOverMaxDistanceChanged},
0141             {{1, 6, 5}, Parrot::Ardrone3PilotingSettingsStateAutonomousFlightMaxHorizontalSpeed},
0142             {{1, 6, 6}, Parrot::Ardrone3PilotingSettingsStateAutonomousFlightMaxVerticalSpeed},
0143             {{1, 6, 7}, Parrot::Ardrone3PilotingSettingsStateAutonomousFlightMaxHorizontalAcceleration},
0144             {{1, 6, 8}, Parrot::Ardrone3PilotingSettingsStateAutonomousFlightMaxVerticalAcceleration},
0145             {{1, 6, 9}, Parrot::Ardrone3PilotingSettingsStateAutonomousFlightMaxRotationSpeed},
0146             {{1, 6, 10}, Parrot::Ardrone3PilotingSettingsStateBankedTurnChanged},
0147             {{1, 6, 16}, Parrot::Ardrone3PilotingSettingsStateMotionDetection},
0148             {{1, 11, 0}, Parrot::Ardrone3SpeedSettingsMaxVerticalSpeed},
0149             {{1, 11, 1}, Parrot::Ardrone3SpeedSettingsMaxRotationSpeed},
0150             {{1, 11, 2}, Parrot::Ardrone3SpeedSettingsHullProtection},
0151             {{1, 11, 4}, Parrot::Ardrone3SpeedSettingsMaxPitchRollRotationSpeed},
0152             {{1, 12, 0}, Parrot::Ardrone3SpeedSettingsStateMaxVerticalSpeedChanged},
0153             {{1, 12, 1}, Parrot::Ardrone3SpeedSettingsStateMaxRotationSpeedChanged},
0154             {{1, 12, 2}, Parrot::Ardrone3SpeedSettingsStateHullProtectionChanged},
0155             {{1, 12, 4}, Parrot::Ardrone3SpeedSettingsStateMaxPitchRollRotationSpeedChanged},
0156             {{1, 9, 0}, Parrot::Ardrone3NetworkSettingsWifiSelection},
0157             {{1, 9, 1}, Parrot::Ardrone3NetworkSettingswifiSecurity},
0158             {{1, 10, 0}, Parrot::Ardrone3NetworkSettingsStateWifiSelectionChanged},
0159             {{1, 10, 2}, Parrot::Ardrone3NetworkSettingsStatewifiSecurity},
0160             {{1, 16, 1}, Parrot::Ardrone3SettingsStateProductGPSVersionChanged},
0161             {{1, 16, 2}, Parrot::Ardrone3SettingsStateMotorErrorStateChanged},
0162             {{1, 16, 4}, Parrot::Ardrone3SettingsStateMotorFlightsStatusChanged},
0163             {{1, 16, 5}, Parrot::Ardrone3SettingsStateMotorErrorLastErrorChanged},
0164             {{1, 16, 7}, Parrot::Ardrone3SettingsStateCPUID},
0165             {{1, 19, 0}, Parrot::Ardrone3PictureSettingsPictureFormatSelection},
0166             {{1, 19, 1}, Parrot::Ardrone3PictureSettingsAutoWhiteBalanceSelection},
0167             {{1, 19, 2}, Parrot::Ardrone3PictureSettingsExpositionSelection},
0168             {{1, 19, 3}, Parrot::Ardrone3PictureSettingsSaturationSelection},
0169             {{1, 19, 4}, Parrot::Ardrone3PictureSettingsTimelapseSelection},
0170             {{1, 19, 5}, Parrot::Ardrone3PictureSettingsVideoAutorecordSelection},
0171             {{1, 19, 6}, Parrot::Ardrone3PictureSettingsVideoStabilizationMode},
0172             {{1, 19, 7}, Parrot::Ardrone3PictureSettingsVideoRecordingMode},
0173             {{1, 19, 8}, Parrot::Ardrone3PictureSettingsVideoFramerate},
0174             {{1, 19, 9}, Parrot::Ardrone3PictureSettingsVideoResolutions},
0175             {{1, 20, 0}, Parrot::Ardrone3PictureSettingsStatePictureFormatChanged},
0176             {{1, 20, 1}, Parrot::Ardrone3PictureSettingsStateAutoWhiteBalanceChanged},
0177             {{1, 20, 2}, Parrot::Ardrone3PictureSettingsStateExpositionChanged},
0178             {{1, 20, 3}, Parrot::Ardrone3PictureSettingsStateSaturationChanged},
0179             {{1, 20, 4}, Parrot::Ardrone3PictureSettingsStateTimelapseChanged},
0180             {{1, 20, 5}, Parrot::Ardrone3PictureSettingsStateVideoAutorecordChanged},
0181             {{1, 20, 6}, Parrot::Ardrone3PictureSettingsStateVideoStabilizationModeChanged},
0182             {{1, 20, 7}, Parrot::Ardrone3PictureSettingsStateVideoRecordingModeChanged},
0183             {{1, 20, 8}, Parrot::Ardrone3PictureSettingsStateVideoFramerateChanged},
0184             {{1, 20, 9}, Parrot::Ardrone3PictureSettingsStateVideoResolutionsChanged},
0185             {{1, 21, 0}, Parrot::Ardrone3MediaStreamingVideoEnable},
0186             {{1, 21, 1}, Parrot::Ardrone3MediaStreamingVideoStreamMode},
0187             {{1, 22, 0}, Parrot::Ardrone3MediaStreamingStateVideoEnableChanged},
0188             {{1, 22, 1}, Parrot::Ardrone3MediaStreamingStateVideoStreamModeChanged},
0189             {{1, 23, 2}, Parrot::Ardrone3GPSSettingsSendControllerGPS},
0190             {{1, 23, 3}, Parrot::Ardrone3GPSSettingsHomeType},
0191             {{1, 23, 4}, Parrot::Ardrone3GPSSettingsReturnHomeDelay},
0192             {{1, 24, 0}, Parrot::Ardrone3GPSSettingsStateHomeChanged},
0193             {{1, 24, 2}, Parrot::Ardrone3GPSSettingsStateGPSFixStateChanged},
0194             {{1, 24, 4}, Parrot::Ardrone3GPSSettingsStateHomeTypeChanged},
0195             {{1, 24, 5}, Parrot::Ardrone3GPSSettingsStateReturnHomeDelayChanged},
0196             {{1, 24, 6}, Parrot::Ardrone3GPSSettingsStateGeofenceCenterChanged},
0197             {{1, 25, 2}, Parrot::Ardrone3CameraStateOrientationV2},
0198             {{1, 25, 3}, Parrot::Ardrone3CameraStatedefaultCameraOrientationV2},
0199             {{1, 25, 4}, Parrot::Ardrone3CameraStateVelocityRange},
0200             {{1, 29, 0}, Parrot::Ardrone3AntiflickeringelectricFrequency},
0201             {{1, 29, 1}, Parrot::Ardrone3AntiflickeringsetMode},
0202             {{1, 30, 0}, Parrot::Ardrone3AntiflickeringStateelectricFrequencyChanged},
0203             {{1, 30, 1}, Parrot::Ardrone3AntiflickeringStatemodeChanged},
0204             {{1, 31, 0}, Parrot::Ardrone3GPSStateNumberOfSatelliteChanged},
0205             {{1, 31, 1}, Parrot::Ardrone3GPSStateHomeTypeAvailabilityChanged},
0206             {{1, 31, 2}, Parrot::Ardrone3GPSStateHomeTypeChosenChanged},
0207             {{1, 33, 1}, Parrot::Ardrone3AccessoryStateBattery},
0208             {{1, 35, 0}, Parrot::Ardrone3SoundStartAlertSound},
0209             {{1, 35, 1}, Parrot::Ardrone3SoundStopAlertSound},
0210             {{1, 36, 0}, Parrot::Ardrone3SoundStateAlertSound}};
0211 }
0212 
0213 QHash<ParrotCommand::Tuple, Parrot::Command> ParrotCommand::m_commandForTuple = initCommandForTuple();
0214 
0215 QHash<Parrot::Command, ParrotCommand::Tuple> initTupleForCommand()
0216 {
0217     return {{Parrot::CommonNetworkEventDisconnection, {0, 1, 0}},
0218             {Parrot::CommonSettingsAllSettings, {0, 2, 0}},
0219             {Parrot::CommonSettingsReset, {0, 2, 1}},
0220             {Parrot::CommonSettingsProductName, {0, 2, 2}},
0221             {Parrot::CommonSettingsCountry, {0, 2, 3}},
0222             {Parrot::CommonSettingsAutoCountry, {0, 2, 4}},
0223             {Parrot::CommonSettingsStateAllSettingsChanged, {0, 3, 0}},
0224             {Parrot::CommonSettingsStateResetChanged, {0, 3, 1}},
0225             {Parrot::CommonSettingsStateProductNameChanged, {0, 3, 2}},
0226             {Parrot::CommonSettingsStateProductVersionChanged, {0, 3, 3}},
0227             {Parrot::CommonSettingsStateProductSerialHighChanged, {0, 3, 4}},
0228             {Parrot::CommonSettingsStateProductSerialLowChanged, {0, 3, 5}},
0229             {Parrot::CommonSettingsStateCountryChanged, {0, 3, 6}},
0230             {Parrot::CommonSettingsStateAutoCountryChanged, {0, 3, 7}},
0231             {Parrot::CommonCommonAllStates, {0, 4, 0}},
0232             {Parrot::CommonCommonCurrentDate, {0, 4, 1}},
0233             {Parrot::CommonCommonCurrentTime, {0, 4, 2}},
0234             {Parrot::CommonCommonReboot, {0, 4, 3}},
0235             {Parrot::CommonCommonStateAllStatesChanged, {0, 5, 0}},
0236             {Parrot::CommonCommonStateBatteryStateChanged, {0, 5, 1}},
0237             {Parrot::CommonCommonStateMassStorageStateListChanged, {0, 5, 2}},
0238             {Parrot::CommonCommonStateMassStorageInfoStateListChanged, {0, 5, 3}},
0239             {Parrot::CommonCommonStateCurrentDateChanged, {0, 5, 4}},
0240             {Parrot::CommonCommonStateCurrentTimeChanged, {0, 5, 5}},
0241             {Parrot::CommonCommonStateWifiSignalChanged, {0, 5, 7}},
0242             {Parrot::CommonCommonStateSensorsStatesListChanged, {0, 5, 8}},
0243             {Parrot::CommonCommonStateMassStorageContent, {0, 5, 12}},
0244             {Parrot::CommonCommonStateMassStorageContentForCurrentRun, {0, 5, 13}},
0245             {Parrot::CommonCommonStateVideoRecordingTimestamp, {0, 5, 14}},
0246             {Parrot::CommonOverHeatStateOverHeatRegulationChanged, {0, 7, 1}},
0247             {Parrot::CommonControllerisPiloting, {0, 8, 0}},
0248             {Parrot::CommonWifiSettingsOutdoorSetting, {0, 9, 0}},
0249             {Parrot::CommonWifiSettingsStateoutdoorSettingsChanged, {0, 10, 0}},
0250             {Parrot::CommonMavlinkStart, {0, 11, 0}},
0251             {Parrot::CommonMavlinkPause, {0, 11, 1}},
0252             {Parrot::CommonMavlinkStop, {0, 11, 2}},
0253             {Parrot::CommonMavlinkStateMavlinkFilePlayingStateChanged, {0, 12, 0}},
0254             {Parrot::CommonMavlinkStateMissionItemExecuted, {0, 12, 2}},
0255             {Parrot::CommonFlightPlanSettingsReturnHomeOnDisconnect, {0, 32, 0}},
0256             {Parrot::CommonFlightPlanSettingsStateReturnHomeOnDisconnectChanged, {0, 33, 0}},
0257             {Parrot::CommonCalibrationMagnetoCalibration, {0, 13, 0}},
0258             {Parrot::CommonCalibrationStateMagnetoCalibrationStateChanged, {0, 14, 0}},
0259             {Parrot::CommonCalibrationStateMagnetoCalibrationRequiredState, {0, 14, 1}},
0260             {Parrot::CommonCalibrationStateMagnetoCalibrationAxisToCalibrateChanged, {0, 14, 2}},
0261             {Parrot::CommonCalibrationStateMagnetoCalibrationStartedChanged, {0, 14, 3}},
0262             {Parrot::CommonCalibrationStatePitotCalibrationStateChanged, {0, 14, 4}},
0263             {Parrot::CommonCameraSettingsStateCameraSettingsChanged, {0, 15, 0}},
0264             {Parrot::CommonFlightPlanStateAvailabilityStateChanged, {0, 17, 0}},
0265             {Parrot::CommonFlightPlanStateComponentStateListChanged, {0, 17, 1}},
0266             {Parrot::CommonFlightPlanStateLockStateChanged, {0, 17, 2}},
0267             {Parrot::CommonFlightPlanEventStartingErrorEvent, {0, 19, 0}},
0268             {Parrot::CommonFlightPlanEventSpeedBridleEvent, {0, 19, 1}},
0269             {Parrot::CommonARLibsVersionsStateControllerLibARCommandsVersion, {0, 18, 0}},
0270             {Parrot::CommonARLibsVersionsStateSkyControllerLibARCommandsVersion, {0, 18, 1}},
0271             {Parrot::CommonARLibsVersionsStateDeviceLibARCommandsVersion, {0, 18, 2}},
0272             {Parrot::CommonRunStateRunIdChanged, {0, 30, 0}},
0273             {Parrot::CommonFactoryReset, {0, 31, 0}},
0274             {Parrot::Ardrone3PilotingFlatTrim, {1, 0, 0}},
0275             {Parrot::Ardrone3PilotingTakeOff, {1, 0, 1}},
0276             {Parrot::Ardrone3PilotingPCMD, {1, 0, 2}},
0277             {Parrot::Ardrone3PilotingLanding, {1, 0, 3}},
0278             {Parrot::Ardrone3PilotingEmergency, {1, 0, 4}},
0279             {Parrot::Ardrone3PilotingNavigateHome, {1, 0, 5}},
0280             {Parrot::Ardrone3PilotingmoveBy, {1, 0, 7}},
0281             {Parrot::Ardrone3PilotingUserTakeOff, {1, 0, 8}},
0282             {Parrot::Ardrone3PilotingmoveTo, {1, 0, 10}},
0283             {Parrot::Ardrone3PilotingCancelMoveTo, {1, 0, 11}},
0284             {Parrot::Ardrone3PilotingStartPilotedPOI, {1, 0, 12}},
0285             {Parrot::Ardrone3PilotingStopPilotedPOI, {1, 0, 13}},
0286             {Parrot::Ardrone3AnimationsFlip, {1, 5, 0}},
0287             {Parrot::Ardrone3CameraOrientationV2, {1, 1, 1}},
0288             {Parrot::Ardrone3CameraVelocity, {1, 1, 2}},
0289             {Parrot::Ardrone3MediaRecordPictureV2, {1, 7, 2}},
0290             {Parrot::Ardrone3MediaRecordVideoV2, {1, 7, 3}},
0291             {Parrot::Ardrone3MediaRecordStatePictureStateChangedV2, {1, 8, 2}},
0292             {Parrot::Ardrone3MediaRecordStateVideoStateChangedV2, {1, 8, 3}},
0293             {Parrot::Ardrone3MediaRecordEventPictureEventChanged, {1, 3, 0}},
0294             {Parrot::Ardrone3MediaRecordEventVideoEventChanged, {1, 3, 1}},
0295             {Parrot::Ardrone3PilotingStateFlatTrimChanged, {1, 4, 0}},
0296             {Parrot::Ardrone3PilotingStateFlyingStateChanged, {1, 4, 1}},
0297             {Parrot::Ardrone3PilotingStateAlertStateChanged, {1, 4, 2}},
0298             {Parrot::Ardrone3PilotingStateNavigateHomeStateChanged, {1, 4, 3}},
0299             {Parrot::Ardrone3PilotingStatePositionChanged, {1, 4, 4}},
0300             {Parrot::Ardrone3PilotingStateSpeedChanged, {1, 4, 5}},
0301             {Parrot::Ardrone3PilotingStateAttitudeChanged, {1, 4, 6}},
0302             {Parrot::Ardrone3PilotingStateAltitudeChanged, {1, 4, 8}},
0303             {Parrot::Ardrone3PilotingStateGpsLocationChanged, {1, 4, 9}},
0304             {Parrot::Ardrone3PilotingStatemoveToChanged, {1, 4, 12}},
0305             {Parrot::Ardrone3PilotingStateMotionState, {1, 4, 13}},
0306             {Parrot::Ardrone3PilotingStatePilotedPOI, {1, 4, 14}},
0307             {Parrot::Ardrone3PilotingStateReturnHomeBatteryCapacity, {1, 4, 15}},
0308             {Parrot::Ardrone3PilotingEventmoveByEnd, {1, 34, 0}},
0309             {Parrot::Ardrone3NetworkWifiScan, {1, 13, 0}},
0310             {Parrot::Ardrone3NetworkWifiAuthChannel, {1, 13, 1}},
0311             {Parrot::Ardrone3NetworkStateWifiScanListChanged, {1, 14, 0}},
0312             {Parrot::Ardrone3NetworkStateAllWifiScanChanged, {1, 14, 1}},
0313             {Parrot::Ardrone3NetworkStateWifiAuthChannelListChanged, {1, 14, 2}},
0314             {Parrot::Ardrone3NetworkStateAllWifiAuthChannelChanged, {1, 14, 3}},
0315             {Parrot::Ardrone3PilotingSettingsMaxAltitude, {1, 2, 0}},
0316             {Parrot::Ardrone3PilotingSettingsMaxTilt, {1, 2, 1}},
0317             {Parrot::Ardrone3PilotingSettingsMaxDistance, {1, 2, 3}},
0318             {Parrot::Ardrone3PilotingSettingsNoFlyOverMaxDistance, {1, 2, 4}},
0319             {Parrot::Ardrone3PilotingSettingssetAutonomousFlightMaxHorizontalSpeed, {1, 2, 5}},
0320             {Parrot::Ardrone3PilotingSettingssetAutonomousFlightMaxVerticalSpeed, {1, 2, 6}},
0321             {Parrot::Ardrone3PilotingSettingssetAutonomousFlightMaxHorizontalAcceleration, {1, 2, 7}},
0322             {Parrot::Ardrone3PilotingSettingssetAutonomousFlightMaxVerticalAcceleration, {1, 2, 8}},
0323             {Parrot::Ardrone3PilotingSettingssetAutonomousFlightMaxRotationSpeed, {1, 2, 9}},
0324             {Parrot::Ardrone3PilotingSettingsBankedTurn, {1, 2, 10}},
0325             {Parrot::Ardrone3PilotingSettingsSetMotionDetectionMode, {1, 2, 16}},
0326             {Parrot::Ardrone3PilotingSettingsStateMaxAltitudeChanged, {1, 6, 0}},
0327             {Parrot::Ardrone3PilotingSettingsStateMaxTiltChanged, {1, 6, 1}},
0328             {Parrot::Ardrone3PilotingSettingsStateMaxDistanceChanged, {1, 6, 3}},
0329             {Parrot::Ardrone3PilotingSettingsStateNoFlyOverMaxDistanceChanged, {1, 6, 4}},
0330             {Parrot::Ardrone3PilotingSettingsStateAutonomousFlightMaxHorizontalSpeed, {1, 6, 5}},
0331             {Parrot::Ardrone3PilotingSettingsStateAutonomousFlightMaxVerticalSpeed, {1, 6, 6}},
0332             {Parrot::Ardrone3PilotingSettingsStateAutonomousFlightMaxHorizontalAcceleration, {1, 6, 7}},
0333             {Parrot::Ardrone3PilotingSettingsStateAutonomousFlightMaxVerticalAcceleration, {1, 6, 8}},
0334             {Parrot::Ardrone3PilotingSettingsStateAutonomousFlightMaxRotationSpeed, {1, 6, 9}},
0335             {Parrot::Ardrone3PilotingSettingsStateBankedTurnChanged, {1, 6, 10}},
0336             {Parrot::Ardrone3PilotingSettingsStateMotionDetection, {1, 6, 16}},
0337             {Parrot::Ardrone3SpeedSettingsMaxVerticalSpeed, {1, 11, 0}},
0338             {Parrot::Ardrone3SpeedSettingsMaxRotationSpeed, {1, 11, 1}},
0339             {Parrot::Ardrone3SpeedSettingsHullProtection, {1, 11, 2}},
0340             {Parrot::Ardrone3SpeedSettingsMaxPitchRollRotationSpeed, {1, 11, 4}},
0341             {Parrot::Ardrone3SpeedSettingsStateMaxVerticalSpeedChanged, {1, 12, 0}},
0342             {Parrot::Ardrone3SpeedSettingsStateMaxRotationSpeedChanged, {1, 12, 1}},
0343             {Parrot::Ardrone3SpeedSettingsStateHullProtectionChanged, {1, 12, 2}},
0344             {Parrot::Ardrone3SpeedSettingsStateMaxPitchRollRotationSpeedChanged, {1, 12, 4}},
0345             {Parrot::Ardrone3NetworkSettingsWifiSelection, {1, 9, 0}},
0346             {Parrot::Ardrone3NetworkSettingswifiSecurity, {1, 9, 1}},
0347             {Parrot::Ardrone3NetworkSettingsStateWifiSelectionChanged, {1, 10, 0}},
0348             {Parrot::Ardrone3NetworkSettingsStatewifiSecurity, {1, 10, 2}},
0349             {Parrot::Ardrone3SettingsStateProductGPSVersionChanged, {1, 16, 1}},
0350             {Parrot::Ardrone3SettingsStateMotorErrorStateChanged, {1, 16, 2}},
0351             {Parrot::Ardrone3SettingsStateMotorFlightsStatusChanged, {1, 16, 4}},
0352             {Parrot::Ardrone3SettingsStateMotorErrorLastErrorChanged, {1, 16, 5}},
0353             {Parrot::Ardrone3SettingsStateCPUID, {1, 16, 7}},
0354             {Parrot::Ardrone3PictureSettingsPictureFormatSelection, {1, 19, 0}},
0355             {Parrot::Ardrone3PictureSettingsAutoWhiteBalanceSelection, {1, 19, 1}},
0356             {Parrot::Ardrone3PictureSettingsExpositionSelection, {1, 19, 2}},
0357             {Parrot::Ardrone3PictureSettingsSaturationSelection, {1, 19, 3}},
0358             {Parrot::Ardrone3PictureSettingsTimelapseSelection, {1, 19, 4}},
0359             {Parrot::Ardrone3PictureSettingsVideoAutorecordSelection, {1, 19, 5}},
0360             {Parrot::Ardrone3PictureSettingsVideoStabilizationMode, {1, 19, 6}},
0361             {Parrot::Ardrone3PictureSettingsVideoRecordingMode, {1, 19, 7}},
0362             {Parrot::Ardrone3PictureSettingsVideoFramerate, {1, 19, 8}},
0363             {Parrot::Ardrone3PictureSettingsVideoResolutions, {1, 19, 9}},
0364             {Parrot::Ardrone3PictureSettingsStatePictureFormatChanged, {1, 20, 0}},
0365             {Parrot::Ardrone3PictureSettingsStateAutoWhiteBalanceChanged, {1, 20, 1}},
0366             {Parrot::Ardrone3PictureSettingsStateExpositionChanged, {1, 20, 2}},
0367             {Parrot::Ardrone3PictureSettingsStateSaturationChanged, {1, 20, 3}},
0368             {Parrot::Ardrone3PictureSettingsStateTimelapseChanged, {1, 20, 4}},
0369             {Parrot::Ardrone3PictureSettingsStateVideoAutorecordChanged, {1, 20, 5}},
0370             {Parrot::Ardrone3PictureSettingsStateVideoStabilizationModeChanged, {1, 20, 6}},
0371             {Parrot::Ardrone3PictureSettingsStateVideoRecordingModeChanged, {1, 20, 7}},
0372             {Parrot::Ardrone3PictureSettingsStateVideoFramerateChanged, {1, 20, 8}},
0373             {Parrot::Ardrone3PictureSettingsStateVideoResolutionsChanged, {1, 20, 9}},
0374             {Parrot::Ardrone3MediaStreamingVideoEnable, {1, 21, 0}},
0375             {Parrot::Ardrone3MediaStreamingVideoStreamMode, {1, 21, 1}},
0376             {Parrot::Ardrone3MediaStreamingStateVideoEnableChanged, {1, 22, 0}},
0377             {Parrot::Ardrone3MediaStreamingStateVideoStreamModeChanged, {1, 22, 1}},
0378             {Parrot::Ardrone3GPSSettingsSendControllerGPS, {1, 23, 2}},
0379             {Parrot::Ardrone3GPSSettingsHomeType, {1, 23, 3}},
0380             {Parrot::Ardrone3GPSSettingsReturnHomeDelay, {1, 23, 4}},
0381             {Parrot::Ardrone3GPSSettingsStateHomeChanged, {1, 24, 0}},
0382             {Parrot::Ardrone3GPSSettingsStateGPSFixStateChanged, {1, 24, 2}},
0383             {Parrot::Ardrone3GPSSettingsStateHomeTypeChanged, {1, 24, 4}},
0384             {Parrot::Ardrone3GPSSettingsStateReturnHomeDelayChanged, {1, 24, 5}},
0385             {Parrot::Ardrone3GPSSettingsStateGeofenceCenterChanged, {1, 24, 6}},
0386             {Parrot::Ardrone3CameraStateOrientationV2, {1, 25, 2}},
0387             {Parrot::Ardrone3CameraStatedefaultCameraOrientationV2, {1, 25, 3}},
0388             {Parrot::Ardrone3CameraStateVelocityRange, {1, 25, 4}},
0389             {Parrot::Ardrone3AntiflickeringelectricFrequency, {1, 29, 0}},
0390             {Parrot::Ardrone3AntiflickeringsetMode, {1, 29, 1}},
0391             {Parrot::Ardrone3AntiflickeringStateelectricFrequencyChanged, {1, 30, 0}},
0392             {Parrot::Ardrone3AntiflickeringStatemodeChanged, {1, 30, 1}},
0393             {Parrot::Ardrone3GPSStateNumberOfSatelliteChanged, {1, 31, 0}},
0394             {Parrot::Ardrone3GPSStateHomeTypeAvailabilityChanged, {1, 31, 1}},
0395             {Parrot::Ardrone3GPSStateHomeTypeChosenChanged, {1, 31, 2}},
0396             {Parrot::Ardrone3AccessoryStateBattery, {1, 33, 1}},
0397             {Parrot::Ardrone3SoundStartAlertSound, {1, 35, 0}},
0398             {Parrot::Ardrone3SoundStopAlertSound, {1, 35, 1}},
0399             {Parrot::Ardrone3SoundStateAlertSound, {1, 36, 0}}};
0400 }
0401 
0402 QHash<Parrot::Command, ParrotCommand::Tuple> ParrotCommand::m_tupleForCommand = initTupleForCommand();
0403 
0404 QHash<Parrot::Command, QVector<Parrot::ArgumentType>> initSignatureForCommand()
0405 {
0406     return {{Parrot::CommonNetworkEventDisconnection, {Parrot::TYPE_ENUM}},
0407             {Parrot::CommonSettingsProductName, {Parrot::TYPE_STRING}},
0408             {Parrot::CommonSettingsCountry, {Parrot::TYPE_STRING}},
0409             {Parrot::CommonSettingsAutoCountry, {Parrot::TYPE_U8}},
0410             {Parrot::CommonSettingsStateProductNameChanged, {Parrot::TYPE_STRING}},
0411             {Parrot::CommonSettingsStateProductVersionChanged, {Parrot::TYPE_STRING, Parrot::TYPE_STRING}},
0412             {Parrot::CommonSettingsStateProductSerialHighChanged, {Parrot::TYPE_STRING}},
0413             {Parrot::CommonSettingsStateProductSerialLowChanged, {Parrot::TYPE_STRING}},
0414             {Parrot::CommonSettingsStateCountryChanged, {Parrot::TYPE_STRING}},
0415             {Parrot::CommonSettingsStateAutoCountryChanged, {Parrot::TYPE_U8}},
0416             {Parrot::CommonCommonCurrentDate, {Parrot::TYPE_STRING}},
0417             {Parrot::CommonCommonCurrentTime, {Parrot::TYPE_STRING}},
0418             {Parrot::CommonCommonStateBatteryStateChanged, {Parrot::TYPE_U8}},
0419             {Parrot::CommonCommonStateMassStorageStateListChanged, {Parrot::TYPE_U8, Parrot::TYPE_STRING}},
0420             {Parrot::CommonCommonStateMassStorageInfoStateListChanged,
0421              {Parrot::TYPE_U8, Parrot::TYPE_U32, Parrot::TYPE_U32, Parrot::TYPE_U8, Parrot::TYPE_U8, Parrot::TYPE_U8}},
0422             {Parrot::CommonCommonStateCurrentDateChanged, {Parrot::TYPE_STRING}},
0423             {Parrot::CommonCommonStateCurrentTimeChanged, {Parrot::TYPE_STRING}},
0424             {Parrot::CommonCommonStateWifiSignalChanged, {Parrot::TYPE_I16}},
0425             {Parrot::CommonCommonStateSensorsStatesListChanged, {Parrot::TYPE_ENUM, Parrot::TYPE_U8}},
0426             {Parrot::CommonCommonStateMassStorageContent,
0427              {Parrot::TYPE_U8, Parrot::TYPE_U16, Parrot::TYPE_U16, Parrot::TYPE_U16, Parrot::TYPE_U16, Parrot::TYPE_U16}},
0428             {Parrot::CommonCommonStateMassStorageContentForCurrentRun, {Parrot::TYPE_U8, Parrot::TYPE_U16, Parrot::TYPE_U16, Parrot::TYPE_U16}},
0429             {Parrot::CommonCommonStateVideoRecordingTimestamp, {Parrot::TYPE_U64, Parrot::TYPE_U64}},
0430             {Parrot::CommonOverHeatStateOverHeatRegulationChanged, {Parrot::TYPE_U8}},
0431             {Parrot::CommonControllerisPiloting, {Parrot::TYPE_U8}},
0432             {Parrot::CommonWifiSettingsOutdoorSetting, {Parrot::TYPE_U8}},
0433             {Parrot::CommonWifiSettingsStateoutdoorSettingsChanged, {Parrot::TYPE_U8}},
0434             {Parrot::CommonMavlinkStart, {Parrot::TYPE_STRING, Parrot::TYPE_ENUM}},
0435             {Parrot::CommonMavlinkStateMavlinkFilePlayingStateChanged, {Parrot::TYPE_ENUM, Parrot::TYPE_STRING, Parrot::TYPE_ENUM}},
0436             {Parrot::CommonMavlinkStateMissionItemExecuted, {Parrot::TYPE_U32}},
0437             {Parrot::CommonFlightPlanSettingsReturnHomeOnDisconnect, {Parrot::TYPE_U8}},
0438             {Parrot::CommonFlightPlanSettingsStateReturnHomeOnDisconnectChanged, {Parrot::TYPE_U8, Parrot::TYPE_U8}},
0439             {Parrot::CommonCalibrationMagnetoCalibration, {Parrot::TYPE_U8}},
0440             {Parrot::CommonCalibrationStateMagnetoCalibrationStateChanged, {Parrot::TYPE_U8, Parrot::TYPE_U8, Parrot::TYPE_U8, Parrot::TYPE_U8}},
0441             {Parrot::CommonCalibrationStateMagnetoCalibrationRequiredState, {Parrot::TYPE_U8}},
0442             {Parrot::CommonCalibrationStateMagnetoCalibrationAxisToCalibrateChanged, {Parrot::TYPE_ENUM}},
0443             {Parrot::CommonCalibrationStateMagnetoCalibrationStartedChanged, {Parrot::TYPE_U8}},
0444             {Parrot::CommonCalibrationStatePitotCalibrationStateChanged, {Parrot::TYPE_ENUM, Parrot::TYPE_U8}},
0445             {Parrot::CommonCameraSettingsStateCameraSettingsChanged,
0446              {Parrot::TYPE_FLOAT, Parrot::TYPE_FLOAT, Parrot::TYPE_FLOAT, Parrot::TYPE_FLOAT, Parrot::TYPE_FLOAT}},
0447             {Parrot::CommonFlightPlanStateAvailabilityStateChanged, {Parrot::TYPE_U8}},
0448             {Parrot::CommonFlightPlanStateComponentStateListChanged, {Parrot::TYPE_ENUM, Parrot::TYPE_U8}},
0449             {Parrot::CommonFlightPlanStateLockStateChanged, {Parrot::TYPE_U8}},
0450             {Parrot::CommonARLibsVersionsStateControllerLibARCommandsVersion, {Parrot::TYPE_STRING}},
0451             {Parrot::CommonARLibsVersionsStateSkyControllerLibARCommandsVersion, {Parrot::TYPE_STRING}},
0452             {Parrot::CommonARLibsVersionsStateDeviceLibARCommandsVersion, {Parrot::TYPE_STRING}},
0453             {Parrot::CommonRunStateRunIdChanged, {Parrot::TYPE_STRING}},
0454             {Parrot::Ardrone3PilotingPCMD, {Parrot::TYPE_U8, Parrot::TYPE_I8, Parrot::TYPE_I8, Parrot::TYPE_I8, Parrot::TYPE_I8, Parrot::TYPE_U32}},
0455             {Parrot::Ardrone3PilotingNavigateHome, {Parrot::TYPE_U8}},
0456             {Parrot::Ardrone3PilotingmoveBy, {Parrot::TYPE_FLOAT, Parrot::TYPE_FLOAT, Parrot::TYPE_FLOAT, Parrot::TYPE_FLOAT}},
0457             {Parrot::Ardrone3PilotingUserTakeOff, {Parrot::TYPE_U8}},
0458             {Parrot::Ardrone3PilotingmoveTo, {Parrot::TYPE_DOUBLE, Parrot::TYPE_DOUBLE, Parrot::TYPE_DOUBLE, Parrot::TYPE_ENUM, Parrot::TYPE_FLOAT}},
0459             {Parrot::Ardrone3PilotingStartPilotedPOI, {Parrot::TYPE_DOUBLE, Parrot::TYPE_DOUBLE, Parrot::TYPE_DOUBLE}},
0460             {Parrot::Ardrone3AnimationsFlip, {Parrot::TYPE_ENUM}},
0461             {Parrot::Ardrone3CameraOrientationV2, {Parrot::TYPE_FLOAT, Parrot::TYPE_FLOAT}},
0462             {Parrot::Ardrone3CameraVelocity, {Parrot::TYPE_FLOAT, Parrot::TYPE_FLOAT}},
0463             {Parrot::Ardrone3MediaRecordVideoV2, {Parrot::TYPE_ENUM}},
0464             {Parrot::Ardrone3MediaRecordStatePictureStateChangedV2, {Parrot::TYPE_ENUM, Parrot::TYPE_ENUM}},
0465             {Parrot::Ardrone3MediaRecordStateVideoStateChangedV2, {Parrot::TYPE_ENUM, Parrot::TYPE_ENUM}},
0466             {Parrot::Ardrone3MediaRecordEventPictureEventChanged, {Parrot::TYPE_ENUM, Parrot::TYPE_ENUM}},
0467             {Parrot::Ardrone3MediaRecordEventVideoEventChanged, {Parrot::TYPE_ENUM, Parrot::TYPE_ENUM}},
0468             {Parrot::Ardrone3PilotingStateFlyingStateChanged, {Parrot::TYPE_ENUM}},
0469             {Parrot::Ardrone3PilotingStateAlertStateChanged, {Parrot::TYPE_ENUM}},
0470             {Parrot::Ardrone3PilotingStateNavigateHomeStateChanged, {Parrot::TYPE_ENUM, Parrot::TYPE_ENUM}},
0471             {Parrot::Ardrone3PilotingStatePositionChanged, {Parrot::TYPE_DOUBLE, Parrot::TYPE_DOUBLE, Parrot::TYPE_DOUBLE}},
0472             {Parrot::Ardrone3PilotingStateSpeedChanged, {Parrot::TYPE_FLOAT, Parrot::TYPE_FLOAT, Parrot::TYPE_FLOAT}},
0473             {Parrot::Ardrone3PilotingStateAttitudeChanged, {Parrot::TYPE_FLOAT, Parrot::TYPE_FLOAT, Parrot::TYPE_FLOAT}},
0474             {Parrot::Ardrone3PilotingStateAltitudeChanged, {Parrot::TYPE_DOUBLE}},
0475             {Parrot::Ardrone3PilotingStateGpsLocationChanged,
0476              {Parrot::TYPE_DOUBLE, Parrot::TYPE_DOUBLE, Parrot::TYPE_DOUBLE, Parrot::TYPE_I8, Parrot::TYPE_I8, Parrot::TYPE_I8}},
0477             {Parrot::Ardrone3PilotingStatemoveToChanged,
0478              {Parrot::TYPE_DOUBLE, Parrot::TYPE_DOUBLE, Parrot::TYPE_DOUBLE, Parrot::TYPE_ENUM, Parrot::TYPE_FLOAT, Parrot::TYPE_ENUM}},
0479             {Parrot::Ardrone3PilotingStateMotionState, {Parrot::TYPE_ENUM}},
0480             {Parrot::Ardrone3PilotingStatePilotedPOI, {Parrot::TYPE_DOUBLE, Parrot::TYPE_DOUBLE, Parrot::TYPE_DOUBLE, Parrot::TYPE_ENUM}},
0481             {Parrot::Ardrone3PilotingStateReturnHomeBatteryCapacity, {Parrot::TYPE_ENUM}},
0482             {Parrot::Ardrone3PilotingEventmoveByEnd, {Parrot::TYPE_FLOAT, Parrot::TYPE_FLOAT, Parrot::TYPE_FLOAT, Parrot::TYPE_FLOAT, Parrot::TYPE_ENUM}},
0483             {Parrot::Ardrone3NetworkWifiScan, {Parrot::TYPE_ENUM}},
0484             {Parrot::Ardrone3NetworkStateWifiScanListChanged, {Parrot::TYPE_STRING, Parrot::TYPE_I16, Parrot::TYPE_ENUM, Parrot::TYPE_U8}},
0485             {Parrot::Ardrone3NetworkStateWifiAuthChannelListChanged, {Parrot::TYPE_ENUM, Parrot::TYPE_U8, Parrot::TYPE_U8}},
0486             {Parrot::Ardrone3PilotingSettingsMaxAltitude, {Parrot::TYPE_FLOAT}},
0487             {Parrot::Ardrone3PilotingSettingsMaxTilt, {Parrot::TYPE_FLOAT}},
0488             {Parrot::Ardrone3PilotingSettingsMaxDistance, {Parrot::TYPE_FLOAT}},
0489             {Parrot::Ardrone3PilotingSettingsNoFlyOverMaxDistance, {Parrot::TYPE_U8}},
0490             {Parrot::Ardrone3PilotingSettingssetAutonomousFlightMaxHorizontalSpeed, {Parrot::TYPE_FLOAT}},
0491             {Parrot::Ardrone3PilotingSettingssetAutonomousFlightMaxVerticalSpeed, {Parrot::TYPE_FLOAT}},
0492             {Parrot::Ardrone3PilotingSettingssetAutonomousFlightMaxHorizontalAcceleration, {Parrot::TYPE_FLOAT}},
0493             {Parrot::Ardrone3PilotingSettingssetAutonomousFlightMaxVerticalAcceleration, {Parrot::TYPE_FLOAT}},
0494             {Parrot::Ardrone3PilotingSettingssetAutonomousFlightMaxRotationSpeed, {Parrot::TYPE_FLOAT}},
0495             {Parrot::Ardrone3PilotingSettingsBankedTurn, {Parrot::TYPE_U8}},
0496             {Parrot::Ardrone3PilotingSettingsSetMotionDetectionMode, {Parrot::TYPE_U8}},
0497             {Parrot::Ardrone3PilotingSettingsStateMaxAltitudeChanged, {Parrot::TYPE_FLOAT, Parrot::TYPE_FLOAT, Parrot::TYPE_FLOAT}},
0498             {Parrot::Ardrone3PilotingSettingsStateMaxTiltChanged, {Parrot::TYPE_FLOAT, Parrot::TYPE_FLOAT, Parrot::TYPE_FLOAT}},
0499             {Parrot::Ardrone3PilotingSettingsStateMaxDistanceChanged, {Parrot::TYPE_FLOAT, Parrot::TYPE_FLOAT, Parrot::TYPE_FLOAT}},
0500             {Parrot::Ardrone3PilotingSettingsStateNoFlyOverMaxDistanceChanged, {Parrot::TYPE_U8}},
0501             {Parrot::Ardrone3PilotingSettingsStateAutonomousFlightMaxHorizontalSpeed, {Parrot::TYPE_FLOAT}},
0502             {Parrot::Ardrone3PilotingSettingsStateAutonomousFlightMaxVerticalSpeed, {Parrot::TYPE_FLOAT}},
0503             {Parrot::Ardrone3PilotingSettingsStateAutonomousFlightMaxHorizontalAcceleration, {Parrot::TYPE_FLOAT}},
0504             {Parrot::Ardrone3PilotingSettingsStateAutonomousFlightMaxVerticalAcceleration, {Parrot::TYPE_FLOAT}},
0505             {Parrot::Ardrone3PilotingSettingsStateAutonomousFlightMaxRotationSpeed, {Parrot::TYPE_FLOAT}},
0506             {Parrot::Ardrone3PilotingSettingsStateBankedTurnChanged, {Parrot::TYPE_U8}},
0507             {Parrot::Ardrone3PilotingSettingsStateMotionDetection, {Parrot::TYPE_U8}},
0508             {Parrot::Ardrone3SpeedSettingsMaxVerticalSpeed, {Parrot::TYPE_FLOAT}},
0509             {Parrot::Ardrone3SpeedSettingsMaxRotationSpeed, {Parrot::TYPE_FLOAT}},
0510             {Parrot::Ardrone3SpeedSettingsHullProtection, {Parrot::TYPE_U8}},
0511             {Parrot::Ardrone3SpeedSettingsMaxPitchRollRotationSpeed, {Parrot::TYPE_FLOAT}},
0512             {Parrot::Ardrone3SpeedSettingsStateMaxVerticalSpeedChanged, {Parrot::TYPE_FLOAT, Parrot::TYPE_FLOAT, Parrot::TYPE_FLOAT}},
0513             {Parrot::Ardrone3SpeedSettingsStateMaxRotationSpeedChanged, {Parrot::TYPE_FLOAT, Parrot::TYPE_FLOAT, Parrot::TYPE_FLOAT}},
0514             {Parrot::Ardrone3SpeedSettingsStateHullProtectionChanged, {Parrot::TYPE_U8}},
0515             {Parrot::Ardrone3SpeedSettingsStateMaxPitchRollRotationSpeedChanged, {Parrot::TYPE_FLOAT, Parrot::TYPE_FLOAT, Parrot::TYPE_FLOAT}},
0516             {Parrot::Ardrone3NetworkSettingsWifiSelection, {Parrot::TYPE_ENUM, Parrot::TYPE_ENUM, Parrot::TYPE_U8}},
0517             {Parrot::Ardrone3NetworkSettingswifiSecurity, {Parrot::TYPE_ENUM, Parrot::TYPE_STRING, Parrot::TYPE_ENUM}},
0518             {Parrot::Ardrone3NetworkSettingsStateWifiSelectionChanged, {Parrot::TYPE_ENUM, Parrot::TYPE_ENUM, Parrot::TYPE_U8}},
0519             {Parrot::Ardrone3NetworkSettingsStatewifiSecurity, {Parrot::TYPE_ENUM, Parrot::TYPE_STRING, Parrot::TYPE_ENUM}},
0520             {Parrot::Ardrone3SettingsStateProductGPSVersionChanged, {Parrot::TYPE_STRING, Parrot::TYPE_STRING}},
0521             {Parrot::Ardrone3SettingsStateMotorErrorStateChanged, {Parrot::TYPE_U8, Parrot::TYPE_ENUM}},
0522             {Parrot::Ardrone3SettingsStateMotorFlightsStatusChanged, {Parrot::TYPE_U16, Parrot::TYPE_U16, Parrot::TYPE_U32}},
0523             {Parrot::Ardrone3SettingsStateMotorErrorLastErrorChanged, {Parrot::TYPE_ENUM}},
0524             {Parrot::Ardrone3SettingsStateCPUID, {Parrot::TYPE_STRING}},
0525             {Parrot::Ardrone3PictureSettingsPictureFormatSelection, {Parrot::TYPE_ENUM}},
0526             {Parrot::Ardrone3PictureSettingsAutoWhiteBalanceSelection, {Parrot::TYPE_ENUM}},
0527             {Parrot::Ardrone3PictureSettingsExpositionSelection, {Parrot::TYPE_FLOAT}},
0528             {Parrot::Ardrone3PictureSettingsSaturationSelection, {Parrot::TYPE_FLOAT}},
0529             {Parrot::Ardrone3PictureSettingsTimelapseSelection, {Parrot::TYPE_U8, Parrot::TYPE_FLOAT}},
0530             {Parrot::Ardrone3PictureSettingsVideoAutorecordSelection, {Parrot::TYPE_U8, Parrot::TYPE_U8}},
0531             {Parrot::Ardrone3PictureSettingsVideoStabilizationMode, {Parrot::TYPE_ENUM}},
0532             {Parrot::Ardrone3PictureSettingsVideoRecordingMode, {Parrot::TYPE_ENUM}},
0533             {Parrot::Ardrone3PictureSettingsVideoFramerate, {Parrot::TYPE_ENUM}},
0534             {Parrot::Ardrone3PictureSettingsVideoResolutions, {Parrot::TYPE_ENUM}},
0535             {Parrot::Ardrone3PictureSettingsStatePictureFormatChanged, {Parrot::TYPE_ENUM}},
0536             {Parrot::Ardrone3PictureSettingsStateAutoWhiteBalanceChanged, {Parrot::TYPE_ENUM}},
0537             {Parrot::Ardrone3PictureSettingsStateExpositionChanged, {Parrot::TYPE_FLOAT, Parrot::TYPE_FLOAT, Parrot::TYPE_FLOAT}},
0538             {Parrot::Ardrone3PictureSettingsStateSaturationChanged, {Parrot::TYPE_FLOAT, Parrot::TYPE_FLOAT, Parrot::TYPE_FLOAT}},
0539             {Parrot::Ardrone3PictureSettingsStateTimelapseChanged, {Parrot::TYPE_U8, Parrot::TYPE_FLOAT, Parrot::TYPE_FLOAT, Parrot::TYPE_FLOAT}},
0540             {Parrot::Ardrone3PictureSettingsStateVideoAutorecordChanged, {Parrot::TYPE_U8, Parrot::TYPE_U8}},
0541             {Parrot::Ardrone3PictureSettingsStateVideoStabilizationModeChanged, {Parrot::TYPE_ENUM}},
0542             {Parrot::Ardrone3PictureSettingsStateVideoRecordingModeChanged, {Parrot::TYPE_ENUM}},
0543             {Parrot::Ardrone3PictureSettingsStateVideoFramerateChanged, {Parrot::TYPE_ENUM}},
0544             {Parrot::Ardrone3PictureSettingsStateVideoResolutionsChanged, {Parrot::TYPE_ENUM}},
0545             {Parrot::Ardrone3MediaStreamingVideoEnable, {Parrot::TYPE_U8}},
0546             {Parrot::Ardrone3MediaStreamingVideoStreamMode, {Parrot::TYPE_ENUM}},
0547             {Parrot::Ardrone3MediaStreamingStateVideoEnableChanged, {Parrot::TYPE_ENUM}},
0548             {Parrot::Ardrone3MediaStreamingStateVideoStreamModeChanged, {Parrot::TYPE_ENUM}},
0549             {Parrot::Ardrone3GPSSettingsSendControllerGPS,
0550              {Parrot::TYPE_DOUBLE, Parrot::TYPE_DOUBLE, Parrot::TYPE_DOUBLE, Parrot::TYPE_DOUBLE, Parrot::TYPE_DOUBLE}},
0551             {Parrot::Ardrone3GPSSettingsHomeType, {Parrot::TYPE_ENUM}},
0552             {Parrot::Ardrone3GPSSettingsReturnHomeDelay, {Parrot::TYPE_U16}},
0553             {Parrot::Ardrone3GPSSettingsStateHomeChanged, {Parrot::TYPE_DOUBLE, Parrot::TYPE_DOUBLE, Parrot::TYPE_DOUBLE}},
0554             {Parrot::Ardrone3GPSSettingsStateGPSFixStateChanged, {Parrot::TYPE_U8}},
0555             {Parrot::Ardrone3GPSSettingsStateHomeTypeChanged, {Parrot::TYPE_ENUM}},
0556             {Parrot::Ardrone3GPSSettingsStateReturnHomeDelayChanged, {Parrot::TYPE_U16}},
0557             {Parrot::Ardrone3GPSSettingsStateGeofenceCenterChanged, {Parrot::TYPE_DOUBLE, Parrot::TYPE_DOUBLE}},
0558             {Parrot::Ardrone3CameraStateOrientationV2, {Parrot::TYPE_FLOAT, Parrot::TYPE_FLOAT}},
0559             {Parrot::Ardrone3CameraStatedefaultCameraOrientationV2, {Parrot::TYPE_FLOAT, Parrot::TYPE_FLOAT}},
0560             {Parrot::Ardrone3CameraStateVelocityRange, {Parrot::TYPE_FLOAT, Parrot::TYPE_FLOAT}},
0561             {Parrot::Ardrone3AntiflickeringelectricFrequency, {Parrot::TYPE_ENUM}},
0562             {Parrot::Ardrone3AntiflickeringsetMode, {Parrot::TYPE_ENUM}},
0563             {Parrot::Ardrone3AntiflickeringStateelectricFrequencyChanged, {Parrot::TYPE_ENUM}},
0564             {Parrot::Ardrone3AntiflickeringStatemodeChanged, {Parrot::TYPE_ENUM}},
0565             {Parrot::Ardrone3GPSStateNumberOfSatelliteChanged, {Parrot::TYPE_U8}},
0566             {Parrot::Ardrone3GPSStateHomeTypeAvailabilityChanged, {Parrot::TYPE_ENUM, Parrot::TYPE_U8}},
0567             {Parrot::Ardrone3GPSStateHomeTypeChosenChanged, {Parrot::TYPE_ENUM}},
0568             {Parrot::Ardrone3AccessoryStateBattery, {Parrot::TYPE_U8, Parrot::TYPE_U8, Parrot::TYPE_U8}},
0569             {Parrot::Ardrone3SoundStateAlertSound, {Parrot::TYPE_ENUM}}};
0570 }
0571 
0572 QHash<Parrot::Command, QVector<Parrot::ArgumentType>> ParrotCommand::m_signatureForCommand = initSignatureForCommand();
0573 
0574 ParrotCommand::ParrotCommand(Parrot::Command command, const QVariantList &arguments)
0575     : tuple(tupleForCommand(command))
0576 {
0577     if (!arguments.isEmpty() && m_signatureForCommand.contains(command)) {
0578         const QVector<Parrot::ArgumentType> &signature = m_signatureForCommand.value(command);
0579 
0580         QDataStream s(&data, QIODevice::WriteOnly);
0581         s.setByteOrder(QDataStream::LittleEndian);
0582 
0583         for (int i = 0; i < signature.count(); ++i) {
0584             const Parrot::ArgumentType argType = signature.at(i);
0585 
0586             switch (argType) {
0587             case Parrot::TYPE_U8: {
0588                 s << arguments.at(i).value<quint8>();
0589                 break;
0590             }
0591             case Parrot::TYPE_I8: {
0592                 s << arguments.at(i).value<qint8>();
0593                 break;
0594             }
0595             case Parrot::TYPE_U16: {
0596                 s << arguments.at(i).value<quint16>();
0597                 break;
0598             }
0599             case Parrot::TYPE_I16: {
0600                 s << arguments.at(i).value<qint16>();
0601                 break;
0602             }
0603             case Parrot::TYPE_U32: {
0604                 s << arguments.at(i).value<quint32>();
0605                 break;
0606             }
0607             case Parrot::TYPE_I32: {
0608                 s << arguments.at(i).value<qint32>();
0609                 break;
0610             }
0611             case Parrot::TYPE_U64: {
0612                 s << arguments.at(i).value<quint64>();
0613                 break;
0614             }
0615             case Parrot::TYPE_I64: {
0616                 s << arguments.at(i).value<qint64>();
0617                 break;
0618             }
0619             case Parrot::TYPE_FLOAT: {
0620                 s.setFloatingPointPrecision(QDataStream::SinglePrecision);
0621                 s << arguments.at(i).value<float>();
0622                 break;
0623             }
0624             case Parrot::TYPE_DOUBLE: {
0625                 s.setFloatingPointPrecision(QDataStream::DoublePrecision);
0626                 s << arguments.at(i).value<qreal>();
0627                 break;
0628             }
0629             case Parrot::TYPE_STRING: {
0630                 s << arguments.at(i).toString().toLatin1(); // FIXME UTF-8?
0631                 break;
0632             }
0633             case Parrot::TYPE_ENUM: {
0634                 s << arguments.at(i).value<qint32>();
0635                 break;
0636             }
0637             }
0638         }
0639     }
0640 }
0641 
0642 ParrotCommand::ParrotCommand(Parrot::Command command, const QByteArray &arguments)
0643     : tuple(tupleForCommand(command))
0644     , data(arguments)
0645 {
0646 }
0647 
0648 ParrotCommand::ParrotCommand(const QByteArray &_data)
0649 {
0650     QDataStream s(_data);
0651     s.setByteOrder(QDataStream::LittleEndian);
0652 
0653     s >> tuple.productId >> tuple.classId >> tuple.commandId;
0654 
0655     const int dataSize = _data.size() - Parrot::HEADER_COMMAND;
0656 
0657     if (dataSize > 0) {
0658         data = QByteArray(dataSize, 0);
0659         s.readRawData(data.data(), dataSize);
0660     }
0661 }
0662 
0663 ParrotCommand::ParrotCommand() = default;
0664 
0665 ParrotCommand::~ParrotCommand() = default;
0666 
0667 QByteArray ParrotCommand::pack() const
0668 {
0669     QByteArray command;
0670 
0671     QDataStream s(&command, QIODevice::WriteOnly);
0672     s.setByteOrder(QDataStream::LittleEndian);
0673 
0674     s << tuple.productId << tuple.classId << tuple.commandId;
0675 
0676     if (!data.isNull()) {
0677         s.writeRawData(data.constData(), data.size()); // FIXME Doesn't null-terminate strings anymore.
0678     }
0679 
0680     return command;
0681 }
0682 
0683 Parrot::Command ParrotCommand::id() const
0684 {
0685     return commandForTuple(tuple);
0686 }
0687 
0688 Parrot::Command ParrotCommand::commandForTuple(const Tuple &tuple)
0689 {
0690     if (m_commandForTuple.contains(tuple)) {
0691         return m_commandForTuple.value(tuple);
0692     }
0693 
0694     return Parrot::UnknownCommand;
0695 }
0696 
0697 ParrotCommand::Tuple ParrotCommand::tupleForCommand(Parrot::Command command)
0698 {
0699     if (m_tupleForCommand.contains(command)) {
0700         return m_tupleForCommand.value(command);
0701     }
0702 
0703     return Tuple();
0704 }
0705 
0706 ParrotFrame::ParrotFrame(quint8 _dataType, quint8 _bufferId, quint8 _seq, const QByteArray &_data)
0707     : dataType(_dataType)
0708     , bufferId(_bufferId)
0709     , seq(_seq)
0710     , size(Parrot::HEADER_FRAME + (_data.size() > Parrot::HEADER_COMMAND ? _data.size() + 1 : _data.size())) // FIXME HACK for null-terminating strings.
0711     , data(_data)
0712 {
0713 }
0714 
0715 ParrotFrame::ParrotFrame(const QByteArray &_data, int start = 0)
0716 {
0717     QDataStream s(_data);
0718     s.setByteOrder(QDataStream::LittleEndian);
0719 
0720     s.skipRawData(start);
0721 
0722     s >> dataType >> bufferId >> seq >> size;
0723 
0724     const int dataSize = size - Parrot::HEADER_FRAME;
0725     data = QByteArray(dataSize, 0);
0726     s.readRawData(data.data(), dataSize);
0727 }
0728 
0729 ParrotFrame::~ParrotFrame() = default;
0730 
0731 QByteArray ParrotFrame::pack() const
0732 {
0733     QByteArray frame;
0734     frame.reserve(data.size() + Parrot::HEADER_FRAME);
0735 
0736     QDataStream s(&frame, QIODevice::WriteOnly);
0737     s.setByteOrder(QDataStream::LittleEndian);
0738 
0739     s << dataType << bufferId << seq << size;
0740 
0741     if (!data.isNull()) {
0742         const int dataSize = data.size() > Parrot::HEADER_COMMAND ? data.size() + 1 : data.size(); // FIXME HACK for null-terminating strings.
0743         s.writeRawData(data.constData(), dataSize);
0744     }
0745 
0746     return frame;
0747 }
0748 
0749 ParrotCommand ParrotFrame::command() const
0750 {
0751     return ParrotCommand(data);
0752 }