private async Task SendRequest(RequestType requestType, byte[] payload) { this._count = (this._count + 1) & 0xffff; byte[] packet = new byte[0x38]; packet[0x00] = 0x5a; packet[0x01] = 0xa5; packet[0x02] = 0xaa; packet[0x03] = 0x55; packet[0x04] = 0x5a; packet[0x05] = 0xa5; packet[0x06] = 0xaa; packet[0x07] = 0x55; packet[0x24] = 0x2a; packet[0x25] = 0x27; packet[0x26] = (byte)requestType; packet[0x28] = (byte)(this._count & 0xff); packet[0x29] = (byte)(this._count >> 8); packet[0x2a] = this._macAddress[5]; packet[0x2b] = this._macAddress[4]; packet[0x2c] = this._macAddress[3]; packet[0x2d] = this._macAddress[2]; packet[0x2e] = this._macAddress[1]; packet[0x2f] = this._macAddress[0]; packet[0x30] = this._id[0]; packet[0x31] = this._id[1]; packet[0x32] = this._id[2]; packet[0x33] = this._id[3]; int checksum = payload.Checksum(); payload = await this.GetEncryptedBytes(payload).ConfigureAwait(false); packet[0x34] = (byte)(checksum & 0xff); packet[0x35] = (byte)(checksum >> 8); packet = RMDevice.Combine(packet, payload); checksum = packet.Checksum(); packet[0x20] = (byte)(checksum & 0xff); packet[0x21] = (byte)(checksum >> 8); await this._client.SendAsync(packet, packet.Length).ConfigureAwait(false); }
public Task SendData(byte[] data) => this.SendRequest(RequestType.Command, RMDevice.Combine(RMDevice._dataHeader, data));