init

Dependencies:   aconno_I2C Lis2dh12 WatchdogTimer

main.h

Committer:
pathfindr
Date:
2019-06-25
Revision:
54:2840f2d50734
Parent:
52:bd7678eade77
Child:
56:efd9f5613549

File content as of revision 54:2840f2d50734:

/*
================================================================================
Project:    GPS Tracker
Module:     ---
Status:     Development
Type:       .h header file
Copyright (c) 2018 Pathfindr Ltd
All Rights Reserved.
================================================================================
Notes:
================================================================================
*/
#ifndef MAIN_INTERFACE_H_
#define MAIN_INTERFACE_H_

//------------------------------------------------------------------------------
//FW DETAILS
//------------------------------------------------------------------------------ 
#define FW_VERSION          26
//#define SKU                 "GPSPLUSDEV"
#define SKU                 "GPSPLUS"
#define HW_MAJORREVISION    "001"

//OPTIONS
#define USE_NRF_TEMP_SENSOR                 false
#define BLE_ENABLED                         true

//DEFAULT VELUES
#define DEFAULT_SLEEP_FRAME                 30000
#define DEFAULT_FORCE2G                     false
#define DEFAULT_LOCATION_MODE               1
#define DEFAULT_LOCATION_ACCURACY           1  // 0 = no location, 1 = cl only, 2 = gps then cl
#define DEFAULT_LOCATION_TX_INTERVAL_MINS   1440
#define DEFAULT_LOCATION_TX_FAILSAFE_HRS    168
#define DEFAULT_LOCATION_TIMEOUT            120
#define DEFAULT_MOTION_G                    7
#define DEFAULT_MOTION_START_SECONDS        120
#define DEFAULT_MOTION_STOP_SECONDS         120
#define DEFAULT_IMPACT_G                    127
#define DEFAULT_CONNECTION_ATTEMPTS         1
#define DEFAULT_CONNECTION_TIMEOUT          140
#define DEFAULT_MAX_FAILED_CONNECTIONS      3 //max number of failed connections before device stops broadcasting until movement detected
#define DEFAULT_MAX_FAILED_GPS              3 //max number of failed gps searches before device stops trying gps until movement detected
#define DEFAULT_MAX_MODEMBROWNOUTS          2
#define DEFAULT_BEACON_INTERVAL_SECONDS     10
#define DEFAULT_BEACON_POWER                4 //(accepted values are -40, -30, -20, -16, -12, -8, -4, 0, and 4 dBm)

//CONSTS
#define ONEDAYINSECONDS                     86400
#define THREEDAYSINSECONDS                  259200
#define SEVENDAYSINSECONDS                  604800
#define TENDAYSINSECONDS                    864000

//MODES
#define LOCATION_MODE_INTERVAL              1
#define LOCATION_MODE_INTERVAL_MOTION       2
#define LOCATION_MODE_INTELLIGENT           3
#define LOCATION_MODE_REALTIME              4

//DEFINES
#define ACTIVITY_BUFFERSIZE                 100
#define DEBUG_BUFFERSIZE                    200

//------------------------------------------------------------------------------
//mbed Libraries
//------------------------------------------------------------------------------
#include "mbed.h"
//#include "nrf_soc.h"
#include "board.h"
#if BLE_ENABLED 
    #include "ble/BLE.h" 
#endif
//------------------------------------------------------------------------------
//peripheral Libraries
//------------------------------------------------------------------------------
#include "WatchdogTimer.h"
#include "LIS3DH.h"
#include "SI7060.h"
#include "acd_nrf52_saadc.h"

//------------------------------------------------------------------------------
//Application headers
//------------------------------------------------------------------------------
#include "NRFuart.h"
#include "app_data.h"
#include "states.h"
#include "common.h"
#include "sensors.h"
#include "modem.h"

//BLE SERVICE IDS
#define BLE_SERVICEID_GPSPLUS               0xfb10
#define BLE_SERVICEID_PFDETECTOR1           0x4e96
#define BLE_SERVICEID_PFBEACON1             0xfe9a //ESTIMOTE
#define BLE_SERVICEID_BT04                  0xcbff //TZBT04 Temp/humid
#define BLE_SERVICEID_PFBEACON2             0xfb20

//------------------------------------------------------------------------------
//Global macros
//------------------------------------------------------------------------------
//#define lowByte(w) ((uint8_t) ((w) & 0xff))
//#define highByte(w) ((uint8_t) ((w) >> 8))

//------------------------------------------------------------------------------
//GLOBAL VARS
//------------------------------------------------------------------------------ 

extern bool GLOBAL_accel_healthy;
extern bool GLOBAL_requireSoftReset;
extern bool GLOBAL_motionFlagTriggered;
extern bool GLOBAL_debugLED;
extern bool GLOBAL_needToConfigureLis3dh;
extern bool GLOBAL_registeredOnNetwork;
extern bool GLOBAL_modemOn;
extern bool GLOBAL_LEDSequenceinProgress;
extern time_t GLOBAL_RTCunixtime;
extern time_t GLOBAL_wakeTime;
extern char GLOBAL_debug_buffer[DEBUG_BUFFERSIZE];
extern char GLOBAL_GPSlocString_prev[70];
extern bool GLOBAL_have_GPSlocString_prev;
extern char GLOBAL_exceptionStringRetainedUntilSuccess[10];
//FUNCS
extern void watchdogKick();
extern void addToExceptionString(char* value);
#endif