Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Registering TimeSlot API as SoftDevice Observer

I am attempting to implement the Time Slot API into SDK 15, based on the SDK 11 Multi-Acitivy example: https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.sdk5.v11.0.0%2Fble_sdk_app_multi_activity.html

I am having a hard time registering the Time Slot instance as a soft device event observer. Specifically, it seems like a structure needs to be created to hold the status info, but I am not sure how to create this structure, or what would need to be included in it. ("app_beacon_on_sys_evt") Any thoughts?

#ifndef ADVERTISER_BEACON_H__
#define ADVERTISER_BEACON_H__

#include <stdint.h>
#include <stdbool.h>
#include "ble_types.h"
#include "ble_gap.h"
#include "ble_srv_common.h"
#include "nrf_soc.h"


/**@brief   Macro for defining a beacon instance.
 *
 * @param   _name   Name of the instance.
 * @hideinitializer
 */
#define BLE_BEACON_DEF(_name)                                                                  \
static ble_beacon_t _name;                                                                     \                                         \
NRF_SDH_SOC_OBSERVER(_name ## _soc_obs,                                                             \
                     BLE_ADV_SOC_OBSERVER_PRIO,                                                     \
                     app_beacon_on_sys_evt, &_name)

// Forward declaration of the ble_beacon_t type. 
typedef struct ble_beacon_s ble_beacon_t;

static struct
{
    ble_uuid128_t           uuid;                               /** 128 proprietary service UUID to include in advertisement packets*/
    uint32_t                adv_interval;                       /** Advertising interval in milliseconds to be used for 'beacon' advertisements*/
    uint16_t                major;                              /** Major identifier to use for 'beacon'*/
    uint16_t                minor;                              /** Minor identifier to use for 'beacon'*/
    bool                    keep_running;                       /** */
    bool                    is_running;                         /** is the 'beacon' running*/
    uint32_t                slot_length;                        /** */
    nrf_radio_request_t     timeslot_request;                   /** */
    uint16_t                manuf_id;
    uint16_t                rssi;                               /** measured RSSI at 1 meter distance in dBm*/
    ble_gap_addr_t          beacon_addr;                        /** ble address to be used by the beacon*/
    ble_srv_error_handler_t error_handler;                      /**< Function to be called in case of an error. */
} ble_beacon_s;

typedef struct
{
    ble_uuid128_t           uuid;
    uint32_t                adv_interval;
    uint16_t                major;
    uint16_t                minor;
    uint16_t                manuf_id;
    uint8_t                 rssi;                               /** measured RSSI at 1 meter distance in dBm*/
    ble_gap_addr_t          beacon_addr;                        /** ble address to be used by the beacon*/    
    ble_srv_error_handler_t error_handler;                      /**< Function to be called in case of an error. */
} ble_beacon_init_t;


/**@brief Function for handling system events.
 *
 * @details Handles all system events of interest to the Advertiser module. 
 *
 * @param[in]   event     received event.
 */
void app_beacon_on_sys_evt(uint32_t event);

/**@brief Function for initializing the advertiser module.
 *
 * @param[in]   p_init     structure containing advertiser configuration information.
 */
void app_beacon_init(ble_beacon_init_t * p_init);

/**@brief Function for starting the advertisement.
 *
 */
void app_beacon_start(void);

/**@brief Function for stopping the advertisement.
 * @note This functions returns immediately, but the advertisement is actually stopped after the next radio slot.
 *
 */
void app_beacon_stop(void);

#endif // ADVERTISER_BEACON_H__

Parents Reply Children
Related