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 using nRF52832 and segger latest version 3.1 mesh  sdk

i am trying to send the message from client to server side using light switch example , I have made some changes in light switch client example ,i have changed the boolen(APP_STATE_ON ,OFF) to character and then  flashed , scanned , provisioned successfully but how to check my messages have transmitted  or not ?

where can i see ? can we able to print the received messages in server side . here is my code ,where i have assign a character and sent to server side

client side 

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]
     */
 char arr[5] = "code";
 char ara[5] = "set";
 
    switch(button_number)
    {
        case 0:
        case 2:
            set_params.on_off = arr;
            break;

        case 1:
        case 3:
            set_params.on_off = Ara;
            break;
    }

debug terminal(client side )

  • As noted in your previous thread, this code:

     char arr[5] = "code";
     char ara[5] = "set";

    defines both 'arr' and 'ara' to be char arrays.

    Therefore, for this code to work:

    set_params.on_off = arr;

    'set_params.on_off' mus be a char pointer.

    You still haven't confirmed this.

    This is because, as explained in your previous thread, the thing on the left-hand side of an assignment has to be of the same type (or a "compatible" type) as the thing on the right-hand side of the assignment.

    Again, this is standard 'C' programming - nothing specific to Nordic or nRF52 or BLE.

    And this line can't be right:

    set_params.on_off = Ara;

    because the 'C' programming language is case-sensitive - so 'ara' is not the same thing as 'Ara'

    Surely, you must have got build errors or warnings for these?

  • but i have not used the bool state value even i have not included the generic_onoff_common.h which has definition , typestructure for bool state value, instead of that i created a variable which is used throughout the program

  • is this correct or  wrong , i equallized both the sides... if it is wrong , what is wrong say me clearly please

     uint16_t x_in;
        char a = 78;
     //char arr[80] = "code";
    // char ara [80] = "set";
     
        switch(button_number)
        {
            case 0:
            case 2:
            
               x_in = a;
                break;
    
            case 1:
            case 3:
           
                x_in = a;
                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",x_in);

  • It is syntactically valid.

    I have no idea what you are actually trying to achieve - so can't say whether or not it is "correct" in that sense.

    Comments on 'C' style:

    char a = 78;

    What's with the magic number 78 ?

    If you want a lowercase letter X, then say so:

    char a = 'x';

    Why have two cases here:

        switch(button_number)
        {
            case 0:
            case 2:
            
               x_in = a;
                break;
    
            case 1:
            case 3:
           
                x_in = a;
                break;
        }

    They both do the same thing - so why not just

        switch(button_number)
        {
            case 0:
            case 2:
            case 1:
            case 3:
           
                x_in = a;
                break;
        }

    and note that the value of x_in will be undefined in any other case.

    Why is x_in a uint16_t when you are assigning a char to it ?

  • Why is x_in an unsigned 16 int & a is a character? I have tested it and it will "work", but I do not understand why you did this.

Related