VLCB SDK
An opinionated SDK for VLCB protocol
Loading...
Searching...
No Matches
node_new_number.c
Go to the documentation of this file.
1#include "vlcb/common/node.h"
2
3#include <assert.h>
4#include <stdbool.h>
5#include <stddef.h>
6
7bool IsNodeNumberValid(const VlcbNodeNumber addr) { return addr > 0; }
8
9int vlcb_defs_NewNodeNumber(const uint16_t val, VlcbNodeNumber *const addr) {
10 assert(addr != NULL);
11 const VlcbNodeNumber _addr = val;
12 if (IsNodeNumberValid(_addr)) {
13 *addr = _addr;
14 return 0;
15 }
16 return 1;
17}
18
19int vlcb_defs_NewNodeNumberFromBytes(const uint8_t hi, const uint8_t lo,
20 VlcbNodeNumber *const addr) {
21 const VlcbNodeNumber _addr =
23 if (IsNodeNumberValid(_addr)) {
24 *addr = _addr;
25 return 0;
26 }
27 return 1;
28}
uint16_t VlcbNodeNumber
Definition node.h:8
VlcbNodeNumber vlcb_defs_NewNodeNumberFromBytesUnchecked(uint8_t hi, uint8_t lo)
int vlcb_defs_NewNodeNumber(const uint16_t val, VlcbNodeNumber *const addr)
int vlcb_defs_NewNodeNumberFromBytes(const uint8_t hi, const uint8_t lo, VlcbNodeNumber *const addr)
bool IsNodeNumberValid(const VlcbNodeNumber addr)