public string toJSON() { AirFrameJSON json = new AirFrameJSON(); json.Address = BitConverter.ToString(address).Replace("-", ":"); json.PID = pid; json.RSSI = rssi; json.Length = payloadLength; if (payload != null) { json.Payload = BitConverter.ToString(payload).Replace("-", ":"); } else { json.Payload = ""; } if (decryptedPayload != null) { json.DecryptedPayload = BitConverter.ToString(decryptedPayload).Replace("-", ":"); } else { json.DecryptedPayload = ""; } return(new JavaScriptSerializer().Serialize(json)); }
public AirFrame(AirFrameJSON input) { address = Form1.HexStringToByteArray(input.Address.Replace(":", "")); pid = input.PID; rf_channel = input.Ch; rssi = input.RSSI; payloadLength = input.Length; payload = Form1.HexStringToByteArray(input.Payload.Replace(":", "")); decryptedPayload = Form1.HexStringToByteArray(input.DecryptedPayload.Replace(":", "")); }