cancel
Showing results for 
Search instead for 
Did you mean: 

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

Deepak.Aagri
Associate III

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

1 REPLY 1
Saurabh.Rawat
ST Employee

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