1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-18 12:52:44 +01:00

tests/pkg_qr-code-generator: improve encoder buffer lenghts

This commit is contained in:
Alexandre Abadie 2021-05-11 10:32:25 +02:00
parent 612eb5a4bf
commit 55fc61f295
No known key found for this signature in database
GPG Key ID: 1C919A403CAE1405

View File

@ -23,6 +23,8 @@
#include <stdbool.h>
#include <stdint.h>
#include "test_utils/expect.h"
#include "qrcodegen.h"
#ifdef MODULE_DISP_DEV
@ -33,8 +35,11 @@
#define MESSAGE_TO_ENCODE "unknown"
#endif
static uint8_t qr0[qrcodegen_BUFFER_LEN_FOR_VERSION(2)];
static uint8_t buffer[qrcodegen_BUFFER_LEN_FOR_VERSION(2)];
/* Compute buffer sizes based on the message to encode len to avoid a
* failed assertion in qrcodegen */
#define ENCODER_VERSION (sizeof(MESSAGE_TO_ENCODE) >> 3)
static uint8_t qr0[qrcodegen_BUFFER_LEN_FOR_VERSION(ENCODER_VERSION)];
static uint8_t buffer[qrcodegen_BUFFER_LEN_FOR_VERSION(ENCODER_VERSION)];
#ifdef MODULE_DISP_DEV
#define DISPLAY_BUFFER_MAX_SIZE (320)
@ -43,6 +48,8 @@ static uint16_t display_buffer[DISPLAY_BUFFER_MAX_SIZE] = { 0 };
int main(void)
{
expect(ENCODER_VERSION <= qrcodegen_VERSION_MAX);
if (!qrcodegen_encodeText(MESSAGE_TO_ENCODE,
buffer, qr0, qrcodegen_Ecc_MEDIUM,
qrcodegen_VERSION_MIN, qrcodegen_VERSION_MAX,