-
-
Notifications
You must be signed in to change notification settings - Fork 198
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: add/update message decoders
- Loading branch information
1 parent
89fd2fb
commit 14e14fe
Showing
8 changed files
with
80 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
GalaxyBudsClient/Message/Decoder/CouplingHelperReadDecoder.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using System.IO; | ||
using GalaxyBudsClient.Generated.Model.Attributes; | ||
using GalaxyBudsClient.Model.Constants; | ||
using GalaxyBudsClient.Utils.Extensions; | ||
|
||
namespace GalaxyBudsClient.Message.Decoder; | ||
|
||
[MessageDecoder(MsgIds.COUPLING_HELPER_READ)] | ||
public class CouplingHelperReadDecoder : BaseMessageDecoder | ||
{ | ||
public string FirmwareVersion { get; } | ||
public string LocalAddress { get; } | ||
public string PeerAddress { get; } | ||
public DevicesInverted HostDevice { get; } | ||
public bool BridgeStatus { get; } | ||
public byte RcvGrade { get; } | ||
|
||
public CouplingHelperReadDecoder(SppMessage msg) : base(msg) | ||
{ | ||
using var stream = new MemoryStream(msg.Payload); | ||
using var reader = new BinaryReader(stream); | ||
|
||
// Note: This string is normally 12 bytes long, the last 8 bytes are always null | ||
FirmwareVersion = new string(reader.ReadChars(20)); | ||
|
||
LocalAddress = reader.ReadBytes(6).BytesToMacString(); | ||
PeerAddress = reader.ReadBytes(6).BytesToMacString(); | ||
|
||
HostDevice = (DevicesInverted)reader.ReadByte(); | ||
BridgeStatus = reader.ReadBoolean(); | ||
RcvGrade = reader.ReadByte(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters