2 #if RT_COMMUNICATION_ENABLED
12 #define MAC_BYTES (6U)
14 #define CHAR_PER_BYTE (3U)
16 #define BITS_PER_BYTE (8U)
32 static rd_status_t u64_to_hexstr (
const uint64_t value,
char *
const str,
33 const size_t str_len,
const uint8_t bytes)
38 uint8_t num_delimiters = bytes - 1U;
40 for (
size_t ii = 0; (ii < bytes) && (str_len > (written + NULL_LEN)); ii++)
42 uint8_t
byte = (uint8_t) (value >> bit_offset);
43 written += snprintf (str + written, str_len - written,
"%02X",
byte);
45 if ( (ii < num_delimiters) && (str_len > written))
47 written += snprintf (str + written, str_len - written,
":");
53 if ( (written + NULL_LEN) < CHAR_PER_BYTE * bytes
54 || (str_len < written + NULL_LEN))
78 status |= u64_to_hexstr (mac, mac_str, mac_len, MAC_BYTES);
96 status |= u64_to_hexstr (
id, id_str, id_len, ID_BYTES);
#define RD_ERROR_NULL
Null Pointer.
uint32_t rd_status_t
bitfield for representing errors
#define RD_ERROR_INVALID_LENGTH
Invalid Length.
#define RD_SUCCESS
Internal Error.
#define RD_ERROR_INVALID_STATE
Invalid state, operation disallowed in this state.
bool ri_radio_is_init()
Check if radio is initialized.
rd_status_t ri_radio_address_get(uint64_t *const address)
rd_status_t rt_com_get_mac_str(char *const mac_str, const size_t mac_len)
Get MAC address of the device from radio driver and write it to given string.
rd_status_t rt_com_get_id_str(char *const id_str, const size_t id_len)
Get Unique ID of the device and write it to given string.
Header to enable and disable module compilation.
Ruuvi error codes and error check function.
#define BITS_PER_BYTE
Number of bits in a byte.
Ruuvi sensor interface Lifecycle: Beta
rd_status_t ri_comm_id_get(uint64_t *const id)
Helper functions for communication.