public static byte[] PrepareStatement2(MessageType msgType, String session, byte[] message, int packet_count) { Object[] ob = { (byte)255, (byte)1, (byte)0, (byte)0, (int)(session != null ? Convert.ToInt32(session.Substring(2), 16) : 0), (int)packet_count, (byte)0, (byte)0, (short)msgType, (int)351 }; byte[] end = { (byte)0 }; return(Concat(Concat(StructConverter.Pack(ob), message), end)); }
/// <summary> /// Create an ACK packet based on the given header information /// </summary> /// <param name="data_type"></param> /// <param name="buffer_id"></param> /// <param name="seq_no"></param> /// <returns></returns> private byte[] _create_ack_packet(byte data_type, byte buffer_id, byte seq_no) { Debug.Assert(data_type == (byte)SumoConstantsCustom.ARNETWORKAL_FRAME_TYPE.ARNETWORKAL_FRAME_TYPE_DATA_WITH_ACK); // The payload of an ACK frame is the sequence no. of the data frame byte payload = seq_no; // The buffer id is 128 + base_id byte[] buffer = StructConverter.Pack("<BBBI", new object[] { (byte)SumoConstantsCustom.ARNETWORKAL_FRAME_TYPE.ARNETWORKAL_FRAME_TYPE_ACK, (byte)buffer_id + 128, (byte)0, (byte)8 }); //"<BBBI" return(buffer.Concat(new byte[] { payload }).ToArray()); }
/// <summary> /// Creates a complete frame by prepending a header to the given payload // Data type: normal data(2) // Target buffer ID: // Sequence number // Frame size // Payload /// </summary> /// <param name="payload"></param> /// <returns></returns> public static byte[] _pack_frame(byte[] payload) { var data_type = 2; var buffer_id = 10; var seq_no = 0; var frame_size = 7 + payload.Length; var header = StructConverter.Pack("<BBBI", data_type, buffer_id, seq_no, frame_size); return(header.Concat(payload).ToArray()); }
/// <summary> /// Immediately Send Audio Stream /// </summary> /// <param name="AudioData"></param> public void SendAudioFrame(byte[] AudioData) { if (isConnected) { if (AudioData != null) { byte[] AudioHeader = StructConverter.Pack("<QHHI", new Object[] { (UInt64)0, (UInt32)0, (UInt32)0, (UInt16)0 }); byte[] AudioFrame = AudioHeader.Concat(AudioData).ToArray(); this.Send(AudioFrame); } } }
public byte[] Bytes(bool includeLength) { var sid = GetRandomBytes(8); var ts = (int)DateTimeOffset.UtcNow.ToUnixTimeSeconds(); var packet = new List <object>(); packet.Add(1); packet.Add(ts); packet.Add((byte)(7 << 3)); foreach (var s in sid) { packet.Add(s); } packet.Add((byte)0); packet.Add(0); using (var h = new HMACSHA1()) { h.Key = _key.Take(h.HashSize / 8).ToArray(); var data = StructConverter.Pack(packet.ToArray(), false); var hash = h.ComputeHash(data); var result = new List <object>(); result.Add((byte)(7 << 3)); foreach (var s in sid) { result.Add(s); } foreach (var hs in hash) { result.Add(hs); } result.Add(1); result.Add(ts); result.Add((byte)0); result.Add(0); var bytes = StructConverter.Pack(result.ToArray(), false); if (!includeLength) { return(bytes); } var length = StructConverter.Pack(new object[] { (ushort)bytes.Length }, false); return(length.Concat(bytes).ToArray()); } }
/// <summary> /// RoadPlan_AllScriptsMetadata /// /// Command to ask device all metadata scripts. /// /// </summary> public static byte[] RoadPlan_AllScriptsMetadata_cmd() { return(StructConverter.Pack("<BBH", 3, 14, 0)); }
/// <summary> /// RoadPlan_ScriptUploaded /// /// Notify device that a new file has been uploaded. /// /// /// args : string string /// </summary> public static byte[] RoadPlan_ScriptUploaded_cmd(String uuid, String md5Hash) { return(StructConverter.Pack("<BBHss", 3, 14, 1, uuid, md5Hash)); }
/// <summary> /// Factory_Reset /// This command will request a factory reset from the prodcut. *The factory reset procedure implies an automatic reboot*, which will be done immediately after receiving this command. /// The product will reboot, all settings will be reset to their default values. All data on the product will also be erased. /// </summary> public static byte[] Factory_Reset_cmd() { return(StructConverter.Pack("<BBH", 0, 31, 0)); }
/// <summary> /// Animations_JumpCancel /// /// Cancel jump and come back to previous state (if possible). /// /// </summary> public static byte[] Animations_JumpCancel_cmd() { return(StructConverter.Pack("<BBH", 3, 2, 1)); }
/// <summary> /// VideoSettings_Autorecord /// /// Set video automatic recording state. /// /// /// args : u8 /// </summary> public static byte[] VideoSettings_Autorecord_cmd(byte enabled) { return(StructConverter.Pack("<BBHB", 3, 21, 0, enabled)); }
/// <summary> /// Common_AllStates /// Ask for all states. /// **Please note that you should not send this command if you are using the /// libARController API as this library is handling the connection process for you.** /// The product will trigger all states events (such as [FlyingState](#1-4-1) for the Bebop). /// Then, it will trigger [AllStatesEnd](#0-5-0). /// </summary> public static byte[] Common_AllStates_cmd() { return(StructConverter.Pack("<BBH", 0, 4, 0)); }
/// <summary> /// MediaRecord_VideoV2 /// /// Video record /// /// /// args : enum /// </summary> public static byte[] MediaRecord_VideoV2_cmd(SumoEnumGenerated.VideoV2_record record) { return(StructConverter.Pack("<BBHI", 3, 6, 3, (UInt16)record)); }
/// <summary> /// Settings_Country /// Set the country for Wifi products. /// This can modify Wifi band and/or channel. /// **Please note that you might be disconnected from the product after changing the country as it changes Wifi parameters.** /// The country is set. /// Then, it will trigger [CountryChanged](#0-3-6). /// args : string /// </summary> public static byte[] Settings_Country_cmd(String code) { return(StructConverter.Pack("<BBHs", 0, 2, 3, code)); }
/// <summary> /// MediaRecord_PictureV2 /// /// Take picture /// /// </summary> public static byte[] MediaRecord_PictureV2_cmd() { return(StructConverter.Pack("<BBH", 3, 6, 2)); }
/// <summary> /// Settings_ProductName /// Set the product name. /// It also sets the name of the SSID for Wifi products and advertisement name for BLE products (changed after a reboot of the product). /// Name is changed. /// Then, it will trigger [NameChanged](#0-3-2). /// args : string /// </summary> public static byte[] Settings_ProductName_cmd(String name) { return(StructConverter.Pack("<BBHs", 0, 2, 2, name)); }
/// <summary> /// Animations_SimpleAnimation /// /// Play a parameterless animation. /// /// /// args : enum /// </summary> public static byte[] Animations_SimpleAnimation_cmd(SumoEnumGenerated.SimpleAnimation_id id) { return(StructConverter.Pack("<BBHI", 3, 2, 4, (UInt16)id)); }
/// <summary> /// Animations_Jump /// /// Request a jump /// /// /// args : enum /// </summary> public static byte[] Animations_Jump_cmd(SumoEnumGenerated.Jump_type type) { return(StructConverter.Pack("<BBHI", 3, 2, 3, (UInt16)type)); }
/// <summary> /// Animations_JumpLoad /// /// Request jump loading /// /// </summary> public static byte[] Animations_JumpLoad_cmd() { return(StructConverter.Pack("<BBH", 3, 2, 2)); }
/// <summary> /// RoadPlan_ScriptDelete /// /// Ask the device to delete a script. /// /// /// args : string /// </summary> public static byte[] RoadPlan_ScriptDelete_cmd(String uuid) { return(StructConverter.Pack("<BBHs", 3, 14, 2, uuid)); }
/// <summary> /// NetworkSettings_WifiSelection /// /// Auto-select channel of choosen band /// /// /// args : enum enum u8 /// </summary> public static byte[] NetworkSettings_WifiSelection_cmd(SumoEnumGenerated.WifiSelection_type type, SumoEnumGenerated.WifiSelection_band band, byte channel) { return(StructConverter.Pack("<BBHIIB", 3, 8, 0, (UInt16)type, (UInt16)band, channel)); }
/// <summary> /// RoadPlan_PlayScript /// /// Ask the device to play a script. /// /// /// args : string /// </summary> public static byte[] RoadPlan_PlayScript_cmd(String uuid) { return(StructConverter.Pack("<BBHs", 3, 14, 3, uuid)); }
/// <summary> /// Network_WifiScan /// /// Launches wifi network scan /// /// /// args : enum /// </summary> public static byte[] Network_WifiScan_cmd(SumoEnumGenerated.WifiScan_band band) { return(StructConverter.Pack("<BBHI", 3, 10, 0, (UInt16)band)); }
/// <summary> /// MediaStreaming_VideoEnable /// /// Enable/disable video streaming. /// /// /// args : u8 /// </summary> public static byte[] MediaStreaming_VideoEnable_cmd(byte enable) { return(StructConverter.Pack("<BBHB", 3, 18, 0, enable)); }
/// <summary> /// Piloting_Posture /// /// Request a posture /// /// /// args : enum /// </summary> public static byte[] Piloting_Posture_cmd(SumoEnumGenerated.Posture_type type) { return(StructConverter.Pack("<BBHI", 3, 0, 1, (UInt16)type)); }
/// <summary> /// Settings_AutoCountry /// Enable auto-country. /// If auto-country is set, the drone will guess its Wifi country by itself by checking other Wifi country around it. /// **Please note that you might be disconnected from the product after changing the country as it changes Wifi parameters.** /// The auto-country of the product is changed. /// Then, it will trigger [AutoCountryChanged](#0-3-7) and [CountryChanged](#0-3-6). /// args : u8 /// </summary> public static byte[] Settings_AutoCountry_cmd(byte automatic) { return(StructConverter.Pack("<BBHB", 0, 2, 4, automatic)); }
/// <summary> /// AudioSettings_MasterVolume /// /// Master volume control. /// /// /// args : u8 /// </summary> public static byte[] AudioSettings_MasterVolume_cmd(byte volume) { return(StructConverter.Pack("<BBHB", 3, 12, 0, volume)); }
/// <summary> /// Piloting_PCMD /// /// Ask the JS speed and turn ratio. /// /// /// args : u8 i8 i8 /// </summary> public static byte[] Piloting_PCMD_cmd(byte flag, sbyte speed, sbyte turn) { return(StructConverter.Pack("<BBHBbb", 3, 0, 0, flag, speed, turn)); }
/// <summary> /// AudioSettings_Theme /// /// Audio Theme. /// /// /// args : enum /// </summary> public static byte[] AudioSettings_Theme_cmd(SumoEnumGenerated.Theme_theme theme) { return(StructConverter.Pack("<BBHI", 3, 12, 1, (UInt16)theme)); }
/// <summary> /// Network_WifiAuthChannel /// /// Controller inquire the list of authorized wifi channels. /// /// </summary> public static byte[] Network_WifiAuthChannel_cmd() { return(StructConverter.Pack("<BBH", 3, 10, 1)); }
/// <summary> /// Piloting_addCapOffset /// /// Add the specified offset to the current cap. /// /// /// args : float /// </summary> public static byte[] Piloting_addCapOffset_cmd(float offset) { return(StructConverter.Pack("<BBHd", 3, 0, 2, offset)); }