diff --git a/ARM_Tag_FW/88MZ100_OpenEpaperLink_7.4/mkfsOEPL/compile_fs_tools.sh b/ARM_Tag_FW/88MZ100_OpenEpaperLink_7.4/mkfsOEPL/compile_fs_tools.sh new file mode 100644 index 00000000..afd6c07c --- /dev/null +++ b/ARM_Tag_FW/88MZ100_OpenEpaperLink_7.4/mkfsOEPL/compile_fs_tools.sh @@ -0,0 +1,7 @@ +rm mkfs.oepl genprofile +g++ mkfs.oepl.cpp -lz -o mkfs.oepl +g++ genprofile.cpp -o genprofile +chmod +x mkfs.oepl +chmod +x genprofile + + diff --git a/ARM_Tag_FW/88MZ100_OpenEpaperLink_7.4/mkfsOEPL/genprofile b/ARM_Tag_FW/88MZ100_OpenEpaperLink_7.4/mkfsOEPL/genprofile new file mode 100644 index 00000000..1bfffbac Binary files /dev/null and b/ARM_Tag_FW/88MZ100_OpenEpaperLink_7.4/mkfsOEPL/genprofile differ diff --git a/ARM_Tag_FW/88MZ100_OpenEpaperLink_7.4/mkfsOEPL/genprofile.cpp b/ARM_Tag_FW/88MZ100_OpenEpaperLink_7.4/mkfsOEPL/genprofile.cpp new file mode 100644 index 00000000..7582fe28 --- /dev/null +++ b/ARM_Tag_FW/88MZ100_OpenEpaperLink_7.4/mkfsOEPL/genprofile.cpp @@ -0,0 +1,61 @@ +#include +#include +#include +// #include +#include +#include +#include +#include +#include +using json = nlohmann::json; + +#include "../tagprofile_struct.h" + +struct tagHardwareProfile* getProfileFromJson(); + +int main() { + struct tagHardwareProfile* thwp = getProfileFromJson(); + printf("MAC: %02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X, xRes: %d\n", thwp->macAddress[0],thwp->macAddress[1],thwp->macAddress[2],thwp->macAddress[3],thwp->macAddress[4],thwp->macAddress[5],thwp->macAddress[6],thwp->macAddress[7], thwp->xRes); + FILE* wptr = fopen("tagprofile.bin", "wb"); + fwrite((uint8_t*)thwp, sizeof(struct tagHardwareProfile), 1, wptr); + fclose(wptr); +} + +struct tagHardwareProfile* getProfileFromJson() { + struct tagHardwareProfile* thwp = new struct tagHardwareProfile; + + std::ifstream f("tagprofile.json"); + json jsonData = json::parse(f); + + // Check if the 'mac' key exists in the JSON object + if (jsonData.find("mac") != jsonData.end()) { + std::string macString = jsonData["mac"]; + thwp->xRes = jsonData["xRes"]; + thwp->yRes = jsonData["yRes"]; + thwp->bpp = jsonData["bpp"]; + thwp->controllerType = jsonData["controllerType"]; + thwp->OEPLType = jsonData["OEPLType"]; + + // Attempt to parse the MAC address with ":" separators + int resultWithColons = sscanf(macString.c_str(), "%2hhx:%2hhx:%2hhx:%2hhx:%2hhx:%2hhx:%2hhx:%2hhx", + &thwp->macAddress[0], &thwp->macAddress[1], &thwp->macAddress[2], &thwp->macAddress[3], + &thwp->macAddress[4], &thwp->macAddress[5], &thwp->macAddress[6], &thwp->macAddress[7]); + if (resultWithColons != 8) { + int resultWithoutColons = sscanf(macString.c_str(), "%2hhx%2hhx%2hhx%2hhx%2hhx%2hhx%2hhx%2hhx", + &thwp->macAddress[0], &thwp->macAddress[1], &thwp->macAddress[2], &thwp->macAddress[3], + &thwp->macAddress[4], &thwp->macAddress[5], &thwp->macAddress[6], &thwp->macAddress[7]); + + // Check if either format successfully parsed the MAC address + if (resultWithoutColons != 8) { + std::cerr << "Error parsing MAC address from JSON string." << std::endl; + delete thwp; + return nullptr; + } + } + return thwp; + } else { + std::cerr << "Error: 'mac' key not found in JSON." << std::endl; + delete thwp; + return nullptr; + } +} diff --git a/ARM_Tag_FW/88MZ100_OpenEpaperLink_7.4/mkfsOEPL/img_tbird.bin b/ARM_Tag_FW/88MZ100_OpenEpaperLink_7.4/mkfsOEPL/img_tbird.bin deleted file mode 100644 index 72798458..00000000 Binary files a/ARM_Tag_FW/88MZ100_OpenEpaperLink_7.4/mkfsOEPL/img_tbird.bin and /dev/null differ diff --git a/ARM_Tag_FW/88MZ100_OpenEpaperLink_7.4/mkfsOEPL/mkbinaryimage.py b/ARM_Tag_FW/88MZ100_OpenEpaperLink_7.4/mkfsOEPL/mkbinaryimage.py new file mode 100644 index 00000000..12a92659 --- /dev/null +++ b/ARM_Tag_FW/88MZ100_OpenEpaperLink_7.4/mkfsOEPL/mkbinaryimage.py @@ -0,0 +1,95 @@ +import sys +from PIL import Image +import struct +import math + +def convert_image_to_binary(input_image_path, output_file_path): + # Open the image + img = Image.open(input_image_path) + + # Calculate the padded X size + new_x_size = math.ceil(img.size[0] / 8) * 8 + + # Create a new image with the padded X size + img_padded = Image.new("RGB", (new_x_size, img.size[1]), (255, 255, 255)) + img_padded.paste(img, (0, 0)) + + # Convert the padded image to grayscale and invert + img_bw = img_padded.convert('L').point(lambda x: 255 - x) + + # Check if the image has a red channel + has_red_channel = 'R' in img.getbands() + pixel_data_red = img_padded.split()[0].point(lambda x: 255 - x).tobytes() + if any(pixel_data_red): + has_red_channel = 1; + else: + has_red_channel = 0; + + # Calculate unpadded resolution + unpadded_resolution = (img.size[0], img.size[1]) + + # Create binary file + with open(output_file_path, "wb") as binary_file: + # Write header: 0x06, unpadded X size, Y size, bits-per-pixel + binary_file.write(b'\x06') + binary_file.write(unpadded_resolution[0].to_bytes(2, byteorder='little')) + binary_file.write(unpadded_resolution[1].to_bytes(2, byteorder='little')) + + # Determine bits-per-pixel + bits_per_pixel = 2 if has_red_channel else 1 + binary_file.write(bits_per_pixel.to_bytes(1, byteorder='big')) + + # Extract pixel data + pixel_data_bw = img_bw.tobytes() + + # If there's a red channel, extract red pixels + if has_red_channel: + pixel_data_red = img_padded.split()[0].point(lambda x: 255 - x).tobytes() + + # Process pixel data in chunks of 8 and pack into bytes for black/white + packed_data_bw = bytearray() + packed_data_red = bytearray() + for i in range(0, len(pixel_data_bw), 8): + chunk_bw = pixel_data_bw[i:i + 8] + packed_byte_bw = 0 + for j, pixel_value in enumerate(chunk_bw): + packed_byte_bw |= (pixel_value >> j) & 1 << (7 - j) + + packed_data_bw.append(packed_byte_bw) + + chunk_red = pixel_data_red[i:i + 8] + packed_byte_red = 0 + for j, pixel_value in enumerate(chunk_red): + packed_byte_red |= (pixel_value >> j) & 1 << (7 - j) + + packed_byte_red = packed_byte_red ^ packed_byte_bw + + packed_data_red.append(packed_byte_red) + + + # Write packed pixel data to binary file + binary_file.write(bytes(packed_data_bw)) + binary_file.write(bytes(packed_data_red)) + else: + # Process pixel data in chunks of 8 and pack into bytes for black/white + packed_data_bw = bytearray() + for i in range(0, len(pixel_data_bw), 8): + chunk_bw = pixel_data_bw[i:i + 8] + packed_byte_bw = 0 + for j, pixel_value in enumerate(chunk_bw): + packed_byte_bw |= (pixel_value >> j) & 1 << (7 - j) + + packed_data_bw.append(packed_byte_bw) + + # Write packed pixel data to binary file + binary_file.write(bytes(packed_data_bw)) + + print(f"Conversion completed. Output saved to {output_file_path}") + +if __name__ == "__main__": + if len(sys.argv) != 3: + print("Usage: python script_name.py input_image_path output_file_path") + else: + input_image_path = sys.argv[1] + output_file_path = sys.argv[2] + convert_image_to_binary(input_image_path, output_file_path) diff --git a/ARM_Tag_FW/88MZ100_OpenEpaperLink_7.4/mkfsOEPL/mkfs.oepl b/ARM_Tag_FW/88MZ100_OpenEpaperLink_7.4/mkfsOEPL/mkfs.oepl index fb5ef57e..bb104bda 100644 Binary files a/ARM_Tag_FW/88MZ100_OpenEpaperLink_7.4/mkfsOEPL/mkfs.oepl and b/ARM_Tag_FW/88MZ100_OpenEpaperLink_7.4/mkfsOEPL/mkfs.oepl differ diff --git a/ARM_Tag_FW/88MZ100_OpenEpaperLink_7.4/mkfsOEPL/mkfs.oepl.cpp b/ARM_Tag_FW/88MZ100_OpenEpaperLink_7.4/mkfsOEPL/mkfs.oepl.cpp index b6cfd50d..9722dac7 100644 --- a/ARM_Tag_FW/88MZ100_OpenEpaperLink_7.4/mkfsOEPL/mkfs.oepl.cpp +++ b/ARM_Tag_FW/88MZ100_OpenEpaperLink_7.4/mkfsOEPL/mkfs.oepl.cpp @@ -14,6 +14,7 @@ Jelmer Bruijn 2024 */ + #define PROGMEM #define WINDOW_SIZE 12 // 4096 bytes #define FILENAME_LENGTH 32 @@ -108,7 +109,7 @@ unsigned long doCompress(uint8_t* in, uint32_t in_len, uint8_t* out) { fprintf(stderr, "Error finalizing compression\n"); return 1; } - dump(out, 16); + //dump(out, 16); return stream.total_out+4; } @@ -232,7 +233,6 @@ void saveFontData(const GFXfont* font, char* name){ #include "../../common/fonts/FreeSans9pt7b.h" #include "../../common/fonts/FreeSansBold18pt7b.h" #include "../../common/fonts/FreeSansBold24pt7b.h" -#include "../../common/bitmaps.h" int main(){ wptr = fopen("../build/fs.img","wb"); // w for write, b for binary @@ -243,11 +243,14 @@ int main(){ saveFontData(&FreeSans9pt7b, (char*)"font/FreeSans9pt7b"); /* OTHER STUFF */ - addFile((uint8_t*)sadpanda, sizeof(sadpanda), "img/sadpanda", true); - //addFileFromFS("img_tbird.bin", true); + addFileFromFS("tagprofile.bin", false); + addFileFromFS("norf.bin", true); + addFileFromFS("lowbat.bin", true); + addFileFromFS("sadpanda.bin", true); + addFileFromFS("tbird2.bin", true); + addFileFromFS("jet.bin", true); printFAT(); fwrite(buffer,curOffset,1,wptr); fclose(wptr); - return 0; } diff --git a/ARM_Tag_FW/88MZ100_OpenEpaperLink_7.4/mkfsOEPL/mkfs.oepl.sh b/ARM_Tag_FW/88MZ100_OpenEpaperLink_7.4/mkfsOEPL/mkfs.oepl.sh index 343a0699..b8c585d3 100644 --- a/ARM_Tag_FW/88MZ100_OpenEpaperLink_7.4/mkfsOEPL/mkfs.oepl.sh +++ b/ARM_Tag_FW/88MZ100_OpenEpaperLink_7.4/mkfsOEPL/mkfs.oepl.sh @@ -1,4 +1,8 @@ -rm mkfs.oepl -g++ mkfs.oepl.cpp -lz -o mkfs.oepl -./mkfs.oepl +python3 mkbinaryimage.py ../../common/assets/norf48.png norf.bin +python3 mkbinaryimage.py ../../common/assets/lowbat48.png lowbat.bin +python3 mkbinaryimage.py ../../common/assets/sadpanda.png sadpanda.bin +python3 mkbinaryimage.py ../../common/assets/tbird2.png tbird2.bin +python3 mkbinaryimage.py ../../common/assets/jet.png jet.bin +./genprofile +./mkfs.oepl diff --git a/ARM_Tag_FW/88MZ100_OpenEpaperLink_7.4/mkfsOEPL/tagprofile.json b/ARM_Tag_FW/88MZ100_OpenEpaperLink_7.4/mkfsOEPL/tagprofile.json new file mode 100644 index 00000000..54320263 --- /dev/null +++ b/ARM_Tag_FW/88MZ100_OpenEpaperLink_7.4/mkfsOEPL/tagprofile.json @@ -0,0 +1,8 @@ +{ + "mac":"0000021ECA8C743F", + "xRes":640, + "yRes":384, + "bpp":2, + "controllerType":0, + "OEPLType":5 +} diff --git a/ARM_Tag_FW/88MZ100_OpenEpaperLink_7.4/mkfsOEPL/testcompress.cpp b/ARM_Tag_FW/88MZ100_OpenEpaperLink_7.4/mkfsOEPL/testcompress.cpp deleted file mode 100644 index 110ccbd5..00000000 --- a/ARM_Tag_FW/88MZ100_OpenEpaperLink_7.4/mkfsOEPL/testcompress.cpp +++ /dev/null @@ -1,57 +0,0 @@ -#include -#include -#include -#include - -int main() { - // Input string to compress - const char* inputString = "This is a sample string to compress and add a gzip header.werugweroiguie;wroigj;eworijg;oewirjg;oeiwrjg;oiewrj;goiewjr;ogiejw;rojig;ewoirjg;oewijrg;oewirj;goeiwj;roiwheg;orihg"; - - // Length of the input string - size_t inputLength = strlen(inputString); - - // Allocate memory for compressed data - size_t compressedBufferSize = compressBound(inputLength) + 18; // Additional space for gzip header - char* compressedBuffer = (char*)malloc(compressedBufferSize); - - // Compression parameters with reduced window size (8 bits) - z_stream stream; - stream.zalloc = Z_NULL; - stream.zfree = Z_NULL; - stream.opaque = Z_NULL; - stream.avail_in = (uInt)inputLength; - stream.next_in = (Bytef*)inputString; - stream.avail_out = (uInt)compressedBufferSize; - stream.next_out = (Bytef*)compressedBuffer; - - // Initialize compression with gzip header and reduced window size (8 bits) - if (deflateInit2(&stream, Z_DEFAULT_COMPRESSION, Z_DEFLATED, 8, 8, Z_DEFAULT_STRATEGY) != Z_OK) { - fprintf(stderr, "Error initializing zlib for compression\n"); - free(compressedBuffer); - return 1; - } - - // Perform compression - if (deflate(&stream, Z_FINISH) != Z_STREAM_END) { - fprintf(stderr, "Error compressing data\n"); - deflateEnd(&stream); - free(compressedBuffer); - return 1; - } - - // Finalize compression - if (deflateEnd(&stream) != Z_OK) { - fprintf(stderr, "Error finalizing compression\n"); - free(compressedBuffer); - return 1; - } - - // Display results - printf("Original string length: %zu bytes\n", inputLength); - printf("Compressed data length: %lu bytes\n", (unsigned long)stream.total_out); - - // Clean up - free(compressedBuffer); - - return 0; -} diff --git a/ARM_Tag_FW/common/assets/jet.png b/ARM_Tag_FW/common/assets/jet.png new file mode 100644 index 00000000..27861a49 Binary files /dev/null and b/ARM_Tag_FW/common/assets/jet.png differ diff --git a/ARM_Tag_FW/common/assets/lowbat128.png b/ARM_Tag_FW/common/assets/lowbat128.png new file mode 100644 index 00000000..a16e11e3 Binary files /dev/null and b/ARM_Tag_FW/common/assets/lowbat128.png differ diff --git a/ARM_Tag_FW/common/assets/lowbat48.png b/ARM_Tag_FW/common/assets/lowbat48.png new file mode 100644 index 00000000..b5399dc6 Binary files /dev/null and b/ARM_Tag_FW/common/assets/lowbat48.png differ diff --git a/ARM_Tag_FW/common/assets/norf48.png b/ARM_Tag_FW/common/assets/norf48.png new file mode 100644 index 00000000..f5279552 Binary files /dev/null and b/ARM_Tag_FW/common/assets/norf48.png differ diff --git a/ARM_Tag_FW/common/assets/sadpanda.png b/ARM_Tag_FW/common/assets/sadpanda.png new file mode 100644 index 00000000..422bb146 Binary files /dev/null and b/ARM_Tag_FW/common/assets/sadpanda.png differ diff --git a/ARM_Tag_FW/common/assets/tbird2.png b/ARM_Tag_FW/common/assets/tbird2.png new file mode 100644 index 00000000..155160e9 Binary files /dev/null and b/ARM_Tag_FW/common/assets/tbird2.png differ diff --git a/ARM_Tag_FW/common/oepl-protocol.cpp b/ARM_Tag_FW/common/oepl-protocol.cpp index 4c0d3da7..a8c7f6b9 100644 --- a/ARM_Tag_FW/common/oepl-protocol.cpp +++ b/ARM_Tag_FW/common/oepl-protocol.cpp @@ -77,7 +77,6 @@ static bool checkCRC(const void *p, const uint8_t len) { for (uint8_t c = 1; c < len; c++) { total += ((uint8_t *)p)[c]; } - // printf("CRC: rx %d, calc %d\n", ((uint8_t *)p)[0], total); return ((uint8_t *)p)[0] == total; } static void addCRC(void *p, const uint8_t len) { @@ -229,7 +228,6 @@ static bool processBlockPart(const struct blockPart *bp, uint8_t *blockbuffer) { uint16_t size = BLOCK_PART_DATA_SIZE; // validate if it's okay to copy data if (bp->blockId != curBlock.blockId) { - // printf("got a packet for block %02X\n", bp->blockId); return false; } if (start >= BLOCK_XFER_BUFFER_SIZE - 1) @@ -335,7 +333,9 @@ static struct blockRequestAck *performBlockRequest() { case PKT_CANCEL_XFER: return NULL; default: - printf("pkt w/type %02X\n", getPacketType(inBuffer)); +#ifdef DEBUG_PROTO + printf("PROTO: pkt w/type %02X\n", getPacketType(inBuffer)); +#endif break; } } @@ -374,30 +374,42 @@ static void sendXferComplete() { int8_t ret = HAL_PacketRX(inBuffer); if (ret > 1) { if (getPacketType(inBuffer) == PKT_XFER_COMPLETE_ACK) { - printf("XFC ACK\n"); +#ifdef DEBUG_PROTO + printf("PROTO: XFC ACK\n"); +#endif return; } } } } - printf("XFC NACK!\n"); +#ifdef DEBUG_PROTO + printf("PROTO: XFC NACK!\n"); +#endif return; } static bool validateBlockData(uint8_t *blockbuffer) { struct blockData *bd = (struct blockData *)blockbuffer; - printf("expected len = %d, checksum=%d\n", bd->size, bd->checksum); +#ifdef DEBUG_PROTO + printf("PROTO: expected len = %d, checksum=%d\n", bd->size, bd->checksum); +#endif if (bd->size > BLOCK_XFER_BUFFER_SIZE - sizeof(blockData)) { - printf("Impossible data size; size = %d\n", bd->size); + printf("PROTO: Impossible data size; size = %d\n", bd->size); return false; } uint16_t t = 0; for (uint16_t c = 0; c < bd->size; c++) { t += bd->data[c]; } - printf("calculated checksum = %04X, %d\n", t, t); - if (t != bd->checksum) dump(blockbuffer, BLOCK_XFER_BUFFER_SIZE + sizeof(blockData)); +#ifdef DEBUG_PROTO + printf("PROTO: calculated checksum = %04X, %d\n", t, t); + if (t != bd->checksum) printf("PROTO: Checksum failed!\n"); +#endif + +#ifdef DEBUG_DONTVALIDATEPROTO return true; +#else return bd->checksum == t; +#endif } // EEprom related stuff @@ -406,19 +418,22 @@ static uint32_t getAddressForSlot(const uint8_t s) { } static void getNumSlots() { uint32_t eeSize = eepromGetSize(); - printf("eeSize = %lu, image = %lu\n", eeSize, tag.imageSize); - +#ifdef DEBUG_PROTO + printf("PROTO: eeSize = %lu, image = %lu\n", eeSize, tag.imageSize); +#endif uint16_t nSlots = (eeSize - EEPROM_SETTINGS_SIZE) / (tag.imageSize >> 8) >> 8; if (!nSlots) { - printf("eeprom is too small\n"); + printf("PROTO: eeprom is too small\n"); while (1) ; } else if (nSlots >> 8) { - printf("eeprom is too big, some will be unused\n"); + printf("PROTO: eeprom is too big, some will be unused\n"); imgSlots = 254; } else imgSlots = nSlots; - printf("EEPROM reported size = %lu, %d slots\n", eeSize, imgSlots); +#ifdef DEBUG_PROTO + printf("PROTO: EEPROM reported size = %lu, %d slots\n", eeSize, imgSlots); +#endif } static uint8_t findSlotVer(uint64_t ver) { #ifdef DEBUGBLOCKS @@ -485,7 +500,7 @@ static void eraseImageBlock(const uint8_t c) { } static void saveUpdateBlockData(uint8_t blockId, uint8_t *blockbuffer) { if (!eepromWrite(FW_LOC + (blockId * BLOCK_DATA_SIZE), blockbuffer + sizeof(struct blockData), BLOCK_DATA_SIZE)) - printf("EEPROM write failed\n"); + printf("PROTO: EEPROM write failed\n"); } static void saveImgBlockData(const uint8_t imgSlot, const uint8_t blockId, uint8_t *blockbuffer) { @@ -494,7 +509,7 @@ static void saveImgBlockData(const uint8_t imgSlot, const uint8_t blockId, uint8 length = 4096; if (!eepromWrite(getAddressForSlot(imgSlot) + sizeof(struct EepromImageHeader) + (blockId * BLOCK_DATA_SIZE), blockbuffer + sizeof(struct blockData), length)) - printf("EEPROM write failed\n"); + printf("PROTO: EEPROM write failed\n"); } void eraseImageBlocks() { for (uint8_t c = 0; c < imgSlots; c++) { @@ -517,7 +532,9 @@ static uint32_t getHighSlotId() { } } } - printf("found high id=%lu in slot %d\n", temp, nextImgSlot); +#ifdef DEBUG_PROTO + printf("PROTO: found high id=%lu in slot %d\n", temp, nextImgSlot); +#endif return temp; } @@ -527,7 +544,7 @@ static uint8_t *getDataBlock(const uint16_t blockSize) { uint8_t *blockbuffer = (uint8_t *)malloc(BLOCK_XFER_BUFFER_SIZE); if (!blockbuffer) { - printf("failed to allocate block buffer\n"); + printf("PROTO: failed to allocate block buffer\n"); return nullptr; } @@ -566,7 +583,9 @@ static uint8_t *getDataBlock(const uint16_t blockSize) { powerUp(INIT_RADIO); struct blockRequestAck *ack = performBlockRequest(); if (ack == NULL) { - printf("Cancelled request\n"); +#ifdef DEBUG_PROTO + printf("PROTO: Cancelled request\n"); +#endif free(blockbuffer); return nullptr; } @@ -621,7 +640,7 @@ static uint8_t *getDataBlock(const uint16_t blockSize) { curBlock.requestedParts[c / 8] |= (1 << (c % 8)); } requestPartialBlock = false; - printf("blk failed validation!\n"); + printf("PROTO: blk failed validation!\n"); } } else { #ifndef DEBUGBLOCKS @@ -631,7 +650,7 @@ static uint8_t *getDataBlock(const uint16_t blockSize) { requestPartialBlock = true; } } - printf("failed getting block\n"); + printf("PROTO: failed getting block\n"); free(blockbuffer); return nullptr; } @@ -696,7 +715,9 @@ static bool downloadImageDataToEEPROM(const struct AvailDataInfo *avail) { // check if we already started the transfer of this information & haven't completed it if (!memcmp((const void *)&avail->dataVer, (const void *)&xferDataInfo.dataVer, 8) && xferDataInfo.dataSize) { // looks like we did. We'll carry on where we left off. - printf("restarting image download"); +#ifdef DEBUG_PROTO + printf("PROTO: restarting image download"); +#endif // curImgSlot = nextImgSlot; // hmmm } else { // new transfer @@ -707,7 +728,7 @@ static bool downloadImageDataToEEPROM(const struct AvailDataInfo *avail) { if (nextImgSlot == startingSlot) { // looped powerDown(INIT_EEPROM); - printf("no slot available...\n"); + printf("PROTO: no slot available...\n"); return true; } struct EepromImageHeader eih; @@ -739,7 +760,9 @@ static bool downloadImageDataToEEPROM(const struct AvailDataInfo *avail) { #endif NVIC_SystemReset(); eraseSuccess: - printf("new download, writing to slot %d\n", xferImgSlot); +#ifdef DEBUG_PROTO + printf("PROTO: new download, writing to slot %d\n", xferImgSlot); +#endif // start, or restart the transfer. Copy data from the AvailDataInfo struct, and the struct intself. This forces a new transfer curBlock.blockId = 0; memcpy(&(curBlock.ver), &(avail->dataVer), 8); @@ -761,7 +784,7 @@ static bool downloadImageDataToEEPROM(const struct AvailDataInfo *avail) { // succesfully downloaded datablock, save to eeprom powerUp(INIT_EEPROM); #ifdef DEBUGBLOCKS - printf("Saving block %d to slot %d\n", curBlock.blockId, xferImgSlot); + printf("PROTO: Saving block %d to slot %d\n", curBlock.blockId, xferImgSlot); #endif saveImgBlockData(xferImgSlot, curBlock.blockId, blockbuffer); powerDown(INIT_EEPROM); @@ -784,7 +807,7 @@ static bool downloadImageDataToEEPROM(const struct AvailDataInfo *avail) { eih.argument = xferDataInfo.dataTypeArgument; #ifdef DEBUGBLOCKS - printf("Now writing datatype 0x%02X to slot %d\n", xferDataInfo.dataType, xferImgSlot); + printf("PROTO: Now writing datatype 0x%02X to slot %d\n", xferDataInfo.dataType, xferImgSlot); #endif powerUp(INIT_EEPROM); @@ -806,7 +829,9 @@ bool processImageDataAvail(struct AvailDataInfo *avail) { struct imageDataTypeArgStruct arg = *((struct imageDataTypeArgStruct *)avail->dataTypeArgument); if (arg.preloadImage) { - printf("Preloading image with type 0x%02X from arg 0x%02X\n", arg.specialType, avail->dataTypeArgument); +#ifdef DEBUG_PROTO + printf("PROTO: Preloading image with type 0x%02X from arg 0x%02X\n", arg.specialType, avail->dataTypeArgument); +#endif powerUp(INIT_EEPROM); switch (arg.specialType) { // check if a slot with this argument is already set; if so, erase. Only one of each arg type should exist @@ -831,11 +856,14 @@ bool processImageDataAvail(struct AvailDataInfo *avail) { break; } powerDown(INIT_EEPROM); - - printf("downloading preload image...\n"); +#ifdef DEBUG_PROTO + printf("PROTO: downloading preload image...\n"); +#endif if (downloadImageDataToEEPROM(avail)) { // sets xferImgSlot to the right slot - printf("preload complete!\n"); +#ifdef DEBUG_PROTO + printf("PROTO: preload complete!\n"); +#endif powerUp(INIT_RADIO); sendXferComplete(); powerDown(INIT_RADIO); @@ -848,8 +876,9 @@ bool processImageDataAvail(struct AvailDataInfo *avail) { // check if we're currently displaying this data payload if (avail->dataVer == curDispDataVer) { // currently displayed, not doing anything except for sending an XFC - - printf("currently shown image, send xfc\n"); +#ifdef DEBUG_PROTO + printf("PROTO: currently shown image, send xfc\n"); +#endif powerUp(INIT_RADIO); sendXferComplete(); powerDown(INIT_RADIO); @@ -882,10 +911,14 @@ bool processImageDataAvail(struct AvailDataInfo *avail) { } else { // not found in cache, prepare to download - printf("downloading image...\n"); +#ifdef DEBUG_PROTO + printf("PROTO: downloading image...\n"); +#endif if (downloadImageDataToEEPROM(avail)) { // sets xferImgSlot to the right slot - printf("download complete!\n"); +#ifdef DEBUG_PROTO + printf("PROTO: download complete!\n"); +#endif powerUp(INIT_RADIO); sendXferComplete(); powerDown(INIT_RADIO); @@ -919,8 +952,9 @@ bool processAvailDataInfo(struct AvailDataInfo *avail) { case DATATYPE_FW_UPDATE: powerUp(INIT_EEPROM); if (uint32_t fwsize = downloadFWUpdate(avail)) { - printf("firmware download complete, doing update.\n"); - +#ifdef DEBUG_PROTO + printf("PROTO: firmware download complete, doing update.\n"); +#endif powerUp(INIT_EPD); // showApplyUpdate(); @@ -954,11 +988,14 @@ bool processAvailDataInfo(struct AvailDataInfo *avail) { powerDown(INIT_RADIO); return true; } - - printf("NFC URL received\n"); +#ifdef DEBUG_PROTO + printf("PROTO: NFC URL received\n"); +#endif if (xferDataInfo.dataSize == 0 && !memcmp((const void *)&avail->dataVer, (const void *)&xferDataInfo.dataVer, 8)) { // we've already downloaded this NFC data, disregard and send XFC - printf("this was the same as the last transfer, disregard\n"); +#ifdef DEBUG_PROTO + printf("PROTO: this was the same as the last transfer, disregard\n"); +#endif powerUp(INIT_RADIO); sendXferComplete(); powerDown(INIT_RADIO); @@ -995,7 +1032,9 @@ bool processAvailDataInfo(struct AvailDataInfo *avail) { memcpy(&xferDataInfo, (void *)avail, sizeof(struct AvailDataInfo)); #ifdef LEDSENABLED if (avail->dataTypeArgument == 4) { - printf("LED CMD"); +#ifdef DEBUG_PROTO + printf("PROTO: LED CMD"); +#endif setled(xferDataInfo.dataVer, xferDataInfo.dataSize); } #endif @@ -1009,7 +1048,9 @@ bool processAvailDataInfo(struct AvailDataInfo *avail) { break; case DATATYPE_TAG_CONFIG_DATA: if (xferDataInfo.dataSize == 0 && memcmp((const void *)&avail->dataVer, (const void *)&xferDataInfo.dataVer, 8) == 0) { - printf("this was the same as the last transfer, disregard\n"); +#ifdef DEBUG_PROTO + printf("PROTO: this was the same as the last transfer, disregard\n"); +#endif powerUp(INIT_RADIO); sendXferComplete(); powerDown(INIT_RADIO);