Document

LoRaWAN® Fragmented Data Block Transport Specification v1.0.0

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

Contents of this Issue

Navigation

Page 25 of 29

LoRaWAN Fragmented Data Block Transport v1.0.0 Specification ©2018 LoRa Alliance™ Page 26 of 30 The authors reserve the right to change specifications without notice. 11 Preliminary Matlab code 619 620 621 This matlab code generates a list of coded fragments from an arbitrary binary file 622 Notations: 623 w = 32; %the number of fragments into which the binary file is split 624 fragment_size=10; %the size of each fragment in bytes 625 DATA; %a vector of bytes = the binary file to be sent. The length must be 626 w*fragment_size 627 628 629 630 Encoding process in matlab 631 632 633 w = 32; %number of uncoded fragments 634 fragment_size=10; %nb of bytes per fragment 635 fprintf('\n number of uncoded fragments:%d, fragment size (bytes):%d bytes\n total 636 broacast size %d bytes\n',w,fragment_size,w*fragment_size); 637 638 DATA = mod([0:w*fragment_size-1],256); %arbitrary binary file to be sent 639 640 % start of the fragmentation and encoding process 641 % UNCODED_F is an array of uncoded fragments 642 UNCODED_F = zeros(w,fragment_size); 643 for k=1:w 644 UNCODED_F(k,:) = DATA( (k-1)*fragment_size+1:k*fragment_size); 645 end 646 647 648 % now encode. 649 % we will create 2w CODED fragments, this number is arbitrary. Those can be 650 generated by the transmitter on the fly one by one. 651 CODED_F = []; % this will contain the array of 2w coded fragments 652 for y=1:w 653 CODED_F(y,:) = UNCODED_F(y,:); %the first w coded fragments are equal to the 654 uncoded fragments (binary data without coding) 655 end 656 %then we add w parity check fragments 657 for y=1:w 658 s=zeros(1,fragment_size); 659 A = matrix_line(y,w); %line y of w.w matrix 660 for x=1:w 661 if (A(x) == 1) %if bit x is set to 1 then xor the corresponding fragment 662 s = bitxor(s,UNCODED_F(x,:)); 663 end 664 end 665 CODED_F = [CODED_F ; s]; % add the resulting coded fragment to the list 666 end 667 668 669 Matlab code of the matrix_line function generating a parity check vector: 670 %this funciton returns line N of the MxM parity matrix 671 function matrix_line = matrix_line(N,M) 672 matrix_line = zeros(1,M); 673 s=0; 674 675 % we must treat powers of 2 differently to make sure mtrix content is close 676 % to random . Powers of 2 tend to generate patterns 677 if (M == 2^floor(log2(M))) % if M is a power of 2 678

Articles in this issue

view archives of Document - LoRaWAN® Fragmented Data Block Transport Specification v1.0.0