/* ************************************************************************ ** ** Copyright (c) 2008..2013 by ** Core|Vision B.V. ** Cereslaan 10b ** 5384 VT Heesch ** The Netherlands ** ** All Rights Reserved ** ************************************************************************ */ /* ************************************************************************ ** ** Project name: Dual Inventive: Zelfsignalerende Kortsluit Lans ** Filename: database-if.h ** Author: Jack Weeland ** Date: September 2, 2008 ** File version: $Revision: 1.8 $ ** $Date: 2014/10/23 14:35:51 $ ** ************************************************************************ */ /* ************************************************************************ ** ** TCP server; interface to the database ** Definitions ** ************************************************************************ */ #ifndef _DATABASE_IF_H #define _DATABASE_IF_H /* ** Constants */ // buffer size for database queries #define DB_QUERY_BUFSIZE 4096 // buffer size for string results from a query #define DB_STR_BUFSIZE 1024 // Version numbers and device info #define N_VERSION 56 // (first entries are present in the database) #define N_VERSION_ALL 64 // (number including special items) #define VERSIONIDX_IMEI 0 // Equipment identifier #define VERSIONIDX_IMSI 1 // Subscriber identifier #define VERSIONIDX_CCID 2 // SIM card number #define VERSIONIDX_PHONENR 3 // Device's telephone number #define VERSIONIDX_MECH_VERSION 4 // Mechanics #define VERSIONIDX_IDCODE 6 // Customer's identification for the device #define VERSIONIDX_SERIAL 7 // Serial number #define VERSIONIDX_PCB_VERSION 9 // PCB version #define VERSIONIDX_PCB_REVISION 10 // PCB hardware revision #define VERSIONIDX_PCB_SERIAL 11 // PCB serial number (production number) #define VERSIONIDX_MCU_FIRMWARE 12 // MCU firmware version #define VERSIONIDX_MCU_HARDWARE 13 // MCU hardware version and revision #define VERSIONIDX_WCPU_FIRMWARE 16 // WCPU firmware version #define VERSIONIDX_MODEM_FIRMWARE 20 // Modem firmware version #define VERSIONIDX_MODEM_HARDWARE 21 // Modem hardware version and revision #define VERSIONIDX_MODEM_SERIAL 23 // Modem serial number #define VERSIONIDX_IO_FIRMWARE 24 // I/O chip (uALFAT) firmware version #define VERSIONIDX_IO_HARDWARE 25 // I/O chip (uALFAT) brand, model, revision #define VERSIONIDX_GPS_FIRMWARE 28 // GPS receiver's firmware revision #define VERSIONIDX_GPS_HARDWARE 29 // GPS receiver brand, model and hardware version #define VERSIONIDX_GPS_SERIAL 31 // GPS receiver's serial number #define VERSIONIDX_SW3000_HARDWARE 33 // Switch 3000, hardware version #define VERSIONIDX_SW3000D_FIRMWARE 36 // Switch 3000, "drive" firmware version #define VERSIONIDX_SW3000M_FIRMWARE 40 // Switch 3000, "measure" firmware version #define VERSIONIDX_GPRS_APN 44 // GPRS APN, username and password #define VERSIONIDX_TCPSERVER 45 // IP-address or hostname for the TCP server #define VERSIONIDX_SMSSERVER 46 // IP-address or hostname for the SMS server #define VERSIONIDX_TELSERVER 47 // Phone number of the SMS server #define VERSIONIDX_IPADDRESS 48 // Fixed IP address #define VERSIONIDX_GATEWAY 49 // Fixed gateway address // specials (not in the database or via another table) #define VERSIONIDX_DEVICE_TYPE 56 // 16-bit device or firmware type (4-digit hexadecimal) #define VERSIONIDX_GPS_FIXED 57 // fixed GPS position // special purpose flags #define VERSIONIDX_ALL (-1) #define VERSION_BITFIELD(index) ((uint64_t)1 << (index)) extern const char *VERSION_FIELDS[N_VERSION]; // SYNCDB fields #define N_SYNCDB 20 #define SYNCDB_ID 0x00000001 // synchronize device identification and version numbers #define SYNCDB_CONFIG 0x00000002 // synchronize device configuration #define SYNCDB_SERVERS 0x00000004 // synchronize server addresses #define SYNCDB_PHONENR 0x00000008 // retrieve device's telephone number (via SMS server) #define SYNCDB_SECURE 0x00000010 // generate and exchange a new secure key #define SYNCDB_GATEWAY 0x00000020 // update gateway and child devices #define SYNCDB_I18N 0x00000100 // program SMS translation table #define SYNCDB_TZ 0x00000200 // set device's time zone #define SYNCDB_SMS 0x00000400 // not used; SMS translation table is programmed when SYNCDB_I18N is set #define SYNCDB_PHONEBOOK 0x00001000 // synchronize the device's phone book for autonomous warnings via SMS #define SYNCDB_TIMERS 0x00002000 // timers for periodic events #define SYNCDB_HEARTBEAT 0x00004000 // request heartbeats from the device (synchronized to about too much data traffic) #define SYNCDB_GEOFENCE 0x00010000 // program a (new) geofence #define SYNCDB_THRESHOLDS 0x00020000 // program (new) temperature, and perhaps other thresholds #define SYNCDB_RELEASE 0x00080000 // release or inhibit the device (RC functionality) #define SYNCDB_ANY 0xFFFFFFFF extern const char *SYNCDB_FIELDS[N_SYNCDB]; // CAPABILITY fields #define N_CAPABILITY 32 #define CAPABILITY_MEASUREMENT 0x00000001 // device is equiped for measuring the short between the rails #define CAPABILITY_SWITCH 0x00000002 // short between the rails can be switched #define CAPABILITY_KEY_ONOFF 0x00000004 // device has a key switch and not just a button #define CAPABILITY_GPS 0x00000010 // device has a GPS receiver #define CAPABILITY_GPS_FIXED 0x00000020 // device has a fixed GPS position #define CAPABILITY_GEOFENCE 0x00000040 // device supports geofences #define CAPABILITY_LED 0x00000100 // device has LEDs with an adjustable intensity #define CAPABILITY_LANTERN 0x00000200 // device has a lantern #define CAPABILITY_EXTCONTACT 0x00000400 // device has an external contact to control external hardware #define CAPABILITY_RELAY 0x00000800 // device has a relay to control external hardware #define CAPABILITY_GSM 0x00001000 // device has GSM #define CAPABILITY_GPRS 0x00002000 // device can set up an network connection over GPRS/UMTS/3G/4G/ethernet/wifi/Zigbee/XBee/etc #define CAPABILITY_SMS 0x00004000 // device has direct SMS capabilities, via its modem // NB: this flag is not part of the database // NB: wehn not set yet the device can send an SMS, it is sent via an SMS-MO #define CAPABILITY_GATEWAY 0x00008000 // device is the gateway to its children #define CAPABILITY_T_ONBOARD 0x00010000 // device has an on-board temperature sensor #define CAPABILITY_T_EXTERN 0x00020000 // device has one or more external temperature sensors, such as an NTC #define CAPABILITY_VIBR 0x00100000 // device has a vibration sensor #define CAPABILITY_TILT 0x00200000 // device has a tilt sensor #define CAPABILITY_LOCK 0x01000000 // device can be locked extern const char *CAPABILITIES[N_CAPABILITY]; // mappings from CAPABILITY to STATUPDATE fields #define N_BATTERY 2 // maximum number of batteries supported by database #define N_TEMPSENSOR 2 // maximum number of temperature sensor supported extern const unsigned int CAPABILITY_DEFAULT; extern const unsigned int CAPABILITY_BATTERY[N_BATTERY]; extern const unsigned int CAPABILITY_UPDATE_FIELD[N_CAPABILITY]; // Device status #define N_LANSSTATUS 7 // (enum) #define LANSSTATUS_NEW 0 // recently added to the database #define LANSSTATUS_PRODUCTION 1 // device is being prepared for future use #define LANSSTATUS_SERVICE 2 // device is in service #define LANSSTATUS_ACTIVE 3 // (normal operational state) #define LANSSTATUS_SHOP 4 // device is not yet sold or assigned #define LANSSTATUS_WRITEOFF 5 // device is lost due to damage #define LANSSTATUS_LOST 6 // device location is unknown extern const char *LANSSTATUS[N_LANSSTATUS]; #endif /* _DATABASE_IF_H */