54typedef enum : uint8_t {
73typedef enum : uint8_t {
97 if ((digit >= (uint8_t)
'0') && (digit <= (uint8_t)
'9')) {
98 *out = (uint8_t)(digit - (uint8_t)
'0');
101 if ((digit >= (uint8_t)
'a') && (digit <= (uint8_t)
'f')) {
105 if ((digit >= (uint8_t)
'A') && (digit <= (uint8_t)
'F')) {
140 const size_t encoded = end - begin;
141 if ((encoded % 2U) != 0U) {
144 const size_t decoded = encoded / 2U;
145 if (decoded > capacity) {
148 for (
size_t index = 0U; index < decoded; ++index) {
157 output[index] = (char)((uint8_t)(high << 4U) | low);
159 output[decoded] =
'\0';
160 *out_length = decoded;
182 for (
size_t index = 0U; index < length; ++index) {
183 const uint8_t
byte = (uint8_t)text[index];
210 uint8_t ignored = 0U;
280 size_t separators[2] = {};
281 uint8_t separator_count = 0U;
284 if (line[index] == (uint8_t)
':') {
285 if (separator_count >= 2U) {
288 separators[separator_count] = index;
292 if (separator_count != 2U) {
296 size_t decoded_length = 0U;
303 candidate->
ssid_len = (uint8_t)decoded_length;
311 candidate->
psk_len = (uint8_t)decoded_length;
320 candidate->
url_len = (uint16_t)decoded_length;
343 if (line[index] !=
s_prefix[index]) {
352 if (credentials !=
nullptr) {
360 if (out ==
nullptr) {
364 if (line ==
nullptr) {
374 if (line[line_length - 1U] != (uint8_t)
'\n') {
407 if (uart ==
nullptr) {
410 if (uart->
write ==
nullptr) {
413 if (uart->
read ==
nullptr) {
416 if (uart->
wait_ms ==
nullptr) {
445 *newline_offset = 0U;
446 for (
size_t index = 0U; index < length; ++index) {
447 if (chunk[index] == (uint8_t)
'\n') {
448 *newline_offset = index;
480 size_t line_capacity,
485 bool complete =
false;
486 for (uint32_t elapsed = 0U; elapsed < timeout_ms; ++elapsed) {
487 size_t received = 0U;
488 const size_t remaining = line_capacity - used;
489 err = uart->
read(&line[used], remaining, &received);
493 if (received > remaining) {
497 size_t newline_offset = 0U;
499 used += newline_offset + 1U;
500 if ((newline_offset + 1U) != received) {
507 if (used == line_capacity) {
513 if ((err ==
k_ra8_ok) && !complete) {
524 if (out ==
nullptr) {
Annotation-attribute framework macros for ra8-firmware.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
Error Code Definitions for ra8-firmware.
@ k_ra8_err_invalid_arg
Invalid function argument.
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
@ k_ra8_err_null_ptr
Pointer was NULL where a valid pointer was required.
@ k_ra8_err_protocol_error
Protocol-level error (e.g.
@ k_ra8_err_timeout
Operation exceeded its time budget.
@ k_ra8_err_invalid_size
Invalid size parameter (too large, too small, or misaligned).
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
static bool internal_hex_nibble(uint8_t digit, uint8_t *out)
Decode one hexadecimal digit.
static ra8_err_t internal_receive_line(const ra8_net_provision_uart_t *uart, uint32_t timeout_ms, uint8_t *line, size_t line_capacity, size_t *line_length)
Receive exactly one newline-terminated provisioning record.
static ra8_err_t internal_decode_field(const uint8_t *line, size_t begin, size_t end, char *output, size_t capacity, size_t *out_length)
Decode one bounded hexadecimal field.
static ra8_err_t internal_validate_receiver(const ra8_net_provision_uart_t *uart, uint32_t timeout_ms)
Validate the injected receiver dependencies and timeout.
static ra8_err_t internal_decode_line(const uint8_t *line, size_t line_length, ra8_net_credentials_t *candidate)
Decode the three fields between already-validated framing bytes.
ra8_net_provision_text_byte_t
Control-byte boundaries rejected from decoded text fields.
@ k_ra8_net_provision_text_delete
ASCII DEL control byte.
@ k_ra8_net_provision_text_printable_min
First printable ASCII byte.
static bool internal_prefix_matches(const uint8_t *line)
Check the fixed version prefix without a libc comparison.
ra8_err_t ra8_net_provision_parse(const uint8_t *line, size_t line_length, ra8_net_credentials_t *out)
Parse one complete version-one ASCII-hex provisioning line.
static const uint8_t s_prefix[k_ra8_net_provision_prefix_bytes]
Exact protocol prefix, including the first field separator.
static bool internal_psk_is_hex(const char *psk)
Check whether a decoded 64-byte PSK contains only ASCII hex.
static ra8_err_t internal_validate_candidate(const ra8_net_credentials_t *candidate)
Validate decoded field lengths and string compatibility.
ra8_err_t ra8_net_provision_receive(const ra8_net_provision_uart_t *uart, uint32_t timeout_ms, ra8_net_credentials_t *out)
Prompt once and receive one provisioning line within a fixed timeout.
static bool internal_find_newline(const uint8_t *chunk, size_t length, size_t *newline_offset)
Locate a newline in one newly received chunk.
void ra8_net_provision_clear(ra8_net_credentials_t *credentials)
Explicitly erase one decoded credential record.
static bool internal_has_no_controls(const char *text, size_t length)
Check a decoded text field for C0 and DEL control bytes.
ra8_net_provision_hex_t
Numeric base of hexadecimal alphabet digits.
@ k_ra8_net_provision_hex_alpha_offset
Value represented by A or a.
Runtime network provisioning contract for EK-RA8D2 applications.
struct ra8_net_credentials ra8_net_credentials_t
struct ra8_net_provision_uart ra8_net_provision_uart_t
const char k_ra8_net_provision_ready_prompt[]
Exact non-secret line emitted before the receiver drains UART input.
@ k_ra8_net_provision_timeout_ms_max
Longest accepted receive timeout.
@ k_ra8_net_provision_psk_bytes_max
Maximum decoded PSK text bytes.
@ k_ra8_net_provision_ssid_bytes_max
Maximum decoded SSID bytes.
@ k_ra8_net_provision_line_bytes_max
Longest complete encoded line.
@ k_ra8_net_provision_prefix_bytes
Bytes in RA8NET1:.
@ k_ra8_net_provision_url_bytes_max
Maximum decoded optional URL.
Secure-comparison primitives for the crypto / secure-boot paths.
void ra8_secure_memzero(void *ptr, size_t len)
Securely zero a buffer such that the write cannot be optimised away.
uint8_t psk_len
Decoded PSK bytes, excluding the NUL.
char psk[k_ra8_net_provision_psk_bytes_max+1U]
NUL-terminated PSK storage.
uint16_t url_len
Decoded URL bytes, excluding the NUL.
char url[k_ra8_net_provision_url_bytes_max+1U]
NUL-terminated optional URL storage.
uint8_t ssid_len
Decoded SSID bytes, excluding the NUL.
char ssid[k_ra8_net_provision_ssid_bytes_max+1U]
NUL-terminated SSID storage.
ra8_net_provision_uart_read_fn read
Non-blocking input drain.
ra8_net_provision_wait_fn wait_ms
Incomplete-poll pacing operation.
ra8_net_provision_uart_write_fn write
Non-secret prompt transmitter.