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 #ifdef __cplusplus 26 extern "C" { 27 #endif 28 29 #include "LoRaMac.h" 30 #include "LmHandlerTypes.h" 31 #include "LmhPackage.h" 32 #include "FragDecoder.h" 33 34 /*! 35 * Fragmentation data block transport package identifier. 36 * 37 * \remark This value must be unique amongst the packages 38 */ 39 #define PACKAGE_ID_FRAGMENTATION 3 40 41 /*! 42 * Fragmentation package parameters 43 */ 44 typedef struct LmhpFragmentationParams_s 45 { 46 #if( FRAG_DECODER_FILE_HANDLING_NEW_API == 1 ) 47 /*! 48 * FragDecoder Write/Read function callbacks 49 */ 50 FragDecoderCallbacks_t DecoderCallbacks; 51 #else 52 /*! 53 * Pointer to the un-fragmented received buffer. 54 */ 55 uint8_t *Buffer; 56 /*! 57 * Size of the un-fragmented received buffer. 58 */ 59 uint32_t BufferSize; 60 #endif 61 /*! 62 * Notifies the progress of the current fragmentation session 63 * 64 * \param [IN] fragCounter Fragment counter 65 * \param [IN] fragNb Number of fragments 66 * \param [IN] fragSize Size of fragments 67 * \param [IN] fragNbLost Number of lost fragments 68 */ 69 void ( *OnProgress )( uint16_t fragCounter, uint16_t fragNb, uint8_t fragSize, uint16_t fragNbLost ); 70 #if( FRAG_DECODER_FILE_HANDLING_NEW_API == 1 ) 71 /*! 72 * Notifies that the fragmentation session is finished 73 * 74 * \param [IN] status Fragmentation session status [FRAG_SESSION_ONGOING, 75 * FRAG_SESSION_FINISHED or 76 * FragDecoder.Status.FragNbLost] 77 * \param [IN] size Received file size 78 */ 79 void ( *OnDone )( int32_t status, uint32_t size ); 80 #else 81 /*! 82 * Notifies that the fragmentation session is finished 83 * 84 * \param [IN] status Fragmentation session status [FRAG_SESSION_ONGOING, 85 * FRAG_SESSION_FINISHED or 86 * FragDecoder.Status.FragNbLost] 87 * \param [IN] file Pointer to the reception file buffer 88 * \param [IN] size Received file size 89 */ 90 void ( *OnDone )( int32_t status, uint8_t *file, uint32_t size ); 91 #endif 92 }LmhpFragmentationParams_t; 93 94 LmhPackage_t *LmhpFragmentationPackageFactory( void ); 95 96 #ifdef __cplusplus 97 } 98 #endif 99 100 #endif // __LMHP_FRAGMENTATION_H__ 101