WizziLab / modem_ref

Dependents:   modem_ref_helper

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers alp_helpers.h Source File

alp_helpers.h

Go to the documentation of this file.
00001 /// @copyright
00002 /// ========================================================================={{{
00003 /// Copyright (c) 2012-2020 WizziLab                                           /
00004 /// All rights reserved                                                        /
00005 ///                                                                            /
00006 /// =========================================================================}}}
00007 /// @endcopyright
00008 
00009 //  =======================================================================
00010 /// @file           alp_helpers.h
00011 /// @defgroup       ALP
00012 /// @brief          ALP helpers functions
00013 //  =======================================================================
00014 
00015 #ifndef __ALP_HELPERS_H__
00016 #define __ALP_HELPERS_H__
00017 
00018 #include "hal_types.h"
00019 
00020 //======================================================================
00021 //======================================================================
00022 //  ALP Helpers
00023 //======================================================================
00024 //======================================================================
00025 
00026 // Basic _public container for ALP payload.
00027 typedef struct {
00028     u32             len;
00029     u8              d[1];
00030 } alp_pub_payload_t;
00031 
00032 typedef struct {
00033     u8*             data;   // data
00034     int             type;
00035     union
00036     {
00037         struct {
00038             u32             length;
00039             u32             offset;
00040             u8              fid;
00041         } f_data;
00042         struct {
00043             u32             length;
00044             u32             offset;
00045             u8              fid;
00046         } f_prop;
00047         struct {
00048             s8              code;
00049             u8              id; // Action ID
00050         } status;
00051         struct {
00052             u8              itf;
00053             s8              err;
00054         } istatus;
00055         struct {
00056             u32             length;
00057             u8              type;
00058         } itf;
00059         struct {
00060             u8              id;
00061             u8              eop;
00062             u8              err;
00063         } tag;
00064         struct {
00065             u32             per;
00066             u8              type;
00067             u8              ifid;
00068         } urc;
00069     } meta;
00070 } alp_parsed_chunk_t;
00071 
00072 //======================================================================
00073 // alp_size
00074 //----------------------------------------------------------------------
00075 /// @brief Return payload length of most ALP operations
00076 /// @param op       : ALP Action amongst alp_opcodes_t
00077 /// @param offset   : Associated Offset if relevant
00078 /// @param size     : Associated Size if relevant
00079 /// @retval payload size in bytes
00080 //======================================================================
00081 uint alp_size(u8 op, u32 offset, u32 length);
00082 
00083 //======================================================================
00084 // alp_encode_length
00085 //----------------------------------------------------------------------
00086 /// @brief Encodes an ALP length/offset field
00087 /// @param p        : pointer to the payload buffer
00088 /// @param len      : value to be encoded
00089 /// @retval resulting payload size in bytes
00090 //======================================================================
00091 u8 alp_encode_length(u8* p, u32 len);
00092 
00093 //======================================================================
00094 // alp_encode_length
00095 //----------------------------------------------------------------------
00096 /// @brief Decodes an ALP length/offset field
00097 /// @param p        : pointer to the pointer to payload buffer
00098 /// @param actp     : pointer to ALP's Action Protocol Substitution flag
00099 ///                   Result amongst alp_actp_substitution_mode_t
00100 /// @retval decoded value
00101 //======================================================================
00102 u32 alp_decode_length(u8** p, u8* actp);
00103 
00104 //======================================================================
00105 // alp_parse_chunk
00106 //----------------------------------------------------------------------
00107 /// @brief Parses an ALP response payload to a more generic
00108 ///        alp_parsed_chunk_t structure.
00109 /// @param payload  : pointer to the pointer to payload buffer
00110 /// @param resp     : pointer to alp_parsed_chunk_t structure
00111 /// @retval number of parsed bytes
00112 //======================================================================
00113 int alp_parse_chunk(u8** payload, alp_parsed_chunk_t* resp);
00114 
00115 
00116 #endif // __ALP_HELPERS_H__