Esempio n. 1
0
ret_code_t nfc_hs_rec_payload_constructor(nfc_hs_rec_payload_desc_t * p_nfc_hs_rec_payload_desc,
                                          uint8_t                   * p_buff,
                                          uint32_t                  * p_len)
{  
    ret_code_t err_code = NRF_SUCCESS;
    
    // There must be at least 1 free byte in buffer for version byte.
    if (*p_len < HS_REC_VERSION_SIZE)
    {    
        return NRF_ERROR_NO_MEM;
    }

    // Major/minor version byte.
    *p_buff = ( (p_nfc_hs_rec_payload_desc->major_version << 4) & 0xF0) |
              (  p_nfc_hs_rec_payload_desc->minor_version       & 0x0F);
    p_buff += HS_REC_VERSION_SIZE;
    
    // Decrement remaining buffer size.
    *p_len -= HS_REC_VERSION_SIZE;

    // Encode local records encapsulated in a message.
    err_code = nfc_ndef_msg_encode(p_nfc_hs_rec_payload_desc->p_local_records, p_buff, p_len);
    if (err_code!= NRF_SUCCESS)
    {
        return err_code;
    }

    // Add version byte to the total record size.
    *p_len += HS_REC_VERSION_SIZE;
        
    return NRF_SUCCESS;
}
Esempio n. 2
0
ret_code_t nfc_launchapp_msg_encode(uint8_t const * p_android_package_name,
                                    uint8_t         android_package_name_length,
                                    uint8_t const * p_win_app_id,
                                    uint8_t         win_app_id_length,
                                    uint8_t       * p_buf,
                                    uint32_t      * p_len)
{
    nfc_ndef_msg_desc_t * p_launchapp_msg_desc;
    ret_code_t            err_code;

    err_code = nfc_launchapp_msg_declare(p_android_package_name,
                                         android_package_name_length,
                                         p_win_app_id,
                                         win_app_id_length,
                                         &p_launchapp_msg_desc);

    if (err_code != NRF_SUCCESS)
        return err_code;

    /* Encode whole message into buffer */
    err_code = nfc_ndef_msg_encode(p_launchapp_msg_desc,
                                   p_buf,
                                   p_len);

    return err_code;
}
Esempio n. 3
0
ret_code_t nfc_uri_msg_encode( nfc_uri_id_t           uri_id_code,
                               uint8_t const *  const p_uri_data,
                               uint8_t                uri_data_len,
                               uint8_t       *        p_buf,
                               uint32_t      *        p_len)
{
    ret_code_t err_code;
    nfc_ndef_msg_desc_t * p_uri_msg_desc;

    /* Create NFC NDEF message description with URI record */
    err_code = nfc_uri_msg_declare( uri_id_code,
                                    p_uri_data,
                                    uri_data_len,
                                    &p_uri_msg_desc);

    if (err_code != NRF_SUCCESS)
    {
        return err_code;
    }

    /* Encode whole message into buffer */
    err_code = nfc_ndef_msg_encode(p_uri_msg_desc,
                                   p_buf,
                                   p_len);

    return err_code;
}
Esempio n. 4
0
ret_code_t nfc_ble_full_handover_select_msg_encode(ble_advdata_t const * const p_le_advdata,
                                                   ble_advdata_t const * const p_ep_advdata,
                                                   uint8_t             *       p_buf,
                                                   uint32_t            *       p_len)
{
    nfc_ndef_msg_desc_t * p_full_hs_msg_desc;
    ret_code_t            err_code;

    err_code = nfc_ble_full_handover_select_msg_declare(p_le_advdata,
                                                        p_ep_advdata,
                                                        &p_full_hs_msg_desc);

    if (err_code != NRF_SUCCESS)
    {
        return err_code;
    }
    
    if (!m_tk_modifier_on)
    {
        nfc_tk_group_modifier_config(NULL, 0);
    }

    /* Encode whole message into buffer */
    err_code = nfc_ndef_msg_encode(p_full_hs_msg_desc,
                                   p_buf,
                                   p_len);

    return err_code;
}
Esempio n. 5
0
File: main.c Progetto: IOIOI/nRF51
/**
 * @brief Function for encoding the welcome message.
 */
static void welcome_msg_encode(uint8_t * p_buffer, uint32_t * p_len)
{
    NFC_NDEF_MSG_DEF(welcome_msg, MAX_REC_COUNT);

    en_record_add(&NFC_NDEF_MSG(welcome_msg));
    no_record_add(&NFC_NDEF_MSG(welcome_msg));
    pl_record_add(&NFC_NDEF_MSG(welcome_msg));

    /** @snippet [NFC text usage_2] */
    uint32_t err_code = nfc_ndef_msg_encode(&NFC_NDEF_MSG(welcome_msg),
                                            p_buffer,
                                            p_len);
    APP_ERROR_CHECK(err_code);
    /** @snippet [NFC text usage_2] */
}
Esempio n. 6
0
ret_code_t nfc_ble_simplified_ep_oob_msg_encode( ble_advdata_t     const * const p_ep_advdata,
                                                 uint8_t                 *       p_buf,
                                                 uint32_t                *       p_len)
{
    nfc_ndef_msg_desc_t * p_ep_oob_msg_desc;
    ret_code_t            err_code;

    err_code = nfc_ble_simplified_ep_oob_msg_declare(p_ep_advdata, &p_ep_oob_msg_desc);

    if (err_code != NRF_SUCCESS)
    {
        return err_code;
    }

    /* Encode whole message into buffer */
    err_code = nfc_ndef_msg_encode(p_ep_oob_msg_desc,
                                   p_buf,
                                   p_len);

    return err_code;
}