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

device manager application context in central

Hi,

I'm having a hard time figuring out how to load and store application context from the device manager without being connected to a peripheral.

According to the device_manager.h header file:

/**
 * @brief Function for setting Application Context for a peer device identified by the 'p_handle' parameter.
 *
 * @details This application allows the setting of the application context for the peer device identified by
 *          the 'p_handle'. Application context is stored persistently by the module and can be
 *          requested by the application at any time using the \ref dm_application_context_get
 *          API. Note that this procedure is permitted only for bonded devices. If the
 *          device is not bonded, application context cannot be set. However, it is not mandatory
 *          that the bonded device is connected when requesting this procedure.
 *
 * @param[in] p_handle  Identifies peer device for which procedure is requested.
 *
 * @param[in] p_context Application context being set. The context information includes length of the
 *                      data and pointer to the contextual data being set. The memory pointed to by
 *                      the data pointer is assumed to be resident when API is being called and
 *                      can be freed or reused once the set procedure is complete. Set procedure
 *                      completion is notified by the event \ref DM_EVT_APPL_CONTEXT_STORED.
 *                      The event result is notified along with the event and indicates success or
 *                      failure of this procedure.
 *
 * @retval NRF_SUCCESS             On success, else an error code indicating reason for failure.
 * @retval NRF_ERROR_INVALID_STATE If the API is called without module initialization and/or
 *                                 application registration.
 * @retval NRF_ERROR_NULL          If p_handle and/or p_context is NULL.
 * @retval NRF_ERROR_INVALID_ADDR  If peer is not identified the handle provided by the application.
 *
 * @note The API returns FEATURE_NOT_ENABLED in case DEVICE_MANAGER_APP_CONTEXT_SIZE is set to zero.
 */
api_result_t dm_application_context_set(dm_handle_t const              * p_handle,
                                        dm_application_context_t const * p_context);

dm_application_context_set(...) can be called at any time and "it is not mandatory that the bonded device is connected when requesting this procedure".

However, I can't figure out how I would get the dm_handle_t to identify the peer device without getting this information passed into my device manager event handler function which has the following signature:

static api_result_t device_manager_event_handler(const dm_handle_t    * p_handle,
                                                 const dm_event_t     * p_event,
                                                 const api_result_t     event_result)
{
...
} 

What I actually want to do is load a mapping table so that I can correlate a stored whitelist with specific peer numbers at bootup time. Each one of this peer numbers would correspond to a bonded client and an LED that would reflect the state of that client.

Anyone have any ideas?

Edit: commas between tags.

Related