forked from nrfconnect/sdk-nrf
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathzigbee_error_handler.h
More file actions
83 lines (72 loc) · 2.06 KB
/
Copy pathzigbee_error_handler.h
File metadata and controls
83 lines (72 loc) · 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/*
* Copyright (c) 2020 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
*/
/**
* @file
* @defgroup zb_error ZBOSS error handling utilities
* @{
* @brief This file defines the error handler utilities for ZBOSS error codes.
*/
#ifndef ZIGBEE_ERROR_HANDLER_H__
#define ZIGBEE_ERROR_HANDLER_H__
#include <kernel.h>
#include <zboss_api.h>
#include <zb_errors.h>
#ifdef CONFIG_ZBOSS_ERROR_PRINT_TO_LOG
#include "zb_error_to_string.h"
#include <logging/log.h>
/**@brief Macro for calling the error handler function if the supplied
* ZBOSS return code is different than RET_OK.
*
* @param[in] ERR_CODE Error code supplied to the error handler.
*/
#define ZB_ERROR_CHECK(ERR_CODE) \
do { \
const uint32_t LOCAL_ERR_CODE = (uint32_t) (-ERR_CODE); \
if (LOCAL_ERR_CODE != RET_OK) { \
LOG_ERR("ERROR %u [%s] at %s:%u", \
LOCAL_ERR_CODE, \
zb_error_to_string_get(LOCAL_ERR_CODE), \
__FILE__, \
__LINE__); \
k_fatal_halt(K_ERR_KERNEL_PANIC); \
} \
} while (0)
/**@brief Macro for calling the error handler function
* if the return code for bdb_start_top_level_commissioning
* indicates that the BDB procedure did not succeed.
*
* @param[in] COMM_STATUS Value returned by the
* bdb_start_top_level_commissioning function.
*/
#define ZB_COMM_STATUS_CHECK(COMM_STATUS) \
do { \
if (COMM_STATUS != ZB_TRUE) { \
LOG_ERR("Unable to start BDB commissioning at %s:%u", \
__FILE__, \
__LINE__); \
ZB_ERROR_CHECK(RET_ERROR); \
} \
} while (0)
#else
#define ZB_ERROR_CHECK(ERR_CODE) \
do { \
const uint32_t LOCAL_ERR_CODE = (uint32_t) (-ERR_CODE); \
if (LOCAL_ERR_CODE != RET_OK) { \
k_fatal_halt(K_ERR_KERNEL_PANIC); \
} \
} while (0)
#define ZB_COMM_STATUS_CHECK(COMM_STATUS) \
do { \
if (COMM_STATUS != ZB_TRUE) { \
ZB_ERROR_CHECK(RET_ERROR); \
} \
} while (0)
#endif
/**
* @}
*
*/
#endif /* ZIGBEE_ERROR_HANDLER_H__ */