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

nRF MESH

HI........ I am working on nRF MESH latest version , so i am here using three boards nRF52832 , i have set the character message in client side , when the button 1 is pressed , corresponding character message will be sent to server , how to print this data (received character in server side) in uart using termite.

Thanks in Advance 

Parents
  • Hello ,

    Look at how it is done in the ble_app_uart example.

    you need to use the same uart_init() function, and then you use a function similar to nus_data_handler(ble_nus_evt_t * p_evt) from the ble_app_uart event.

    basically, you use app_uart_put(uint8_t byte) for all the characters that you receive.

    Best regards,

    Edvin

  • Hi edvin ,

    i want to print the same data which is transferred from client to server ,how to get that same data i mean at which function i can find my received data in server side . 

    Thanks in advance

  • yes i am not getting char properly in server side look at above pic

  • What does your log line in main.c on line 97 look like?

    From your "ap_onoff.c, 204, msg: SET: 1, it looks like you are just receiving a bool, and not a character.

    BR,

    Edvin

  • yeah how to change that .. ap_on.off.c  , msg :SET:1 LINE ... 

    see the pic i have made some changes i dono whether it is correct or not 

    please guide me 

    
    /***** Generic OnOff model interface callbacks *****/
    
    static void generic_onoff_state_get_cb(const generic_onoff_server_t * p_self,
                                           const access_message_rx_meta_t * p_meta,
                                           generic_onoff_status_params_t * p_out)
    {
        __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "msg: GET \n");
    
        app_onoff_server_t   * p_server = PARENT_BY_FIELD_GET(app_onoff_server_t, server, p_self);
    
        /* Requirement: Provide the current value of the OnOff state */
        p_server->onoff_get_cb(p_server, &p_server->state.present_onoff);
        p_out->present_on_off = p_server->state.present_onoff;
        p_out->target_on_off = p_server->state.target_onoff;
    
        /* Requirement: Always report remaining time */
        if (p_server->state.remaining_time_ms > 0 && p_server->state.delay_ms == 0)
        {
            uint32_t delta = (1000ul * app_timer_cnt_diff_compute(app_timer_cnt_get(), p_server->last_rtc_counter)) / APP_TIMER_CLOCK_FREQ;
            if (p_server->state.remaining_time_ms >= delta && delta > 0)
            {
                p_out->remaining_time_ms = p_server->state.remaining_time_ms - delta;
            }
            else
            {
                p_out->remaining_time_ms = 0;
            }
        }
        else
        {
            p_out->remaining_time_ms = p_server->state.remaining_time_ms;
        }
    }
    
    static void generic_onoff_state_set_cb(const generic_onoff_server_t * p_self,
                                           const access_message_rx_meta_t * p_meta,
                                           const generic_onoff_set_params_t * p_in,
                                           const model_transition_t * p_in_transition,
                                           generic_onoff_status_params_t * p_out)
    {
        __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "msg: SET: %d\n", p_in->cat);
    
        app_onoff_server_t   * p_server = PARENT_BY_FIELD_GET(app_onoff_server_t, server, p_self);
    
        /* Update internal representation of OnOff value, process timing */
        p_server->value_updated = false;
        p_server->state.target_onoff = p_in->cat;
        if (p_in_transition == NULL)
        {
            p_server->state.delay_ms = 0;
            p_server->state.remaining_time_ms = 0;
        }
        else
        {
            p_server->state.delay_ms = p_in_transition->delay_ms;
            p_server->state.remaining_time_ms = p_in_transition->transition_time_ms;
        }
    
        onoff_state_value_update(p_server);
        onoff_state_process_timing(p_server);
    
        /* Prepare response */
        if (p_out != NULL)
        {
            p_out->present_on_off = p_server->state.present_onoff;
            p_out->target_on_off = p_server->state.target_onoff;
            p_out->remaining_time_ms = p_server->state.remaining_time_ms;
        }
    }
    
    
    /***** Interface functions *****/
    
    void app_onoff_status_publish(app_onoff_server_t * p_server)
    {
        p_server->onoff_get_cb(p_server, &p_server->state.present_onoff);
    
        p_server->state.target_onoff = p_server->state.present_onoff;
        p_server->state.delay_ms = 0;
        p_server->state.remaining_time_ms = 0;
        (void) app_timer_stop(*p_server->p_timer_id);
    
        generic_onoff_status_params_t status = {
                    .present_on_off = p_server->state.present_onoff,
                    .target_on_off = p_server->state.target_onoff,
                    .remaining_time_ms = p_server->state.remaining_time_ms
                };
        (void) generic_onoff_server_status_publish(&p_server->server, &status);
    }
    

  • Thank you  for response .

    Here this is my log line ,i am printing a value by assigning to a character

    this is my server code 

    /* Callback for updating the hardware state */
    static void app_onoff_server_set_cb(const app_onoff_server_t * p_server,char cat)
    {
        /* Resolve the server instance here if required, this example uses only 1 instance. */
    
        __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "character: %d\n",  cat);
        
        hal_led_pin_set(ONOFF_SERVER_0_LED, cat);
    }
    

  • Try to change %d to %c, since it is a character, and not an integer.

Reply Children
No Data
Related