1 /*
2  * Copyright (c) 2020 - 2023, Nordic Semiconductor ASA
3  * All rights reserved.
4  *
5  * SPDX-License-Identifier: BSD-3-Clause
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions are met:
9  *
10  * 1. Redistributions of source code must retain the above copyright notice, this
11  *    list of conditions and the following disclaimer.
12  *
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in the
15  *    documentation and/or other materials provided with the distribution.
16  *
17  * 3. Neither the name of Nordic Semiconductor ASA nor the names of its
18  *    contributors may be used to endorse or promote products derived from this
19  *    software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23  * IMPLIED WARRANTIES OF MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE
24  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
25  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31  * POSSIBILITY OF SUCH DAMAGE.
32  *
33  */
34 
35 /**
36  * @defgroup nrf_802154_serialization_error
37  * 802.15.4 radio driver serialization error handler
38  * @{
39  *
40  */
41 
42 #ifndef NRF_802154_SERIALIZATION_ERROR_H_
43 #define NRF_802154_SERIALIZATION_ERROR_H_
44 
45 #include <stdint.h>
46 
47 #ifdef __cplusplus
48 extern "C" {
49 #endif
50 
51 /**
52  * @brief No error.
53  */
54 #define NRF_802154_SERIALIZATION_ERROR_OK               (0)
55 
56 /**
57  * @brief Error was reported by backend.
58  */
59 #define NRF_802154_SERIALIZATION_ERROR_BACKEND_FAILURE  (-1)
60 
61 /**
62  * @brief Error was reported by spinel data packing layer.
63  */
64 #define NRF_802154_SERIALIZATION_ERROR_ENCODING_FAILURE (-2)
65 
66 /**
67  * @brief Error was reported by spinel data unpacking layer.
68  */
69 #define NRF_802154_SERIALIZATION_ERROR_DECODING_FAILURE (-3)
70 
71 /**
72  * @brief Invalid command response was received.
73  */
74 #define NRF_802154_SERIALIZATION_ERROR_RESPONSE_INVALID (-4)
75 
76 /**
77  * @brief Timeout occured when waiting for command response.
78  */
79 #define NRF_802154_SERIALIZATION_ERROR_RESPONSE_TIMEOUT (-5)
80 
81 /**
82  * @brief Initialization of spinel serialization failed.
83  */
84 #define NRF_802154_SERIALIZATION_ERROR_INIT_FAILED      (-6)
85 
86 /**
87  * @brief Received command with invalid arguments.
88  */
89 #define NRF_802154_SERIALIZATION_ERROR_REQUEST_INVALID  (-7)
90 
91 /**
92  * @brief Frame buffering reported an error.
93  */
94 #define NRF_802154_SERIALIZATION_ERROR_INVALID_BUFFER   (-8)
95 
96 /**
97  * @brief Insufficient amount of memory reported by frame buffering.
98  */
99 #define NRF_802154_SERIALIZATION_ERROR_NO_MEMORY        (-9)
100 
101 /**
102  * @brief Datatype for nrf_802154 serialization error reason.
103  */
104 typedef int32_t nrf_802154_ser_err_t;
105 
106 /**
107  * @brief Struct with nrf_802154 serialization error description.
108  */
109 typedef struct
110 {
111     /**
112      * @brief Reason of the reported error.
113      */
114     nrf_802154_ser_err_t reason;
115 } nrf_802154_ser_err_data_t;
116 
117 /**
118  * @brief Notifies any serialization related errors to the next higher layer.
119  *
120  * @param[in]  p_err  Pointer to a @ref nrf_802154_ser_err_data_t with error description.
121  *
122  */
123 extern void nrf_802154_serialization_error(const nrf_802154_ser_err_data_t * p_err);
124 
125 #ifdef __cplusplus
126 }
127 #endif
128 
129 #endif /* NRF_802154_SERIALIZATION_ERROR_H_ */
130 
131 /** @} */
132