Skip to main content
Deepak.Aagri
Associate III
June 8, 2022
Question

How to Set callback for handling heartbeat messages in BLE Mesh?

  • June 8, 2022
  • 1 reply
  • 612 views

Hello ST,

I am working on BLE_MeshLightingProvisioner sample project and trying to set heartbeat messages mention below:

MOBLE_RESULT BLEMesh_SetHeartbeatCallback(MOBLE_HEARTBEAT_CB cb);

Could you please help me to figure out how to use this function from Provisioner side or share the example code to test this function.

Best Regards

Deepak Aagri

This topic has been closed for replies.

1 reply

Saurabh.Rawat
ST Employee
June 23, 2022

Hello @Deepak.Aagri​ 

For Smartphone as a provisioner you can use the following code to set the Heartbeat (using the configmodel)

Message :

mConfigModel.setPublicationHeartBeat(targetAddress, heartbeatReciever, mCountLog, mPeriodLog, mTTL, mFeatures, mKeyIndex,

configHeartBeatPublicationStatusCallback_callback);

Response/Callback :

final ConfigurationModelClient.ConfigHeartBeatPublicationStatusCallback configHeartBeatPublicationStatusCallback_callback = new

ConfigurationModelClient.ConfigHeartBeatPublicationStatusCallback() {

@Override

public void onHeartBeatPublicationStatus(boolean timeout, ApplicationParameters.Status status, ApplicationParameters.Address address,

ApplicationParameters.CountLog countLog, ApplicationParameters.PeriodLog periodLog,

ApplicationParameters.TTL ttl, ApplicationParameters.Features features,

ApplicationParameters.NetKeyIndex netKeyIndex) {

if (timeout) {

Toast.makeText(context,"Timeout Error Occured!",Toast.LENGTH_LONG).show();

UserApplication.trace("HeartBeat timeout occurred");

} else {

Toast.makeText(context,"HeartBeat Published to =>" + address ,Toast.LENGTH_LONG).show();

UserApplication.trace("HeartBeatSuccess==>"+status);

}

}

};

You can find this reference code(for Android) in the Android Source code provided in the ST BLE Mesh setup when you install it.

 Location of the code : C:\Users\<user_name>\ST\STSW-BNRG-Mesh_1.11.000

Regards,

Saurabh