NordicSemiconductor/Android-nRF-Mesh-Library

Change abstract ApplicationMessage to public

anhhh11 opened this issue · 7 comments

no\nordicsemi\android\mesh\transport\ApplicationMessage.java
abstract class ApplicationMessage extends MeshMessage

Currently, the app I am working on relies on the functionality provided by the ApplicationMessage class. However, the class is currently inaccessible or internal, which prevents me from customizing its content to suit my application's specific requirements.
I believe making the ApplicationMessage class public would greatly benefit not only my application but also other developers who may encounter similar requirements. By allowing customization of this class, it would enable us to tailor our applications more effectively and efficiently.

Hi ok, could you elaborate what you are trying to achieve?

You can use vendor model message class to send custom messages.

I find VendorModelMessageUnacked but assembleMessageParameters but it is final. Can you provide some class name or sample?

Take a look at the following snippet, this should hopefully help you.

public void sendVendorModelMessage(final int opcode, final byte[] parameters, final boolean acknowledged) {
final Element element = mViewModel.getSelectedElement().getValue();
if (element != null) {
final VendorModel model = (VendorModel) mViewModel.getSelectedModel().getValue();
if (model != null) {
final int appKeyIndex = model.getBoundAppKeyIndexes().get(0);
final ApplicationKey appKey = mViewModel.getNetworkLiveData().getMeshNetwork().getAppKey(appKeyIndex);
if (acknowledged) {
sendAcknowledgedMessage(element.getElementAddress() ,
new VendorModelMessageAcked(appKey, model.getModelId(), model.getCompanyIdentifier(), opcode, parameters));
} else {
sendUnacknowledgedMessage(element.getElementAddress() ,
new VendorModelMessageAcked(appKey, model.getModelId(), model.getCompanyIdentifier(), opcode, parameters));
}
}
}
}
}

Library already having VendorModelMessageAcked, VendorModelMessageUnacked for custom (vendor) message