Pubnub demo for AT&T IoT Starter Kit. Functionally similar to the Flow demo.

Dependencies:   FXOS8700CQ MODSERIAL mbed

http://pubnub.github.io/slides/workshop/pictures/broadcast.png

Pubnub demo for AT&T IoT Starter Kit

This demo is functionally similar to the Flow demo, so you can find general information here: https://developer.mbed.org/users/JMF/code/Avnet_ATT_Cellular_IOT/.

The only difference is that we use Pubnub to publish the measurements and subscribe to receiving the instructions to set the LED.

Settings

Pubnub related settings are:

Pubnub settings in `config_me.h`

PUBNUB_SUBSCRIBE_KEY
PUBNUB_PUBLISH_KEY
PUBNUB_CHANNEL

All are documented in their respective comments.

Pubnub context class

Similar to Pubnub SDKs, we provide a Pubnub context class. It is defined in pubnub.h header file and implemented in pubnub.cpp.

It provides only the fundamental "publish" and "subscribe" methods. They are documented in the header file.

This class is reusable in other code (it is not specific to this demo), it has a very narrow interface to the AT&T IoT cellular modem code. For example of use, you can look at the main() (in main.c).

Sample of published data

Published message w/measurement data

{"serial":"vstarterkit001","temp":89.61,"humidity":35,"accelX":0.97,"accelY":0.013,"accelZ":-0.038}

Don't worry, nobody got burnt, the temperature is in degrees Fahrenheit. :)

Publish a message (from, say, the Pubnub console http://pubnub.com/console) of the form {"LED":<name-of-the-color>} on the channel that this demo listens to (default is hello_world) to turn the LED to that color on the Starter Kit:

Turn LED to red

{"LED":"Red"}

Turn LED to green

{"LED":"Green"}

Turn LED to blue

{"LED":"Blue"}

Files at this revision

API Documentation at this revision

Comitter:
stefanrousseau
Date:
Thu Aug 11 04:38:02 2016 +0000
Parent:
68:6e311c747045
Child:
70:24d5800f27be
Commit message:
Added code for Xadow GPS. Not done sending to Flow Designer yet.

Changed in this revision

config_me.h Show annotated file Show diff for this revision Revisions of this file
sensors.cpp Show annotated file Show diff for this revision Revisions of this file
xadow_gps.cpp Show annotated file Show diff for this revision Revisions of this file
xadow_gps.h Show annotated file Show diff for this revision Revisions of this file
--- a/config_me.h	Thu Aug 11 00:03:09 2016 +0000
+++ b/config_me.h	Thu Aug 11 04:38:02 2016 +0000
@@ -53,8 +53,9 @@
 // sensors can also be made available via USB.
 #define TEMP_HUMIDITY_ONLY                                      1
 #define TEMP_HUMIDITY_ACCELEROMETER                             2
-#define TEMP_HUMIDITY_ACCELEROMETER_PMODSENSORS                 3
-#define TEMP_HUMIDITY_ACCELEROMETER_PMODSENSORS_VIRTUALSENSORS  4
+#define TEMP_HUMIDITY_ACCELEROMETER_GPS                         3
+#define TEMP_HUMIDITY_ACCELEROMETER_PMODSENSORS                 4
+#define TEMP_HUMIDITY_ACCELEROMETER_PMODSENSORS_VIRTUALSENSORS  5
 static int iSensorsToReport = TEMP_HUMIDITY_ACCELEROMETER; //modify this to change your selection
 
 // This is the APN name for the cellular network, you will need to change this, check the instructions included with your SIM card kit:
--- a/sensors.cpp	Thu Aug 11 00:03:09 2016 +0000
+++ b/sensors.cpp	Thu Aug 11 04:38:02 2016 +0000
@@ -18,8 +18,10 @@
 #include "mbed.h"
 #include "sensors.h"
 #include "hardware.h"
+#include "config_me.h"
 #include "FXOS8700CQ.h"
 #include "HTS221.h"
+#include "xadow_gps.h"
 #include <string>
 
 //I2C for pmod sensors:
@@ -419,6 +421,78 @@
     } //bHTS221_present
 } //Read_HTS221()
 
+bool bGPS_present = false;
+void Init_GPS(void)
+{
+    char scan_id[GPS_SCAN_SIZE+2]; //The first two bytes are the response length (0x00, 0x04)
+    I2C_WriteSingleByte(GPS_DEVICE_ADDR, GPS_SCAN_ID, false); //no hold, must do read
+
+    unsigned char i;
+    for(i=0;i<(GPS_SCAN_SIZE+2);i++)
+    {
+        scan_id[i] = I2C_ReadSingleByte(GPS_DEVICE_ADDR);
+    }
+
+    if(scan_id[5] != GPS_DEVICE_ID)
+    {
+        bGPS_present = false;
+        PRINTF("Xadow GPS not found\n");
+    }
+    else 
+    {
+        bGPS_present = true;
+        PRINTF("Xadow GPS Scan ID response = 0x%02X%02X (length), 0x%02X%02X%02X%02X\r\n", scan_id[0], scan_id[1], scan_id[2], scan_id[3], scan_id[4], scan_id[5]);
+        char status = gps_get_status();
+        if (iSensorsToReport == TEMP_HUMIDITY_ACCELEROMETER_GPS)
+        { //we must wait for GPS to initialize
+            PRINTF("Waiting for GPS to become ready... ");
+            while (status != 'A')
+            {
+                wait (5.0);        
+                char status = gps_get_status();
+                unsigned char num_satellites = gps_get_sate_in_veiw();
+                PRINTF("%c%d", status, num_satellites);
+            }
+            PRINTF("\r\n");
+        } //we must wait for GPS to initialize
+        PRINTF("gps_check_online is %d\r\n", gps_check_online());
+        unsigned char *data;
+        data = gps_get_utc_date_time();       
+        PRINTF("gps_get_utc_date_time : %d-%d-%d,%d:%d:%d\r\n", data[0], data[1], data[2], data[3], data[4], data[5]); 
+        PRINTF("gps_get_status        : %c ('A' = Valid, 'V' = Invalid)\r\n", gps_get_status());
+        PRINTF("gps_get_latitude      : %c:%f\r\n", gps_get_ns(), gps_get_latitude());
+        PRINTF("gps_get_longitude     : %c:%f\r\n", gps_get_ew(), gps_get_longitude());
+        PRINTF("gps_get_altitude      : %f meters\r\n", gps_get_altitude());
+        PRINTF("gps_get_speed         : %f knots\r\n", gps_get_speed());
+        PRINTF("gps_get_course        : %f degrees\r\n", gps_get_course());
+        PRINTF("gps_get_position_fix  : %c\r\n", gps_get_position_fix());
+        PRINTF("gps_get_sate_in_view  : %d satellites\r\n", gps_get_sate_in_veiw());
+        PRINTF("gps_get_sate_used     : %d\r\n", gps_get_sate_used());
+        PRINTF("gps_get_mode          : %c ('A' = Automatic, 'M' = Manual)\r\n", gps_get_mode());
+        PRINTF("gps_get_mode2         : %c ('1' = no fix, '1' = 2D fix, '3' = 3D fix)\r\n", gps_get_mode2()); 
+    } //bool bGPS_present = true
+} //Init_GPS()
+
+void Read_GPS()
+{
+    unsigned char gps_quality = 0; //default 
+    if (bGPS_present)
+    {
+        if ((gps_get_status() == 'A') && (gps_get_mode2() != '1'))
+        {
+            gps_quality = 1;
+        }
+        PRINTF("gps_quality           : %d\r\n", gps_quality);
+        PRINTF("gps_get_latitude      : %c:%f\r\n", gps_get_ns(), gps_get_latitude());
+        PRINTF("gps_get_longitude     : %c:%f\r\n", gps_get_ew(), gps_get_longitude());
+        PRINTF("gps_get_altitude      : %f meters\r\n", gps_get_altitude());
+        PRINTF("gps_get_speed         : %f knots\r\n", gps_get_speed());
+        PRINTF("gps_get_course        : %f degrees\r\n", gps_get_course());
+        //sprintf(SENSOR_DATA.Temperature, "%0.2f", CTOF(hts221.readTemperature()));
+        //sprintf(SENSOR_DATA.Humidity, "%02d", hts221.readHumidity());
+    } //bGPS_present
+} //Read_GPS()
+
 #ifdef USE_VIRTUAL_SENSORS
 bool bUsbConnected = false;
 volatile uint8_t usb_uart_rx_buff[256];
@@ -558,6 +632,7 @@
     Init_Si7020();
     Init_Si1145();
     Init_motion_sensor();
+    Init_GPS();
 } //sensors_init
 
 void read_sensors(void)
@@ -566,4 +641,5 @@
     Read_Si7020();
     Read_Si1145();
     Read_motion_sensor();
+    Read_GPS();
 } //read_sensors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xadow_gps.cpp	Thu Aug 11 04:38:02 2016 +0000
@@ -0,0 +1,303 @@
+/* ===================================================================
+Copyright © 2016, AVNET Inc.  
+
+Licensed under the Apache License, Version 2.0 (the "License"); 
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+   http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, 
+software distributed under the License is distributed on an 
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 
+either express or implied. See the License for the specific 
+language governing permissions and limitations under the License.
+
+======================================================================== */
+
+#include "mbed.h"
+#include "xadow_gps.h"
+#include "hardware.h"
+
+//  Xadow code based on Eclipse test project at
+//  https://github.com/WayenWeng/Xadow_GPS_v2_test/
+
+//  These first 3 routines are to allow the mbed I2C to be used instead of what was in the Eclipse test code
+void dlc_i2c_configure(int slave_addr, int speed)
+{ 
+} //dlc_i2c_configure
+
+unsigned char dlc_i2c_receive_byte(void)
+{
+    char rxbuffer [1];
+    i2c.read(GPS_DEVICE_ADDR, rxbuffer, 1 );
+    return (unsigned char)rxbuffer[0];
+} //dlc_i2c_receive_byte()
+
+unsigned char dlc_i2c_send_byte(unsigned char ucData)
+{
+    int status;
+    char txbuffer [1];
+    txbuffer[0] = (char)ucData;
+    status = i2c.write(GPS_DEVICE_ADDR, txbuffer, 1, false); //true: do not send stop
+    return status;
+} //dlc_i2c_send_byte()
+ 
+
+unsigned char gps_check_online(void)
+{
+    unsigned char data[GPS_SCAN_SIZE+2];
+    unsigned char i;
+
+    dlc_i2c_configure(GPS_DEVICE_ADDR, 100);
+
+    dlc_i2c_send_byte(GPS_SCAN_ID);
+
+    for(i=0;i<(GPS_SCAN_SIZE+2);i++)
+    {
+        data[i] = dlc_i2c_receive_byte();
+    }
+
+    if(data[5] == GPS_DEVICE_ID)
+    return 1;
+    else return 0;
+}
+ 
+unsigned char gps_utc_date_time[GPS_UTC_DATE_TIME_SIZE] = {0};
+
+unsigned char* gps_get_utc_date_time(void)
+{
+    unsigned char data[GPS_UTC_DATE_TIME_SIZE+2];
+    unsigned char i;
+
+    dlc_i2c_configure(GPS_DEVICE_ADDR, 100);
+
+    dlc_i2c_send_byte(GPS_UTC_DATE_TIME_ID);
+ 
+    for(i=0;i<(GPS_UTC_DATE_TIME_SIZE+2);i++)
+    {
+        data[i] = dlc_i2c_receive_byte();
+    }
+
+    for(i=0;i<GPS_UTC_DATE_TIME_SIZE;i++)
+    gps_utc_date_time[i] = data[i+2];
+
+    return gps_utc_date_time;
+} 
+
+unsigned char gps_get_status(void)
+{
+    unsigned char data[GPS_STATUS_SIZE+2];
+    unsigned char i;
+
+    dlc_i2c_configure(GPS_DEVICE_ADDR, 100);
+
+    dlc_i2c_send_byte(GPS_STATUS_ID);
+    for(i=0;i<(GPS_STATUS_SIZE+2);i++)
+    {
+        data[i] = dlc_i2c_receive_byte();
+    }
+
+    return data[2];
+} 
+
+float gps_get_latitude(void)
+{
+    char data[GPS_LATITUDE_SIZE+2];
+    unsigned char i;
+
+    dlc_i2c_configure(GPS_DEVICE_ADDR, 100);
+
+    dlc_i2c_send_byte(GPS_LATITUDE_ID);
+    for(i=0;i<(GPS_LATITUDE_SIZE+2);i++)
+    {
+        data[i] = (char)dlc_i2c_receive_byte();
+    }
+
+    return atof(&data[2]);
+}
+
+unsigned char gps_get_ns(void)
+{
+    unsigned char data[GPS_NS_SIZE+2];
+    unsigned char i;
+
+    dlc_i2c_configure(GPS_DEVICE_ADDR, 100);
+
+    dlc_i2c_send_byte(GPS_NS_ID);
+    for(i=0;i<(GPS_NS_SIZE+2);i++)
+    {
+        data[i] = dlc_i2c_receive_byte();
+    }
+
+    if(data[2] == 'N' || data[2] == 'S')return data[2];
+    else return data[2] = '-';
+
+}
+
+float gps_get_longitude(void)
+{
+    char data[GPS_LONGITUDE_SIZE+2];
+    unsigned char i;
+
+    dlc_i2c_configure(GPS_DEVICE_ADDR, 100);
+
+    dlc_i2c_send_byte(GPS_LONGITUDE_ID);
+    for(i=0;i<(GPS_LONGITUDE_SIZE+2);i++)
+    {
+        data[i] = (char)dlc_i2c_receive_byte();
+    }
+
+    return atof(&data[2]);
+}
+
+unsigned char gps_get_ew(void)
+{
+    unsigned char data[GPS_EW_SIZE+2];
+    unsigned char i;
+
+    dlc_i2c_configure(GPS_DEVICE_ADDR, 100);
+
+    dlc_i2c_send_byte(GPS_EW_ID);
+    for(i=0;i<(GPS_EW_SIZE+2);i++)
+    {
+        data[i] = dlc_i2c_receive_byte();
+    }
+
+    if(data[2] == 'E' || data[2] == 'W')return data[2];
+    else return data[2] = '-';
+}
+
+float gps_get_speed(void)
+{
+    char data[GPS_SPEED_SIZE+2];
+    unsigned char i;
+
+    dlc_i2c_configure(GPS_DEVICE_ADDR, 100);
+
+    dlc_i2c_send_byte(GPS_SPEED_ID);
+    for(i=0;i<(GPS_SPEED_SIZE+2);i++)
+    {
+        data[i] = (char)dlc_i2c_receive_byte();
+    }
+
+    return atof(&data[2]);
+}
+
+float gps_get_course(void)
+{
+    char data[GPS_COURSE_SIZE+2];
+    unsigned char i;
+
+    dlc_i2c_configure(GPS_DEVICE_ADDR, 100);
+
+    dlc_i2c_send_byte(GPS_COURSE_ID);
+    for(i=0;i<(GPS_COURSE_SIZE+2);i++)
+    {
+        data[i] = (char)dlc_i2c_receive_byte();
+    }
+
+    return atof(&data[2]);
+}
+
+unsigned char gps_get_position_fix(void)
+{
+    unsigned char data[GPS_POSITION_FIX_SIZE+2];
+    unsigned char i;
+
+    dlc_i2c_configure(GPS_DEVICE_ADDR, 100);
+
+    dlc_i2c_send_byte(GPS_POSITION_FIX_ID);
+    for(i=0;i<(GPS_POSITION_FIX_SIZE+2);i++)
+    {
+        data[i] = dlc_i2c_receive_byte();
+    }
+
+    return data[2];
+}
+
+unsigned char gps_get_sate_used(void)
+{
+    unsigned char data[GPS_SATE_USED_SIZE+2];
+    unsigned char i;
+    unsigned char value;
+
+    dlc_i2c_configure(GPS_DEVICE_ADDR, 100);
+
+    dlc_i2c_send_byte(GPS_SATE_USED_ID);
+    for(i=0;i<(GPS_SATE_USED_SIZE+2);i++)
+    {
+        data[i] = dlc_i2c_receive_byte();
+    }
+
+    if(data[3] >= '0' && data[3] <= '9')value = (data[3] - '0') * 10;
+    else value = 0;
+    if(data[2] >= '0' && data[2] <= '9')value += (data[2] - '0');
+    else value += 0;
+
+    return value;
+}
+
+float gps_get_altitude(void)
+{
+    char data[GPS_ALTITUDE_SIZE+2];
+    unsigned char i;
+
+    dlc_i2c_configure(GPS_DEVICE_ADDR, 100);
+
+    dlc_i2c_send_byte(GPS_ALTITUDE_ID);
+    for(i=0;i<(GPS_ALTITUDE_SIZE+2);i++)
+    {
+        data[i] = (char)dlc_i2c_receive_byte();
+    }
+
+    return atof(&data[2]);
+}
+
+unsigned char gps_get_mode(void)
+{
+    unsigned char data[GPS_MODE_SIZE+2];
+    unsigned char i;
+
+    dlc_i2c_configure(GPS_DEVICE_ADDR, 100);
+
+    dlc_i2c_send_byte(GPS_MODE_ID);
+    for(i=0;i<(GPS_MODE_SIZE+2);i++)
+    {
+        data[i] = dlc_i2c_receive_byte();
+    }
+
+    return data[2];
+}
+
+unsigned char gps_get_mode2(void)
+{
+    unsigned char data[GPS_MODE2_SIZE+2];
+    unsigned char i;
+
+    dlc_i2c_configure(GPS_DEVICE_ADDR, 100);
+
+    dlc_i2c_send_byte(GPS_MODE2_ID);
+    for(i=0;i<(GPS_MODE2_SIZE+2);i++)
+    {
+        data[i] = dlc_i2c_receive_byte();
+    }
+
+    return data[2];
+}
+
+unsigned char gps_get_sate_in_veiw(void)
+{
+    unsigned char data[GPS_SATE_IN_VIEW_SIZE+2];
+    unsigned char i;
+
+    dlc_i2c_configure(GPS_DEVICE_ADDR, 100);
+
+    dlc_i2c_send_byte(GPS_SATE_IN_VIEW_ID);
+    for(i=0;i<(GPS_SATE_IN_VIEW_SIZE+2);i++)
+    {
+        data[i] = dlc_i2c_receive_byte();
+    }
+
+    return data[2];
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xadow_gps.h	Thu Aug 11 04:38:02 2016 +0000
@@ -0,0 +1,280 @@
+/* ===================================================================
+Copyright © 2016, AVNET Inc.  
+
+Licensed under the Apache License, Version 2.0 (the "License"); 
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+   http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, 
+software distributed under the License is distributed on an 
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 
+either express or implied. See the License for the specific 
+language governing permissions and limitations under the License.
+
+======================================================================== */
+
+#ifndef __XADOW_GPS_H_
+#define __XADOW_GPS_H_
+
+/*!
+    \def GPS_DEVICE_ADDR
+    The I2C address GPS
+
+    \def GPS_SCAN_ID
+    The id of scan data, the format is 0,0,0,Device address
+    \def GPS_SCAN_SIZE
+    The length of scan data
+
+    \def GPS_UTC_DATE_TIME_ID
+    The id of utc date and time, the format is YMDHMS
+    \def GPS_UTC_DATE_TIME_SIZE
+    The length of utc date and time data
+
+    \def GPS_STATUS_ID
+    The id of GPS status, the format is A/V
+    \def GPS_STATUS_SIZE
+    The length of GPS status data
+
+    \def GPS_LATITUDE_ID
+    The id of latitude, the format is dd.dddddd
+    \def GPS_LATITUDE_SIZE
+    The length of latitude data
+
+    \def GPS_NS_ID
+    The id of latitude direction, the format is N/S
+    \def GPS_NS_SIZE
+    The length of latitude direction data
+
+    \def GPS_LONGITUDE_ID
+    The id of longitude, the format is ddd.dddddd
+    \def GPS_LONGITUDE_SIZE
+    The length of longitude data
+
+    \def GPS_EW_ID
+    The id of longitude direction, the format is E/W
+    \def GPS_EW_SIZE
+    The length of longitude direction data
+
+    \def GPS_SPEED_ID
+    The id of speed, the format is 000.0~999.9 Knots
+    \def GPS_SPEED_SIZE
+    The length of speed data
+
+    \def GPS_COURSE_ID
+    The id of course, the format is 000.0~359.9
+    \def GPS_COURSE_SIZE
+    The length of course data
+
+    \def GPS_POSITION_FIX_ID
+    The id of position fix status, the format is 0,1,2,6
+    \def GPS_POSITION_FIX_SIZE
+    The length of position fix status data
+
+    \def GPS_SATE_USED_ID
+    The id of state used, the format is 00~12
+    \def GPS_SATE_USED_SIZE
+    The length of sate used data
+
+    \def GPS_ALTITUDE_ID
+    The id of altitude, the format is -9999.9~99999.9
+    \def GPS_ALTITUDE_SIZE
+    The length of altitude data
+
+    \def GPS_MODE_ID
+    The id of locate mode, the format is A/M
+    \def GPS_MODE_SIZE
+    The length of locate mode data
+
+    \def GPS_MODE2_ID
+    The id of current status, the format is 1,2,3
+    \def GPS_MODE2_SIZE
+    The length of current status data
+
+    \def GPS_SATE_IN_VIEW_ID
+    The id of sate in view
+    \def GPS_SATE_IN_VIEW_SIZE
+    The length of sate in view data
+*/
+
+/* Data format:
+ * ID(1 byte), Data length(1 byte), Data 1, Data 2, ... Data n (n bytes, n = data length)
+ * For example, get the scan data.
+ * First, Send GPS_SCAN_ID(1 byte) to device.
+ * Second, Receive scan data(ID + Data length + GPS_SCAN_SIZE = 6 bytes).
+ * Third, The scan data begin from the third data of received.
+ * End
+ */
+
+#define GPS_DEVICE_ID         0x05
+//#define GPS_DEVICE_ADDR         0x05
+#define GPS_DEVICE_ADDR         0x0A //For mbed, the address has to be  << 1
+
+#define GPS_SCAN_ID             0 // 4 bytes
+#define GPS_SCAN_SIZE           4 // 0,0,0,Device address
+
+#define GPS_UTC_DATE_TIME_ID    1 // YMDHMS
+#define GPS_UTC_DATE_TIME_SIZE  6 // 6 bytes
+
+#define GPS_STATUS_ID           2 // A/V
+#define GPS_STATUS_SIZE         1 // 1 byte
+
+#define GPS_LATITUDE_ID         3 // dd.dddddd
+#define GPS_LATITUDE_SIZE       9 // 9 bytes
+
+#define GPS_NS_ID               4 // N/S
+#define GPS_NS_SIZE             1 // 1 byte
+
+#define GPS_LONGITUDE_ID        5 // ddd.dddddd
+#define GPS_LONGITUDE_SIZE      10 // 10 bytes
+
+#define GPS_EW_ID               6 // E/W
+#define GPS_EW_SIZE             1 // 1 byte
+
+#define GPS_SPEED_ID            7 // 000.0~999.9 Knots
+#define GPS_SPEED_SIZE          5 // 5 bytes
+
+#define GPS_COURSE_ID           8 // 000.0~359.9
+#define GPS_COURSE_SIZE         5 // 5 bytes
+
+#define GPS_POSITION_FIX_ID     9 // 0,1,2,6
+#define GPS_POSITION_FIX_SIZE   1 // 1 byte
+
+#define GPS_SATE_USED_ID        10 // 00~12
+#define GPS_SATE_USED_SIZE      2 // 2 bytes
+
+#define GPS_ALTITUDE_ID         11 // -9999.9~99999.9
+#define GPS_ALTITUDE_SIZE       7 // 7 bytes
+
+#define GPS_MODE_ID             12 // A/M
+#define GPS_MODE_SIZE           1 // 1 byte
+
+#define GPS_MODE2_ID            13 // 1,2,3
+#define GPS_MODE2_SIZE          1 // 1 byte
+
+#define GPS_SATE_IN_VIEW_ID     14 // 0~12
+#define GPS_SATE_IN_VIEW_SIZE   1 // 1 byte
+
+
+/**
+ *  \brief Get the status of the device.
+ *
+ *  \return Return TRUE or FALSE. TRUE is on line, FALSE is off line.
+ *
+ */
+unsigned char gps_check_online(void);
+
+/**
+ *  \brief Get the utc date and time.
+ *
+ *  \return Return the pointer of utc date sand time, the format is YMDHMS.
+ *
+ */
+unsigned char* gps_get_utc_date_time(void);
+
+/**
+ *  \brief Get the status of GPS.
+ *
+ *  \return Return A or V. A is orientation, V is navigation.
+ *
+ */
+unsigned char gps_get_status(void);
+
+/**
+ *  \brief Get the altitude.
+ *
+ *  \return Return altitude data. The format is dd.dddddd.
+ *
+ */
+float gps_get_latitude(void);
+
+/**
+ *  \brief Get the lattitude direction.
+ *
+ *  \return Return lattitude direction data. The format is N/S. N is north, S is south.
+ *
+ */
+unsigned char gps_get_ns(void);
+
+/**
+ *  \brief Get the longitude.
+ *
+ *  \return Return longitude data. The format is ddd.dddddd.
+ *
+ */
+float gps_get_longitude(void);
+
+/**
+ *  \brief Get the longitude direction.
+ *
+ *  \return Return longitude direction data. The format is E/W. E is east, W is west.
+ *
+ */
+unsigned char gps_get_ew(void);
+
+/**
+ *  \brief Get the speed.
+ *
+ *  \return Return speed data. The format is 000.0~999.9 Knots.
+ *
+ */
+float gps_get_speed(void);
+
+/**
+ *  \brief Get the course.
+ *
+ *  \return Return course data. The format is 000.0~359.9.
+ *
+ */
+float gps_get_course(void);
+
+/**
+ *  \brief Get the status of position fix.
+ *
+ *  \return Return position fix data. The format is 0,1,2,6.
+ *
+ */
+unsigned char gps_get_position_fix(void);
+
+/**
+ *  \brief Get the number of state used¡£
+ *
+ *  \return Return number of state used. The format is 0-12.
+ *
+ */
+unsigned char gps_get_sate_used(void);
+
+/**
+ *  \brief Get the altitude¡£ the format is -9999.9~99999.9
+ *
+ *  \return Return altitude data. The format is -9999.9~99999.9.
+ *
+ */
+float gps_get_altitude(void);
+
+/**
+ *  \brief Get the mode of location.
+ *
+ *  \return Return mode of location. The format is A/M. A:automatic, M:manual.
+ *
+ */
+unsigned char gps_get_mode(void);
+
+/**
+ *  \brief Get the current status of GPS.
+ *
+ *  \return Return current status. The format is 1,2,3. 1:null, 2:2D, 3:3D.
+ *
+ */
+unsigned char gps_get_mode2(void);
+
+/**
+ *  \brief Get the number of sate in view.
+ *
+ *  \return Return the number of sate in view.
+ *
+ */
+unsigned char gps_get_sate_in_veiw(void);
+ 
+#endif
\ No newline at end of file