Search code examples
unetstack

How to use "preamble" and "basebandRx" in MATLAB to transmit baseband signals in unetstack?


I referred to this blog post, "Using MATLAB with UnetStack3" ([https://blog.unetstack.net/using-matlab-with-unetstack3][1]), and added a preamble at the transmission part:

% load the baseband signal
% signal.txt contains interleaved real and imaginary values in a single column
% with values normalized between +1 and ‐1
x = load('signal.txt');

% open the modem gateway
modem = org.arl.fjage.remote.Gateway('192.168.0.42', 1100);

% subscribe to the agent providing baseband service
bb = modem.agentForService(org.arl.unet.Services.BASEBAND);

% create the message with relevant attributes to be sent to the modem
msg = org.arl.unet.bb.TxBasebandSignalReq();
msg.setPreamble(3); % add preamble
msg.setSignal(x);
msg.setRecipient(bb);

% send the message to modem
rsp = modem.request(msg, 1000);

% check if the message was successfully sent
if isjava(rsp) && rsp.getPerformative() == org.arl.fjage.Performative.AGREE
    cls = org.arl.unet.phy.TxFrameNtf().getClass();
    % receive the notification message
    ntf = modem.receive(cls, 5000);
end

It seems to work well,but how can I modify the receiver-side code:

% subscribe to the agent providing the baseband service
agent = modem.agentForService(org.arl.unet.Services.BASEBAND);
modem.subscribe(agent);

% create the message with relevant attributes to be sent to the modem
req = org.arl.unet.bb.RecordBasebandSignalReq();
req.setRecipient(agent);

% send the message to the modem and wait for the response
rsp = modem.request(req, 5000);

% check if the message was successfully sent
if isjava(rsp) && rsp.getPerformative() == org.arl.fjage.Performative.AGREE
    % receive the notification message containing the signal
    cls = org.arl.unet.bb.RxBasebandSignalNtf().getClass();
    ntf = modem.receive(cls, 5000);
end

% plot the recorded signal
plot(ntf.getSignal())

in order to enable the basebandRx capability, detecting the preamble, and capturing signals of specified length? [1]: https://blog.unetstack.net/using-matlab-with-unetstack3


Solution

  • If you attach a preamble and the same preamble is configured on the receiving modem (parameters phy[3].preamble, phy[3].threshold, phy[3].basebandRx and phy[3].basebandExtra in your example), the modem will generate a RxBasebandSignalNtf whenever it detects a signal with that preamble. To receive the notification, you can replace your request() in your code example with a receive() instead, and look for the returned message being a RxBasebandSignalNtf.

    You can set the parameters on the modem beforehand, or use MATLAB to set parameters on the modem via a ParameterReq.

    This is all documented in the Unet Handbook section 16.4 with code examples.