%% Subscribe and Unsubscribe to a Characteristic on a Bluetooth Low Energy Peripheral Device
% Subscribe to a characteristic that supports notification or indication. Unsubscribe after you finish working with the characteristic.
% Create a connection to a nearby Bluetooth Low Energy peripheral device.

b = ble("DemoDev")

% Create a characteristic object that represents the "Heart Rate Measurement" characteristic.

c = characteristic(b,"Heart Rate","Heart Rate Measurement")

% This characteristic supports "Notify".
% Start receiving notifications using subscribe.

subscribe(c)

% Read from the characteristic to check that you are receiving data.

read(c)

% After you finish working with the characteristic, disable notifications using unsubscribe.

unsubscribe(c)

% Copyright 2019 The MathWorks, Inc.