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

Misunderstanding of writing from Client to Server.

Hello everyone,

I write datas from my Client to my Server, but I don't really understand where I can retrieve my data on my server.

 

err_code = sd_ble_gatts_value_get(m_cus.conn_handle,handle,&gatts_value);

Is this function allowing to get data from the Server to Client or It allow to retrieve data on the Server from the server to put them into a local or global variable?

In fact, I use this function from my server like that :

//VARIABLE DEFINED IN A LIBRARY.H
R0_val

//CODE EXECUTED IN MAIN.C

ble_gatts_value_t gatts_value;

memset(&gatts_value,'0',sizeof(gatts_value));
gatts_value.len = sizeof (R0_val);
gatts_value.p_value = &R0_val;
gatts_value.offset  = 0;

err_code = sd_ble_gatts_value_get(m_cus.conn_handle, m_cus.R0_heater_handles.value_handle, &gatts_value);
APP_ERROR_CHECK(err_code);

The strange problem is that when I read the value in debug from the main I got the right value, but when I look the value from the library it's always 0. I really don't understand since this is the same variable.

Sylvain.

Config : Segger Embedded Studio, SDKs v15.0, Windows 10, PCA10056 0.12.0 2018.9

Parents
  • Hi Sylvain.

    The API function sd_ble_gatts_value_get() is used to get the value of a given attribute from the server, ref: infocenter.

    It is used locally, so you don't get data from the server to the client.

    If you want to read/write from a client to a server you have to use  sd_ble_gattc_read() or  sd_ble_gattc_write().

     

    The strange problem is that when I read the value in debug from the main I got the right value, but when I look the value from the library it's always 0. I really don't understand since this is the same variable.

     I'm a bit unsure what you mean, could you explain more?

    Best regards.

    Andreas

Reply
  • Hi Sylvain.

    The API function sd_ble_gatts_value_get() is used to get the value of a given attribute from the server, ref: infocenter.

    It is used locally, so you don't get data from the server to the client.

    If you want to read/write from a client to a server you have to use  sd_ble_gattc_read() or  sd_ble_gattc_write().

     

    The strange problem is that when I read the value in debug from the main I got the right value, but when I look the value from the library it's always 0. I really don't understand since this is the same variable.

     I'm a bit unsure what you mean, could you explain more?

    Best regards.

    Andreas

Children
Related