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

how to get the data on server side in mesh

hi ...

I am working on mesh 3.1 version . I have used light switch example . In this case , i am sending the character in generic_onoff_set_cb , and changed from bool to character on client side . Now what are the change on server side , in order  to get the character from client to server . on server side i need to get the same data . 

Thanks

pspavi

Parents Reply Children
  • hi

    mttrinh i am using mesh 3.1 version sdk . i have done somechanges please check here, correct me if i am wrong.

    static void button_event_handler(uint32_t button_number)
    {
        __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "Button %u pressed\n", button_number);
    
        uint32_t status = NRF_SUCCESS;
        generic_onoff_set_params_t set_params;
        model_transition_t transition_params;
        static uint8_t tid = 0;
    
        /* Button 1: On, Button 2: Off, Client[0]
         * Button 2: On, Button 3: Off, Client[1]
         */
    
        switch(button_number)
        {
            case 0:
            case 2:
                set_params.on_off = 32;
                break;
    
            case 1:
            case 3:
                set_params.on_off = 8;
                break;
        }
    
        set_params.tid = tid++;
        transition_params.delay_ms = APP_CONFIG_ONOFF_DELAY_MS;
        transition_params.transition_time_ms = APP_CONFIG_ONOFF_TRANSITION_TIME_MS;
        __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "Sending msg: ONOFF SET %d\n", set_params.on_off);
    
        switch (button_number)
        {
            case 0:
            case 1:
                /* Demonstrate acknowledged transaction, using 1st client model instance */
                /* In this examples, users will not be blocked if the model is busy */
                (void)access_model_reliable_cancel(m_clients[0].model_handle);
                status = generic_onoff_client_set(&m_clients[0], &set_params, &transition_params);
                hal_led_pin_set(BSP_LED_0, set_params.on_off);
                break;
    
            case 2:
            case 3:
                /* Demonstrate un-acknowledged transaction, using 2nd client model instance */
                status = generic_onoff_client_set_unack(&m_clients[1], &set_params,
                                                        &transition_params, APP_UNACK_MSG_REPEAT_COUNT);
                hal_led_pin_set(BSP_LED_1, set_params.on_off);
                break;
        }

    then generic_onoff_common.h file changed the bool to uint8_t and generic_onoff_client.c  file modified the  message_set_packet_create 

    p_set->on_off = p_params->on_off ;
    p_set->tid = p_params->tid; 

    thats all . it is correct or wrong ?

    explanation for above , i want to sent the integer from client to server when i press the button the respective integer has to go . 

     

    Thanks 

    pspavi

  • how to pass 150 bytes from client to server for the latest version ..

  • but i am not received the integer in server side instead of that i am getting 1 always

  • Hi,

    My mistake, you would need to make some changes on the server side too, to be able to send string/integer to the server. Did you have a look at the links that Joakim mentioned in your other case?

    It included a custom simple_message model example that will let you send a string over the mesh network. It is made for Mesh SDK v1.0.0 but I suggest you to use the example application as a reference/guidance on how you can make a custom model for Mesh SDK 3.1.0, that let you send a string/integer.

    Here is documentation on how to create a model.

    Also have a look at this, it might be of help.

Related