OZEO-DOOZ / nrf_mesh_plugin

A Flutter plugin to enable mesh network management and communication using Nordic Semiconductor's SDKs.
https://pub.dev/packages/nordic_nrf_mesh
BSD 3-Clause "New" or "Revised" License
28 stars 19 forks source link

How to set device name to node name in json file #253

Closed Hung6129 closed 1 year ago

Hung6129 commented 2 years ago

When i provisioned a node then i export json file In the node list the node name is default "My node " like is always So i want to set the node name in the json file according to the device name that i provisioning

from this image

to this

image

thanks

Hung6129 commented 2 years ago

Am i doing wrong some where
Do i have to change something on the native code ? Pls help In the android app https://github.com/NordicSemiconductor/Android-nRF-Mesh-Library when i use it to export json file it still keep my device name also in ios app

ghost commented 2 years ago

Hi @Hung6129,

Nothing wrong here, we just don't expose the api and we don't use device name when creating node object !

This looks like a feature request ๐Ÿ‘

Hung6129 commented 2 years ago

hope this feature will appear soon

ghost commented 2 years ago

Yes, just a reminder : you shouldn't rely on device name to identify it. So I hope this is not a blocker for you ?

Hung6129 commented 2 years ago

i don't identify it by using device name, i use uuid i just need to show the device name on the json file just like the android app when i export it

bc i will send that json file to the server and they want to know the device name in the list node :(

can you give me some solution to get the device name instead of the default name "My node"

i see that in the DiscoveredDevice models has the name Now how can i add it into the ProvisionedMeshNode Or should i need to add it in provisioning function image

Thanks

ghost commented 2 years ago

Hello @Hung6129,

If you want to try and implement it, I think it's more on the native code that you have to change something. The provisioning process may look complex, so you better begin by just exposing Node.setName from Nordic API

him1010 commented 1 year ago

Hello I am new to app development and I want to save the new provisioned device with its original name or provide a name for it. If possible can you help me with this.

Thanks

Hung6129 commented 1 year ago

image

hello @him1010 Well for now i added that line to set the provisioned nodeName after the provisioning step done It works and show the name of the device instead of My Node @R0m4in-dooz sir, a feature request ??

ghost commented 1 year ago

Hello !

Ah yes this line is ok โœ…

Feel free to open a PR ๐Ÿ‘

It could be great to also expose the name setter in mesh mngr in case you want to change it later (user customization for instance)

him1010 commented 1 year ago

Hello @Hung6129 Thanks for the suggestion. It worked. @R0m4in-dooz how can I expose the name setter in mesh manager and use it, if you could give an example that would be really helpful.

Thanks

ghost commented 1 year ago

Hello @him1010,

Actually I found that it is already exposed, see models file for mesh nodes, there is ProvisionedMeshNodes which defines an async setter : https://github.com/OZEO-DOOZ/nrf_mesh_plugin/blob/master/lib/src/models/mesh_node/provisioned_mesh_node.dart

ghost commented 1 year ago

So to do it after provisioning you can write :

// with an instance that implements IMeshNetwork
IMeshNetwork _meshNetwork;
// and target nodeยดs unicast
int unicast;

final node = await _meshNetwork.getNode(unicast);
// /!\ the operation will be asynchronous, wait for onNetworkUpdated callback
node.nodeName = 'my awesome mesh node';
him1010 commented 1 year ago

Hi @R0m4in-dooz Thank you for the suggestion, you were a great help.

ghost commented 1 year ago

This issue seems resolved. If you think it's not the case, feel free to re-open it ๐Ÿ˜Š