Publish custom message using access layer mesh

Hi! I am taking reference to following issue :

 How to send status data from server to client's UART in mesh 

I have implemented same method as discussed in above link. I am getting message on client side successfully only when code for custom message transmission is in  button event handler.

But when I use in separate function and call from main function then getting following error.

Error Message Log -->  "app_error_weak.c,  105, Mesh assert at 0x000229AC"

Following is my code that I want to send custom message.

void publish_message(void)
{
    access_message_tx_t msg;

    msg.opcode.opcode = SENSOR_OPCODE_STATUS;
    msg.opcode.company_id = 0xFFFF;
    msg.force_segmented = m_sensor_server_0.server.settings.force_segmented;
    msg.transmic_size =  m_sensor_server_0.server.settings.transmic_size;

    char *message = "Enable Reciever\n";
    __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "Message from Initiator =  %s\n",  message);
    msg.p_buffer = (const uint8_t *)message;
    msg.length   = strlen(message);
    access_model_publish(m_sensor_server_0.server.model_handle, &msg);   
}

And I have also added delay but error message still persist.

int main(void)
{
    nrf_power_dcdcen_set(1);

    initialize();
    start();
    nrf_delay_ms(20000);

    //Publish message to address assigned by static provisioner
    publish_message();

    for (;;)
    {

        (void)sd_app_evt_wait();
    }
}

Best Regards: Danish Riaz

Parents
  • Hi! I have also try this implementation " Running application and mesh event handling in main loop" in nrf documentation following is link .

    https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.meshsdk.v4.2.0%2Fmd_doc_user_guide_mesh_interrupt_priorities.html&cp=7_2_2_5

    Here is my code detail.

    void publish_message(void)
    {
        access_message_tx_t msg;
    
        msg.opcode.opcode = SENSOR_OPCODE_STATUS;
        msg.opcode.company_id = 0xFFFF;
        msg.force_segmented = m_sensor_server_0.server.settings.force_segmented;
        msg.transmic_size =  m_sensor_server_0.server.settings.transmic_size;
    
        char *message = "Enable Reciever\n";
        __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "Message from Initiator =  %s\n",  message);
        msg.p_buffer = (const uint8_t *)message;
        msg.length   = strlen(message);
        int status = access_model_publish(m_sensor_server_0.server.model_handle, &msg);   
    
         if (status == NRF_ERROR_INVALID_STATE ||
          status == NRF_ERROR_BUSY||status == NRF_ERROR_NO_MEM)
           {
             __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "Cannot send. Device is busy.\n");
           }
           else
           {
                 ERROR_CHECK(status);
           }
    }
    
    
    int main(void)
    {
        nrf_power_dcdcen_set(1);
    
        //Initialize schedular to handle events from mesh
        APP_SCHED_INIT(APP_SCHED_EVENT_SIZE, APP_SCHED_QUEUE_SIZE);
    
        initialize();
        start();
    
        for (;;)
        {
    
          app_sched_execute();
          bool done = nrf_mesh_process();
    
          //Publish message to address assigned by static provisioner
          publish_message();
    
           if (done)
           {
              sd_app_evt_wait();
           }
        }
    }

    I have got reference from following issue. But now getting "NRF_ERROR_FORBIDDEN"  " app_error_weak.c,  115, Mesh error 15"

     app_error_weak.c, 105, Mesh assert at 0x0002BCAA (:0) 

    Best Regards : Danish Riaz

Reply
  • Hi! I have also try this implementation " Running application and mesh event handling in main loop" in nrf documentation following is link .

    https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.meshsdk.v4.2.0%2Fmd_doc_user_guide_mesh_interrupt_priorities.html&cp=7_2_2_5

    Here is my code detail.

    void publish_message(void)
    {
        access_message_tx_t msg;
    
        msg.opcode.opcode = SENSOR_OPCODE_STATUS;
        msg.opcode.company_id = 0xFFFF;
        msg.force_segmented = m_sensor_server_0.server.settings.force_segmented;
        msg.transmic_size =  m_sensor_server_0.server.settings.transmic_size;
    
        char *message = "Enable Reciever\n";
        __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "Message from Initiator =  %s\n",  message);
        msg.p_buffer = (const uint8_t *)message;
        msg.length   = strlen(message);
        int status = access_model_publish(m_sensor_server_0.server.model_handle, &msg);   
    
         if (status == NRF_ERROR_INVALID_STATE ||
          status == NRF_ERROR_BUSY||status == NRF_ERROR_NO_MEM)
           {
             __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "Cannot send. Device is busy.\n");
           }
           else
           {
                 ERROR_CHECK(status);
           }
    }
    
    
    int main(void)
    {
        nrf_power_dcdcen_set(1);
    
        //Initialize schedular to handle events from mesh
        APP_SCHED_INIT(APP_SCHED_EVENT_SIZE, APP_SCHED_QUEUE_SIZE);
    
        initialize();
        start();
    
        for (;;)
        {
    
          app_sched_execute();
          bool done = nrf_mesh_process();
    
          //Publish message to address assigned by static provisioner
          publish_message();
    
           if (done)
           {
              sd_app_evt_wait();
           }
        }
    }

    I have got reference from following issue. But now getting "NRF_ERROR_FORBIDDEN"  " app_error_weak.c,  115, Mesh error 15"

     app_error_weak.c, 105, Mesh assert at 0x0002BCAA (:0) 

    Best Regards : Danish Riaz

Children
No Data
Related