Meach will / libmDot-mbed5

Dependents:   ncu_project

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers FragmentationSession.h Source File

FragmentationSession.h

00001 /**********************************************************************
00002 * COPYRIGHT 2018 MULTI-TECH SYSTEMS, INC.
00003 *
00004 * ALL RIGHTS RESERVED BY AND FOR THE EXCLUSIVE BENEFIT OF
00005 * MULTI-TECH SYSTEMS, INC.
00006 *
00007 * MULTI-TECH SYSTEMS, INC. - CONFIDENTIAL AND PROPRIETARY
00008 * INFORMATION AND/OR TRADE SECRET.
00009 *
00010 * NOTICE: ALL CODE, PROGRAM, INFORMATION, SCRIPT, INSTRUCTION,
00011 * DATA, AND COMMENT HEREIN IS AND SHALL REMAIN THE CONFIDENTIAL
00012 * INFORMATION AND PROPERTY OF MULTI-TECH SYSTEMS, INC.
00013 * USE AND DISCLOSURE THEREOF, EXCEPT AS STRICTLY AUTHORIZED IN A
00014 * WRITTEN AGREEMENT SIGNED BY MULTI-TECH SYSTEMS, INC. IS PROHIBITED.
00015 *
00016 ***********************************************************************/
00017 
00018 #ifndef _FRAGMENTATION_SESSION_H
00019 #define _FRAGMENTATION_SESSION_H
00020 #ifdef FOTA
00021 
00022 #include "mbed.h"
00023 #include "FragmentationMath.h"
00024 #include "mDot.h"
00025 #include "WriteFile.h"
00026 
00027 #define MAX_PARITY 300
00028 #define FRAG_OFFSET 3
00029 #define MULTICAST_SESSIONS 3
00030 
00031 class FragmentationSession {
00032 
00033     public:
00034         FragmentationSession(mDot* dot, std::vector<uint8_t>* ret, bool* filled, uint32_t* delay);
00035         ~FragmentationSession();
00036         void processCmd(uint8_t* payload, uint8_t size);
00037         void reset();
00038 
00039     private:
00040 
00041         typedef struct {
00042             uint8_t  Padding;
00043             uint8_t  FragmentSize;
00044             uint16_t NumberOfFragments;
00045         } FragmentationSessionOpts_t;
00046 
00047         typedef struct {
00048             bool reset;
00049             bool failed;
00050             uint8_t fragMatrix;
00051             uint8_t blockAckDelay;
00052             uint8_t total_sessions;
00053             uint8_t mcGroupBitMask;
00054             uint8_t current_session;
00055             uint16_t index;
00056             uint16_t last_frag_num;
00057             uint32_t total_frags;
00058             FragmentationMath* math;
00059             FragmentationSessionOpts_t opts;
00060         } fragGroup;
00061 
00062 
00063         enum FragResult {
00064             FRAG_OK,
00065             FRAG_SIZE_INCORRECT,
00066             FRAG_FLASH_WRITE_ERROR,
00067             FRAG_NO_MEMORY,
00068             FRAG_COMPLETE
00069         };
00070 
00071         enum FragCmd {
00072             PACKAGE_VERSION_FRAG,
00073             FRAG_STATUS,
00074             FRAG_SESSION_SETUP,
00075             FRAG_SESSION_DELETE,
00076             DATA_FRAGMENT = 0x08,
00077             CHECKSUM = 0x80
00078         };
00079 
00080         void reset(uint16_t num);
00081         void upgradeFile(uint8_t fragIndex);
00082         bool process_frame(uint8_t fragIndex,uint16_t index, uint8_t buffer[], size_t size);
00083 
00084         mDot* _dot;
00085         WriteFile* _fh;
00086         fragGroup fg[MULTICAST_SESSIONS];
00087 
00088         uint8_t ans;
00089         bool* _filled;
00090         uint32_t* _delay;
00091         uint8_t fragIndex;
00092         std::vector<uint8_t>* _ret;
00093         std::string _org_class;
00094 };
00095 #endif
00096 #endif // _FRAGMENTATION_SESSION_H