Mobile Life IoT project using the AT&T IoT Starter Kit Software and files for my device to monitor the status or our Airstream travel trailer RV. A full description of the project is at Hackster.IO here as part of the Realtime AT&T IoT Starter Kit Challenge: https://www.hackster.io/Anubus/mobile-life-iot-9c10be

Dependencies:   FXOS8700CQ MODSERIAL mbed

Committer:
Anubus
Date:
Sun Apr 02 12:28:21 2017 +0000
Revision:
0:bd276b1f1249
public version commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Anubus 0:bd276b1f1249 1 /* ===================================================================
Anubus 0:bd276b1f1249 2 Copyright © 2016, AVNET Inc.
Anubus 0:bd276b1f1249 3
Anubus 0:bd276b1f1249 4 Licensed under the Apache License, Version 2.0 (the "License");
Anubus 0:bd276b1f1249 5 you may not use this file except in compliance with the License.
Anubus 0:bd276b1f1249 6 You may obtain a copy of the License at
Anubus 0:bd276b1f1249 7
Anubus 0:bd276b1f1249 8 http://www.apache.org/licenses/LICENSE-2.0
Anubus 0:bd276b1f1249 9
Anubus 0:bd276b1f1249 10 Unless required by applicable law or agreed to in writing,
Anubus 0:bd276b1f1249 11 software distributed under the License is distributed on an
Anubus 0:bd276b1f1249 12 "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
Anubus 0:bd276b1f1249 13 either express or implied. See the License for the specific
Anubus 0:bd276b1f1249 14 language governing permissions and limitations under the License.
Anubus 0:bd276b1f1249 15
Anubus 0:bd276b1f1249 16 ======================================================================== */
Anubus 0:bd276b1f1249 17
Anubus 0:bd276b1f1249 18 #ifndef __XADOW_GPS_H_
Anubus 0:bd276b1f1249 19 #define __XADOW_GPS_H_
Anubus 0:bd276b1f1249 20
Anubus 0:bd276b1f1249 21 /*!
Anubus 0:bd276b1f1249 22 \def GPS_DEVICE_ADDR
Anubus 0:bd276b1f1249 23 The I2C address GPS
Anubus 0:bd276b1f1249 24
Anubus 0:bd276b1f1249 25 \def GPS_SCAN_ID
Anubus 0:bd276b1f1249 26 The id of scan data, the format is 0,0,0,Device address
Anubus 0:bd276b1f1249 27 \def GPS_SCAN_SIZE
Anubus 0:bd276b1f1249 28 The length of scan data
Anubus 0:bd276b1f1249 29
Anubus 0:bd276b1f1249 30 \def GPS_UTC_DATE_TIME_ID
Anubus 0:bd276b1f1249 31 The id of utc date and time, the format is YMDHMS
Anubus 0:bd276b1f1249 32 \def GPS_UTC_DATE_TIME_SIZE
Anubus 0:bd276b1f1249 33 The length of utc date and time data
Anubus 0:bd276b1f1249 34
Anubus 0:bd276b1f1249 35 \def GPS_STATUS_ID
Anubus 0:bd276b1f1249 36 The id of GPS status, the format is A/V
Anubus 0:bd276b1f1249 37 \def GPS_STATUS_SIZE
Anubus 0:bd276b1f1249 38 The length of GPS status data
Anubus 0:bd276b1f1249 39
Anubus 0:bd276b1f1249 40 \def GPS_LATITUDE_ID
Anubus 0:bd276b1f1249 41 The id of latitude, the format is dd.dddddd
Anubus 0:bd276b1f1249 42 \def GPS_LATITUDE_SIZE
Anubus 0:bd276b1f1249 43 The length of latitude data
Anubus 0:bd276b1f1249 44
Anubus 0:bd276b1f1249 45 \def GPS_NS_ID
Anubus 0:bd276b1f1249 46 The id of latitude direction, the format is N/S
Anubus 0:bd276b1f1249 47 \def GPS_NS_SIZE
Anubus 0:bd276b1f1249 48 The length of latitude direction data
Anubus 0:bd276b1f1249 49
Anubus 0:bd276b1f1249 50 \def GPS_LONGITUDE_ID
Anubus 0:bd276b1f1249 51 The id of longitude, the format is ddd.dddddd
Anubus 0:bd276b1f1249 52 \def GPS_LONGITUDE_SIZE
Anubus 0:bd276b1f1249 53 The length of longitude data
Anubus 0:bd276b1f1249 54
Anubus 0:bd276b1f1249 55 \def GPS_EW_ID
Anubus 0:bd276b1f1249 56 The id of longitude direction, the format is E/W
Anubus 0:bd276b1f1249 57 \def GPS_EW_SIZE
Anubus 0:bd276b1f1249 58 The length of longitude direction data
Anubus 0:bd276b1f1249 59
Anubus 0:bd276b1f1249 60 \def GPS_SPEED_ID
Anubus 0:bd276b1f1249 61 The id of speed, the format is 000.0~999.9 Knots
Anubus 0:bd276b1f1249 62 \def GPS_SPEED_SIZE
Anubus 0:bd276b1f1249 63 The length of speed data
Anubus 0:bd276b1f1249 64
Anubus 0:bd276b1f1249 65 \def GPS_COURSE_ID
Anubus 0:bd276b1f1249 66 The id of course, the format is 000.0~359.9
Anubus 0:bd276b1f1249 67 \def GPS_COURSE_SIZE
Anubus 0:bd276b1f1249 68 The length of course data
Anubus 0:bd276b1f1249 69
Anubus 0:bd276b1f1249 70 \def GPS_POSITION_FIX_ID
Anubus 0:bd276b1f1249 71 The id of position fix status, the format is 0,1,2,6
Anubus 0:bd276b1f1249 72 \def GPS_POSITION_FIX_SIZE
Anubus 0:bd276b1f1249 73 The length of position fix status data
Anubus 0:bd276b1f1249 74
Anubus 0:bd276b1f1249 75 \def GPS_SATE_USED_ID
Anubus 0:bd276b1f1249 76 The id of state used, the format is 00~12
Anubus 0:bd276b1f1249 77 \def GPS_SATE_USED_SIZE
Anubus 0:bd276b1f1249 78 The length of sate used data
Anubus 0:bd276b1f1249 79
Anubus 0:bd276b1f1249 80 \def GPS_ALTITUDE_ID
Anubus 0:bd276b1f1249 81 The id of altitude, the format is -9999.9~99999.9
Anubus 0:bd276b1f1249 82 \def GPS_ALTITUDE_SIZE
Anubus 0:bd276b1f1249 83 The length of altitude data
Anubus 0:bd276b1f1249 84
Anubus 0:bd276b1f1249 85 \def GPS_MODE_ID
Anubus 0:bd276b1f1249 86 The id of locate mode, the format is A/M
Anubus 0:bd276b1f1249 87 \def GPS_MODE_SIZE
Anubus 0:bd276b1f1249 88 The length of locate mode data
Anubus 0:bd276b1f1249 89
Anubus 0:bd276b1f1249 90 \def GPS_MODE2_ID
Anubus 0:bd276b1f1249 91 The id of current status, the format is 1,2,3
Anubus 0:bd276b1f1249 92 \def GPS_MODE2_SIZE
Anubus 0:bd276b1f1249 93 The length of current status data
Anubus 0:bd276b1f1249 94
Anubus 0:bd276b1f1249 95 \def GPS_SATE_IN_VIEW_ID
Anubus 0:bd276b1f1249 96 The id of sate in view
Anubus 0:bd276b1f1249 97 \def GPS_SATE_IN_VIEW_SIZE
Anubus 0:bd276b1f1249 98 The length of sate in view data
Anubus 0:bd276b1f1249 99 */
Anubus 0:bd276b1f1249 100
Anubus 0:bd276b1f1249 101 /* Data format:
Anubus 0:bd276b1f1249 102 * ID(1 byte), Data length(1 byte), Data 1, Data 2, ... Data n (n bytes, n = data length)
Anubus 0:bd276b1f1249 103 * For example, get the scan data.
Anubus 0:bd276b1f1249 104 * First, Send GPS_SCAN_ID(1 byte) to device.
Anubus 0:bd276b1f1249 105 * Second, Receive scan data(ID + Data length + GPS_SCAN_SIZE = 6 bytes).
Anubus 0:bd276b1f1249 106 * Third, The scan data begin from the third data of received.
Anubus 0:bd276b1f1249 107 * End
Anubus 0:bd276b1f1249 108 */
Anubus 0:bd276b1f1249 109
Anubus 0:bd276b1f1249 110 #define GPS_DEVICE_ID 0x05
Anubus 0:bd276b1f1249 111 //#define GPS_DEVICE_ADDR 0x05
Anubus 0:bd276b1f1249 112 #define GPS_DEVICE_ADDR 0x0A //For mbed, the address has to be << 1
Anubus 0:bd276b1f1249 113
Anubus 0:bd276b1f1249 114 #define GPS_SCAN_ID 0 // 4 bytes
Anubus 0:bd276b1f1249 115 #define GPS_SCAN_SIZE 4 // 0,0,0,Device address
Anubus 0:bd276b1f1249 116
Anubus 0:bd276b1f1249 117 #define GPS_UTC_DATE_TIME_ID 1 // YMDHMS
Anubus 0:bd276b1f1249 118 #define GPS_UTC_DATE_TIME_SIZE 6 // 6 bytes
Anubus 0:bd276b1f1249 119
Anubus 0:bd276b1f1249 120 #define GPS_STATUS_ID 2 // A/V
Anubus 0:bd276b1f1249 121 #define GPS_STATUS_SIZE 1 // 1 byte
Anubus 0:bd276b1f1249 122
Anubus 0:bd276b1f1249 123 #define GPS_LATITUDE_ID 3 // dd.dddddd
Anubus 0:bd276b1f1249 124 #define GPS_LATITUDE_SIZE 9 // 9 bytes
Anubus 0:bd276b1f1249 125
Anubus 0:bd276b1f1249 126 #define GPS_NS_ID 4 // N/S
Anubus 0:bd276b1f1249 127 #define GPS_NS_SIZE 1 // 1 byte
Anubus 0:bd276b1f1249 128
Anubus 0:bd276b1f1249 129 #define GPS_LONGITUDE_ID 5 // ddd.dddddd
Anubus 0:bd276b1f1249 130 #define GPS_LONGITUDE_SIZE 10 // 10 bytes
Anubus 0:bd276b1f1249 131
Anubus 0:bd276b1f1249 132 #define GPS_EW_ID 6 // E/W
Anubus 0:bd276b1f1249 133 #define GPS_EW_SIZE 1 // 1 byte
Anubus 0:bd276b1f1249 134
Anubus 0:bd276b1f1249 135 #define GPS_SPEED_ID 7 // 000.0~999.9 Knots
Anubus 0:bd276b1f1249 136 #define GPS_SPEED_SIZE 5 // 5 bytes
Anubus 0:bd276b1f1249 137
Anubus 0:bd276b1f1249 138 #define GPS_COURSE_ID 8 // 000.0~359.9
Anubus 0:bd276b1f1249 139 #define GPS_COURSE_SIZE 5 // 5 bytes
Anubus 0:bd276b1f1249 140
Anubus 0:bd276b1f1249 141 #define GPS_POSITION_FIX_ID 9 // 0,1,2,6
Anubus 0:bd276b1f1249 142 #define GPS_POSITION_FIX_SIZE 1 // 1 byte
Anubus 0:bd276b1f1249 143
Anubus 0:bd276b1f1249 144 #define GPS_SATE_USED_ID 10 // 00~12
Anubus 0:bd276b1f1249 145 #define GPS_SATE_USED_SIZE 2 // 2 bytes
Anubus 0:bd276b1f1249 146
Anubus 0:bd276b1f1249 147 #define GPS_ALTITUDE_ID 11 // -9999.9~99999.9
Anubus 0:bd276b1f1249 148 #define GPS_ALTITUDE_SIZE 7 // 7 bytes
Anubus 0:bd276b1f1249 149
Anubus 0:bd276b1f1249 150 #define GPS_MODE_ID 12 // A/M
Anubus 0:bd276b1f1249 151 #define GPS_MODE_SIZE 1 // 1 byte
Anubus 0:bd276b1f1249 152
Anubus 0:bd276b1f1249 153 #define GPS_MODE2_ID 13 // 1,2,3
Anubus 0:bd276b1f1249 154 #define GPS_MODE2_SIZE 1 // 1 byte
Anubus 0:bd276b1f1249 155
Anubus 0:bd276b1f1249 156 #define GPS_SATE_IN_VIEW_ID 14 // 0~12
Anubus 0:bd276b1f1249 157 #define GPS_SATE_IN_VIEW_SIZE 1 // 1 byte
Anubus 0:bd276b1f1249 158
Anubus 0:bd276b1f1249 159
Anubus 0:bd276b1f1249 160 /**
Anubus 0:bd276b1f1249 161 * \brief Get the status of the device.
Anubus 0:bd276b1f1249 162 *
Anubus 0:bd276b1f1249 163 * \return Return TRUE or FALSE. TRUE is on line, FALSE is off line.
Anubus 0:bd276b1f1249 164 *
Anubus 0:bd276b1f1249 165 */
Anubus 0:bd276b1f1249 166 unsigned char gps_check_online(void);
Anubus 0:bd276b1f1249 167
Anubus 0:bd276b1f1249 168 /**
Anubus 0:bd276b1f1249 169 * \brief Get the utc date and time.
Anubus 0:bd276b1f1249 170 *
Anubus 0:bd276b1f1249 171 * \return Return the pointer of utc date sand time, the format is YMDHMS.
Anubus 0:bd276b1f1249 172 *
Anubus 0:bd276b1f1249 173 */
Anubus 0:bd276b1f1249 174 unsigned char* gps_get_utc_date_time(void);
Anubus 0:bd276b1f1249 175
Anubus 0:bd276b1f1249 176 /**
Anubus 0:bd276b1f1249 177 * \brief Get the status of GPS.
Anubus 0:bd276b1f1249 178 *
Anubus 0:bd276b1f1249 179 * \return Return A or V. A is orientation, V is navigation.
Anubus 0:bd276b1f1249 180 *
Anubus 0:bd276b1f1249 181 */
Anubus 0:bd276b1f1249 182 unsigned char gps_get_status(void);
Anubus 0:bd276b1f1249 183
Anubus 0:bd276b1f1249 184 /**
Anubus 0:bd276b1f1249 185 * \brief Get the altitude.
Anubus 0:bd276b1f1249 186 *
Anubus 0:bd276b1f1249 187 * \return Return altitude data. The format is dd.dddddd.
Anubus 0:bd276b1f1249 188 *
Anubus 0:bd276b1f1249 189 */
Anubus 0:bd276b1f1249 190 float gps_get_latitude(void);
Anubus 0:bd276b1f1249 191
Anubus 0:bd276b1f1249 192 /**
Anubus 0:bd276b1f1249 193 * \brief Get the lattitude direction.
Anubus 0:bd276b1f1249 194 *
Anubus 0:bd276b1f1249 195 * \return Return lattitude direction data. The format is N/S. N is north, S is south.
Anubus 0:bd276b1f1249 196 *
Anubus 0:bd276b1f1249 197 */
Anubus 0:bd276b1f1249 198 unsigned char gps_get_ns(void);
Anubus 0:bd276b1f1249 199
Anubus 0:bd276b1f1249 200 /**
Anubus 0:bd276b1f1249 201 * \brief Get the longitude.
Anubus 0:bd276b1f1249 202 *
Anubus 0:bd276b1f1249 203 * \return Return longitude data. The format is ddd.dddddd.
Anubus 0:bd276b1f1249 204 *
Anubus 0:bd276b1f1249 205 */
Anubus 0:bd276b1f1249 206 float gps_get_longitude(void);
Anubus 0:bd276b1f1249 207
Anubus 0:bd276b1f1249 208 /**
Anubus 0:bd276b1f1249 209 * \brief Get the longitude direction.
Anubus 0:bd276b1f1249 210 *
Anubus 0:bd276b1f1249 211 * \return Return longitude direction data. The format is E/W. E is east, W is west.
Anubus 0:bd276b1f1249 212 *
Anubus 0:bd276b1f1249 213 */
Anubus 0:bd276b1f1249 214 unsigned char gps_get_ew(void);
Anubus 0:bd276b1f1249 215
Anubus 0:bd276b1f1249 216 /**
Anubus 0:bd276b1f1249 217 * \brief Get the speed.
Anubus 0:bd276b1f1249 218 *
Anubus 0:bd276b1f1249 219 * \return Return speed data. The format is 000.0~999.9 Knots.
Anubus 0:bd276b1f1249 220 *
Anubus 0:bd276b1f1249 221 */
Anubus 0:bd276b1f1249 222 float gps_get_speed(void);
Anubus 0:bd276b1f1249 223
Anubus 0:bd276b1f1249 224 /**
Anubus 0:bd276b1f1249 225 * \brief Get the course.
Anubus 0:bd276b1f1249 226 *
Anubus 0:bd276b1f1249 227 * \return Return course data. The format is 000.0~359.9.
Anubus 0:bd276b1f1249 228 *
Anubus 0:bd276b1f1249 229 */
Anubus 0:bd276b1f1249 230 float gps_get_course(void);
Anubus 0:bd276b1f1249 231
Anubus 0:bd276b1f1249 232 /**
Anubus 0:bd276b1f1249 233 * \brief Get the status of position fix.
Anubus 0:bd276b1f1249 234 *
Anubus 0:bd276b1f1249 235 * \return Return position fix data. The format is 0,1,2,6.
Anubus 0:bd276b1f1249 236 *
Anubus 0:bd276b1f1249 237 */
Anubus 0:bd276b1f1249 238 unsigned char gps_get_position_fix(void);
Anubus 0:bd276b1f1249 239
Anubus 0:bd276b1f1249 240 /**
Anubus 0:bd276b1f1249 241 * \brief Get the number of state used¡£
Anubus 0:bd276b1f1249 242 *
Anubus 0:bd276b1f1249 243 * \return Return number of state used. The format is 0-12.
Anubus 0:bd276b1f1249 244 *
Anubus 0:bd276b1f1249 245 */
Anubus 0:bd276b1f1249 246 unsigned char gps_get_sate_used(void);
Anubus 0:bd276b1f1249 247
Anubus 0:bd276b1f1249 248 /**
Anubus 0:bd276b1f1249 249 * \brief Get the altitude¡£ the format is -9999.9~99999.9
Anubus 0:bd276b1f1249 250 *
Anubus 0:bd276b1f1249 251 * \return Return altitude data. The format is -9999.9~99999.9.
Anubus 0:bd276b1f1249 252 *
Anubus 0:bd276b1f1249 253 */
Anubus 0:bd276b1f1249 254 float gps_get_altitude(void);
Anubus 0:bd276b1f1249 255
Anubus 0:bd276b1f1249 256 /**
Anubus 0:bd276b1f1249 257 * \brief Get the mode of location.
Anubus 0:bd276b1f1249 258 *
Anubus 0:bd276b1f1249 259 * \return Return mode of location. The format is A/M. A:automatic, M:manual.
Anubus 0:bd276b1f1249 260 *
Anubus 0:bd276b1f1249 261 */
Anubus 0:bd276b1f1249 262 unsigned char gps_get_mode(void);
Anubus 0:bd276b1f1249 263
Anubus 0:bd276b1f1249 264 /**
Anubus 0:bd276b1f1249 265 * \brief Get the current status of GPS.
Anubus 0:bd276b1f1249 266 *
Anubus 0:bd276b1f1249 267 * \return Return current status. The format is 1,2,3. 1:null, 2:2D, 3:3D.
Anubus 0:bd276b1f1249 268 *
Anubus 0:bd276b1f1249 269 */
Anubus 0:bd276b1f1249 270 unsigned char gps_get_mode2(void);
Anubus 0:bd276b1f1249 271
Anubus 0:bd276b1f1249 272 /**
Anubus 0:bd276b1f1249 273 * \brief Get the number of sate in view.
Anubus 0:bd276b1f1249 274 *
Anubus 0:bd276b1f1249 275 * \return Return the number of sate in view.
Anubus 0:bd276b1f1249 276 *
Anubus 0:bd276b1f1249 277 */
Anubus 0:bd276b1f1249 278 unsigned char gps_get_sate_in_veiw(void);
Anubus 0:bd276b1f1249 279
Anubus 0:bd276b1f1249 280 #endif