📄 create_packet.m
字号:
function packet = create_packet(start_samples,stop_samples,compound_channel,... ch_len,chip_span,tx_bit,ths,scrambling,symbol_start,CODE_ID,L,TC,... FS_CONT,DATA_LENGTH,RSCODE,PACKET_LENGTH,BURST_LENGTH,SYMBOL_LENGTH,... samples,PLOT_DEBUG)%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%create preamble for user of interest[uoi_pre sfd_code N_sync N_sfd] = generate_preamble(L,CODE_ID);code_len = length(len31_preamble_code(CODE_ID));%the packet chunk that will be outputpacket = zeros(1,stop_samples-start_samples+1);%calculate length of preamble in samplespre_len_samples = (N_sync + N_sfd) * code_len * L * samples.chip; %check whether we need sth from data partif(stop_samples<=pre_len_samples) %upsample, apply pulse shape and multipath channel [rx_uoi] = get_preamble_signal(uoi_pre,compound_channel,... ch_len, chip_span, TC,... FS_CONT,PLOT_DEBUG); packet(1:end)=rx_uoi(start_samples:stop_samples);else temp_len = 0; %what we already have % Pre-construction of the data signal of interest [burst, burstlength] ... = condor_init_data_signal(FS_CONT, PACKET_LENGTH, ... TC,BURST_LENGTH,SYMBOL_LENGTH, ... ths, scrambling, samples, ... compound_channel); %first index into rx_data part start_idx = max(1,start_samples-pre_len_samples); % Get the data signal of interest [rx_data] ... = get_data_signal(PACKET_LENGTH, ... samples.burst, samples.symbol, burstlength, ... burst,ths,symbol_start,tx_bit); %do we also need sth from preamble ? if(start_samples <= pre_len_samples || start_idx < ch_len) %calculate preamble part %upsample, apply pulse shape and multipath channel [rx_uoi] = get_preamble_signal(uoi_pre,compound_channel,... ch_len, chip_span, TC,... FS_CONT,PLOT_DEBUG); %is a part of the packet from the preamble? if(start_samples <= pre_len_samples) %how much temp_len = length(rx_uoi)-(ch_len-1)-start_samples+1; packet(1:temp_len) = rx_uoi(start_samples:end-(ch_len-1)); end %do we need the overlap? if(start_idx < ch_len) %keep the overlapping part of the preamble overlap = rx_uoi(end-(ch_len-1)+1:end); %now we have to add the overlap from the multipath channel rx_data(1:ch_len-1) = rx_data(1:ch_len-1) + overlap; end clear rx_uoi; %free memory end %cat the part we still need% start_idx% temp_len% start_idx + stop_samples - start_samples - temp_len packet(temp_len+1:end) = rx_data(start_idx:start_idx + stop_samples - start_samples - temp_len);% if(length(packet)~=stop_samples-start_samples+1)% error('error while creating packet...');% endend
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -