compression WIP

compression works. next is to store it in the proto as a oneof and then decompress it on use.
raytac-diy
Jm Casler 2022-04-11 22:12:04 -07:00
rodzic 478274aff1
commit a4bdef4151
2 zmienionych plików z 16 dodań i 10 usunięć

Wyświetl plik

@ -110,11 +110,14 @@ lib_ignore =
ESP32 BLE Arduino
platform_packages =
framework-arduinoespressif32@https://github.com/meshtastic/arduino-esp32.git#4cde0f5d412d2695184f32e8a47e9bea57b45276
; leave this commented out to avoid breaking Windows
; leave this commented out to avoid breaking Windows
;upload_port = /dev/ttyUSB0
;monitor_port = /dev/ttyUSB0
upload_port = /dev/cu.SLAB_USBtoUART
monitor_port = /dev/cu.SLAB_USBtoUART
; customize the partition table
; http://docs.platformio.org/en/latest/platforms/espressif32.html#partition-tables
board_build.partitions = partition-table.csv

Wyświetl plik

@ -325,26 +325,29 @@ Routing_Error perhapsEncode(MeshPacket *p)
size_t numbytes = pb_encode_to_bytes(bytes, sizeof(bytes), Data_fields, &p->decoded);
if (1) {
// int orig_len, compressed_len;
if (p->decoded.portnum == PortNum_TEXT_MESSAGE_APP) {
char original_payload[Constants_DATA_PAYLOAD_LEN];
memcpy(original_payload, p->decoded.payload.bytes, p->decoded.payload.size);
int compressed_len;
char compressed_out[100] = {0};
// char *orig = (char *)"Hiiiiiiii! :) How are you doing? I am doing well.";
// char *orig = (char *)"Meshtastic";
// orig_len = strlen(orig);
// compressed_len = unishox2_compress_simple(orig, orig_len, compressed_out);
compressed_len = unishox2_compress_simple((char *)bytes, numbytes, compressed_out);
compressed_len = unishox2_compress_simple(original_payload, p->decoded.payload.size, compressed_out);
Serial.print("Original length - ");
Serial.println(p->decoded.payload.size);
Serial.print("Compressed length - ");
Serial.println(compressed_len);
Serial.println(compressed_out);
//&p->decoded.portnum;
//Serial.println(compressed_out);
char decompressed_out[100] = {};
int decompressed_len;
decompressed_len = unishox2_decompress_simple(compressed_out, compressed_len, decompressed_out);
Serial.print("Decompressed length - ");
Serial.println(decompressed_len);
Serial.println(decompressed_out);
}