Beispiel #1
0
uint32_t ble_opt_get_req_dec(uint8_t const * const   p_buf,
                             uint16_t                packet_len,
                             uint32_t *  const       p_opt_id,
                             ble_opt_t **const       pp_opt )
{
    SER_REQ_DEC_BEGIN(SD_BLE_OPT_GET);

    SER_ASSERT_NOT_NULL(p_opt_id);
    SER_ASSERT_NOT_NULL(pp_opt);
    SER_ASSERT_NOT_NULL(*pp_opt);

    SER_PULL_uint32(p_opt_id);
    SER_ASSERT(((*p_opt_id == BLE_COMMON_OPT_CONN_BW)           ||
                (*p_opt_id == BLE_COMMON_OPT_PA_LNA)            ||
                (*p_opt_id == BLE_COMMON_OPT_CONN_EVT_EXT)      ||
                (*p_opt_id == BLE_GAP_OPT_CH_MAP)               ||
                (*p_opt_id == BLE_GAP_OPT_LOCAL_CONN_LATENCY)   ||
                (*p_opt_id == BLE_GAP_OPT_PASSKEY)              ||
                (*p_opt_id == BLE_GAP_OPT_SCAN_REQ_REPORT)      ||
                (*p_opt_id == BLE_GAP_OPT_COMPAT_MODE)          ||
                (*p_opt_id == BLE_GAP_OPT_AUTH_PAYLOAD_TIMEOUT) ||
                (*p_opt_id == BLE_GAP_OPT_EXT_LEN)), NRF_ERROR_INVALID_PARAM);

    SER_PULL_COND(pp_opt, NULL);

    SER_REQ_DEC_END;
}
uint32_t ble_gatts_cfg_attr_tab_size_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_cfg_attr_tab_size_t);
    SER_PULL_uint32(&p_struct->attr_tab_size);
    SER_STRUCT_DEC_END;
}
Beispiel #3
0
uint32_t ble_opt_id_pre_dec(uint8_t const * const   p_buf,
                            uint16_t                packet_len,
                            uint32_t *  const       p_opt_id)
{
    SER_REQ_DEC_BEGIN(SD_BLE_OPT_SET);

    SER_ASSERT_NOT_NULL(p_opt_id);
    SER_PULL_uint32(p_opt_id);

    // Pre-decoding; do not check if the whole packet was processed.
    return NRF_SUCCESS;
}
uint32_t ble_gatts_enable_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_enable_params_t);

    uint8_t ser_data;
    SER_PULL_uint8(&ser_data);
    SER_PULL_uint32(&p_struct->attr_tab_size);

    p_struct->service_changed = ser_data & 0x01;

    SER_STRUCT_DEC_END;
}
Beispiel #5
0
uint32_t ble_opt_set_req_dec(uint8_t const * const   p_buf,
                             uint16_t                packet_len,
                             uint32_t *  const       p_opt_id,
                             ble_opt_t **const       pp_opt )
{
    SER_REQ_DEC_BEGIN(SD_BLE_OPT_SET);

    SER_ASSERT_NOT_NULL(p_opt_id);
    SER_ASSERT_NOT_NULL(pp_opt);
    SER_ASSERT_NOT_NULL(*pp_opt);

    SER_PULL_uint32(p_opt_id);
    SER_ASSERT(((*p_opt_id == BLE_COMMON_OPT_CONN_BW)           ||
                (*p_opt_id == BLE_COMMON_OPT_PA_LNA)            ||
                (*p_opt_id == BLE_COMMON_OPT_CONN_EVT_EXT)      ||
                (*p_opt_id == BLE_GAP_OPT_CH_MAP)               ||
                (*p_opt_id == BLE_GAP_OPT_LOCAL_CONN_LATENCY)   ||
                (*p_opt_id == BLE_GAP_OPT_PASSKEY)              ||
                (*p_opt_id == BLE_GAP_OPT_SCAN_REQ_REPORT)      ||
                (*p_opt_id == BLE_GAP_OPT_COMPAT_MODE)          ||
                (*p_opt_id == BLE_GAP_OPT_AUTH_PAYLOAD_TIMEOUT) ||
                (*p_opt_id == BLE_GAP_OPT_EXT_LEN)), NRF_ERROR_INVALID_PARAM);

    SER_PULL_COND(pp_opt, NULL);
    if (*pp_opt)
    {
        field_decoder_handler_t fp_decoder = NULL;
        void * p_struct = NULL;

        switch(*p_opt_id)
        {
            case BLE_COMMON_OPT_CONN_BW:
                fp_decoder = ble_common_opt_conn_bw_t_dec;
                p_struct   = &((*pp_opt)->common_opt.conn_bw);
            break;
            case BLE_COMMON_OPT_PA_LNA:
                fp_decoder = ble_common_opt_pa_lna_t_dec;
                p_struct   = &((*pp_opt)->common_opt.pa_lna);
            break;
            case BLE_COMMON_OPT_CONN_EVT_EXT:
                fp_decoder = ble_common_opt_conn_evt_ext_t_dec;
                p_struct   = &((*pp_opt)->common_opt.conn_evt_ext);
            break;
            case BLE_GAP_OPT_CH_MAP:
                fp_decoder = ble_gap_opt_ch_map_t_dec;
                p_struct   = &((*pp_opt)->gap_opt.ch_map);
            break;
            case BLE_GAP_OPT_LOCAL_CONN_LATENCY:
                fp_decoder = ble_gap_opt_local_conn_latency_t_dec;
                p_struct   = &((*pp_opt)->gap_opt.local_conn_latency);
            break;
            case BLE_GAP_OPT_PASSKEY:
                fp_decoder = ble_gap_opt_passkey_t_dec;
                p_struct   = &((*pp_opt)->gap_opt.passkey);
            break;
            case BLE_GAP_OPT_AUTH_PAYLOAD_TIMEOUT:
                fp_decoder = ble_gap_opt_auth_payload_timeout_t_dec;
                p_struct   = &((*pp_opt)->gap_opt.auth_payload_timeout);
            break;
            case BLE_GAP_OPT_EXT_LEN:
                fp_decoder = ble_gap_opt_ext_len_t_dec;
                p_struct   = &((*pp_opt)->gap_opt.ext_len);
            break;
            case BLE_GAP_OPT_SCAN_REQ_REPORT:
                fp_decoder = ble_gap_opt_scan_req_report_t_dec;
                p_struct   = &((*pp_opt)->gap_opt.scan_req_report);
            break;
            case BLE_GAP_OPT_COMPAT_MODE:
                fp_decoder = ble_gap_opt_compat_mode_t_dec;
                p_struct   = &((*pp_opt)->gap_opt.compat_mode);
            break;
            default:
                SER_ASSERT(NRF_ERROR_INVALID_PARAM,NRF_ERROR_INVALID_PARAM);
            break;
        }
        
        SER_PULL_FIELD(p_struct, fp_decoder);
    }

    SER_REQ_DEC_END;
}