Zephyr API Documentation  3.6.0
A Scalable Open Source RTOS
3.6.0
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
lwm2m_path.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2020 Endian Technologies AB
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7#ifndef ZEPHYR_INCLUDE_NET_LWM2M_PATH_H_
8#define ZEPHYR_INCLUDE_NET_LWM2M_PATH_H_
9
40#define LWM2M_PATH(...) \
41 LWM2M_PATH_MACRO(__VA_ARGS__, LWM2M_PATH4, LWM2M_PATH3, \
42 LWM2M_PATH2, LWM2M_PATH1)(__VA_ARGS__)
43
44
46/* Internal helper macros for the LWM2M_PATH macro */
47#define LWM2M_PATH_VA_NUM_ARGS(...) \
48 LWM2M_PATH_VA_NUM_ARGS_IMPL(__VA_ARGS__, 5, 4, 3, 2, 1)
49#define LWM2M_PATH_VA_NUM_ARGS_IMPL(_1, _2, _3, _4, N, ...) N
50
51#define LWM2M_PATH1(_x) #_x
52#define LWM2M_PATH2(_x, _y) #_x "/" #_y
53#define LWM2M_PATH3(_x, _y, _z) #_x "/" #_y "/" #_z
54#define LWM2M_PATH4(_a, _x, _y, _z) #_a "/" #_x "/" #_y "/" #_z
55
56#define LWM2M_PATH_MACRO(_1, _2, _3, _4, NAME, ...) NAME
78#define LWM2M_OBJ(...) \
79 GET_OBJ_MACRO(__VA_ARGS__, LWM2M_OBJ4, LWM2M_OBJ3, LWM2M_OBJ2, LWM2M_OBJ1)(__VA_ARGS__)
80
82/* Internal helper macros for the LWM2M_OBJ macro */
83#define GET_OBJ_MACRO(_1, _2, _3, _4, NAME, ...) NAME
84#define LWM2M_OBJ1(oi) (struct lwm2m_obj_path) {.obj_id = oi, .level = 1}
85#define LWM2M_OBJ2(oi, oii) (struct lwm2m_obj_path) {.obj_id = oi, .obj_inst_id = oii, .level = 2}
86#define LWM2M_OBJ3(oi, oii, ri) (struct lwm2m_obj_path) \
87 {.obj_id = oi, .obj_inst_id = oii, .res_id = ri, .level = 3}
88#define LWM2M_OBJ4(oi, oii, ri, rii) (struct lwm2m_obj_path) \
89 {.obj_id = oi, .obj_inst_id = oii, .res_id = ri, .res_inst_id = rii, .level = 4}
94#endif /* ZEPHYR_INCLUDE_NET_LWM2M_PATH_H_ */