This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Rather than reporting the status of the LED, how do I configure the Light sample to publish the ADC's readings?

I see on the forums that this is done through access_model_publish, but I cannot find where that is called in the Light sample.

  • Hi Jala, 

    Could you let me know which exact example you are working on ? 
    You are correct that you can call access_model_publish() to send the data to a node. But you need to define your own model instead of using the light switch model for example. (In the light switch example the data is sent inside status_send() function)

    We have created some proprietary models that you can have a look inside \models\vendor.

  • Hi Hung,

    I am working on the server one referred to here https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/samples/bluetooth/mesh/light/README.html#bluetooth-mesh-light.

    I've went through the forums and it seems most use the client node (light switch sample) to send, is this not possible on a server node?

    I'll have a look at those models and post my findings, thanks.

  • Where are these models located? Couldn't find \models\vendors in ncs\1.7.1

    Also couldn't find where status_send() is called

  • Hi Jala, 
    Sorry I was thinking that you were asking about mesh example in nRF5 SDK not nRF Connect SDK (access_model_publish() is a function in nRF5 SDK) 

    In light example the publication of the sever model is sent in 

    led_work() in model_handler.c . You can find model_send() is called in the function. 
    You would need to define your own proprietary model to send your ADC data. 

    I would suggest to have a look at the chat example as it's a proprietary. It's client only. So you need to refer to the light example to know how to define a server. 
  • I found https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/ug_bt_mesh_vendor_model_dev_overview.html

    I've added

    #define YOUR_COMPANY_ID 0xFFFF
    #define YOUR_MODEL_ID   0x2323
    
    static struct bt_mesh_elem elements[] = {
    #if DT_NODE_EXISTS(DT_ALIAS(led0))
    	BT_MESH_ELEM(
    		1, BT_MESH_MODEL_LIST(
    			BT_MESH_MODEL_CFG_SRV,
    			BT_MESH_MODEL_HEALTH_SRV(&health_srv, &health_pub),
    			BT_MESH_MODEL_ONOFF_SRV(&led_ctx[0].srv)),
    		BT_MESH_MODEL_NONE),
    #endif
    #if DT_NODE_EXISTS(DT_ALIAS(led1))
    	BT_MESH_ELEM(
    		2, BT_MESH_MODEL_LIST(BT_MESH_MODEL_ONOFF_SRV(&led_ctx[1].srv)),
    		BT_MESH_MODEL_NONE),
    #endif
    #if DT_NODE_EXISTS(DT_ALIAS(led2))
    	BT_MESH_ELEM(
    		3, BT_MESH_MODEL_LIST(BT_MESH_MODEL_ONOFF_SRV(&led_ctx[2].srv)),
    		BT_MESH_MODEL_NONE),
    #endif
    #if DT_NODE_EXISTS(DT_ALIAS(led3))
    	BT_MESH_ELEM(
    		4, BT_MESH_MODEL_LIST(BT_MESH_MODEL_ONOFF_SRV(&led_ctx[3].srv)),
    		BT_MESH_MODEL_NONE),
    #endif
           BT_MESH_ELEM(
            5,
    		BT_MESH_MODEL_NONE,
            BT_MESH_MODEL_LIST(BT_MESH_MODEL_VND_CB(YOUR_COMPANY_ID,
                                                    YOUR_MODEL_ID,
                                                    _opcode_list,
                                                    NULL,
                                                    NULL,
                                                    NULL))
        ),
    };

    Is it okay to reuse the generic onoff opcodes (0x82) and, if I understand this correctly, send back ADC values through the opcode handler?

Related