Document

TS004-2.0.0 Fragmented Data Block Transport

Issue link: https://read.uberflip.com/i/1464683

Contents of this Issue

Navigation

Page 30 of 31

LoRaWAN ® Fragmented Data Block Transport Specification TS004-2.0.0 ©2022 LoRa Alliance ® Page 31 of 32 The authors reserve the right to change specifications without notice. A.5 Preliminary MATLAB Code 798 799 This MATLAB code generates a list of coded fragments from an arbitrary binary file 800 notation: 801 802 w = 32; %the number of fragments into which the binary file is split 803 fragment_size=10; %the size of each fragment in bytes 804 DATA; %a vector of bytes = the binary file to be sent. The length must be 805 w*fragment_size 806 807 The encoding process in MATLAB: 808 809 w = 32; %number of uncoded fragments 810 fragment_size=10; %nb of bytes per fragment 811 fprintf('\n number of uncoded fragments:%d, fragment size (bytes):%d bytes\n total 812 broacast size %d bytes\n',w,fragment_size,w*fragment_size); 813 814 DATA = mod([0:w*fragment_size-1],256); %arbitrary binary file to be sent 815 816 % start of the fragmentation and encoding process 817 % UNCODED_F is an array of uncoded fragments 818 UNCODED_F = zeros(w,fragment_size); 819 for k=1:w 820 UNCODED_F(k,:) = DATA( (k-1)*fragment_size+1:k*fragment_size); 821 end 822 823 824 % now encode. 825 % we will create 2w CODED fragments, this number is arbitrary. Those can be 826 generated by the transmitter on the fly one by one. 827 CODED_F = []; % this will contain the array of 2w coded fragments 828 829 %then we add w parity check fragments 830 for y=1:2*w 831 s=zeros(1,fragment_size); 832 A = matrix_line(y,w); %line y of w.w matrix 833 for x=1:w 834 if (A(x) == 1) %if bit x is set to 1 then xor the corresponding fragment 835 s = bitxor(s,UNCODED_F(x,:)); 836 end 837 end 838 CODED_F = [CODED_F ; s]; % add the resulting coded fragment to the list 839 end 840 841 The MATLAB code of the matrix_line function generating a parity check vector: 842 843 %this funciton returns line N of the MxM parity matrix 844 function matrix_line = matrix_line(N,M) 845 matrix_line = zeros(1,M); 846 847 if (N <= M) %the first N coded fragments are equal to the uncoded fragments (binary 848 data without coding) 849 matrix_line(N) = 1 850 return 851 end 852 853 % we must treat powers of 2 differently to make sure mtrix content is close 854 % to random . Powers of 2 tend to generate patterns 855 if (M == 2^floor(log2(M))) % if M is a power of 2 856 m=1; 857 else 858

Articles in this issue

view archives of Document - TS004-2.0.0 Fragmented Data Block Transport