Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
FragmentationMath.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_MATH_H 00019 #define _FRAGMENTATION_MATH_H 00020 #ifdef FOTA 00021 00022 #include "mbed.h" 00023 #include "mDot.h" 00024 #include "WriteFile.h" 00025 00026 #define FRAG_SESSION_ONGOING 0xffffffff 00027 #ifndef MAX_PARITY 00028 #define MAX_PARITY 300 00029 #endif 00030 class FragmentationMath 00031 { 00032 public: 00033 FragmentationMath(mDot* dot, uint16_t frame_count, uint8_t frame_size, WriteFile* fh); 00034 ~FragmentationMath(); 00035 bool Init(); 00036 int getLostFrameCount(); 00037 void reset(uint16_t fcount); 00038 void setFrameFound(uint16_t frameCounter); 00039 bool processParityFrag(uint16_t frameCounter, uint8_t *pFrag); 00040 00041 int FragmentationPrbs23(int x); 00042 bool IsPowerOfTwo(unsigned int x); 00043 int32_t FindMissingFrameIndex(uint16_t x); 00044 int32_t FindTrueFrameIndex(uint16_t x); 00045 void GetRowInFlash(int l, uint8_t *rowData); 00046 int FindFirstOne(uint8_t *boolData, int size); 00047 void StoreRowInFlash(uint8_t *rowData, int index); 00048 void XorLineData(uint8_t *dataL1, uint8_t *dataL2, int size); 00049 void XorLineBit(uint8_t *dataL1, uint8_t *dataL2, int size); 00050 void XorRowWithMatrix(uint8_t* row, int matrix_row_num); 00051 void FragmentationGetParityMatrixRow(int N, int M, uint8_t *matrixRow); 00052 void CondenseRow(uint8_t *row, int row_number, int start); 00053 void ExpandAndXorRow(uint8_t *row, int row_number); 00054 bool CheckIfMissing(int row_number, int index); 00055 void CompleteRow(int row_num); 00056 void printMatrix(); 00057 00058 uint8_t _frame_size; 00059 uint16_t _frame_count; 00060 uint16_t _max_parity; 00061 uint16_t numFramesMissing; 00062 uint16_t lastReceiveFrameCnt; 00063 00064 uint8_t *matrix; 00065 uint8_t *matrixRow; 00066 uint8_t *parity_frag; 00067 uint8_t *missingFrameIndex; 00068 uint8_t *frag_in_flash; 00069 00070 bool empty; 00071 int index_of_first; 00072 int matrix_row_num; 00073 int index; 00074 00075 mDot* _dot; 00076 WriteFile* _fh; 00077 }; 00078 #endif 00079 #endif // _FRAGMENTATION_MATH_H
Generated on Fri Jul 15 2022 21:40:31 by
1.7.2