This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How to inmplement Client model on a phone?

Hi!

I met some issue ). 

I use nrf mesh app on my phone and change it for my goals. I would like to get messages from nodes to phone via mesh. I read some posts that it is possible to implement client model on a phone and subscribe to server of nodes to get messages. I tried to figure out how .... And may i should configure node on my phone and then add models?  May be there is examples ? Or you can explain in a nutshell.

Thank you for your time.

Parents
  • Hi,

    I use nrf mesh app on my phone and change it for my goals

    What kind of changes have you made to the app? 

    When you say "subscribe to server of nodes to get messages", do you mean status messages from the server?

    In our current nRF Mesh app, there is a local client model on the phone. Have a look at this thread on how you can receive status messages from server. 

  • I have download from GitHub latest version, but when i start it it shows error: 

    E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #1
        Process: no.nordicsemi.android.nrfmeshprovisioner, PID: 7448
        java.lang.RuntimeException: An error occurred while executing doInBackground()
            at android.os.AsyncTask$3.done(AsyncTask.java:353)
            at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383)
            at java.util.concurrent.FutureTask.setException(FutureTask.java:252)
            at java.util.concurrent.FutureTask.run(FutureTask.java:271)
            at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
            at java.lang.Thread.run(Thread.java:764)
         Caused by: java.lang.IllegalStateException: A migration from 10 to 9 was required but not found. Please provide the necessary Migration path via RoomDatabase.Builder.addMigration(Migration ...) or allow for destructive migrations via one of the RoomDatabase.Builder.fallbackToDestructiveMigration* methods.
            at androidx.room.RoomOpenHelper.onUpgrade(RoomOpenHelper.java:117)
            at androidx.room.RoomOpenHelper.onDowngrade(RoomOpenHelper.java:129)
            at androidx.sqlite.db.framework.FrameworkSQLiteOpenHelper$OpenHelper.onDowngrade(FrameworkSQLiteOpenHelper.java:135)
            at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:297)
            at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:194)
            at androidx.sqlite.db.framework.FrameworkSQLiteOpenHelper$OpenHelper.getWritableSupportDatabase(FrameworkSQLiteOpenHelper.java:92)
            at androidx.sqlite.db.framework.FrameworkSQLiteOpenHelper.getWritableDatabase(FrameworkSQLiteOpenHelper.java:53)
            at androidx.room.RoomDatabase.inTransaction(RoomDatabase.java:476)
            at androidx.room.RoomDatabase.assertNotSuspendingTransaction(RoomDatabase.java:281)
            at no.nordicsemi.android.mesh.data.MeshNetworkDao_Impl.getMeshNetwork(MeshNetworkDao_Impl.java:248)
            at no.nordicsemi.android.mesh.MeshNetworkDb$LoadNetworkAsyncTask.doInBackground(MeshNetworkDb.java:356)
            at no.nordicsemi.android.mesh.MeshNetworkDb$LoadNetworkAsyncTask.doInBackground(MeshNetworkDb.java:325)
            at android.os.AsyncTask$2.call(AsyncTask.java:333)
            at java.util.concurrent.FutureTask.run(FutureTask.java:266)
            at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245) 
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162) 
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636) 
            at java.lang.Thread.run(Thread.java:764) 

  • At the end I run app at the virtual devices, and I couldn't see Phone tab

  • Sorry for the confusion. Seems like the local node I talked about is only implemented on the iOS version as of now. Like you said you have to implement this yourself.

    A suggestion from our developer:

    They can just send messages, as if they had a node with elements.
    Each time they send and message, the source unicastAddress is added to proxy filtr on the connected proxy. Add messages, that the proxy device will receive, will be relayed to gatt client.

    If they want additional addresses, or set filter to black list, they have to use proxy filter API
Reply
  • Sorry for the confusion. Seems like the local node I talked about is only implemented on the iOS version as of now. Like you said you have to implement this yourself.

    A suggestion from our developer:

    They can just send messages, as if they had a node with elements.
    Each time they send and message, the source unicastAddress is added to proxy filtr on the connected proxy. Add messages, that the proxy device will receive, will be relayed to gatt client.

    If they want additional addresses, or set filter to black list, they have to use proxy filter API
Children
  • Thank you for your reply. I tried to do it, but i couldn't achieve result. I have two provisioned nodes. First - proxy has onoff server. Second onoff client. Server receives messages from client, but phone doesn't get any messages and events on onDataReceived().

    Also i tryed to adjust proxyfilter: 

             NodeConfigurationViewModel mViewModelProvisioned;
             mViewModelProvisioned = ViewModelProviders.of(this, mViewModelFactory).get(NodeConfigurationViewModel.class); 
             ProxyFilterType filterType = new ProxyFilterType((byte)0x00) ;
    
             ProxyFilter filter = new ProxyFilter(filterType);
             AddressArray adress = new AddressArray((byte)0x00,(byte)0x03);
    
             filter.addAddress(adress);
             mViewModelProvisioned.getMeshManagerApi().getMeshNetwork().setProxyFilter(filter);

  • Hello,

    In nRF Mesh for Android you may send messages to a server on a remote Node just by sending messages to its Unicast Address or a Group Address. If you are sending a Acknowledged message, you should receive a status back. The phone's Unicast Address is added to Proxy Filter list automatically when you send the first message, so the status should reach you. On contrary to iOS version, where you'd have to implement a local client model, on Android version you need to organize your code on your own.

    To send a message, call createMeshPdu(int dst, MeshMessage meshMessage). You should receive onMeshMessageReceived(int src, MeshMessage meshMessage) when you get the status message.

    It is a bit more difficult if it is the other Node that sends a message to you, as you need to make sure that the target address (unicast or group) is added to the Proxy Filer.

Related