C SIGFOX CALLBACK  0.0.1
A Sigfox Callback program writtent in C
sqls.h
Go to the documentation of this file.
1 
10 #ifndef __SQLS_H__
11 #define __SQLS_H__
12 
13 #ifdef __cplusplus
14 extern "C" {
15 #endif
16 
17 
22 #define SQL_COL_ID_RAWS "id_raws"
23 #define SQL_COL_TIMESTAMP "timestamp"
24 #define SQL_COL_ID_MODEM "id_modem"
25 #define SQL_COL_SNR "snr"
26 #define SQL_COL_STATION "station"
27 #define SQL_COL_ACK "ack"
28 #define SQL_COL_DATA_STR "data_str"
29 #define SQL_COL_DATA_HEX "data_hex"
30 #define SQL_COL_DUPLICATE "duplicate"
31 #define SQL_COL_AVG_SIGNAL "avg_signal"
32 #define SQL_COL_RSSI "rssi"
33 #define SQL_COL_LATITUDE "latitude"
34 #define SQL_COL_LONGITUDE "longitude"
35 #define SQL_COL_SEQ_NUMBER "seq_number"
36 #define SQL_COL_LONG_POLLING "long_polling"
37 #define SQL_COL_ATTRIBUTION "attribution"
38 #define SQL_COL_TIMESTAMP_ATTRIBUTION "timestamp_attribution"
39 
40 
48 #define SQL_IDX_ID_RAWS 0
49 #define SQL_IDX_TIMESTAMP 1
50 #define SQL_IDX_ID_MODEM 2
51 #define SQL_IDX_SNR 3
52 #define SQL_IDX_STATION 4
53 #define SQL_IDX_ACK 5
54 #define SQL_IDX_DATA_STR 6
55 #define SQL_IDX_DATA_HEX 7
56 #define SQL_IDX_DUPLICATE 8
57 #define SQL_IDX_AVG_SIGNAL 9
58 #define SQL_IDX_RSSI 10
59 #define SQL_IDX_LATITUDE 11
60 #define SQL_IDX_LONGITUDE 12
61 #define SQL_IDX_SEQ_NUMBER 13
62 
63 
71 #define CREATE_SIGFOX_TABLES \
72  "-- CREATION OF THE SIGFOX TABLES WITH SOME DATA\n" \
73  "\n" \
74  "--\n" \
75  "-- Create 'raws' table\n" \
76  "--\n" \
77  "CREATE TABLE IF NOT EXISTS `raws` (\n" \
78  " `id_raws` INTEGER PRIMARY KEY AUTOINCREMENT,\n" \
79  " `timestamp` INTEGER NOT NULL,\n" \
80  " `id_modem` TEXT NOT NULL,\n" \
81  " `snr` REAL NOT NULL,\n" \
82  " `station` TEXT NOT NULL,\n" \
83  " `ack` INTEGER,\n" \
84  " `data_str` TEXT NOT NULL,\n" \
85  " `data_hex` BLOB NOT NULL,\n" \
86  " `duplicate` INTEGER NOT NULL,\n" \
87  " `avg_signal` REAL NOT NULL,\n" \
88  " `rssi` REAL NOT NULL,\n" \
89  " `latitude` INTEGER NOT NULL,\n" \
90  " `longitude` INTEGER NOT NULL,\n" \
91  " `seq_number` INTEGER NOT NULL\n" \
92  ");\n" \
93  "\n" \
94  "\n" \
95  "--\n" \
96  "-- Create 'devices' table\n" \
97  "--\n" \
98  "CREATE TABLE IF NOT EXISTS `devices` (\n" \
99  " `id_modem` TEXT NOT NULL UNIQUE,\n" \
100  " `attribution` INTEGER,\n" \
101  " `timestamp_attribution` INTEGER\n" \
102  ");"
103 
104 
108 #define DROP_SIGFOX_TABLES \
109  "-- DELETION OF THE SIGFOX TABLES\n" \
110  "\n" \
111  "-- Delete the tables if they exists\n" \
112  "DROP TABLE IF EXISTS `raws`;\n" \
113  "DROP TABLE IF EXISTS `devices`;"
114 
115 
119 #define SELECT_RAWS \
120  "SELECT timestamp, id_modem, snr, station, ack, data_str, data_hex, duplicate, avg_signal," \
121  "rssi, latitude, longitude, seq_number FROM `raws`"
122 
123 
127 #define SELECT_DEVICES "SELECT * FROM `devices`;"
128 
129 
133 #define DELETE_RAWS "DELETE FROM raws;"
134 
135 
139 #define INSERT_DEVICES "INSERT INTO `devices` VALUES (?, ?, ?);"
140 
141 
145 #define INSERT_RAWS "INSERT INTO `raws` VALUES (NULL, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);"
146 
147 #ifdef __cplusplus
148 }
149 #endif
150 
151 #endif // __SQLS_H__