2022-06-08 07:49 AM
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
2022-06-22 10:04 PM
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