Exemplo n.º 1
0
uint32_t ble_evt_user_mem_release_dec(uint8_t const * const p_buf,
                                      uint32_t              packet_len,
                                      ble_evt_t * const     p_event,
                                      uint32_t * const      p_event_len)
{
    SER_EVT_DEC_BEGIN(BLE_EVT_USER_MEM_RELEASE, common, user_mem_release);

    SER_PULL_uint16(&p_event->evt.common_evt.conn_handle);
    SER_PULL_uint8(&p_event->evt.common_evt.params.user_mem_release.type);
    SER_PULL_uint16(&p_event->evt.common_evt.params.user_mem_release.mem_block.len);

    //Set the memory pointer to not-null value.
    p_event->evt.common_evt.params.user_mem_release.mem_block.p_mem = (uint8_t *)~0;
    SER_PULL_COND(&p_event->evt.common_evt.params.user_mem_release.mem_block.p_mem, NULL);
    if (p_event->evt.common_evt.params.user_mem_release.mem_block.p_mem)
    {
        // Using connection handle find which mem block to release in Application Processor
        uint32_t user_mem_table_index;
        err_code = app_ble_user_mem_context_find(p_event->evt.common_evt.conn_handle, &user_mem_table_index);
        SER_ASSERT(err_code == NRF_SUCCESS, err_code);
        p_event->evt.common_evt.params.user_mem_release.mem_block.p_mem = 
            m_app_user_mem_table[user_mem_table_index].mem_block.p_mem;
    }

    // Now user memory context can be released
    err_code = app_ble_user_mem_context_destroy(p_event->evt.common_evt.conn_handle);
    SER_ASSERT(err_code == NRF_SUCCESS, err_code);

    SER_EVT_DEC_END;
}
uint32_t ble_gattc_evt_write_cmd_tx_complete_dec(uint8_t const * const p_buf,
                                                 uint32_t              packet_len,
                                                 ble_evt_t * const     p_event,
                                                 uint32_t * const      p_event_len)
{
    SER_EVT_DEC_BEGIN(BLE_GATTC_EVT_WRITE_CMD_TX_COMPLETE, gattc, write_cmd_tx_complete);
    SER_PULL_uint16(&p_event->evt.gattc_evt.conn_handle);
    SER_PULL_uint16(&p_event->evt.gattc_evt.gatt_status);
    SER_PULL_uint16(&p_event->evt.gattc_evt.error_handle);
    SER_PULL_uint8(&p_event->evt.gattc_evt.params.write_cmd_tx_complete.count);

    SER_EVT_DEC_END;
}
uint32_t ble_gatts_evt_read_t_dec(uint8_t const * const p_buf,
                                  uint32_t              buf_len,
                                  uint32_t * const      p_index,
                                  void * const          p_void_struct)
{
    SER_STRUCT_DEC_BEGIN(ble_gatts_evt_read_t);

    SER_PULL_uint16(&p_struct->handle);
    SER_PULL_FIELD(&p_struct->uuid, ble_uuid_t_dec);
    SER_PULL_uint16(&p_struct->offset);

    SER_STRUCT_DEC_END;
}
uint32_t ble_gatts_char_handles_t_dec(uint8_t const * const p_buf,
                                    uint32_t              buf_len,
                                    uint32_t * const      p_index,
                                    void * const          p_void_struct)
{
    SER_STRUCT_DEC_BEGIN(ble_gatts_char_handles_t);

    SER_PULL_uint16(&p_struct->value_handle);
    SER_PULL_uint16(&p_struct->user_desc_handle);
    SER_PULL_uint16(&p_struct->cccd_handle);
    SER_PULL_uint16(&p_struct->sccd_handle);

    SER_STRUCT_DEC_END;
}
uint32_t ble_gattc_evt_timeout_dec(uint8_t const * const p_buf,
                                   uint32_t              packet_len,
                                   ble_evt_t * const     p_event,
                                   uint32_t * const      p_event_len)
{
    SER_EVT_DEC_BEGIN(BLE_GATTC_EVT_TIMEOUT, gattc, timeout);

    SER_PULL_uint16(&p_event->evt.gattc_evt.conn_handle);
    SER_PULL_uint16(&p_event->evt.gattc_evt.gatt_status);
    SER_PULL_uint16(&p_event->evt.gattc_evt.error_handle);
    SER_PULL_FIELD(&p_event->evt.gattc_evt.params.timeout,
                   ble_gattc_evt_timeout_t_dec);

    SER_EVT_DEC_END;
}
uint32_t ble_gattc_evt_hvx_dec(uint8_t const * const p_buf,
                               uint32_t              packet_len,
                               ble_evt_t * const     p_event,
                               uint32_t * const      p_event_len)
{
    SER_EVT_DEC_BEGIN(BLE_GATTC_EVT_HVX, gattc, hvx);

    SER_PULL_uint16(&p_event->evt.gattc_evt.conn_handle);
    SER_PULL_uint16(&p_event->evt.gattc_evt.gatt_status);
    SER_PULL_uint16(&p_event->evt.gattc_evt.error_handle);
    SER_PULL_FIELD_EXTENDED(&p_event->evt.gattc_evt.params.hvx,
                            ble_gattc_evt_hvx_t_dec);

    SER_EVT_DEC_END;
}
uint32_t ble_gattc_evt_attr_info_disc_rsp_dec(uint8_t const * const p_buf,
                                              uint32_t              packet_len,
                                              ble_evt_t * const     p_event,
                                              uint32_t * const      p_event_len)
{
    SER_EVT_DEC_BEGIN(BLE_GATTC_EVT_ATTR_INFO_DISC_RSP, gattc, attr_info_disc_rsp);

    SER_PULL_uint16(&p_event->evt.gattc_evt.conn_handle);
    SER_PULL_uint16(&p_event->evt.gattc_evt.gatt_status);
    SER_PULL_uint16(&p_event->evt.gattc_evt.error_handle);
    SER_PULL_FIELD_EXTENDED(&p_event->evt.gattc_evt.params.attr_info_disc_rsp,
                            ble_gattc_evt_attr_info_disc_rsp_t_dec);

    SER_EVT_DEC_END;
}
uint32_t ble_gattc_evt_char_vals_read_rsp_dec(uint8_t const * const p_buf,
                                              uint32_t              packet_len,
                                              ble_evt_t * const     p_event,
                                              uint32_t * const      p_event_len)
{
    SER_EVT_DEC_BEGIN(BLE_GATTC_EVT_CHAR_VALS_READ_RSP, gattc, char_vals_read_rsp);

    SER_PULL_uint16(&p_event->evt.gattc_evt.conn_handle);
    SER_PULL_uint16(&p_event->evt.gattc_evt.gatt_status);
    SER_PULL_uint16(&p_event->evt.gattc_evt.error_handle);
    SER_PULL_FIELD_EXTENDED(&p_event->evt.gattc_evt.params.char_vals_read_rsp,
                            ble_gattc_evt_char_vals_read_rsp_t_dec);

    SER_EVT_DEC_END;
}
uint32_t ble_gatts_attr_t_dec(uint8_t const * const p_buf,
                            uint32_t              buf_len,
                            uint32_t * const      p_index,
                            void * const          p_void_struct)
{
    SER_STRUCT_DEC_BEGIN(ble_gatts_attr_t);

    SER_PULL_COND(&p_struct->p_uuid, ble_uuid_t_dec);
    SER_PULL_COND(&p_struct->p_attr_md, ble_gatts_attr_md_t_dec);
    SER_PULL_uint16(&p_struct->init_offs);
    SER_PULL_uint16(&p_struct->max_len);
    SER_PULL_len16data(&p_struct->p_value, &p_struct->init_len);

    SER_STRUCT_DEC_END;
}
uint32_t ble_gatts_char_pf_t_dec(uint8_t const * const p_buf,
                                 uint32_t              buf_len,
                                 uint32_t * const      p_index,
                                 void * const          p_void_struct)
{
    SER_STRUCT_DEC_BEGIN(ble_gatts_char_pf_t);

    SER_PULL_uint8(&p_struct->format);
    SER_PULL_int8(&p_struct->exponent);
    SER_PULL_uint16(&p_struct->unit);
    SER_PULL_uint8(&p_struct->name_space);
    SER_PULL_uint16(&p_struct->desc);

    SER_STRUCT_DEC_END;
}
uint32_t ble_gattc_evt_exchange_mtu_rsp_dec(uint8_t const * const p_buf,
                                            uint32_t              packet_len,
                                            ble_evt_t * const     p_event,
                                            uint32_t * const      p_event_len)
{
    SER_EVT_DEC_BEGIN(BLE_GATTC_EVT_EXCHANGE_MTU_RSP, gattc, exchange_mtu_rsp);

    SER_PULL_uint16(&p_event->evt.gattc_evt.conn_handle);
    SER_PULL_uint16(&p_event->evt.gattc_evt.gatt_status);
    SER_PULL_uint16(&p_event->evt.gattc_evt.error_handle);
    SER_PULL_FIELD(&p_event->evt.gattc_evt.params.exchange_mtu_rsp,
                            ble_gattc_evt_exchange_mtu_rsp_t_dec);

    SER_EVT_DEC_END;
}
uint32_t ble_gattc_evt_write_rsp_dec(uint8_t const * const p_buf,
                                     uint32_t              packet_len,
                                     ble_evt_t * const     p_event,
                                     uint32_t * const      p_event_len)
{
    SER_EVT_DEC_BEGIN(BLE_GATTC_EVT_WRITE_RSP, gattc, write_rsp);

    SER_PULL_uint16(&p_event->evt.gattc_evt.conn_handle);
    SER_PULL_uint16(&p_event->evt.gattc_evt.gatt_status);
    SER_PULL_uint16(&p_event->evt.gattc_evt.error_handle);
    SER_PULL_FIELD_EXTENDED(&p_event->evt.gattc_evt.params.write_rsp,
                            ble_gattc_evt_write_rsp_t_dec);

    SER_EVT_DEC_END;
}
uint32_t ble_gatts_evt_rw_authorize_request_dec(uint8_t const * const p_buf,
                                                uint32_t              packet_len,
                                                ble_evt_t * const     p_event,
                                                uint32_t * const      p_event_len)
{
    SER_EVT_DEC_BEGIN(BLE_GATTS_EVT_HVC, gatts, rw_authorize_request);

    SER_PULL_uint16(&p_event->evt.gatts_evt.conn_handle);
    SER_PULL_FIELD_EXTENDED(&p_event->evt.gatts_evt.params.authorize_request, ble_gatts_evt_rw_authorize_request_t_dec);

    //Correct event length / memory sync.
    if (p_event->evt.gatts_evt.params.authorize_request.type == BLE_GATTS_AUTHORIZE_TYPE_READ)
    {
        evt_struct_len = offsetof(ble_evt_t, evt.gatts_evt.params.authorize_request.request.read)
                         - offsetof(ble_evt_t, evt)
                         + sizeof(ble_gatts_evt_read_t);
    }
    else if ((p_event->evt.gatts_evt.params.authorize_request.type == BLE_GATTS_AUTHORIZE_TYPE_WRITE) &&
             ( (p_event->evt.gatts_evt.params.authorize_request.request.write.op == BLE_GATTS_OP_EXEC_WRITE_REQ_NOW) ||
               (p_event->evt.gatts_evt.params.authorize_request.request.write.op == BLE_GATTS_OP_PREP_WRITE_REQ)))
    {
        uint32_t conn_index;
        if (app_ble_user_mem_context_find(p_event->evt.gatts_evt.conn_handle, &conn_index) != NRF_ERROR_NOT_FOUND)
        {
            SER_PULL_len16data(&m_app_user_mem_table[conn_index].mem_block.p_mem, &m_app_user_mem_table[conn_index].mem_block.len);
        }
    }

    SER_EVT_DEC_END;
}
uint32_t ble_gatts_evt_write_dec(uint8_t const * const p_buf,
                                 uint32_t              packet_len,
                                 ble_evt_t * const     p_event,
                                 uint32_t * const      p_event_len)
{
    SER_EVT_DEC_BEGIN(BLE_GATTS_EVT_WRITE, gatts, write);

    SER_PULL_uint16(&p_event->evt.gatts_evt.conn_handle);
    SER_PULL_FIELD_EXTENDED(&p_event->evt.gatts_evt.params.write, ble_gatts_evt_write_t_dec);

    if (p_event != NULL)
    {
        if (p_event->evt.gatts_evt.params.write.op == BLE_GATTS_OP_EXEC_WRITE_REQ_NOW)
        {
            uint32_t conn_index;
            if (app_ble_user_mem_context_find(p_event->evt.gatts_evt.conn_handle, &conn_index) != NRF_ERROR_NOT_FOUND)
            {
                SER_PULL_len16data(&m_app_user_mem_table[conn_index].mem_block.p_mem, &m_app_user_mem_table[conn_index].mem_block.len);
                SER_ASSERT(err_code == NRF_SUCCESS, err_code);
            }
        }
    }

    SER_EVT_DEC_END;
}
uint32_t ble_gatts_authorize_params_t_dec(uint8_t const * const p_buf,
                                          uint32_t              buf_len,
                                          uint32_t * const      p_index,
                                          void * const          p_void_struct)
{
    SER_STRUCT_DEC_BEGIN(ble_gatts_authorize_params_t);

    uint8_t ser_data;
    SER_PULL_uint16(&p_struct->gatt_status);
    SER_PULL_uint8(&ser_data);
    SER_PULL_uint16(&p_struct->offset);
    SER_PULL_len16data((uint8_t **) &p_struct->p_data, &p_struct->len);

    p_struct->update = ser_data & 0x01;

    SER_STRUCT_DEC_END;
}
uint32_t ble_gatts_evt_sc_confirm_dec(uint8_t const * const p_buf,
                                      uint32_t              packet_len,
                                      ble_evt_t * const     p_event,
                                      uint32_t * const      p_event_len)
{
    SER_EVT_DEC_BEGIN_NO_STRUCT(BLE_GATTS_EVT_SC_CONFIRM, gatts);
    SER_PULL_uint16(&p_event->evt.gatts_evt.conn_handle);
    SER_EVT_DEC_END;
}
uint32_t ble_gatt_conn_cfg_t_dec(uint8_t const * const p_buf,
                                      uint32_t              buf_len,
                                      uint32_t * const      p_index,
                                      void * const          p_void_struct)
{
    SER_STRUCT_DEC_BEGIN(ble_gatt_conn_cfg_t);
    SER_PULL_uint16(&p_struct->att_mtu);
    SER_STRUCT_DEC_END;
}
uint32_t ble_gatts_evt_hvc_t_dec(uint8_t const * const p_buf,
                                 uint32_t              buf_len,
                                 uint32_t * const      p_index,
                                 void * const          p_void_struct)
{
    SER_STRUCT_DEC_BEGIN(ble_gatts_evt_hvc_t);
    SER_PULL_uint16(&p_struct->handle);
    SER_STRUCT_DEC_END;
}
uint32_t ble_gatts_evt_exchange_mtu_request_t_dec(uint8_t const * const p_buf,
                                                  uint32_t              buf_len,
                                                  uint32_t * const      p_index,
                                                  void * const          p_void_struct)
{
    SER_STRUCT_DEC_BEGIN(ble_gatts_evt_exchange_mtu_request_t);
    SER_PULL_uint16(&p_struct->client_rx_mtu);
    SER_STRUCT_DEC_END;
}
Exemplo n.º 20
0
uint32_t ble_gap_evt_timeout_dec(uint8_t const * const p_buf,
                                 uint32_t              packet_len,
                                 ble_evt_t * const     p_event,
                                 uint32_t * const      p_event_len)
{
    SER_EVT_DEC_BEGIN(BLE_GAP_EVT_TIMEOUT, gap, timeout);

    SER_PULL_uint16(&p_event->evt.gap_evt.conn_handle);
    SER_PULL_uint8(&p_event->evt.gap_evt.params.timeout.src);

    SER_EVT_DEC_END;
}
uint32_t ble_l2cap_evt_rx_dec(uint8_t const * const p_buf,
                              uint32_t              packet_len,
                              ble_evt_t * const     p_event,
                              uint32_t * const      p_event_len)
{
    SER_EVT_DEC_BEGIN(BLE_L2CAP_EVT_RX, l2cap, rx);

    SER_PULL_uint16(&p_event->evt.l2cap_evt.conn_handle);
    SER_PULL_FIELD_EXTENDED(&p_event->evt.l2cap_evt.params.rx, ble_l2cap_evt_rx_t_dec);

    SER_EVT_DEC_END;
}
Exemplo n.º 22
0
uint32_t ble_gap_evt_auth_key_request_dec(uint8_t const * const p_buf,
                                          uint32_t              packet_len,
                                          ble_evt_t * const     p_event,
                                          uint32_t * const      p_event_len)
{
    SER_EVT_DEC_BEGIN(BLE_GAP_EVT_AUTH_KEY_REQUEST, gap, auth_key_request);

    SER_PULL_uint16(&p_event->evt.gap_evt.conn_handle);
    SER_PULL_uint8(&p_event->evt.gap_evt.params.auth_key_request.key_type);

    SER_EVT_DEC_END;
}
uint32_t ble_gatts_value_t_dec(uint8_t const * const p_buf,
                               uint32_t              buf_len,
                               uint32_t * const      p_index,
                               void * const          p_void_struct)
{
    SER_STRUCT_DEC_BEGIN(ble_gatts_value_t);

    SER_PULL_uint16(&p_struct->offset);
    SER_PULL_len16data(&p_struct->p_value, &p_struct->len);

    SER_STRUCT_DEC_END;
}
Exemplo n.º 24
0
uint32_t ble_evt_data_length_changed_dec(uint8_t const * const p_buf,
                                         uint32_t              packet_len,
                                         ble_evt_t * const     p_event,
                                         uint32_t * const      p_event_len)
{
    SER_EVT_DEC_BEGIN(BLE_EVT_DATA_LENGTH_CHANGED, common, data_length_changed);

    SER_PULL_uint16(&p_event->evt.common_evt.conn_handle);
    SER_PULL_FIELD(&p_event->evt.common_evt.params.data_length_changed, ble_evt_data_length_changed_t_dec);

    SER_EVT_DEC_END;
}
Exemplo n.º 25
0
uint32_t ble_evt_user_mem_request_dec(uint8_t const * const p_buf,
                                      uint32_t              packet_len,
                                      ble_evt_t * const     p_event,
                                      uint32_t * const      p_event_len)
{
    SER_EVT_DEC_BEGIN(BLE_EVT_USER_MEM_REQUEST, common, user_mem_request);

    SER_PULL_uint16(&p_event->evt.common_evt.conn_handle);
    SER_PULL_uint8(&p_event->evt.common_evt.params.user_mem_request.type);

    SER_EVT_DEC_END;
}
Exemplo n.º 26
0
uint32_t ble_evt_tx_complete_dec(uint8_t const * const p_buf,
                                 uint32_t              packet_len,
                                 ble_evt_t * const     p_event,
                                 uint32_t * const      p_event_len)
{
    SER_EVT_DEC_BEGIN(BLE_EVT_TX_COMPLETE, common, tx_complete);

    SER_PULL_uint16(&p_event->evt.common_evt.conn_handle);
    SER_PULL_uint8(&p_event->evt.common_evt.params.tx_complete.count);

    SER_EVT_DEC_END;
}
uint32_t ble_gatts_evt_exchange_mtu_request_dec(uint8_t const * const p_buf,
                                                uint32_t              packet_len,
                                                ble_evt_t * const     p_event,
                                                uint32_t * const      p_event_len)
{
    SER_EVT_DEC_BEGIN(BLE_GATTS_EVT_EXCHANGE_MTU_REQUEST, gatts, exchange_mtu_request);

    SER_PULL_uint16(&p_event->evt.gatts_evt.conn_handle);
    SER_PULL_FIELD(&p_event->evt.gatts_evt.params.exchange_mtu_request, ble_gatts_evt_exchange_mtu_request_t_dec);

    SER_EVT_DEC_END;
}
uint32_t ble_gatts_evt_hvn_tx_complete_dec(uint8_t const * const p_buf,
                                           uint32_t              packet_len,
                                           ble_evt_t * const     p_event,
                                           uint32_t * const      p_event_len)
{
    SER_EVT_DEC_BEGIN(BLE_GATTS_EVT_HVN_TX_COMPLETE, gatts, hvn_tx_complete);

    SER_PULL_uint16(&p_event->evt.gatts_evt.conn_handle);
    SER_PULL_uint8(&p_event->evt.gatts_evt.params.hvn_tx_complete.count);

    SER_EVT_DEC_END;
}
Exemplo n.º 29
0
uint32_t ble_tx_packet_count_get_req_dec(uint8_t const * const p_buf,
                                         uint16_t              packet_len,
                                         uint16_t      * const p_conn_handle,
                                         uint8_t * * const     pp_count)
{
    SER_REQ_DEC_BEGIN(SD_BLE_TX_PACKET_COUNT_GET);

    SER_PULL_uint16(p_conn_handle);
    SER_PULL_COND(pp_count, NULL);

    SER_REQ_DEC_END;
}
Exemplo n.º 30
0
uint32_t ble_gap_evt_adv_report_dec(uint8_t const * const p_buf,
                                    uint32_t              packet_len,
                                    ble_evt_t * const     p_event,
                                    uint32_t * const      p_event_len)
{
    SER_EVT_DEC_BEGIN(BLE_GAP_EVT_ADV_REPORT, gap, adv_report);

    SER_PULL_uint16(&p_event->evt.gap_evt.conn_handle);
    SER_PULL_FIELD(&p_event->evt.gap_evt.params.adv_report, ble_gap_evt_adv_report_t_dec);

    SER_EVT_DEC_END;
}