Bluetooth: Mesh: Add prov input_complete cb

Allows the user to pass a provisioning input complete callback to the
provisioning module, letting the application stop displaying its output
OOB value when the other party finishes their OOB input.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
This commit is contained in:
Trond Einar Snekvik 2019-08-26 14:34:44 +02:00 committed by Johan Hedberg
commit c91d0646a6
2 changed files with 21 additions and 0 deletions

View file

@ -128,6 +128,14 @@ struct bt_mesh_prov {
*/
int (*input)(bt_mesh_input_action_t act, u8_t size);
/** @brief The other device finished their OOB input.
*
* This callback notifies the application that it should stop
* displaying its output OOB value, as the other party finished their
* OOB input.
*/
void (*input_complete)(void);
/** @brief Provisioning link has been opened.
*
* This callback notifies the application that a provisioning

View file

@ -112,6 +112,7 @@ enum {
LINK_ACTIVE, /* Link has been opened */
WAIT_NUMBER, /* Waiting for number input from user */
WAIT_STRING, /* Waiting for string input from user */
NOTIFY_INPUT_COMPLETE, /* Notify that input has been completed. */
LINK_INVALID, /* Error occurred during provisioning */
NUM_FLAGS,
@ -672,6 +673,8 @@ static int prov_auth(u8_t method, u8_t action, u8_t size)
return -EINVAL;
}
atomic_set_bit(link.flags, NOTIFY_INPUT_COMPLETE);
if (output == BT_MESH_DISPLAY_STRING) {
unsigned char str[9];
u8_t i;
@ -954,9 +957,18 @@ static void pub_key_ready(const u8_t *pkey)
}
}
static void notify_input_complete(void)
{
if (atomic_test_and_clear_bit(link.flags, NOTIFY_INPUT_COMPLETE) &&
prov->input_complete) {
prov->input_complete();
}
}
static void prov_input_complete(const u8_t *data)
{
BT_DBG("");
notify_input_complete();
}
static void prov_confirm(const u8_t *data)
@ -965,6 +977,7 @@ static void prov_confirm(const u8_t *data)
memcpy(link.conf, data, 16);
notify_input_complete();
send_confirm();
}