1 /*!
2  * \file      LmhpFragmentation.h
3  *
4  * \brief     Implements the LoRa-Alliance fragmented data block transport package
5  *            Specification: https://lora-alliance.org/sites/default/files/2018-09/fragmented_data_block_transport_v1.0.0.pdf
6  *
7  * \copyright Revised BSD License, see section \ref LICENSE.
8  *
9  * \code
10  *                ______                              _
11  *               / _____)             _              | |
12  *              ( (____  _____ ____ _| |_ _____  ____| |__
13  *               \____ \| ___ |    (_   _) ___ |/ ___)  _ \
14  *               _____) ) ____| | | || |_| ____( (___| | | |
15  *              (______/|_____)_|_|_| \__)_____)\____)_| |_|
16  *              (C)2013-2018 Semtech
17  *
18  * \endcode
19  *
20  * \author    Miguel Luis ( Semtech )
21  */
22 #ifndef __LMHP_FRAGMENTATION_H__
23 #define __LMHP_FRAGMENTATION_H__
24 
25 #include "LoRaMac.h"
26 #include "LmHandlerTypes.h"
27 #include "LmhPackage.h"
28 #include "FragDecoder.h"
29 
30 /*!
31  * Fragmentation data block transport package identifier.
32  *
33  * \remark This value must be unique amongst the packages
34  */
35 #define PACKAGE_ID_FRAGMENTATION                    3
36 
37 /*!
38  * Fragmentation package parameters
39  */
40 typedef struct LmhpFragmentationParams_s
41 {
42 #if( FRAG_DECODER_FILE_HANDLING_NEW_API == 1 )
43     /*!
44      * FragDecoder Write/Read function callbacks
45      */
46     FragDecoderCallbacks_t DecoderCallbacks;
47 #else
48     /*!
49      * Pointer to the un-fragmented received buffer.
50      */
51     uint8_t *Buffer;
52     /*!
53      * Size of the un-fragmented received buffer.
54      */
55     uint32_t BufferSize;
56 #endif
57     /*!
58      * Notifies the progress of the current fragmentation session
59      *
60      * \param [IN] fragCounter Fragment counter
61      * \param [IN] fragNb      Number of fragments
62      * \param [IN] fragSize    Size of fragments
63      * \param [IN] fragNbLost  Number of lost fragments
64      */
65     void ( *OnProgress )( uint16_t fragCounter, uint16_t fragNb, uint8_t fragSize, uint16_t fragNbLost );
66 #if( FRAG_DECODER_FILE_HANDLING_NEW_API == 1 )
67     /*!
68      * Notifies that the fragmentation session is finished
69      *
70      * \param [IN] status Fragmentation session status [FRAG_SESSION_ONGOING,
71      *                                                  FRAG_SESSION_FINISHED or
72      *                                                  FragDecoder.Status.FragNbLost]
73      * \param [IN] size   Received file size
74      */
75     void ( *OnDone )( int32_t status, uint32_t size );
76 #else
77     /*!
78      * Notifies that the fragmentation session is finished
79      *
80      * \param [IN] status Fragmentation session status [FRAG_SESSION_ONGOING,
81      *                                                  FRAG_SESSION_FINISHED or
82      *                                                  FragDecoder.Status.FragNbLost]
83      * \param [IN] file   Pointer to the reception file buffer
84      * \param [IN] size   Received file size
85      */
86     void ( *OnDone )( int32_t status, uint8_t *file, uint32_t size );
87 #endif
88 }LmhpFragmentationParams_t;
89 
90 LmhPackage_t *LmhpFragmentationPackageFactory( void );
91 
92 #endif // __LMHP_FRAGMENTATION_H__
93