1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-17 18:43:50 +01:00
AnnsAnn 55fa531e02 examples: restructure to use subfolders based on README structure
examples: Fix incorrect category heading

examples: shorten coap folder name

static-tests/examples: check subfolders for entries

ci/test_native: Adjust to new examples structure

examples: adjust makefiles to new structure

ci/tests: Fix symlinks to point towards proper examples
2025-02-13 11:54:09 +01:00

53 lines
925 B
C

/*
* Copyright (C) 2021 Silke Hofstra
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
/**
* @ingroup examples
* @{
*
* @file
* @brief Short SenML SAUL example
*
* @author Silke Hofstra <silke@slxh.eu>
*
* @}
*/
#include <stdio.h>
#include <string.h>
#include "senml/saul.h"
#include "fmt.h"
static uint8_t cbor_buf[1024];
void print_hex(uint8_t *a, size_t len)
{
for (size_t i = 0; i < len; i++) {
print_byte_hex(a[i]);
}
}
int main(void)
{
size_t len = senml_saul_encode_cbor(cbor_buf, sizeof cbor_buf, saul_reg);
if (len == 0) {
print_str("SenML/SAUL error\n");
return 1;
}
print_str("CBOR (");
print_u32_dec(len);
print_str(" B): ");
print_hex(cbor_buf, len);
print_str("\n");
return 0;
}