#ifndef GLOBALDEFS_H
#define GLOBALDEFS_H

#define IS_SRVC_CHANGED_CHARACT_PRESENT  	1                  /**< Include or exclude the Service Changed characteristic. If excluded, the server's database cannot be changed for the lifetime of the device.*/
#define CENTRAL_LINK_COUNT                  0                  /**<number of central links used by the application. When changing this number remember to adjust the RAM settings*/
#define PERIPHERAL_LINK_COUNT               1                  /**<number of peripheral links used by the application. When changing this number remember to adjust the RAM settings*/

#define TX_POWER_LEVEL                    	(-8)                 							/**< TX Power Level value. This will be set both in the TX Power service, in the advertising data, and also used to set the radio transmit power. */
#define APP_FEATURE_NOT_SUPPORTED        	BLE_GATT_STATUS_ATTERR_APP_BEGIN + 2         	/**< Reply when unsupported features are requested. */


// Firmware Version
#define FW_REVISION	"6"

// Timers Defines
#define DATA_UPDATE_1000_INTERVAL     		APP_TIMER_TICKS(1000, APP_TIMER_PRESCALER)		// 1 Hz
#define DATA_UPDATE_60000_INTERVAL     		APP_TIMER_TICKS(60000, APP_TIMER_PRESCALER)		// 1/min

#define APP_TIMER_PRESCALER              	0                                          		/**< Value of the RTC1 PRESCALER register. */
#define APP_TIMER_MAX_TIMERS             	(6+BSP_APP_TIMERS_NUMBER)                  		/**< Maximum number of simultaneously created timers. */
#define APP_TIMER_OP_QUEUE_SIZE          	4                                          		/**< Size of timer operation queues. */

// Advertising Defines
#define MANUFACTURER_NAME					"InsightSIP"                      				/**< Manufacturer. Will be passed to Device Information Service. */
#if defined(CONFIG_AS_TAG)
#define DEVICE_NAME                       	"UWB_TAG"                              	/**< Name of device. Will be included in the advertising data. */
#elif defined(CONFIG_AS_ANCHOR)
#define DEVICE_NAME                       	"UWB_ANC"                              	/**< Name of device. Will be included in the advertising data. */
#endif
#define APP_ADV_INTERVAL                 	400                                      		/**< The advertising interval (in units of 0.625 ms) 1600 means 1sec */
#define APP_ADV_TIMEOUT_IN_SECONDS       	0	                                       		/**< The advertising time-out in units of seconds. 0 means infinity */

// Connection parameter Defines
#define MIN_CONN_INTERVAL                   MSEC_TO_UNITS(7.5, UNIT_1_25_MS)             	/**< Minimum acceptable connection interval (7.5 ms).  */
#define MAX_CONN_INTERVAL                   MSEC_TO_UNITS(1000, UNIT_1_25_MS)            	/**< Maximum acceptable connection interval (1 second). */
#define SLAVE_LATENCY                       0                                          		/**< Slave latency. */
#define CONN_SUP_TIMEOUT                    MSEC_TO_UNITS(5000, UNIT_10_MS)              	/**< Connection supervisory timeout (4 seconds). */

#define FIRST_CONN_PARAMS_UPDATE_DELAY   	APP_TIMER_TICKS(5000, APP_TIMER_PRESCALER) 		/**< Time from initiating event (connect or start of notification) to first time sd_ble_gap_conn_param_update is called (5 seconds). */
#define NEXT_CONN_PARAMS_UPDATE_DELAY    	APP_TIMER_TICKS(30000, APP_TIMER_PRESCALER)		/**< Time between each call to sd_ble_gap_conn_param_update after the first call (30 seconds). */
#define MAX_CONN_PARAMS_UPDATE_COUNT     	3                                          		/**< Number of attempts before giving up the connection parameter negotiation. */

// Bond Defines
#define SEC_PARAM_BOND                    1	                                            	/**< Perform bonding. */
#define SEC_PARAM_MITM                    0                                            		/**< Man In The Middle protection not required. */
#define SEC_PARAM_LESC                    0                                            		/**< LE Secure Connections not enabled. */
#define SEC_PARAM_KEYPRESS                0                                            		/**< Keypress notifications not enabled. */
#define SEC_PARAM_IO_CAPABILITIES         BLE_GAP_IO_CAPS_NONE                         		/**< No I/O capabilities. */
#define SEC_PARAM_OOB                     0                                            		/**< Out Of Band data not available. */
#define SEC_PARAM_MIN_KEY_SIZE            7                                            		/**< Minimum encryption key size. */
#define SEC_PARAM_MAX_KEY_SIZE            16                                           		/**< Maximum encryption key size. */

// DFU Defines
#define DEAD_BEEF                        0xDEADBEEF                                 		/**< Value used as error code on stack dump, can be used to identify stack location on stack unwind. */
#ifdef BLE_DFU_APP_SUPPORT
#define DFU_REV_MAJOR                    0x00                                       		/** DFU Major revision number to be exposed. */
#define DFU_REV_MINOR                    0x01                                       		/** DFU Minor revision number to be exposed. */
#define DFU_REVISION                     ((DFU_REV_MAJOR << 8) | DFU_REV_MINOR)     		/** DFU Revision number to be exposed. Combined of major and minor versions. */
#define APP_SERVICE_HANDLE_START         0x000C                                     		/**< Handle of first application specific service when when service changed characteristic is present. */
#define BLE_HANDLE_MAX                   0xFFFF                                     		/**< Max handle value in BLE. */

STATIC_ASSERT(IS_SRVC_CHANGED_CHARACT_PRESENT);                                     		/** When having DFU Service support in application the Service Changed Characteristic should always be present. */
#endif // BLE_DFU_APP_SUPPORT

// Decawave
#define DECA_CONF_PRF_OFFSET	(0x0)
#define DECA_CONF_DR_OFFSET		(0x1)
#define DECA_CONF_PLEN_OFFSET	(0x3)
#define DECA_CONF_PC_OFFSET		(0x6)
#define DECA_CONF_CH_OFFSET		(0xB)
#define DECA_CONF_SFD_OFFSET	(0xE)

#define DECA_CONF_PRF_SIZE		(0x1)
#define DECA_CONF_DR_SIZE		(0x3)
#define DECA_CONF_PLEN_SIZE		(0x7)
#define DECA_CONF_PC_SIZE		(0x1F)
#define DECA_CONF_CH_SIZE		(0x7)
#define DECA_CONF_SFD_SIZE		(0x1)

#endif
