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

How to message-passing between models

Dear

 

I increated a Generic Level module to main elements which have a Generic ONOFF module on Mesh example Light Switch Server project base on PCA10056 DK board for nrf52840 chips.(SES + nrf5_SDK_for_Mesh_v4.0.0_src+ nRF5_SDK_16.0.0_98a08e2)

Right now The Generic Level module works well that The Brightness can be change by app of nRF mesh app on cell phone. Because the Generic Level module be implemented by PWM base on PWM model of the nrf52840, the pin of LED0 which be connected to PWM model do not be controlled by GPIO, which mean the Generic ONOFF module do not work and LED do not flash when the reset or for other situation.

My questions is

  1. I believe there must be a way to accomplish message-passing between models within elements and between models within different elements within nodes. How do I implement that?
  2. As mentioned in the first paragraph, the pin of the LED0 have to be controlled by PWM model and gpio model. Do you have any good idea for that.

 

Thanks,

 

B,Rs

 

Di-sheng

  • Hi,

    1. You can send messages between models by publishing directly using unicast addresses or publish/subscribe to a group address. 

    2. 

    which mean the Generic ONOFF module do not work

    Can you tell me what doesn't work? Can you elaborate?

    If I understand you correctly, you want to control one LED with Generic OnOff model and Generic Level Model, am I correct? 

  • Dear Mttrinh

     Thanks for your reply!

    For the first question on my last mail, your answer  is exactly the result I want. My project is a Light switch server note which have 2 elements ,the every element have a Generic ONOFF model and a Generic level model. In order to correlate two models in the same element, I have to exchange state information each other . Because I do not know what code of the mesh stack of nordic should be read. Would you like give me some detile about that.For exemaple,where I can find the unicast addresses and how I can publish/subscribe to a group address. Do you have some information or simple of mesh to recommended or some advice to me?

    Right now I althrough can let the 2 models in the same element work together by determine each other's state variables at the code level, but I do not think it is righgt way.So I want to know how to achieve it by nordic mesh stack code.

    The second question is simply: if the pin is assigned to the PWM module, can the GPIO module still control him and a pin?

     

    Thanks

     

    B,Rs

     

    Di-sheng

  • The easiest would be to use the nRF Mesh app (Android/iOS) as provisioner. After you have finished the provisioning you will be able to see the unicast address in the app. You can also set the publish/subscribtion address in the app.

    When PWM is started it will take control over the GPIO, while when PWM is stopped it will fall back to the normal GPIO usage. So it should work by starting and stopping PWM.

  • Hi Mttrinh

    Thanks for your repaly.

    The answer of the second question is what I want. I will change the control power by connect or disconnect the pin to PWM(PSEL.OUTàCONNECT).

    About the first question, I thinks I may not have made the first question clear. Let me take a different approach and ask specific questions:

    Q1: After a message is received by hardware RF, it is processed by SD because the RF module is not available to the user (as described in the SD manual). Then, the interrupt service routine for RF hardware interrupt should be completed by SD. My question is what does SD do when it receives this message and what is the output?

    Q2: There are two callbacks in each model definition (for example, the Generic Level Module, which defines 2 callback functions:void app_level_server_set_cb(....)  and void app_level_server_get_cb (...).). My question is by whom and where are these callbacks called?

    Q3: I think SD belongs to the Mesh stack, not to the BLE stack. My question is if an application does not use SD, what is the interrupt service routine for RF?

    Thanks

    B,Rs

    Di-sheng

  • Hi,

    1. The application should open radio session and register signal handler at the beginning of every new timeslot that SD provided to the app. Furthermore, it is up to the application to configure RF registers and provide memory for raw data. SD just generates a signal if an interrupt happens. It is up to the application of how to handle and interpret them. It is better to read SD documentation. Looks like I just rewrite it briefly.    

    2. These handlers are called by the behavioral part of the model. That happens according to model specification and depends on the appropriate model state and transition parameters. For instance, for the level model it is implemented here './examples/common/src/app_level.c'.

    3. SD and Mesh stack are autonomic software and do not belong to each other. Mesh stack reuses some functional of SD for example the timeslot system to coexist with SD or GATT. 

Related