/*
	THIS SOFTWARE IS PROVIDED BY INSIGHT SIP "AS IS" AND ANY EXPRESS
	OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
	OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
	DISCLAIMED. IN NO EVENT SHALL INSIGHT SIP OR CONTRIBUTORS BE
	LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
	CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
	GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
	HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
	LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
	OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __USER_CONFIG_H__
#define __USER_CONFIG_H__

// Timer & scheduler
#define APP_TIMER_PRESCALER             0                                           /**< Value of the RTC1 PRESCALER register. */
#define APP_TIMER_OP_QUEUE_SIZE         75                                          /**< Size of timer operation queues: 1 LED, 4 sensor notification timers   . */
#define SCHED_QUEUE_SIZE            	60                                          /**< Maximum number of events in the scheduler queue. */

// BLE
#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 APP_FEATURE_NOT_SUPPORTED       BLE_GATT_STATUS_ATTERR_APP_BEGIN + 2        /**< Reply when unsupported features are requested. */
#define APP_BLE_OBSERVER_PRIO           3                                           /**< Application's BLE observer priority. You shouldn't need to modify this value. */
#define APP_BLE_CONN_CFG_TAG            1                                           /**< A tag identifying the SoftDevice BLE configuration. */
#define APP_ADV_INTERVAL             	480                                         /**< The advertising interval (in units of 0.625 ms. This value corresponds to 300 ms). */
#define APP_ADV_TIMEOUT_IN_SECONDS      0                                           /**< The advertising timeout (in units of seconds). */
#define MIN_CONN_INTERVAL_MS            7.5                                         /**< Minimum acceptable connection interval (20 ms), Connection interval uses 1.25 ms units. */
#define MAX_CONN_INTERVAL_MS            30                                          /**< Maximum acceptable connection interval (75 ms), Connection interval uses 1.25 ms units. */
#define SLAVE_LATENCY                   0                                           /**< Slave latency. */
#define CONN_SUP_TIMEOUT_MS             3200                                        /**< Connection supervisory timeout (4 seconds), Supervision Timeout uses 10 ms units. */
#define FIRST_CONN_PARAMS_UPDATE_DELAY  APP_TIMER_TICKS(1000)                       /**< 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)                      /**< 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. */
#define TX_POWER_LEVEL                  0                                           /**< tx power in dBm. */	

// Power LED
#define PWR_LED_OFF_INTERVAL_MS		5000                                        /**< Power LED OFF interval in ms. */
#define PWR_LED_ON_INTERVAL_MS		300                                         /**< Power LED ON interval in ms. */

// BLE LED
#define BLE_LED_OFF_INTERVAL_MS         1000                                        /**< Power LED OFF interval in ms. */
#define BLE_LED_ON_INTERVAL_MS		500                                         /**< Power LED ON interval in ms. */

// LoRaWan
#define LORAWAN_APP_DATA_BUFF_SIZE	64                                          /**< Size of the data to be transmitted. */  
#define LORAWAN_APP_TX_DUTYCYCLE	10000                                       /**< Defines the application data transmission duty cycle. 10s, value in [ms]. */  
#define APP_TX_DUTYCYCLE_RND      	1000                                        /**< Defines a random delay for application data transmission duty cycle. 1s, value in [ms]. */  
#define JOINREQ_NBTRIALS                3                                           /**< Number of trials for the join request. */  
#define LORAWAN_ADR_ON                  1                                           /**< LoRaWAN Adaptive Data Rate enabled (the end-device should be static here). */  
#define LORAWAN_ADR_OFF            	0                                           /**< LoRaWAN Adaptive Data Rate disabled. */  

#define DEAD_BEEF                       0xDEADBEEF                                  /**< Value used as error code on stack dump, can be used to identify stack location on stack unwind. */


// Dummy sensor values
#define DUMMY_PRESSURE		987.95
#define DUMMY_TEMPERATURE	31.27
#define DUMMY_HUMIDITY		82.45
#define DUMMY_LIGHT             16.67
#define DUMMY_ACC_X             1.05
#define DUMMY_ACC_Y             0.12
#define DUMMY_ACC_Z             -0.01
#define DUMMY_MAG_X             2.04
#define DUMMY_MAG_Y             -6.17
#define DUMMY_MAG_Z             25.07
#define DUMMY_GYRO_X		6.01
#define DUMMY_GYRO_Y		-0.72
#define DUMMY_GYRO_Z		-0.08

/**@brief Default lora configuration. */
#define LORAMNGT_CONFIG_DEFAULT 		\
{                                               \
    .data_rate                          = 3,	\
    .tx_power                           = 0,	\
    .tx_request_interval      		= 30,	\
    .enable_adr                         = 0     \
}

#endif
