From 3ac38b7fb66ea52c30e63bcf777a0b7d6eabaaca Mon Sep 17 00:00:00 2001 From: Ben Menking Date: Sat, 30 May 2026 12:33:09 -0400 Subject: [PATCH] log rx work; added toArray() to model --- src/CoreParser.php | 8 ++++---- src/CoreProtocol.php | 21 +++++++++++++++++++++ src/Model/LogReceiveResponse.php | 3 ++- src/Model/Response.php | 4 ++++ 4 files changed, 31 insertions(+), 5 deletions(-) diff --git a/src/CoreParser.php b/src/CoreParser.php index 42980b7..6101baf 100644 --- a/src/CoreParser.php +++ b/src/CoreParser.php @@ -255,11 +255,11 @@ class CoreParser { $data = new LogReceiveResponse(); $data->code = ord($payload[0]); - //$data->snr = ord($payload[1]) / 4; - //$data->rssi = (ord($payload[2]) >= 128) ? (ord($payload[2]) - 256): ord($payload[2]); + $data->snr = ord($payload[1]) / 4; + $data->rssi = (ord($payload[2]) >= 128) ? (ord($payload[2]) - 256): ord($payload[2]); - $data->flags = ord($payload[1]); - $data->snr = ord($payload[2]) / 4; + //$data->flags = ord($payload[1]); + //$data->snr = ord($payload[2]) / 4; $data->raw = base64_encode(substr($payload, 3, strlen($payload))); return $data; diff --git a/src/CoreProtocol.php b/src/CoreProtocol.php index 6364cf6..6335ae7 100644 --- a/src/CoreProtocol.php +++ b/src/CoreProtocol.php @@ -290,4 +290,25 @@ class CoreProtocol { const STATS_TYPE_CORE = 0; const STATS_TYPE_RADIO = 1; const STATS_TYPE_PACKETS = 2; + + const PACKET_OK = 0x00; + const PACKET_ERROR = 0x01; + const PACKET_CONTACT_START = 0x02; + const PACKET_CONTACT = 0x03; + const PACKET_CONTACT_END = 0x04; + const PACKET_SELF_INFO = 0x05; + const PACKET_MSG_SENT = 0x06; + const PACKET_CONTACT_MSG_RECV = 0x07; + const PACKET_CHANNEL_MSG_RECV = 0x08; + const PACKET_CURRENT_TIME = 0x09; + const PACKET_NO_MORE_MSGS = 0x0A; + const PACKET_BATTERY = 0x0C; + const PACKET_DEVICE_INFO = 0x0D; + const PACKET_CONTACT_MSG_RECV_V3 = 0x10; + const PACKET_CHANNEL_MSG_RECV_V3 = 0x11; + const PACKET_CHANNEL_INFO = 0x12; + const PACKET_ADVERTISEMENT = 0x80; + const PACKET_ACK = 0x82; + const PACKET_MESSAGES_WAITING = 0x83; + const PACKET_LOG_DATA = 0x88; } diff --git a/src/Model/LogReceiveResponse.php b/src/Model/LogReceiveResponse.php index d6d327d..7ace86b 100644 --- a/src/Model/LogReceiveResponse.php +++ b/src/Model/LogReceiveResponse.php @@ -4,8 +4,9 @@ namespace Menking\Meshcore\Model; class LogReceiveResponse extends Response { public int $code; - public int $flags; + //public int $flags; public int $snr; + public int $rssi; public string $raw; public int $header; diff --git a/src/Model/Response.php b/src/Model/Response.php index fd86aac..f6b3ce8 100644 --- a/src/Model/Response.php +++ b/src/Model/Response.php @@ -14,4 +14,8 @@ class Response { return $output; } + + public function toArray(): array { + return get_object_vars($this); + } } \ No newline at end of file