Skip to content

Commit

Permalink
Update RIS_BTLE_Interface.m
Browse files Browse the repository at this point in the history
  • Loading branch information
mheinri committed Nov 15, 2023
1 parent 30674ff commit 14895cc
Showing 1 changed file with 50 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,30 @@

end

%
% Read serial number
%
% Return value: serial number
%
function serialNumber = readSerialNumber(obj)
% Return value, 0 indicates an error
serialNumber = 0;

% Read serial number
response = obj.sendCommand('?SerialNo');

% If readout was successful
if ~isempty(response)
try
% Convert response to voltage
response = char(response);
serialNumber = str2double(response(end-2:end));
catch e
disp(e.getReport());
end
end
end

%
% Read voltage of external power supply
%
Expand All @@ -70,7 +94,6 @@
end
end


%
% Read the current pattern in hex format
%
Expand Down Expand Up @@ -118,13 +141,39 @@

end

%
% Reset RIS and deinitialize RIS object
%
function obj = resetAndDeinit(obj)
% Reset RIS
write(obj.writeCharacteristic, [0x01 '!Reset' 0x0a]);

% Clear object properties
try
obj.bleObject = [];
obj.readDescriptor = [];
obj.readCharacteristic = [];
obj.writeCharacteristic = [];
catch e
disp(e.getReport());
end

end

%
% Deinitialize RIS object by
% - unsubscribing from characteristics
% - clear object properties
%
function obj = deinit(obj)
% Unsibscribe from characteristics
try
unsubscribe(obj.readCharacteristic);
catch e
disp(e.getReport());
end

% Clear object properties
try
obj.bleObject = [];
obj.readDescriptor = [];
Expand All @@ -137,4 +186,3 @@

end
end

0 comments on commit 14895cc

Please sign in to comment.