Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle more than one netowk in DB #598

Open
mpiffari opened this issue Nov 18, 2024 · 5 comments
Open

Handle more than one netowk in DB #598

mpiffari opened this issue Nov 18, 2024 · 5 comments

Comments

@mpiffari
Copy link

mpiffari commented Nov 18, 2024

Hi @philips77 and @roshanrajaratnam ,
Is it possible to add more than one mesh network to the database and to load them from DB? If so, are there any specific steps or limitations to consider?

I saw that in MeshNetworkDao is available the CRUD for insert a new mesh entry in the DB, but it seems not to be called in the mesh manager.

The fields isLastSelected can be edited and updated in DB? @roshanrajaratnam
Is it possible to expose getMeshNetworks? A PR would be accepted by your team (both on Android and iOS libraries)?

@philips77
Copy link
Member

Hello,
I don't think so. Why do you need that? You could merge the 2 networks if key indexes don't overlap, but if they do, you may try importing / exporting network when needed so switch between them.

Also, we're almost done with a new implementation of mesh library for Android, written in Kotlin from scratch. Not backwards compatible so far, but we'll think about migration guides. As far as I know it won't use database under the hood, right @roshanrajaratnam?

@mpiffari
Copy link
Author

I need to manage multiple networks simultaneously, including creating, deleting, and adding nodes to different networks.

However, I'm encountering challenges in maintaining consistency for the field isLastSelected and ensuring database integrity. Is there a more efficient workaround to streamline this process? On Android, I currently have to use reflection to access _meshNetworkDao to create new networks, which feels suboptimal.

@roshanrajaratnam
Copy link
Member

Also, we're almost done with a new implementation of mesh library for Android, written in Kotlin from scratch. Not backwards compatible so far, but we'll think about migration guides. As far as I know it won't use database under the hood, right @roshanrajaratnam?

The new implementation will not be using any databases and we are using datastore. The new library will create a datastore per network and will be using the configuration database format.

However, I'm encountering challenges in maintaining consistency for the field isLastSelected and ensuring database integrity. Is there a more efficient workaround to streamline this process? On Android, I currently have to use reflection to access _meshNetworkDao to create new networks, which feels suboptimal.

Use the following API to create a new network, this should allow to create a new network and you do not have to use reflections.

@mpiffari
Copy link
Author

mpiffari commented Nov 21, 2024

Hi @roshanrajaratnam ,
Will the new library also be made public, like the current one? From the iOS perspective, will there be any changes, or will it continue using local storage and saving data in JSON format as before?

Regarding the creation and management of mesh networks: to create a mesh network and store it in the database entity, I call createMeshNetwork. However, to retrieve the list of all available networks and ensure the last_selected field remains consistent (in my design, only one network at a time can have 'last_selected' set to true - maybe this point is the key), I need to access the database manager to invoke the following APIs:

Fun1
Fun2

public List<MeshNetwork> getMeshNetworks()
public void update(final String uuid, final boolean lastSelected)[Fun2](https://github.com/NordicSemiconductor/Android-nRF-Mesh-Library/blob/37de84ddb24eeab044d041244b246ebf683cde22/mesh/src/main/java/no/nordicsemi/android/mesh/data/MeshNetworkDao.java#L26)

Is there an efficient way to manage multiple networks, allowing the user to seamlessly select, edit, and interact with their chosen network?
Thank you in advance for any guidance or suggestions—it’s greatly appreciated!

@philips77
Copy link
Member

From the iOS perspective, will there be any changes, or will it continue using local storage and saving data in JSON format as before?

No plans in changing it. The lib actually allows you to set custom Storage to save the json (as Data).

Will the new library also be made public, like the current one?

We're working hard to make it as soon as possible. I would say few weeks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants