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AK Miner A - Transmitter Script
|
| 4 |
+
|
| 5 |
+
import os
|
| 6 |
+
import sys
|
| 7 |
+
import time
|
| 8 |
+
import socket
|
| 9 |
+
import argparse
|
| 10 |
+
import hashlib
|
| 11 |
+
|
| 12 |
+
# ==============================================================================
|
| 13 |
+
# LLD-AC Range Coding Logic (Invention 07)
|
| 14 |
+
# ==============================================================================
|
| 15 |
+
class PythonRadicalPredictor:
|
| 16 |
+
def __init__(self, alpha=1, weight=128):
|
| 17 |
+
self.alpha = alpha
|
| 18 |
+
self.weight = weight
|
| 19 |
+
self.trans_rc = {}
|
| 20 |
+
self.trans_rf = {}
|
| 21 |
+
self.trans_ra = {}
|
| 22 |
+
self.prev_rc = 0
|
| 23 |
+
self.prev_rf = 0
|
| 24 |
+
self.prev_ra = 0
|
| 25 |
+
|
| 26 |
+
def observe(self, rc, rf, ra):
|
| 27 |
+
key_rc = self.prev_rc
|
| 28 |
+
if key_rc not in self.trans_rc:
|
| 29 |
+
self.trans_rc[key_rc] = {}
|
| 30 |
+
self.trans_rc[key_rc][rc] = self.trans_rc[key_rc].get(rc, 0) + self.weight
|
| 31 |
+
|
| 32 |
+
key_rf = (rc << 8) | self.prev_rf
|
| 33 |
+
if key_rf not in self.trans_rf:
|
| 34 |
+
self.trans_rf[key_rf] = {}
|
| 35 |
+
self.trans_rf[key_rf][rf] = self.trans_rf[key_rf].get(rf, 0) + self.weight
|
| 36 |
+
|
| 37 |
+
key_ra = (rc << 16) | (rf << 8) | self.prev_ra
|
| 38 |
+
if key_ra not in self.trans_ra:
|
| 39 |
+
self.trans_ra[key_ra] = {}
|
| 40 |
+
self.trans_ra[key_ra][ra] = self.trans_ra[key_ra].get(ra, 0) + self.weight
|
| 41 |
+
|
| 42 |
+
self.prev_rc = rc
|
| 43 |
+
self.prev_rf = rf
|
| 44 |
+
self.prev_ra = ra
|
| 45 |
+
|
| 46 |
+
def get_cum_freqs_rc(self, prev_rc):
|
| 47 |
+
freqs = [self.alpha] * 256
|
| 48 |
+
if prev_rc in self.trans_rc:
|
| 49 |
+
for sym, count in self.trans_rc[prev_rc].items():
|
| 50 |
+
freqs[sym] += count
|
| 51 |
+
cum_freqs = [0] * 257
|
| 52 |
+
for i in range(256):
|
| 53 |
+
cum_freqs[i+1] = cum_freqs[i] + freqs[i]
|
| 54 |
+
return cum_freqs
|
| 55 |
+
|
| 56 |
+
def get_cum_freqs_rf(self, curr_rc, prev_rf):
|
| 57 |
+
freqs = [self.alpha] * 256
|
| 58 |
+
key = (curr_rc << 8) | prev_rf
|
| 59 |
+
if key in self.trans_rf:
|
| 60 |
+
for sym, count in self.trans_rf[key].items():
|
| 61 |
+
freqs[sym] += count
|
| 62 |
+
cum_freqs = [0] * 257
|
| 63 |
+
for i in range(256):
|
| 64 |
+
cum_freqs[i+1] = cum_freqs[i] + freqs[i]
|
| 65 |
+
return cum_freqs
|
| 66 |
+
|
| 67 |
+
def get_cum_freqs_ra(self, curr_rc, curr_rf, prev_ra):
|
| 68 |
+
freqs = [self.alpha] * 256
|
| 69 |
+
key = (curr_rc << 16) | (curr_rf << 8) | prev_ra
|
| 70 |
+
if key in self.trans_ra:
|
| 71 |
+
for sym, count in self.trans_ra[key].items():
|
| 72 |
+
freqs[sym] += count
|
| 73 |
+
cum_freqs = [0] * 257
|
| 74 |
+
for i in range(256):
|
| 75 |
+
cum_freqs[i+1] = cum_freqs[i] + freqs[i]
|
| 76 |
+
return cum_freqs
|
| 77 |
+
|
| 78 |
+
class BitWriter:
|
| 79 |
+
def __init__(self):
|
| 80 |
+
self.buffer = []
|
| 81 |
+
self.current_byte = 0
|
| 82 |
+
self.bit_count = 0
|
| 83 |
+
|
| 84 |
+
def write_bit(self, bit):
|
| 85 |
+
self.current_byte = (self.current_byte << 1) | (bit & 1)
|
| 86 |
+
self.bit_count += 1
|
| 87 |
+
if self.bit_count % 8 == 0:
|
| 88 |
+
self.buffer.append(self.current_byte)
|
| 89 |
+
self.current_byte = 0
|
| 90 |
+
|
| 91 |
+
def write_bit_helper(self, underflow_bits, bit):
|
| 92 |
+
self.write_bit(bit)
|
| 93 |
+
for _ in range(underflow_bits[0]):
|
| 94 |
+
self.write_bit(1 - bit)
|
| 95 |
+
underflow_bits[0] = 0
|
| 96 |
+
|
| 97 |
+
def flush(self):
|
| 98 |
+
if self.bit_count % 8 != 0:
|
| 99 |
+
padding_bits = 8 - (self.bit_count % 8)
|
| 100 |
+
self.current_byte <<= padding_bits
|
| 101 |
+
self.buffer.append(self.current_byte)
|
| 102 |
+
self.current_byte = 0
|
| 103 |
+
self.bit_count += padding_bits
|
| 104 |
+
return bytes(self.buffer)
|
| 105 |
+
|
| 106 |
+
def range_encode_radicals(radicals, alpha=1, weight=128):
|
| 107 |
+
pred = PythonRadicalPredictor(alpha, weight)
|
| 108 |
+
w = BitWriter()
|
| 109 |
+
low = 0
|
| 110 |
+
high = 0xFFFFFFFF
|
| 111 |
+
underflow_bits = [0]
|
| 112 |
+
|
| 113 |
+
for rc, rf, ra in radicals:
|
| 114 |
+
symbols = [rc, rf, ra]
|
| 115 |
+
prev_rc = pred.prev_rc
|
| 116 |
+
prev_rf = pred.prev_rf
|
| 117 |
+
prev_ra = pred.prev_ra
|
| 118 |
+
|
| 119 |
+
for step in range(3):
|
| 120 |
+
if step == 0:
|
| 121 |
+
cum_freqs = pred.get_cum_freqs_rc(prev_rc)
|
| 122 |
+
elif step == 1:
|
| 123 |
+
cum_freqs = pred.get_cum_freqs_rf(symbols[0], prev_rf)
|
| 124 |
+
else:
|
| 125 |
+
cum_freqs = pred.get_cum_freqs_ra(symbols[0], symbols[1], prev_ra)
|
| 126 |
+
|
| 127 |
+
sym = symbols[step]
|
| 128 |
+
total = cum_freqs[256]
|
| 129 |
+
cum_low = cum_freqs[sym]
|
| 130 |
+
cum_high = cum_freqs[sym + 1]
|
| 131 |
+
|
| 132 |
+
range_width = high - low + 1
|
| 133 |
+
high = low + (range_width * cum_high) // total - 1
|
| 134 |
+
low = low + (range_width * cum_low) // total
|
| 135 |
+
|
| 136 |
+
while True:
|
| 137 |
+
if high < 0x80000000:
|
| 138 |
+
w.write_bit_helper(underflow_bits, 0)
|
| 139 |
+
low = (low << 1) & 0xFFFFFFFF
|
| 140 |
+
high = ((high << 1) | 1) & 0xFFFFFFFF
|
| 141 |
+
elif low >= 0x80000000:
|
| 142 |
+
w.write_bit_helper(underflow_bits, 1)
|
| 143 |
+
low = ((low - 0x80000000) << 1) & 0xFFFFFFFF
|
| 144 |
+
high = (((high - 0x80000000) << 1) | 1) & 0xFFFFFFFF
|
| 145 |
+
elif low >= 0x40000000 and high < 0xC0000000:
|
| 146 |
+
underflow_bits[0] += 1
|
| 147 |
+
low = ((low - 0x40000000) << 1) & 0xFFFFFFFF
|
| 148 |
+
high = (((high - 0x40000000) << 1) | 1) & 0xFFFFFFFF
|
| 149 |
+
else:
|
| 150 |
+
break
|
| 151 |
+
pred.observe(rc, rf, ra)
|
| 152 |
+
|
| 153 |
+
underflow_bits[0] += 1
|
| 154 |
+
if low < 0x40000000:
|
| 155 |
+
w.write_bit_helper(underflow_bits, 0)
|
| 156 |
+
else:
|
| 157 |
+
w.write_bit_helper(underflow_bits, 1)
|
| 158 |
+
return w.flush()
|
| 159 |
+
|
| 160 |
+
# ==============================================================================
|
| 161 |
+
# XOR-FEC Chirp Packetization Logic (Invention 05)
|
| 162 |
+
# ==============================================================================
|
| 163 |
+
SYNC_MARKER = 0xBB
|
| 164 |
+
PKT_SIZE = 255
|
| 165 |
+
TRANSPORT_HDR = 3
|
| 166 |
+
DATA_PER_PKT = PKT_SIZE - TRANSPORT_HDR # 252 Bytes
|
| 167 |
+
|
| 168 |
+
def xor_fec_parity(data_packets):
|
| 169 |
+
parity = bytearray(DATA_PER_PKT)
|
| 170 |
+
for pkt in data_packets:
|
| 171 |
+
data_part = pkt[TRANSPORT_HDR:]
|
| 172 |
+
for idx in range(min(len(data_part), DATA_PER_PKT)):
|
| 173 |
+
parity[idx] ^= data_part[idx]
|
| 174 |
+
return bytes(parity)
|
| 175 |
+
|
| 176 |
+
def pack_payload(payload_bytes, num_data_packets):
|
| 177 |
+
total_capacity = num_data_packets * DATA_PER_PKT
|
| 178 |
+
|
| 179 |
+
if len(payload_bytes) < total_capacity:
|
| 180 |
+
payload_bytes = payload_bytes.ljust(total_capacity, b'\x00')
|
| 181 |
+
elif len(payload_bytes) > total_capacity:
|
| 182 |
+
payload_bytes = payload_bytes[:total_capacity]
|
| 183 |
+
|
| 184 |
+
data_packets = []
|
| 185 |
+
total_packets = num_data_packets + 1
|
| 186 |
+
|
| 187 |
+
for idx in range(num_data_packets):
|
| 188 |
+
chunk = payload_bytes[idx * DATA_PER_PKT : (idx + 1) * DATA_PER_PKT]
|
| 189 |
+
header = bytes([SYNC_MARKER, idx, total_packets])
|
| 190 |
+
data_packets.append(header + chunk)
|
| 191 |
+
|
| 192 |
+
# Generate XOR-parity packet
|
| 193 |
+
parity_data = xor_fec_parity(data_packets)
|
| 194 |
+
parity_header = bytes([SYNC_MARKER, num_data_packets, total_packets])
|
| 195 |
+
parity_packet = parity_header + parity_data
|
| 196 |
+
|
| 197 |
+
return data_packets + [parity_packet]
|
| 198 |
+
|
| 199 |
+
# ==============================================================================
|
| 200 |
+
# Main Transmitter Execution
|
| 201 |
+
# ==============================================================================
|
| 202 |
+
def main():
|
| 203 |
+
parser = argparse.ArgumentParser(description="Zymatica LoRa Protocol - RAK Miner A (Transmitter)")
|
| 204 |
+
parser.add_argument("--mode", choices=["udp", "serial"], default="udp", help="Connection interface: udp (local network) or serial (USB/UART)")
|
| 205 |
+
parser.add_argument("--ip", default="192.168.1.51", help="Receiver's IP address (needed for UDP mode)")
|
| 206 |
+
parser.add_argument("--port", type=int, default=50001, help="Receiver's port (needed for UDP mode)")
|
| 207 |
+
parser.add_argument("--device", default="/dev/ttyUSB0", help="Serial port interface (needed for serial mode)")
|
| 208 |
+
parser.add_argument("--baud", type=int, default=115200, help="Serial baud rate")
|
| 209 |
+
args = parser.parse_args()
|
| 210 |
+
|
| 211 |
+
print("=" * 80)
|
| 212 |
+
print(" ZYMATICA | Language-U RAK-Miner A (Transmitter Node)")
|
| 213 |
+
print(" Watermark: ip zymatica.space | astronautshe.com")
|
| 214 |
+
print("=" * 80)
|
| 215 |
+
|
| 216 |
+
# 1. Raw Intent / Coordinates Preparation
|
| 217 |
+
# Equivalent to a sequence of 6D coordinate concepts mapped via Cuneiform-U
|
| 218 |
+
input_radicals = [
|
| 219 |
+
(0x12, 0x01, 0x80),
|
| 220 |
+
(0x12, 0x01, 0x80),
|
| 221 |
+
(0x11, 0x00, 0xA0),
|
| 222 |
+
(0x11, 0x00, 0xA0),
|
| 223 |
+
(0x11, 0x00, 0xA0),
|
| 224 |
+
(0x21, 0x01, 0xA0),
|
| 225 |
+
(0x22, 0x02, 0xF0),
|
| 226 |
+
(0x22, 0x02, 0xF0),
|
| 227 |
+
(0x05, 0x0B, 0xC0), # Coordinate expansion elements
|
| 228 |
+
(0x05, 0x0B, 0xC0)
|
| 229 |
+
]
|
| 230 |
+
|
| 231 |
+
print(f"\n[1] Mapped Intent Coordinates (Cuneiform-U):")
|
| 232 |
+
for idx, rad in enumerate(input_radicals):
|
| 233 |
+
print(f" - Concept {idx+1:02d}: RC=0x{rad[0]:02X}, RF=0x{rad[1]:02X}, RA=0x{rad[2]:02X}")
|
| 234 |
+
|
| 235 |
+
# 2. Compress using Range Encoding
|
| 236 |
+
print(f"\n[2] Applying LLD-AC Range Compression...")
|
| 237 |
+
compressed_bytes = range_encode_radicals(input_radicals, alpha=1, weight=128)
|
| 238 |
+
print(f" - Original Size: {len(input_radicals)*3} bytes")
|
| 239 |
+
print(f" - Compressed Size: {len(compressed_bytes)} bytes")
|
| 240 |
+
print(f" - Compression Ratio: {len(input_radicals)*3 / len(compressed_bytes):.2f}x")
|
| 241 |
+
|
| 242 |
+
# Save payload checksum to broadcast for validation verification
|
| 243 |
+
payload_hash = hashlib.sha256(compressed_bytes).hexdigest()
|
| 244 |
+
print(f" - Payload Checksum (SHA-256): {payload_hash}")
|
| 245 |
+
|
| 246 |
+
# 3. Apply XOR-FEC Chirp Packetization
|
| 247 |
+
print(f"\n[3] Packetizing into XOR-FEC Frames (255-Byte Blocks)...")
|
| 248 |
+
num_data_packets = 1 # Small payload easily fits in 1 packet + 1 parity packet
|
| 249 |
+
packets = pack_payload(compressed_bytes, num_data_packets)
|
| 250 |
+
print(f" - Created {len(packets)} total frames (including 1 FEC Parity frame).")
|
| 251 |
+
|
| 252 |
+
# 4. Transmit Payload
|
| 253 |
+
if args.mode == "udp":
|
| 254 |
+
print(f"\n[4] Initializing UDP Transmission to {args.ip}:{args.port}...")
|
| 255 |
+
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
| 256 |
+
|
| 257 |
+
# We also broadcast the verification metadata header first (hash, count)
|
| 258 |
+
meta_payload = f"META:{len(input_radicals)}:{payload_hash}".encode('utf-8')
|
| 259 |
+
sock.sendto(meta_payload, (args.ip, args.port))
|
| 260 |
+
time.sleep(0.5)
|
| 261 |
+
|
| 262 |
+
for i, pkt in enumerate(packets):
|
| 263 |
+
print(f" -> Sending Frame {i}/{len(packets)-1} ({len(pkt)} bytes)...")
|
| 264 |
+
sock.sendto(pkt, (args.ip, args.port))
|
| 265 |
+
time.sleep(0.5)
|
| 266 |
+
|
| 267 |
+
print("\n[SUCCESS] Transmission sequence completed.")
|
| 268 |
+
|
| 269 |
+
elif args.mode == "serial":
|
| 270 |
+
print(f"\n[4] Initializing Serial LoRa P2P Transmission on {args.device}...")
|
| 271 |
+
try:
|
| 272 |
+
import serial
|
| 273 |
+
except ImportError:
|
| 274 |
+
print(" [-] Error: 'pyserial' library not found. Install it using 'pip install pyserial'")
|
| 275 |
+
sys.exit(1)
|
| 276 |
+
|
| 277 |
+
try:
|
| 278 |
+
ser = serial.Serial(args.device, args.baud, timeout=2)
|
| 279 |
+
print(f" - Port opened successfully.")
|
| 280 |
+
|
| 281 |
+
# Setup RAK LoRa P2P parameters
|
| 282 |
+
# AT Commands configured for P2P mode: frequency, bandwidth, spreading factor, coding rate
|
| 283 |
+
# RAK AT-command set: at+set_config=lorap2p:915000000:7:0:1:8:20
|
| 284 |
+
ser.write(b"at+set_config=lora:work_mode:1\r\n") # Set to P2P
|
| 285 |
+
time.sleep(0.5)
|
| 286 |
+
print(ser.read_all().decode('utf-8', errors='ignore').strip())
|
| 287 |
+
|
| 288 |
+
# Send metadata
|
| 289 |
+
meta_payload = f"META:{len(input_radicals)}:{payload_hash}"
|
| 290 |
+
meta_hex = meta_payload.encode('utf-8').hex()
|
| 291 |
+
cmd = f"at+send=lorap2p:{meta_hex}\r\n".encode('utf-8')
|
| 292 |
+
print(f" - Broadcasting Metadata: {meta_payload}")
|
| 293 |
+
ser.write(cmd)
|
| 294 |
+
time.sleep(1.0)
|
| 295 |
+
|
| 296 |
+
# Send frames
|
| 297 |
+
for i, pkt in enumerate(packets):
|
| 298 |
+
pkt_hex = pkt.hex()
|
| 299 |
+
cmd = f"at+send=lorap2p:{pkt_hex}\r\n".encode('utf-8')
|
| 300 |
+
print(f" - Sending Frame {i:02d} (LoRa payload: {pkt_hex[:20]}...)")
|
| 301 |
+
ser.write(cmd)
|
| 302 |
+
time.sleep(1.0)
|
| 303 |
+
|
| 304 |
+
ser.close()
|
| 305 |
+
print("\n[SUCCESS] Serial transmission sequence completed.")
|
| 306 |
+
|
| 307 |
+
except Exception as e:
|
| 308 |
+
print(f" [-] Serial port communication error: {e}")
|
| 309 |
+
sys.exit(1)
|
| 310 |
+
|
| 311 |
+
if __name__ == "__main__":
|
| 312 |
+
main()
|
RakMiner-B2.py
ADDED
|
@@ -0,0 +1,356 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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|
| 6 |
+
import sys
|
| 7 |
+
import socket
|
| 8 |
+
import argparse
|
| 9 |
+
import hashlib
|
| 10 |
+
|
| 11 |
+
# ==============================================================================
|
| 12 |
+
# LLD-AC Range Decoding Logic (Invention 07)
|
| 13 |
+
# ==============================================================================
|
| 14 |
+
class PythonRadicalPredictor:
|
| 15 |
+
def __init__(self, alpha=1, weight=128):
|
| 16 |
+
self.alpha = alpha
|
| 17 |
+
self.weight = weight
|
| 18 |
+
self.trans_rc = {}
|
| 19 |
+
self.trans_rf = {}
|
| 20 |
+
self.trans_ra = {}
|
| 21 |
+
self.prev_rc = 0
|
| 22 |
+
self.prev_rf = 0
|
| 23 |
+
self.prev_ra = 0
|
| 24 |
+
|
| 25 |
+
def observe(self, rc, rf, ra):
|
| 26 |
+
key_rc = self.prev_rc
|
| 27 |
+
if key_rc not in self.trans_rc:
|
| 28 |
+
self.trans_rc[key_rc] = {}
|
| 29 |
+
self.trans_rc[key_rc][rc] = self.trans_rc[key_rc].get(rc, 0) + self.weight
|
| 30 |
+
|
| 31 |
+
key_rf = (rc << 8) | self.prev_rf
|
| 32 |
+
if key_rf not in self.trans_rf:
|
| 33 |
+
self.trans_rf[key_rf] = {}
|
| 34 |
+
self.trans_rf[key_rf][rf] = self.trans_rf[key_rf].get(rf, 0) + self.weight
|
| 35 |
+
|
| 36 |
+
key_ra = (rc << 16) | (rf << 8) | self.prev_ra
|
| 37 |
+
if key_ra not in self.trans_ra:
|
| 38 |
+
self.trans_ra[key_ra] = {}
|
| 39 |
+
self.trans_ra[key_ra][ra] = self.trans_ra[key_ra].get(ra, 0) + self.weight
|
| 40 |
+
|
| 41 |
+
self.prev_rc = rc
|
| 42 |
+
self.prev_rf = rf
|
| 43 |
+
self.prev_ra = ra
|
| 44 |
+
|
| 45 |
+
def get_cum_freqs_rc(self, prev_rc):
|
| 46 |
+
freqs = [self.alpha] * 256
|
| 47 |
+
if prev_rc in self.trans_rc:
|
| 48 |
+
for sym, count in self.trans_rc[prev_rc].items():
|
| 49 |
+
freqs[sym] += count
|
| 50 |
+
cum_freqs = [0] * 257
|
| 51 |
+
for i in range(256):
|
| 52 |
+
cum_freqs[i+1] = cum_freqs[i] + freqs[i]
|
| 53 |
+
return cum_freqs
|
| 54 |
+
|
| 55 |
+
def get_cum_freqs_rf(self, curr_rc, prev_rf):
|
| 56 |
+
freqs = [self.alpha] * 256
|
| 57 |
+
key = (curr_rc << 8) | prev_rf
|
| 58 |
+
if key in self.trans_rf:
|
| 59 |
+
for sym, count in self.trans_rf[key].items():
|
| 60 |
+
freqs[sym] += count
|
| 61 |
+
cum_freqs = [0] * 257
|
| 62 |
+
for i in range(256):
|
| 63 |
+
cum_freqs[i+1] = cum_freqs[i] + freqs[i]
|
| 64 |
+
return cum_freqs
|
| 65 |
+
|
| 66 |
+
def get_cum_freqs_ra(self, curr_rc, curr_rf, prev_ra):
|
| 67 |
+
freqs = [self.alpha] * 256
|
| 68 |
+
key = (curr_rc << 16) | (curr_rf << 8) | prev_ra
|
| 69 |
+
if key in self.trans_ra:
|
| 70 |
+
for sym, count in self.trans_ra[key].items():
|
| 71 |
+
freqs[sym] += count
|
| 72 |
+
cum_freqs = [0] * 257
|
| 73 |
+
for i in range(256):
|
| 74 |
+
cum_freqs[i+1] = cum_freqs[i] + freqs[i]
|
| 75 |
+
return cum_freqs
|
| 76 |
+
|
| 77 |
+
class BitReader:
|
| 78 |
+
def __init__(self, data):
|
| 79 |
+
self.data = data
|
| 80 |
+
self.byte_index = 0
|
| 81 |
+
self.bit_index = 0
|
| 82 |
+
|
| 83 |
+
def read_bit(self):
|
| 84 |
+
if self.byte_index >= len(self.data):
|
| 85 |
+
return 0
|
| 86 |
+
bit = (self.data[self.byte_index] >> (7 - self.bit_index)) & 1
|
| 87 |
+
self.bit_index += 1
|
| 88 |
+
if self.bit_index == 8:
|
| 89 |
+
self.bit_index = 0
|
| 90 |
+
self.byte_index += 1
|
| 91 |
+
return bit
|
| 92 |
+
|
| 93 |
+
def range_decode_radicals(encoded_bytes, num_concepts, alpha=1, weight=128):
|
| 94 |
+
pred = PythonRadicalPredictor(alpha, weight)
|
| 95 |
+
r = BitReader(encoded_bytes)
|
| 96 |
+
value = 0
|
| 97 |
+
for _ in range(32):
|
| 98 |
+
value = (value << 1) | r.read_bit()
|
| 99 |
+
|
| 100 |
+
low = 0
|
| 101 |
+
high = 0xFFFFFFFF
|
| 102 |
+
decoded_radicals = []
|
| 103 |
+
|
| 104 |
+
for c in range(num_concepts):
|
| 105 |
+
prev_rc = pred.prev_rc
|
| 106 |
+
prev_rf = pred.prev_rf
|
| 107 |
+
prev_ra = pred.prev_ra
|
| 108 |
+
symbols = [0, 0, 0]
|
| 109 |
+
|
| 110 |
+
for step in range(3):
|
| 111 |
+
if step == 0:
|
| 112 |
+
cum_freqs = pred.get_cum_freqs_rc(prev_rc)
|
| 113 |
+
elif step == 1:
|
| 114 |
+
cum_freqs = pred.get_cum_freqs_rf(symbols[0], prev_rf)
|
| 115 |
+
else:
|
| 116 |
+
cum_freqs = pred.get_cum_freqs_ra(symbols[0], symbols[1], prev_ra)
|
| 117 |
+
|
| 118 |
+
total = cum_freqs[256]
|
| 119 |
+
range_width = high - low + 1
|
| 120 |
+
scaled_val = (((value - low) + 1) * total - 1) // range_width
|
| 121 |
+
|
| 122 |
+
sym = 0
|
| 123 |
+
l = 0
|
| 124 |
+
rr = 255
|
| 125 |
+
while l <= rr:
|
| 126 |
+
mid = (l + rr) // 2
|
| 127 |
+
if cum_freqs[mid] <= scaled_val < cum_freqs[mid + 1]:
|
| 128 |
+
sym = mid
|
| 129 |
+
break
|
| 130 |
+
elif scaled_val >= cum_freqs[mid + 1]:
|
| 131 |
+
l = mid + 1
|
| 132 |
+
else:
|
| 133 |
+
rr = mid - 1
|
| 134 |
+
|
| 135 |
+
symbols[step] = sym
|
| 136 |
+
cum_low = cum_freqs[sym]
|
| 137 |
+
cum_high = cum_freqs[sym + 1]
|
| 138 |
+
|
| 139 |
+
high = low + (range_width * cum_high) // total - 1
|
| 140 |
+
low = low + (range_width * cum_low) // total
|
| 141 |
+
|
| 142 |
+
while True:
|
| 143 |
+
if high < 0x80000000:
|
| 144 |
+
low = (low << 1) & 0xFFFFFFFF
|
| 145 |
+
high = ((high << 1) | 1) & 0xFFFFFFFF
|
| 146 |
+
value = ((value << 1) | r.read_bit()) & 0xFFFFFFFF
|
| 147 |
+
elif low >= 0x80000000:
|
| 148 |
+
low = ((low - 0x80000000) << 1) & 0xFFFFFFFF
|
| 149 |
+
high = (((high - 0x80000000) << 1) | 1) & 0xFFFFFFFF
|
| 150 |
+
value = (((value - 0x80000000) << 1) | r.read_bit()) & 0xFFFFFFFF
|
| 151 |
+
elif low >= 0x40000000 and high < 0xC0000000:
|
| 152 |
+
low = ((low - 0x40000000) << 1) & 0xFFFFFFFF
|
| 153 |
+
high = (((high - 0x40000000) << 1) | 1) & 0xFFFFFFFF
|
| 154 |
+
value = (((value - 0x40000000) << 1) | r.read_bit()) & 0xFFFFFFFF
|
| 155 |
+
else:
|
| 156 |
+
break
|
| 157 |
+
decoded_radicals.append((symbols[0], symbols[1], symbols[2]))
|
| 158 |
+
pred.observe(symbols[0], symbols[1], symbols[2])
|
| 159 |
+
return decoded_radicals
|
| 160 |
+
|
| 161 |
+
# ==============================================================================
|
| 162 |
+
# XOR-FEC Packet Reassembly Logic (Invention 05)
|
| 163 |
+
# ==============================================================================
|
| 164 |
+
SYNC_MARKER = 0xBB
|
| 165 |
+
PKT_SIZE = 255
|
| 166 |
+
TRANSPORT_HDR = 3
|
| 167 |
+
DATA_PER_PKT = PKT_SIZE - TRANSPORT_HDR # 252 Bytes
|
| 168 |
+
|
| 169 |
+
def heal_and_reassemble(received_packets):
|
| 170 |
+
if not received_packets:
|
| 171 |
+
return None
|
| 172 |
+
|
| 173 |
+
total_packets = received_packets[0][2]
|
| 174 |
+
received_indices = {pkt[1] for pkt in received_packets}
|
| 175 |
+
|
| 176 |
+
# Check if we have all packets
|
| 177 |
+
if len(received_packets) == total_packets:
|
| 178 |
+
# Sort and assemble payload
|
| 179 |
+
received_packets.sort(key=lambda x: x[1])
|
| 180 |
+
payload = bytearray()
|
| 181 |
+
for idx in range(total_packets - 1): # exclude the parity packet
|
| 182 |
+
payload.extend(received_packets[idx][TRANSPORT_HDR:])
|
| 183 |
+
return bytes(payload)
|
| 184 |
+
|
| 185 |
+
# Check if exactly one packet is missing
|
| 186 |
+
if len(received_packets) == total_packets - 1:
|
| 187 |
+
missing_index = None
|
| 188 |
+
for idx in range(total_packets):
|
| 189 |
+
if idx not in received_indices:
|
| 190 |
+
missing_index = idx
|
| 191 |
+
break
|
| 192 |
+
|
| 193 |
+
print(f" [XOR-FEC] Healing detected: Recovering missing frame index {missing_index}...")
|
| 194 |
+
|
| 195 |
+
# Recover packet using XOR across all received packets
|
| 196 |
+
recovered_data = bytearray(DATA_PER_PKT)
|
| 197 |
+
for pkt in received_packets:
|
| 198 |
+
data_part = pkt[TRANSPORT_HDR:]
|
| 199 |
+
for d_idx in range(DATA_PER_PKT):
|
| 200 |
+
recovered_data[d_idx] ^= data_part[d_idx]
|
| 201 |
+
|
| 202 |
+
recovered_packet = bytes([SYNC_MARKER, missing_index, total_packets]) + bytes(recovered_data)
|
| 203 |
+
|
| 204 |
+
all_packets = list(received_packets) + [recovered_packet]
|
| 205 |
+
all_packets.sort(key=lambda x: x[1])
|
| 206 |
+
|
| 207 |
+
payload = bytearray()
|
| 208 |
+
for idx in range(total_packets - 1):
|
| 209 |
+
payload.extend(all_packets[idx][TRANSPORT_HDR:])
|
| 210 |
+
return bytes(payload)
|
| 211 |
+
|
| 212 |
+
print(f" [XOR-FEC] Error: Insufficient packets for healing. Received {len(received_packets)}/{total_packets}.")
|
| 213 |
+
return None
|
| 214 |
+
|
| 215 |
+
# ==============================================================================
|
| 216 |
+
# Main Receiver Execution
|
| 217 |
+
# ==============================================================================
|
| 218 |
+
def main():
|
| 219 |
+
parser = argparse.ArgumentParser(description="Zymatica LoRa Protocol - RAK Miner B (Receiver)")
|
| 220 |
+
parser.add_argument("--mode", choices=["udp", "serial"], default="udp", help="Connection interface: udp (local network) or serial (USB/UART)")
|
| 221 |
+
parser.add_argument("--ip", default="0.0.0.0", help="Binding IP for UDP socket")
|
| 222 |
+
parser.add_argument("--port", type=int, default=50001, help="Binding port for UDP socket")
|
| 223 |
+
parser.add_argument("--device", default="/dev/ttyUSB0", help="Serial port interface (needed for serial mode)")
|
| 224 |
+
parser.add_argument("--baud", type=int, default=115200, help="Serial baud rate")
|
| 225 |
+
args = parser.parse_args()
|
| 226 |
+
|
| 227 |
+
print("=" * 80)
|
| 228 |
+
print(" ZYMATICA | Language-U RAK-Miner B (Receiver Node)")
|
| 229 |
+
print(" Watermark: ip zymatica.space | astronautshe.com")
|
| 230 |
+
print("=" * 80)
|
| 231 |
+
|
| 232 |
+
num_concepts = 0
|
| 233 |
+
expected_hash = ""
|
| 234 |
+
received_raw_packets = []
|
| 235 |
+
|
| 236 |
+
if args.mode == "udp":
|
| 237 |
+
print(f"\n[1] Starting UDP Server binding to {args.ip}:{args.port}...")
|
| 238 |
+
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
| 239 |
+
sock.bind((args.ip, args.port))
|
| 240 |
+
|
| 241 |
+
expected_total = 99
|
| 242 |
+
while len(received_raw_packets) < expected_total:
|
| 243 |
+
data, addr = sock.recvfrom(512)
|
| 244 |
+
|
| 245 |
+
# Check for metadata signature
|
| 246 |
+
if data.startswith(b"META:"):
|
| 247 |
+
meta_parts = data.decode('utf-8').split(":")
|
| 248 |
+
num_concepts = int(meta_parts[1])
|
| 249 |
+
expected_hash = meta_parts[2]
|
| 250 |
+
print(f" - Received Metadata from {addr[0]}: Concepts={num_concepts}, Checksum={expected_hash}")
|
| 251 |
+
continue
|
| 252 |
+
|
| 253 |
+
# Process received frames
|
| 254 |
+
if len(data) == PKT_SIZE and data[0] == SYNC_MARKER:
|
| 255 |
+
received_raw_packets.append(data)
|
| 256 |
+
expected_total = data[2]
|
| 257 |
+
print(f" - Received Frame {len(received_raw_packets)}/{expected_total} ({len(data)} bytes) from {addr[0]}")
|
| 258 |
+
|
| 259 |
+
sock.close()
|
| 260 |
+
|
| 261 |
+
elif args.mode == "serial":
|
| 262 |
+
print(f"\n[1] Opening Serial Port {args.device} (RAK LoRa P2P Listener)...")
|
| 263 |
+
try:
|
| 264 |
+
import serial
|
| 265 |
+
except ImportError:
|
| 266 |
+
print(" [-] Error: 'pyserial' library not found. Install it using 'pip install pyserial'")
|
| 267 |
+
sys.exit(1)
|
| 268 |
+
|
| 269 |
+
try:
|
| 270 |
+
ser = serial.Serial(args.device, args.baud, timeout=10)
|
| 271 |
+
|
| 272 |
+
# Put RAK module in listening P2P mode
|
| 273 |
+
ser.write(b"at+set_config=lora:work_mode:1\r\n")
|
| 274 |
+
time.sleep(0.5)
|
| 275 |
+
|
| 276 |
+
# Start continuous receive mode
|
| 277 |
+
# at+set_config=lorap2p:rxtx:0 (0 means receive)
|
| 278 |
+
ser.write(b"at+set_config=lorap2p:rxtx:0\r\n")
|
| 279 |
+
time.sleep(0.5)
|
| 280 |
+
ser.read_all() # flush startup logs
|
| 281 |
+
|
| 282 |
+
print(" - Listening for LoRa P2P transmissions (timeout 30s)...")
|
| 283 |
+
|
| 284 |
+
# Read loop
|
| 285 |
+
expected_total = 99
|
| 286 |
+
import re
|
| 287 |
+
|
| 288 |
+
while len(received_raw_packets) < expected_total:
|
| 289 |
+
line = ser.readline().decode('utf-8', errors='ignore').strip()
|
| 290 |
+
if not line:
|
| 291 |
+
continue
|
| 292 |
+
|
| 293 |
+
# Check for RAK AT receive notification pattern:
|
| 294 |
+
# e.g., "at+recv=RSSI,SNR,LEN:HEX_DATA"
|
| 295 |
+
m = re.search(r'at\+recv=[^:]+:(.+)', line)
|
| 296 |
+
if m:
|
| 297 |
+
hex_data = m.group(1).strip()
|
| 298 |
+
bin_data = bytes.fromhex(hex_data)
|
| 299 |
+
|
| 300 |
+
if bin_data.startswith(b"META:"):
|
| 301 |
+
meta_parts = bin_data.decode('utf-8').split(":")
|
| 302 |
+
num_concepts = int(meta_parts[1])
|
| 303 |
+
expected_hash = meta_parts[2]
|
| 304 |
+
print(f" - Received Metadata: Concepts={num_concepts}, Checksum={expected_hash}")
|
| 305 |
+
continue
|
| 306 |
+
|
| 307 |
+
if len(bin_data) == PKT_SIZE and bin_data[0] == SYNC_MARKER:
|
| 308 |
+
received_raw_packets.append(bin_data)
|
| 309 |
+
expected_total = bin_data[2]
|
| 310 |
+
print(f" - Received LoRa Frame {len(received_raw_packets)}/{expected_total}")
|
| 311 |
+
|
| 312 |
+
ser.close()
|
| 313 |
+
except Exception as e:
|
| 314 |
+
print(f" [-] Serial communication error: {e}")
|
| 315 |
+
sys.exit(1)
|
| 316 |
+
|
| 317 |
+
# 2. XOR-FEC Reassembly
|
| 318 |
+
print(f"\n[2] Executing Forward Error Correction (XOR-FEC) Reassembler...")
|
| 319 |
+
payload_bytes = heal_and_reassemble(received_raw_packets)
|
| 320 |
+
|
| 321 |
+
if payload_bytes is None:
|
| 322 |
+
print(" [-] Error: Payload reassembly failed.")
|
| 323 |
+
sys.exit(1)
|
| 324 |
+
|
| 325 |
+
# Trim padding if necessary to align with typical coordinate length bounds
|
| 326 |
+
# (Each concept is decoded via range coder. Total concepts specified by metadata)
|
| 327 |
+
print(f" - Reassembled Payload: {len(payload_bytes)} bytes")
|
| 328 |
+
|
| 329 |
+
# 3. Check checksum
|
| 330 |
+
received_hash = hashlib.sha256(payload_bytes).hexdigest()
|
| 331 |
+
print(f" - Received Payload Checksum: {received_hash}")
|
| 332 |
+
print(f" - Expected Metadata Checksum: {expected_hash}")
|
| 333 |
+
|
| 334 |
+
if received_hash != expected_hash:
|
| 335 |
+
print(" [-] Warning: Hash mismatch! Payload corrupted.")
|
| 336 |
+
else:
|
| 337 |
+
print(" [+] Payload checksum verified successfully! Lossless path confirmed. ✅")
|
| 338 |
+
|
| 339 |
+
# 4. Decrypt / Range Decode Cuneiform-U Coordinates
|
| 340 |
+
print(f"\n[3] Range-Decoding Cuneiform-U Coordinates (LLD-AC System Ascent)...")
|
| 341 |
+
try:
|
| 342 |
+
decoded_radicals = range_decode_radicals(payload_bytes, num_concepts, alpha=1, weight=128)
|
| 343 |
+
print(f" - Decoded Concepts Matrix ({num_concepts} items):")
|
| 344 |
+
for idx, rad in enumerate(decoded_radicals):
|
| 345 |
+
print(f" Concept {idx+1:02d}: RC=0x{rad[0]:02X}, RF=0x{rad[1]:02X}, RA=0x{rad[2]:02X}")
|
| 346 |
+
|
| 347 |
+
print("\n" + "=" * 80)
|
| 348 |
+
print(" [VERIFICATION] Multi-Language runtime FFI structures validated.")
|
| 349 |
+
print("=" * 80)
|
| 350 |
+
|
| 351 |
+
except Exception as e:
|
| 352 |
+
print(f" [-] Coordinate range decoding failed: {e}")
|
| 353 |
+
sys.exit(1)
|
| 354 |
+
|
| 355 |
+
if __name__ == "__main__":
|
| 356 |
+
main()
|