This class provides an API to communicate with a u-blox GNSS chip. The files here were originally part of the C027_Support library (https://developer.mbed.org/teams/ublox/code/C027_Support/ at revision 138:dafbbf31bf76) but have been separated out, primarily for use on the u-blox C030 board where the cellular interace portion of the C027_Support library will instead be provided through the new mbed Cellular API.

Dependents:   example-ublox-at-cellular-interface-ext example-gnss example-low-power-sleep example-C030-out-of-box-demo ... more

Committer:
fahim.alavi@u-blox.com
Date:
Mon Dec 17 12:11:07 2018 +0500
Revision:
29:54fd002f2376
Parent:
27:405a5e611635
Child:
31:9a1ce433f062
Decoding and decoding status of NAV-SAT added

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Bilal Qamar 12:a04f7eeece23 1
Bilal Qamar 12:a04f7eeece23 2 #include "gnss.h"
Bilal Qamar 12:a04f7eeece23 3
Bilal Qamar 12:a04f7eeece23 4 #define UBX_FRAME_SIZE 8
Bilal Qamar 12:a04f7eeece23 5 #ifdef __cplusplus
Bilal Qamar 12:a04f7eeece23 6 extern "C" {
Bilal Qamar 12:a04f7eeece23 7 #endif
Bilal Qamar 12:a04f7eeece23 8
Bilal Qamar 12:a04f7eeece23 9 /** Enums
Bilal Qamar 12:a04f7eeece23 10 */
Bilal Qamar 12:a04f7eeece23 11 enum Command{
Bilal Qamar 12:a04f7eeece23 12 POWER_ON,
Bilal Qamar 12:a04f7eeece23 13 POWER_OFF,
Bilal Qamar 12:a04f7eeece23 14 MON_VER,
Bilal Qamar 12:a04f7eeece23 15 ENABLE_UBX,
Bilal Qamar 12:a04f7eeece23 16 RESTART, // mbed conflict with RESET
Bilal Qamar 12:a04f7eeece23 17 CUSTOMER,
Bilal Qamar 12:a04f7eeece23 18 AVAILABLE_CONFIG
Bilal Qamar 12:a04f7eeece23 19 };
Bilal Qamar 12:a04f7eeece23 20 /** The reset modes
Bilal Qamar 12:a04f7eeece23 21 */
Bilal Qamar 12:a04f7eeece23 22 enum Start{
Bilal Qamar 12:a04f7eeece23 23 HOT,
fahim.alavi@u-blox.com 25:f538f1dc4121 24 COLD,
Bilal Qamar 12:a04f7eeece23 25 WARM,
fahim.alavi@u-blox.com 25:f538f1dc4121 26 MAX_MODE
Bilal Qamar 12:a04f7eeece23 27 };
Bilal Qamar 12:a04f7eeece23 28
Bilal Qamar 12:a04f7eeece23 29 /** The operation modes
Bilal Qamar 12:a04f7eeece23 30 */
Bilal Qamar 12:a04f7eeece23 31 enum Powermodes{
fahim.alavi@u-blox.com 16:cb9861f0f4d8 32
fahim.alavi@u-blox.com 16:cb9861f0f4d8 33 CONSERVATIVE_CONTINOUS,
fahim.alavi@u-blox.com 16:cb9861f0f4d8 34 AGGRESSIVE_CONTINUOS,
fahim.alavi@u-blox.com 16:cb9861f0f4d8 35 SEMI_CONTINOUS,
fahim.alavi@u-blox.com 16:cb9861f0f4d8 36 FULL_POWER,
bqam 18:7adca4350499 37 FULL_POWER_BLOCK_LEVEL,
bqam 18:7adca4350499 38 FULL_POWER_BUILDING_LEVEL,
fahim.alavi@u-blox.com 16:cb9861f0f4d8 39 AVAILABLE_OPERATION
fahim.alavi@u-blox.com 16:cb9861f0f4d8 40 };
fahim.alavi@u-blox.com 16:cb9861f0f4d8 41
Bilal Qamar 12:a04f7eeece23 42
Bilal Qamar 12:a04f7eeece23 43 class GnssOperations : public GnssSerial{
Bilal Qamar 12:a04f7eeece23 44
Bilal Qamar 12:a04f7eeece23 45 //GnssSerial constructor can be called here to configure different baud rate
Bilal Qamar 12:a04f7eeece23 46 //Constructor not required at the moment
Bilal Qamar 12:a04f7eeece23 47 //GnssOperations();
Bilal Qamar 12:a04f7eeece23 48
Bilal Qamar 12:a04f7eeece23 49 public:
Bilal Qamar 12:a04f7eeece23 50
bqam 23:c462bbec7d00 51 /** Enable GNSS receiver UBX-NAV-PVT messages
bqam 23:c462bbec7d00 52 * Navigation Position Velocity Time Solution
bqam 23:c462bbec7d00 53 * @param void
bqam 23:c462bbec7d00 54 * @return int 1: Successful
bqam 23:c462bbec7d00 55 * 0: Failure
bqam 23:c462bbec7d00 56 */
Bilal Qamar 12:a04f7eeece23 57 int enable_ubx_nav_pvt();
bqam 23:c462bbec7d00 58
bqam 23:c462bbec7d00 59 /** Enable GNSS receiver UBX-STATUS messages
bqam 23:c462bbec7d00 60 * Receiver Navigation Status
bqam 23:c462bbec7d00 61 * @param void
bqam 23:c462bbec7d00 62 * @return int 1: Successful
bqam 23:c462bbec7d00 63 * 0: Failure
bqam 23:c462bbec7d00 64 */
fahim.alavi@u-blox.com 21:f91c0334d017 65 int enable_ubx_nav_status();
bqam 23:c462bbec7d00 66
bqam 23:c462bbec7d00 67 /** Enable GNSS receiver UBX-NAV-SAT messages
bqam 23:c462bbec7d00 68 * Satellite Information
bqam 23:c462bbec7d00 69 * @param void
bqam 23:c462bbec7d00 70 * @return int 1: Successful
bqam 23:c462bbec7d00 71 * 0: Failure
bqam 23:c462bbec7d00 72 */
fahim.alavi@u-blox.com 22:d8cd4cf0fcc0 73 int enable_ubx_nav_sat();
bqam 23:c462bbec7d00 74
bqam 23:c462bbec7d00 75 /** Enable GNSS receiver UBX-NAV-SOL messages
bqam 23:c462bbec7d00 76 * Navigation Solution Information
bqam 23:c462bbec7d00 77 * @param void
bqam 23:c462bbec7d00 78 * @return int 1: Successful
bqam 23:c462bbec7d00 79 * 0: Failure
bqam 23:c462bbec7d00 80 */
fahim.alavi@u-blox.com 22:d8cd4cf0fcc0 81 int enable_ubx_nav_sol();
bqam 23:c462bbec7d00 82
bqam 23:c462bbec7d00 83 /** Disable GNSS receiver UBX-NAV-PVT messages
bqam 23:c462bbec7d00 84 * @param void
bqam 23:c462bbec7d00 85 * @return int 1: Successful
bqam 23:c462bbec7d00 86 * 0: Failure
bqam 23:c462bbec7d00 87 */
Bilal Qamar 12:a04f7eeece23 88 int disable_ubx_nav_pvt();
bqam 23:c462bbec7d00 89
bqam 23:c462bbec7d00 90 /** Enable GNSS receiver UBX-NAV5 messages
bqam 23:c462bbec7d00 91 * Navigation Engine Settings
bqam 23:c462bbec7d00 92 * @param uint acc Defines positioning accuracy
bqam 23:c462bbec7d00 93 * @return int 1: Successful
bqam 23:c462bbec7d00 94 * 0: Failure
bqam 23:c462bbec7d00 95 */
Bilal Qamar 12:a04f7eeece23 96 int enable_ubx_nav5(unsigned int acc);
bqam 23:c462bbec7d00 97
bqam 23:c462bbec7d00 98 /** Enable GNSS receiver UBX-CFG-ODO messages
bqam 23:c462bbec7d00 99 * Odometer, Low-speed COG Engine Settings
bqam 23:c462bbec7d00 100 * @param void
bqam 23:c462bbec7d00 101 * @return int 1: Successful
bqam 23:c462bbec7d00 102 * 0: Failure
bqam 23:c462bbec7d00 103 */
Bilal Qamar 12:a04f7eeece23 104 int enable_ubx_odo();
bqam 23:c462bbec7d00 105
bqam 23:c462bbec7d00 106 /** Disable GNSS receiver UBX-CFG-ODO messages
bqam 23:c462bbec7d00 107 * @param void
bqam 23:c462bbec7d00 108 * @return int 1: Successful
bqam 23:c462bbec7d00 109 * 0: Failure
bqam 23:c462bbec7d00 110 */
Bilal Qamar 12:a04f7eeece23 111 int disable_ubx_odo();
bqam 23:c462bbec7d00 112
bqam 23:c462bbec7d00 113 /** Enable GNSS receiver UBX-NAV-ODO messages
bqam 23:c462bbec7d00 114 * Odometer, Low-speed COG Engine Settings
bqam 23:c462bbec7d00 115 * @param void
bqam 23:c462bbec7d00 116 * @return int 1: Successful
bqam 23:c462bbec7d00 117 * 0: Failure
bqam 23:c462bbec7d00 118 */
Bilal Qamar 12:a04f7eeece23 119 int enable_ubx_nav_odo();
bqam 23:c462bbec7d00 120
bqam 23:c462bbec7d00 121 /** Disable GNSS receiver UBX-NAV-ODO messages
bqam 23:c462bbec7d00 122 * Odometer, Low-speed COG Engine Settings
bqam 23:c462bbec7d00 123 * @param void
bqam 23:c462bbec7d00 124 * @return int 1: Successful
bqam 23:c462bbec7d00 125 * 0: Failure
bqam 23:c462bbec7d00 126 */
Bilal Qamar 12:a04f7eeece23 127 int disable_ubx_nav_odo();
bqam 23:c462bbec7d00 128
bqam 23:c462bbec7d00 129 /** Enable GNSS receiver UBX-LOG-BATCH messages
bqam 23:c462bbec7d00 130 * Batched data
bqam 23:c462bbec7d00 131 * @param void
bqam 23:c462bbec7d00 132 * @return int 1: Successful
bqam 23:c462bbec7d00 133 * 0: Failure
bqam 23:c462bbec7d00 134 */
Bilal Qamar 12:a04f7eeece23 135 int enable_ubx_batch_feature();
bqam 23:c462bbec7d00 136
bqam 23:c462bbec7d00 137 /** Disable GNSS receiver UBX-LOG-BATCH messages
bqam 23:c462bbec7d00 138 * Batched data
bqam 23:c462bbec7d00 139 * @param void
bqam 23:c462bbec7d00 140 * @return int 1: Successful
bqam 23:c462bbec7d00 141 * 0: Failure
bqam 23:c462bbec7d00 142 */
Bilal Qamar 12:a04f7eeece23 143 int disable_ubx_batch_feature();
bqam 23:c462bbec7d00 144
bqam 23:c462bbec7d00 145 /** Configure GNSS receiver batching feature
bqam 23:c462bbec7d00 146 * Get/Set data batching configuration
bqam 23:c462bbec7d00 147 * @param tUBX_CFG_BATCH
bqam 23:c462bbec7d00 148 * @return int 1: Successful
bqam 23:c462bbec7d00 149 * 0: Failure
bqam 23:c462bbec7d00 150 */
Bilal Qamar 12:a04f7eeece23 151 int cfg_batch_feature(tUBX_CFG_BATCH *obj);
bqam 23:c462bbec7d00 152
bqam 23:c462bbec7d00 153 /** Configure GNSS receiver power mode
bqam 23:c462bbec7d00 154 * Power mode setup
bqam 23:c462bbec7d00 155 * @param Powermodes SEMI_CONTINOUS
bqam 23:c462bbec7d00 156 * AGGRESSIVE_CONTINUOS
bqam 23:c462bbec7d00 157 * CONSERVATIVE_CONTINOUS
bqam 23:c462bbec7d00 158 * FULL_POWER
bqam 23:c462bbec7d00 159 * FULL_POWER_BLOCK_LEVEL
fahim.alavi@u-blox.com 27:405a5e611635 160 * minimumAcqTime boolean
bqam 23:c462bbec7d00 161 *
bqam 23:c462bbec7d00 162 * @return int 1: Successful
bqam 23:c462bbec7d00 163 * 0: Failure
bqam 23:c462bbec7d00 164 */
fahim.alavi@u-blox.com 27:405a5e611635 165 int cfg_power_mode(Powermodes power_mode, bool minimumAcqTime);
bqam 23:c462bbec7d00 166
bqam 23:c462bbec7d00 167 /** Method to poll the GNSS configuration
bqam 23:c462bbec7d00 168 * @param void
bqam 23:c462bbec7d00 169 * @return bool true: Successful
bqam 23:c462bbec7d00 170 * false: Failure
bqam 23:c462bbec7d00 171 */
fahim.alavi@u-blox.com 20:bc678f383db1 172 bool verify_gnss_mode();
bqam 23:c462bbec7d00 173
bqam 23:c462bbec7d00 174 /** Configure GNSS startup mode
bqam 23:c462bbec7d00 175 * Power mode setup
bqam 23:c462bbec7d00 176 * @param start_mode 0: Hot Start
bqam 23:c462bbec7d00 177 * 1: Warm Start
bqam 23:c462bbec7d00 178 * 2: Cold Start
bqam 23:c462bbec7d00 179 *
bqam 23:c462bbec7d00 180 * @return int 1: Successful
bqam 23:c462bbec7d00 181 * 0: Failure
bqam 23:c462bbec7d00 182 */
Bilal Qamar 12:a04f7eeece23 183 int start_mode(int start_mode);
Bilal Qamar 12:a04f7eeece23 184
bqam 23:c462bbec7d00 185 /** Send char to GNSS receiver
bqam 23:c462bbec7d00 186 * @param char
bqam 23:c462bbec7d00 187 * @return void
bqam 23:c462bbec7d00 188 */
bqam 14:4b22bd505b93 189 void send_to_gnss(char);
bqam 23:c462bbec7d00 190
bqam 23:c462bbec7d00 191 /** Power On GNSS receiver
bqam 23:c462bbec7d00 192 *
bqam 23:c462bbec7d00 193 * @return void
bqam 23:c462bbec7d00 194 */
bqam 14:4b22bd505b93 195 void power_on_gnss();
bqam 14:4b22bd505b93 196
Bilal Qamar 12:a04f7eeece23 197 };
Bilal Qamar 12:a04f7eeece23 198 #ifdef __cplusplus
Bilal Qamar 12:a04f7eeece23 199 }
Bilal Qamar 12:a04f7eeece23 200 #endif