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

Input OOB over button BLE Mesh

Hi,

I have the nRF52833-DK and try to implement the OOB Input method over a simple button press, but at the moment I don't see how this can be managed.

In mesh_provisionee.c I choose the following OOB settings:

uint32_t mesh_provisionee_prov_start(const mesh_provisionee_start_params_t * p_start_params)
{
    nrf_mesh_prov_oob_caps_t prov_caps =
    {
        ACCESS_ELEMENT_COUNT,
        NRF_MESH_PROV_ALGORITHM_FIPS_P256EC,
        0,
        0,
        0,
        0,
        PROVISIONING_DATA_LENGHTH,
        NRF_MESH_PROV_OOB_INPUT_ACTION_PUSH
    };
    ...
}

Now I should receive an event here: 

static void prov_evt_handler(const nrf_mesh_prov_evt_t * p_evt)
{
    switch (p_evt->type)
    {
        case NRF_MESH_PROV_EVT_INVITE_RECEIVED:
            if (m_params.prov_device_identification_start_cb != NULL
                && p_evt->params.invite_received.attention_duration_s > 0)
            {
                m_device_identification_started = true;
                m_params.prov_device_identification_start_cb(p_evt->params.invite_received.attention_duration_s);
            }

            break;

        case NRF_MESH_PROV_EVT_START_RECEIVED:
            if (m_params.prov_device_identification_stop_cb != NULL
                && m_device_identification_started)
            {
                m_device_identification_started = false;
                m_params.prov_device_identification_stop_cb();
            }

            break;

        case NRF_MESH_PROV_EVT_LINK_CLOSED:
            if (!m_device_provisioned)
            {
                if (m_params.prov_abort_cb != NULL)
                {
                    m_device_identification_started = false;
                    m_params.prov_abort_cb();
                }

                (void) provisionee_start();
            }
            else
            {
#if MESH_FEATURE_PB_GATT_ENABLED
                /* it requires switching GATT service before provisioning complete */
                gatt_database_reset();
#else
                if (m_params.prov_complete_cb != NULL)
                {
                    m_params.prov_complete_cb();
                }
#endif  /* MESH_FEATURE_PB_GATT_ENABLED */
            }
            break;

        case NRF_MESH_PROV_EVT_STATIC_REQUEST:
            APP_ERROR_CHECK(nrf_mesh_prov_auth_data_provide(&m_prov_ctx,
                                                                 m_params.p_static_data,
                                                                 NRF_MESH_KEY_SIZE));
            break;
        case NRF_MESH_PROV_EVT_COMPLETE:
        {
            APP_ERROR_CHECK(mesh_stack_provisioning_data_store(
                                    p_evt->params.complete.p_prov_data,
                                    p_evt->params.complete.p_devkey));
            m_device_provisioned = true;
            break;
        }
        case NRF_MESH_PROV_EVT_INPUT_REQUEST:
        {
            APP_ERROR_CHECK(nrf_mesh_prov_auth_data_provide(&m_prov_ctx,
                                                     m_params.p_static_data,
                                                     NRF_MESH_KEY_SIZE));
            break;
        }

        default:
            break;
    }
}

which goes into NRF_MESH_PROV_EVT_INPUT_REQUEST, right?

But how can I now wait for a button press?

Kind Regards,

Sebastian

  • Hi Sebastian, 

    Your understanding is correct. When you receive NRF_MESH_PROV_EVT_INPUT_REQUEST you can call a function inside main.c (in your application) to wait for button press and then count the number of button press. How do you count the press is upto you. You can think of using button_event_handler(). There is a simple debouncing mechanism implemented in simple_hal.c. 

    After you have count the number of press (0-10)  and 5 seconds of no press, then you can send the value back using nrf_mesh_prov_auth_data_provide().

    In my demo here, I added support for OOB Output BLINK to the provisionee. You may use it as a reference. 

Related