Exportable version of WizziLab's modem driver.
include/alp_helpers.h@27:918293e12f1b, 2018-03-05 (annotated)
- Committer:
- Jeej
- Date:
- Mon Mar 05 16:46:05 2018 +0000
- Revision:
- 27:918293e12f1b
- Parent:
- 19:701d5669f2e9
- Child:
- 37:f5424d109c6d
Activated dynamic ISM band selection for LoRaWAN.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Jeej | 0:027760f45e2c | 1 | /// @copyright |
Jeej | 0:027760f45e2c | 2 | /// ========================================================================={{{ |
Jeej | 0:027760f45e2c | 3 | /// Copyright (c) 2012-2013 WizziLab / |
Jeej | 0:027760f45e2c | 4 | /// All rights reserved / |
Jeej | 0:027760f45e2c | 5 | /// / |
Jeej | 0:027760f45e2c | 6 | /// IMPORTANT: This Software may not be modified, copied or distributed unless / |
Jeej | 0:027760f45e2c | 7 | /// embedded on a WizziLab product. Other than for the foregoing purpose, this / |
Jeej | 0:027760f45e2c | 8 | /// Software and/or its documentation may not be used, reproduced, copied, / |
Jeej | 0:027760f45e2c | 9 | /// prepared derivative works of, modified, performed, distributed, displayed / |
Jeej | 0:027760f45e2c | 10 | /// or sold for any purpose. For the sole purpose of embedding this Software / |
Jeej | 0:027760f45e2c | 11 | /// on a WizziLab product, copy, modification and distribution of this / |
Jeej | 0:027760f45e2c | 12 | /// Software is granted provided that the following conditions are respected: / |
Jeej | 0:027760f45e2c | 13 | /// / |
Jeej | 0:027760f45e2c | 14 | /// * Redistributions of source code must retain the above copyright notice, / |
Jeej | 0:027760f45e2c | 15 | /// this list of conditions and the following disclaimer / |
Jeej | 0:027760f45e2c | 16 | /// / |
Jeej | 0:027760f45e2c | 17 | /// * Redistributions in binary form must reproduce the above copyright / |
Jeej | 0:027760f45e2c | 18 | /// notice, this list of conditions and the following disclaimer in the / |
Jeej | 0:027760f45e2c | 19 | /// documentation and/or other materials provided with the distribution. / |
Jeej | 0:027760f45e2c | 20 | /// / |
Jeej | 0:027760f45e2c | 21 | /// * The name of WizziLab can not be used to endorse or promote products / |
Jeej | 0:027760f45e2c | 22 | /// derived from this software without specific prior written permission. / |
Jeej | 0:027760f45e2c | 23 | /// / |
Jeej | 0:027760f45e2c | 24 | /// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS / |
Jeej | 0:027760f45e2c | 25 | /// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED / |
Jeej | 0:027760f45e2c | 26 | /// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR / |
Jeej | 0:027760f45e2c | 27 | /// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR / |
Jeej | 0:027760f45e2c | 28 | /// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, / |
Jeej | 0:027760f45e2c | 29 | /// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, / |
Jeej | 0:027760f45e2c | 30 | /// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, / |
Jeej | 0:027760f45e2c | 31 | /// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY / |
Jeej | 0:027760f45e2c | 32 | /// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING / |
Jeej | 0:027760f45e2c | 33 | /// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS / |
Jeej | 0:027760f45e2c | 34 | /// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. / |
Jeej | 0:027760f45e2c | 35 | /// WIZZILAB HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, / |
Jeej | 0:027760f45e2c | 36 | /// ENHANCEMENTS OR MODIFICATIONS. / |
Jeej | 0:027760f45e2c | 37 | /// / |
Jeej | 0:027760f45e2c | 38 | /// Should you have any questions regarding your right to use this Software, / |
Jeej | 0:027760f45e2c | 39 | /// contact WizziLab at www.wizzilab.com. / |
Jeej | 0:027760f45e2c | 40 | /// / |
Jeej | 0:027760f45e2c | 41 | /// =========================================================================}}} |
Jeej | 0:027760f45e2c | 42 | /// @endcopyright |
Jeej | 0:027760f45e2c | 43 | |
Jeej | 0:027760f45e2c | 44 | // ======================================================================= |
Jeej | 0:027760f45e2c | 45 | /// @file alp_helpers.h |
Jeej | 0:027760f45e2c | 46 | /// @defgroup ALP |
Jeej | 0:027760f45e2c | 47 | /// @brief ALP helpers functions |
Jeej | 0:027760f45e2c | 48 | // ======================================================================= |
Jeej | 0:027760f45e2c | 49 | |
Jeej | 0:027760f45e2c | 50 | #ifndef __ALP_HELPERS_H__ |
Jeej | 0:027760f45e2c | 51 | #define __ALP_HELPERS_H__ |
Jeej | 0:027760f45e2c | 52 | |
Jeej | 0:027760f45e2c | 53 | #include "hal_types.h" |
Jeej | 0:027760f45e2c | 54 | //====================================================================== |
Jeej | 0:027760f45e2c | 55 | //====================================================================== |
Jeej | 0:027760f45e2c | 56 | // ALP Helpers |
Jeej | 0:027760f45e2c | 57 | //====================================================================== |
Jeej | 0:027760f45e2c | 58 | //====================================================================== |
Jeej | 0:027760f45e2c | 59 | typedef struct { |
Jeej | 0:027760f45e2c | 60 | u8* data; // data |
Jeej | 0:027760f45e2c | 61 | int type; |
Jeej | 0:027760f45e2c | 62 | union |
Jeej | 0:027760f45e2c | 63 | { |
Jeej | 0:027760f45e2c | 64 | struct { |
Jeej | 0:027760f45e2c | 65 | u32 length; |
Jeej | 0:027760f45e2c | 66 | u32 offset; |
Jeej | 0:027760f45e2c | 67 | u8 fid; |
Jeej | 0:027760f45e2c | 68 | } f_data; |
Jeej | 0:027760f45e2c | 69 | struct { |
Jeej | 0:027760f45e2c | 70 | u32 length; |
Jeej | 0:027760f45e2c | 71 | u32 offset; |
Jeej | 0:027760f45e2c | 72 | u8 fid; |
Jeej | 0:027760f45e2c | 73 | } f_prop; |
Jeej | 0:027760f45e2c | 74 | struct { |
Jeej | 0:027760f45e2c | 75 | s8 code; |
Jeej | 0:027760f45e2c | 76 | u8 id; // Action ID |
Jeej | 0:027760f45e2c | 77 | } status; |
Jeej | 0:027760f45e2c | 78 | struct { |
Jeej | 0:027760f45e2c | 79 | u32 length; |
Jeej | 0:027760f45e2c | 80 | u8 type; |
Jeej | 0:027760f45e2c | 81 | } itf; |
Jeej | 0:027760f45e2c | 82 | struct { |
Jeej | 0:027760f45e2c | 83 | u8 id; |
Jeej | 0:027760f45e2c | 84 | u8 eop; |
Jeej | 0:027760f45e2c | 85 | u8 err; |
Jeej | 0:027760f45e2c | 86 | } tag; |
Jeej | 0:027760f45e2c | 87 | struct { |
Jeej | 0:027760f45e2c | 88 | u8 type; |
Jeej | 0:027760f45e2c | 89 | u8 ifid; |
Jeej | 0:027760f45e2c | 90 | u8 per; |
Jeej | 0:027760f45e2c | 91 | } urc; |
Jeej | 0:027760f45e2c | 92 | } meta; |
Jeej | 0:027760f45e2c | 93 | } alp_parsed_chunk_t; |
Jeej | 0:027760f45e2c | 94 | |
Jeej | 0:027760f45e2c | 95 | //====================================================================== |
Jeej | 0:027760f45e2c | 96 | // alp_size |
Jeej | 0:027760f45e2c | 97 | //---------------------------------------------------------------------- |
Jeej | 0:027760f45e2c | 98 | /// @brief Return payload length of most ALP operations |
Jeej | 0:027760f45e2c | 99 | /// @param op : ALP Action amongst alp_opcodes_t |
Jeej | 0:027760f45e2c | 100 | /// @param offset : Associated Offset if relevant |
Jeej | 0:027760f45e2c | 101 | /// @param size : Associated Size if relevant |
Jeej | 0:027760f45e2c | 102 | /// @retval payload size in bytes |
Jeej | 0:027760f45e2c | 103 | //====================================================================== |
Jeej | 0:027760f45e2c | 104 | public uint alp_size(u8 op, u32 offset, u32 length); |
Jeej | 0:027760f45e2c | 105 | |
Jeej | 0:027760f45e2c | 106 | //====================================================================== |
Jeej | 0:027760f45e2c | 107 | // alp_encode_length |
Jeej | 0:027760f45e2c | 108 | //---------------------------------------------------------------------- |
Jeej | 0:027760f45e2c | 109 | /// @brief Encodes an ALP length/offset field |
Jeej | 0:027760f45e2c | 110 | /// @param p : pointer to the payload buffer |
Jeej | 0:027760f45e2c | 111 | /// @param len : value to be encoded |
Jeej | 0:027760f45e2c | 112 | /// @retval resulting payload size in bytes |
Jeej | 0:027760f45e2c | 113 | //====================================================================== |
Jeej | 0:027760f45e2c | 114 | public u8 alp_encode_length(u8* p, u32 len); |
Jeej | 0:027760f45e2c | 115 | |
Jeej | 0:027760f45e2c | 116 | //====================================================================== |
Jeej | 0:027760f45e2c | 117 | // alp_encode_length |
Jeej | 0:027760f45e2c | 118 | //---------------------------------------------------------------------- |
Jeej | 0:027760f45e2c | 119 | /// @brief Decodes an ALP length/offset field |
Jeej | 0:027760f45e2c | 120 | /// @param p : pointer to the pointer to payload buffer |
Jeej | 0:027760f45e2c | 121 | /// @param actp : pointer to ALP's Action Protocol Substitution flag |
Jeej | 0:027760f45e2c | 122 | /// Result amongst alp_actp_substitution_mode_t |
Jeej | 0:027760f45e2c | 123 | /// @retval decoded value |
Jeej | 0:027760f45e2c | 124 | //====================================================================== |
Jeej | 0:027760f45e2c | 125 | public u32 alp_decode_length(u8** p, u8* actp); |
Jeej | 0:027760f45e2c | 126 | |
Jeej | 0:027760f45e2c | 127 | //====================================================================== |
Jeej | 0:027760f45e2c | 128 | // alp_parse_chunk |
Jeej | 0:027760f45e2c | 129 | //---------------------------------------------------------------------- |
Jeej | 0:027760f45e2c | 130 | /// @brief Parses an ALP response payload to a more generic |
Jeej | 0:027760f45e2c | 131 | /// alp_parsed_chunk_t structure. |
Jeej | 0:027760f45e2c | 132 | /// @param payload : pointer to the pointer to payload buffer |
Jeej | 0:027760f45e2c | 133 | /// @param resp : pointer to alp_parsed_chunk_t structure |
Jeej | 0:027760f45e2c | 134 | /// @retval number of parsed bytes |
Jeej | 0:027760f45e2c | 135 | //====================================================================== |
Jeej | 0:027760f45e2c | 136 | public int alp_parse_chunk(u8** payload, alp_parsed_chunk_t* resp); |
Jeej | 0:027760f45e2c | 137 | |
Jeej | 11:a077da5fe68f | 138 | |
Jeej | 11:a077da5fe68f | 139 | |
Jeej | 0:027760f45e2c | 140 | #endif // __ALP_HELPERS_H__ |