Code covered by the BSD License  

Highlights from
Bluetooth Full Duplex Voice and Data Transmission

image thumbnail

Bluetooth Full Duplex Voice and Data Transmission

by

 

27 Aug 2002 (Updated )

Simulink® and Stateflow® model of a full duplex Bluetooth® communication link.

device_init.m
% Copyright 2002-2009 The MathWorks, Inc
Block=gcb;

% Calculate packec type

switch mask_packet_type
case 'DM1'
    Packet_Type=4; % two-way
case 'HV1'
    Packet_Type=6;
case 'HV2'
    Packet_Type=7;
case 'HV3'
    Packet_Type=8;
case 'SCORT'
    Packet_Type=13;
otherwise
    error('Unsupported packet type')
end

% Define Variables Used in Block Parameters

Slot_Ts = (1/1600); % Slot Sample rate
Max_Slot_Symbols=625;
Slot_Symbols=366;

% GMSK Modulator and hopping variables
BT_Hop_Seperation=1e6;
BT_Freq_Deviation=2*150e3;
Num_Hop_Frequencies=79;
BT_Samples_Per_Symbol=88;
Filter_Group_Delay=45;

% Tx mask variables
Tx_On_Samples=Slot_Symbols*BT_Samples_Per_Symbol;
Tx_Off_Samples=(Max_Slot_Symbols-Slot_Symbols)*BT_Samples_Per_Symbol;
Tx_Mask=[ones(Tx_On_Samples,1);zeros(Tx_Off_Samples,1)];

% Header Info
Slave_Address= [1 0 1]';
Packet_Type_Code= [1 0 1 0]';
Flow_Control= [1];
ARQ=[1];
Sequence=[1];
Access_Code=zeros(72,1); Access_Code(1:2:72)=1;

switch Device_Type
  case 1 % If device is the Master
    switch Packet_Type
		case 6 % HV1
            Tx_Ts=Slot_Ts*2;
            Frame_Ts=Tx_Ts;
            Num_Slots_Rate=2;
            Num_Payload_Bits=80;
            Tx_Slot_Enable_Phase=0; % Slot Pair
            Rx_Slot_Enable_Phase=1;
		case 7 % HV2
            Tx_Ts=Slot_Ts*4;
            Frame_Ts=Tx_Ts;
            Num_Slots_Rate=4;
            Num_Payload_Bits=160;
            if Slot_Pair == 3
                error('Slot 5&6 cannot be used as initial slot for HV2');
            end;
            Tx_Slot_Enable_Phase=Slot_Pair*2-2; % Slot Pair
            Rx_Slot_Enable_Phase=Tx_Slot_Enable_Phase+1;
		case 8 % HV3
            Tx_Ts=Slot_Ts*6;
            Frame_Ts=Tx_Ts;
            Num_Slots_Rate=6;
            Num_Payload_Bits=240;
            Tx_Slot_Enable_Phase=Slot_Pair*2-2; % Slot Pair
            Rx_Slot_Enable_Phase=Tx_Slot_Enable_Phase+1;
		case 13 % EV1
            Tx_Ts=Slot_Ts*2;
            Frame_Ts=Slot_Ts*6;
            Num_Slots_Rate=2;
            Num_Payload_Bits=240;
            Tx_Slot_Enable_Phase=0; % Slot Pair
            Rx_Slot_Enable_Phase=Tx_Slot_Enable_Phase+1;
        case 4 % DM1
            Tx_Ts=Slot_Ts*2;
            Frame_Ts=Tx_Ts;
            Num_Slots_Rate=2;
            Num_Payload_Bits=160;
            Tx_Slot_Enable_Phase=0; % Slot Pair
            Rx_Slot_Enable_Phase=1;
   end
  case 2 % If device is the Slave
    switch Packet_Type
		case 6 % HV1
            Tx_Ts=Slot_Ts*2;
            Frame_Ts=Tx_Ts;
            Num_Slots_Rate=2;
            Num_Payload_Bits=80;
            Rx_Slot_Enable_Phase=0; % Slot Pair
            Tx_Slot_Enable_Phase=1;
		case 7 % HV2
            Tx_Ts=Slot_Ts*4;
            Frame_Ts=Tx_Ts;
            Num_Slots_Rate=4;
            Num_Payload_Bits=160;
            if Slot_Pair == 3
                error('Slot 5&6 cannot be used as initial slot for HV2');
            end;
            Rx_Slot_Enable_Phase=Slot_Pair*2-2; % Slot Pair
            Tx_Slot_Enable_Phase=Rx_Slot_Enable_Phase+1;
		case 8 % HV3
            Tx_Ts=Slot_Ts*6;
            Frame_Ts=Tx_Ts;
            Num_Slots_Rate=6;
            Num_Payload_Bits=240;
            Rx_Slot_Enable_Phase=Slot_Pair*2-2; % Slot Pair
            Tx_Slot_Enable_Phase=Rx_Slot_Enable_Phase+1;
		case 13 % EV1
            Tx_Ts=Slot_Ts*2;
            Frame_Ts=Slot_Ts*6;
            Num_Slots_Rate=2;
            Num_Payload_Bits=240;
            Rx_Slot_Enable_Phase=0; % Slot Pair
            Tx_Slot_Enable_Phase=Rx_Slot_Enable_Phase+1;
         case 4 % DM1
            Tx_Ts=Slot_Ts*2;
            Frame_Ts=Tx_Ts;
            Num_Slots_Rate=2;
            Num_Payload_Bits=160;
            Rx_Slot_Enable_Phase=0; % Slot Pair
            Tx_Slot_Enable_Phase=1;
    end
end

% Set wave file names
set_param([Block,'/Audio source and speech coding/From Wave File'],'FileName',Input_File_Name);
set_param([Block,'/Speech decoding and audio sink/To Wave File'],'FileName',['Output' num2str(ID) '.wav']);

% Set BER workspace variable name
b=find_system(Block,'LookUnderMasks','on','Followlinks','on','Name','BER To Workspace');
set_param(b{1},'VariableName',['BER_Results' num2str(ID)]);

% Set Throughput workspace variable name
b=find_system(Block,'LookUnderMasks','on','Followlinks','on','Name','Throughput To Workspace');  
set_param(b{1},'VariableName',['Throughput' num2str(ID)]);


Contact us