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

Can nou update Characteristic value

I've created read onle characteristic called "log". In  main.c i try to update it by calling : ulogd_characteristic_update(&m_ulog_service,Log_Data_arr)

But nothing happens, can you solve my issue (p.s. I am new to ble)


void ulogd_characteristic_update(ble_ulog_service_t *p_ulog_service, int32_t *log_data)
{
if (p_ulog_service->conn_handle != BLE_CONN_HANDLE_INVALID)
{
uint16_t len = 10;
ble_gatts_hvx_params_t hvx_params;
memset(&hvx_params, 0, sizeof(hvx_params));

hvx_params.handle = p_ulog_service->ulog_char_handles.value_handle;
hvx_params.type = BLE_GATT_HVX_NOTIFICATION;
hvx_params.offset = 0;
hvx_params.p_len = &len;
hvx_params.p_data = log_data;


sd_ble_gatts_hvx(p_ulog_service->conn_handle, &hvx_params);
}

}

Parents
  • log_service.h


    #ifndef LOG_SERVICE_H
    #define LOG_SERVICE_H

    #include <stdint.h>
    #include "boards.h"
    #include "ble.h"
    #include "ble_srv_common.h"
    #include "nrf_sdh_ble.h"

    #define BLE_ULOG_SERVICE_BLE_OBSERVER_PRIO 2
    #define BLE_ULOG_SERVICE_DEF(_name) \
    static ble_ulog_service_t _name; \
    NRF_SDH_BLE_OBSERVER(_name ## _obs, \
    BLE_ULOG_SERVICE_BLE_OBSERVER_PRIO, \
    ble_ulog_service_on_ble_evt, &_name)
    // Base UUID: E54B0000-67F5-479E-8711-B3B99198CE6C
    #define BLE_UUID_ULOG_SERVICE_BASE_UUID {0x6C, 0xCE, 0x98, 0x91, 0xB9, 0xB3, 0x11, 0x87, 0x9E, 0x47, 0xF5, 0x67, 0x00, 0x00, 0x4B, 0xE5}
    // Service & characteristics UUIDs
    #define BLE_UUID_ULOG_SERVICE_UUID 0xF000
    #define BLE_UUID_ULOG_CHAR_UUID 0xF00A
    #define BLE_UUID_ULOGTIME_CHAR_UUID 0xF00C
    // Forward declaration of the custom_service_t type.
    typedef struct ble_ulog_service_s ble_ulog_service_t;
    //typedef void (*ble_ulog_service_ulog_write_handler_t) (uint16_t conn_handle, ble_ulog_service_t * p_ulog_service, uint8_t new_state);
    typedef void (*ble_ulog_service_ulogtime_write_handler_t) (uint16_t conn_handle, ble_ulog_service_t * p_ulogtime_service, uint8_t* new_state);

    typedef struct
    {
    // ble_ulog_service_ulog_write_handler_t ulog_write_handler;
    ble_ulog_service_ulogtime_write_handler_t ulogtime_write_handler; /**< ulogtime */
    } ble_ulog_service_init_t;

    typedef struct ble_ulog_service_s
    {
    uint16_t conn_handle;
    uint16_t service_handle;
    uint8_t uuid_type;
    ble_gatts_char_handles_t ulog_char_handles;
    ble_gatts_char_handles_t ulogtime_char_handles;
    // ble_ulog_service_ulog_write_handler_t ulog_write_handler;
    ble_ulog_service_ulogtime_write_handler_t ulogtime_write_handler;

    } ble_ulog_service_t;

    uint32_t ble_ulog_service_init(ble_ulog_service_t * p_ulog_service, const ble_ulog_service_init_t * p_ulog_service_init);
    void ble_ulog_service_on_ble_evt(ble_evt_t const * p_ble_evt, void * p_context);
    void ulogd_characteristic_update(ble_ulog_service_t *p_ulog_service, int32_t *log_data);

    #endif

Reply
  • log_service.h


    #ifndef LOG_SERVICE_H
    #define LOG_SERVICE_H

    #include <stdint.h>
    #include "boards.h"
    #include "ble.h"
    #include "ble_srv_common.h"
    #include "nrf_sdh_ble.h"

    #define BLE_ULOG_SERVICE_BLE_OBSERVER_PRIO 2
    #define BLE_ULOG_SERVICE_DEF(_name) \
    static ble_ulog_service_t _name; \
    NRF_SDH_BLE_OBSERVER(_name ## _obs, \
    BLE_ULOG_SERVICE_BLE_OBSERVER_PRIO, \
    ble_ulog_service_on_ble_evt, &_name)
    // Base UUID: E54B0000-67F5-479E-8711-B3B99198CE6C
    #define BLE_UUID_ULOG_SERVICE_BASE_UUID {0x6C, 0xCE, 0x98, 0x91, 0xB9, 0xB3, 0x11, 0x87, 0x9E, 0x47, 0xF5, 0x67, 0x00, 0x00, 0x4B, 0xE5}
    // Service & characteristics UUIDs
    #define BLE_UUID_ULOG_SERVICE_UUID 0xF000
    #define BLE_UUID_ULOG_CHAR_UUID 0xF00A
    #define BLE_UUID_ULOGTIME_CHAR_UUID 0xF00C
    // Forward declaration of the custom_service_t type.
    typedef struct ble_ulog_service_s ble_ulog_service_t;
    //typedef void (*ble_ulog_service_ulog_write_handler_t) (uint16_t conn_handle, ble_ulog_service_t * p_ulog_service, uint8_t new_state);
    typedef void (*ble_ulog_service_ulogtime_write_handler_t) (uint16_t conn_handle, ble_ulog_service_t * p_ulogtime_service, uint8_t* new_state);

    typedef struct
    {
    // ble_ulog_service_ulog_write_handler_t ulog_write_handler;
    ble_ulog_service_ulogtime_write_handler_t ulogtime_write_handler; /**< ulogtime */
    } ble_ulog_service_init_t;

    typedef struct ble_ulog_service_s
    {
    uint16_t conn_handle;
    uint16_t service_handle;
    uint8_t uuid_type;
    ble_gatts_char_handles_t ulog_char_handles;
    ble_gatts_char_handles_t ulogtime_char_handles;
    // ble_ulog_service_ulog_write_handler_t ulog_write_handler;
    ble_ulog_service_ulogtime_write_handler_t ulogtime_write_handler;

    } ble_ulog_service_t;

    uint32_t ble_ulog_service_init(ble_ulog_service_t * p_ulog_service, const ble_ulog_service_init_t * p_ulog_service_init);
    void ble_ulog_service_on_ble_evt(ble_evt_t const * p_ble_evt, void * p_context);
    void ulogd_characteristic_update(ble_ulog_service_t *p_ulog_service, int32_t *log_data);

    #endif

Children
No Data
Related