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 #include "gnss_operations.h"
Bilal Qamar 12:a04f7eeece23 2
fahim.alavi@u-blox.com 16:cb9861f0f4d8 3 #ifndef UBLOX_WEARABLE_FRAMEWORK
fahim.alavi@u-blox.com 16:cb9861f0f4d8 4 #define SEND_LOGGING_MESSAGE printf
fahim.alavi@u-blox.com 16:cb9861f0f4d8 5 #else
fahim.alavi@u-blox.com 16:cb9861f0f4d8 6 #include "MessageView.h"
fahim.alavi@u-blox.com 16:cb9861f0f4d8 7 #endif
fahim.alavi@u-blox.com 16:cb9861f0f4d8 8
Bilal Qamar 12:a04f7eeece23 9 #define FIRST_BYTE 0x000000FF
Bilal Qamar 12:a04f7eeece23 10 #define SECOND_BYTE 0x0000FF00
Bilal Qamar 12:a04f7eeece23 11 #define THIRD_BYTE 0x00FF0000
Bilal Qamar 12:a04f7eeece23 12 #define FOURTH_BYTE 0xFF000000
Bilal Qamar 12:a04f7eeece23 13 #define RETRY 5
Bilal Qamar 12:a04f7eeece23 14
Bilal Qamar 12:a04f7eeece23 15 #define EXTRACT_BYTE(INDEX, BYTE, VALUE) ((VALUE & BYTE) >> (INDEX*8))
Bilal Qamar 12:a04f7eeece23 16
Bilal Qamar 12:a04f7eeece23 17 /**
Bilal Qamar 12:a04f7eeece23 18 *
Bilal Qamar 12:a04f7eeece23 19 * Enable UBX-NAV-PVT using UBX-CFG-MSG
Bilal Qamar 12:a04f7eeece23 20 * @param return SUCCESS: 1
Bilal Qamar 12:a04f7eeece23 21 * FAILURE: 0
Bilal Qamar 12:a04f7eeece23 22 */
Bilal Qamar 12:a04f7eeece23 23 int GnssOperations::enable_ubx_nav_pvt()
Bilal Qamar 12:a04f7eeece23 24 {
Bilal Qamar 12:a04f7eeece23 25 int conf = RETRY;
Bilal Qamar 12:a04f7eeece23 26 unsigned char enable_ubx_nav_pvt[]={0x01, 0x07, 0x01};
Bilal Qamar 12:a04f7eeece23 27 conf = RETRY;
Bilal Qamar 12:a04f7eeece23 28 int length =0;
Bilal Qamar 12:a04f7eeece23 29
Bilal Qamar 12:a04f7eeece23 30 while(conf)
Bilal Qamar 12:a04f7eeece23 31 {
Bilal Qamar 12:a04f7eeece23 32
Bilal Qamar 12:a04f7eeece23 33 length = GnssSerial::sendUbx(0x06, 0x01, enable_ubx_nav_pvt, sizeof(enable_ubx_nav_pvt));
Bilal Qamar 12:a04f7eeece23 34 if(length >= (int)(sizeof(enable_ubx_nav_pvt) + UBX_FRAME_SIZE))
Bilal Qamar 12:a04f7eeece23 35 {
fahim.alavi@u-blox.com 16:cb9861f0f4d8 36 SEND_LOGGING_MESSAGE("UBX-NAV-PVT was enabled\r\n");
wajahat.abbas@u-blox.com 19:119e7c15ff97 37 wait(1);
Bilal Qamar 12:a04f7eeece23 38 break;
Bilal Qamar 12:a04f7eeece23 39 }
Bilal Qamar 12:a04f7eeece23 40 else
Bilal Qamar 12:a04f7eeece23 41 {
fahim.alavi@u-blox.com 16:cb9861f0f4d8 42 SEND_LOGGING_MESSAGE("enabling UBX-NAV-PVT...\r\n");
Bilal Qamar 12:a04f7eeece23 43 conf = conf - 1;
Bilal Qamar 12:a04f7eeece23 44 }
Bilal Qamar 12:a04f7eeece23 45 }
Bilal Qamar 12:a04f7eeece23 46
Bilal Qamar 12:a04f7eeece23 47 return (conf == 0) ? 0 : 1;
Bilal Qamar 12:a04f7eeece23 48 }
Bilal Qamar 12:a04f7eeece23 49
fahim.alavi@u-blox.com 21:f91c0334d017 50 int GnssOperations::enable_ubx_nav_status() {
fahim.alavi@u-blox.com 21:f91c0334d017 51 int conf = RETRY;
fahim.alavi@u-blox.com 21:f91c0334d017 52 unsigned char enable_ubx_nav_status[]={0x01, 0x03, 0x01};
fahim.alavi@u-blox.com 21:f91c0334d017 53 conf = RETRY;
fahim.alavi@u-blox.com 21:f91c0334d017 54 int length =0;
fahim.alavi@u-blox.com 21:f91c0334d017 55
fahim.alavi@u-blox.com 21:f91c0334d017 56 while(conf)
fahim.alavi@u-blox.com 21:f91c0334d017 57 {
fahim.alavi@u-blox.com 21:f91c0334d017 58
fahim.alavi@u-blox.com 21:f91c0334d017 59 length = GnssSerial::sendUbx(0x06, 0x01, enable_ubx_nav_status, sizeof(enable_ubx_nav_status));
fahim.alavi@u-blox.com 21:f91c0334d017 60 if(length >= (int)(sizeof(enable_ubx_nav_status) + UBX_FRAME_SIZE))
fahim.alavi@u-blox.com 21:f91c0334d017 61 {
fahim.alavi@u-blox.com 21:f91c0334d017 62 SEND_LOGGING_MESSAGE("UBX-NAV-STATUS was enabled\r\n");
fahim.alavi@u-blox.com 21:f91c0334d017 63 wait(1);
fahim.alavi@u-blox.com 21:f91c0334d017 64 break;
fahim.alavi@u-blox.com 21:f91c0334d017 65 }
fahim.alavi@u-blox.com 21:f91c0334d017 66 else
fahim.alavi@u-blox.com 21:f91c0334d017 67 {
fahim.alavi@u-blox.com 21:f91c0334d017 68 SEND_LOGGING_MESSAGE("enabling UBX-NAV-STATUS...\r\n");
fahim.alavi@u-blox.com 21:f91c0334d017 69 conf = conf - 1;
fahim.alavi@u-blox.com 21:f91c0334d017 70 }
fahim.alavi@u-blox.com 21:f91c0334d017 71 }
fahim.alavi@u-blox.com 21:f91c0334d017 72
fahim.alavi@u-blox.com 21:f91c0334d017 73 return (conf == 0) ? 0 : 1;
fahim.alavi@u-blox.com 21:f91c0334d017 74
fahim.alavi@u-blox.com 21:f91c0334d017 75 }
fahim.alavi@u-blox.com 21:f91c0334d017 76
fahim.alavi@u-blox.com 22:d8cd4cf0fcc0 77 int GnssOperations::enable_ubx_nav_sat() {
fahim.alavi@u-blox.com 22:d8cd4cf0fcc0 78 int conf = RETRY;
fahim.alavi@u-blox.com 25:f538f1dc4121 79 unsigned char enable_ubx_nav_sat[]={0x01, 0x35, 0x01};
fahim.alavi@u-blox.com 22:d8cd4cf0fcc0 80 conf = RETRY;
fahim.alavi@u-blox.com 22:d8cd4cf0fcc0 81 int length =0;
fahim.alavi@u-blox.com 22:d8cd4cf0fcc0 82
fahim.alavi@u-blox.com 22:d8cd4cf0fcc0 83 while(conf)
fahim.alavi@u-blox.com 22:d8cd4cf0fcc0 84 {
fahim.alavi@u-blox.com 22:d8cd4cf0fcc0 85
fahim.alavi@u-blox.com 25:f538f1dc4121 86 length = GnssSerial::sendUbx(0x06, 0x01, enable_ubx_nav_sat, sizeof(enable_ubx_nav_sat));
fahim.alavi@u-blox.com 25:f538f1dc4121 87 if(length >= (int)(sizeof(enable_ubx_nav_sat) + UBX_FRAME_SIZE))
fahim.alavi@u-blox.com 22:d8cd4cf0fcc0 88 {
fahim.alavi@u-blox.com 22:d8cd4cf0fcc0 89 SEND_LOGGING_MESSAGE("UBX-NAV-STATUS was enabled\r\n");
fahim.alavi@u-blox.com 22:d8cd4cf0fcc0 90 wait(1);
fahim.alavi@u-blox.com 22:d8cd4cf0fcc0 91 break;
fahim.alavi@u-blox.com 22:d8cd4cf0fcc0 92 }
fahim.alavi@u-blox.com 22:d8cd4cf0fcc0 93 else
fahim.alavi@u-blox.com 22:d8cd4cf0fcc0 94 {
fahim.alavi@u-blox.com 22:d8cd4cf0fcc0 95 SEND_LOGGING_MESSAGE("enabling UBX-NAV-STATUS...\r\n");
fahim.alavi@u-blox.com 22:d8cd4cf0fcc0 96 conf = conf - 1;
fahim.alavi@u-blox.com 22:d8cd4cf0fcc0 97 }
fahim.alavi@u-blox.com 22:d8cd4cf0fcc0 98 }
fahim.alavi@u-blox.com 22:d8cd4cf0fcc0 99
fahim.alavi@u-blox.com 22:d8cd4cf0fcc0 100 return (conf == 0) ? 0 : 1;
fahim.alavi@u-blox.com 22:d8cd4cf0fcc0 101
fahim.alavi@u-blox.com 22:d8cd4cf0fcc0 102 }
fahim.alavi@u-blox.com 22:d8cd4cf0fcc0 103
fahim.alavi@u-blox.com 22:d8cd4cf0fcc0 104 int GnssOperations::enable_ubx_nav_sol() {
fahim.alavi@u-blox.com 22:d8cd4cf0fcc0 105 int conf = RETRY;
fahim.alavi@u-blox.com 22:d8cd4cf0fcc0 106 unsigned char enable_ubx_nav_status[]={0x01, 0x06, 0x0A};
fahim.alavi@u-blox.com 22:d8cd4cf0fcc0 107 conf = RETRY;
fahim.alavi@u-blox.com 22:d8cd4cf0fcc0 108 int length =0;
fahim.alavi@u-blox.com 22:d8cd4cf0fcc0 109
fahim.alavi@u-blox.com 22:d8cd4cf0fcc0 110 while(conf)
fahim.alavi@u-blox.com 22:d8cd4cf0fcc0 111 {
fahim.alavi@u-blox.com 22:d8cd4cf0fcc0 112
fahim.alavi@u-blox.com 22:d8cd4cf0fcc0 113 length = GnssSerial::sendUbx(0x06, 0x01, enable_ubx_nav_status, sizeof(enable_ubx_nav_status));
fahim.alavi@u-blox.com 22:d8cd4cf0fcc0 114 if(length >= (int)(sizeof(enable_ubx_nav_status) + UBX_FRAME_SIZE))
fahim.alavi@u-blox.com 22:d8cd4cf0fcc0 115 {
fahim.alavi@u-blox.com 22:d8cd4cf0fcc0 116 SEND_LOGGING_MESSAGE("UBX-NAV-STATUS was enabled\r\n");
fahim.alavi@u-blox.com 22:d8cd4cf0fcc0 117 wait(1);
fahim.alavi@u-blox.com 22:d8cd4cf0fcc0 118 break;
fahim.alavi@u-blox.com 22:d8cd4cf0fcc0 119 }
fahim.alavi@u-blox.com 22:d8cd4cf0fcc0 120 else
fahim.alavi@u-blox.com 22:d8cd4cf0fcc0 121 {
fahim.alavi@u-blox.com 22:d8cd4cf0fcc0 122 SEND_LOGGING_MESSAGE("enabling UBX-NAV-STATUS...\r\n");
fahim.alavi@u-blox.com 22:d8cd4cf0fcc0 123 conf = conf - 1;
fahim.alavi@u-blox.com 22:d8cd4cf0fcc0 124 }
fahim.alavi@u-blox.com 22:d8cd4cf0fcc0 125 }
fahim.alavi@u-blox.com 22:d8cd4cf0fcc0 126
fahim.alavi@u-blox.com 22:d8cd4cf0fcc0 127 return (conf == 0) ? 0 : 1;
fahim.alavi@u-blox.com 22:d8cd4cf0fcc0 128
fahim.alavi@u-blox.com 22:d8cd4cf0fcc0 129 }
fahim.alavi@u-blox.com 22:d8cd4cf0fcc0 130
fahim.alavi@u-blox.com 22:d8cd4cf0fcc0 131
Bilal Qamar 12:a04f7eeece23 132 /**
Bilal Qamar 12:a04f7eeece23 133 *
Bilal Qamar 12:a04f7eeece23 134 * Disable UBX-NAV-PVT
Bilal Qamar 12:a04f7eeece23 135 * @param return SUCCESS: 1
Bilal Qamar 12:a04f7eeece23 136 * FAILURE: 0
Bilal Qamar 12:a04f7eeece23 137 */
Bilal Qamar 12:a04f7eeece23 138 int GnssOperations::disable_ubx_nav_pvt()
Bilal Qamar 12:a04f7eeece23 139 {
Bilal Qamar 12:a04f7eeece23 140 int conf = RETRY;
Bilal Qamar 12:a04f7eeece23 141 unsigned char enable_ubx_nav_pvt[]={0x01, 0x07, 0x00};
Bilal Qamar 12:a04f7eeece23 142 conf = RETRY;
Bilal Qamar 12:a04f7eeece23 143 int length =0;
Bilal Qamar 12:a04f7eeece23 144
Bilal Qamar 12:a04f7eeece23 145 while(conf)
Bilal Qamar 12:a04f7eeece23 146 {
Bilal Qamar 12:a04f7eeece23 147
Bilal Qamar 12:a04f7eeece23 148 length = GnssSerial::sendUbx(0x06, 0x01, enable_ubx_nav_pvt, sizeof(enable_ubx_nav_pvt));
Bilal Qamar 12:a04f7eeece23 149 if(length >= (int)(sizeof(enable_ubx_nav_pvt) + UBX_FRAME_SIZE))
Bilal Qamar 12:a04f7eeece23 150 {
fahim.alavi@u-blox.com 16:cb9861f0f4d8 151 SEND_LOGGING_MESSAGE("UBX-NAV-PVT was disabled\r\n");
Bilal Qamar 12:a04f7eeece23 152 wait(5);
Bilal Qamar 12:a04f7eeece23 153 break;
Bilal Qamar 12:a04f7eeece23 154 }
Bilal Qamar 12:a04f7eeece23 155 else
Bilal Qamar 12:a04f7eeece23 156 {
fahim.alavi@u-blox.com 16:cb9861f0f4d8 157 SEND_LOGGING_MESSAGE("disabling UBX-NAV-PVT...\r\n");
Bilal Qamar 12:a04f7eeece23 158 conf = conf - 1;
Bilal Qamar 12:a04f7eeece23 159 }
Bilal Qamar 12:a04f7eeece23 160 }
Bilal Qamar 12:a04f7eeece23 161
Bilal Qamar 12:a04f7eeece23 162 return (conf == 0) ? 0 : 1;
Bilal Qamar 12:a04f7eeece23 163 }
Bilal Qamar 12:a04f7eeece23 164
Bilal Qamar 12:a04f7eeece23 165 int GnssOperations::enable_ubx_nav5(unsigned int acc)
Bilal Qamar 12:a04f7eeece23 166 {
Bilal Qamar 12:a04f7eeece23 167 int conf = RETRY;
Bilal Qamar 12:a04f7eeece23 168 conf = RETRY;
Bilal Qamar 12:a04f7eeece23 169 int length =0;
Bilal Qamar 12:a04f7eeece23 170 //convert unsigned int acc to hex
Bilal Qamar 12:a04f7eeece23 171 //ask if positioning mask or time accuracy mask
bqam 18:7adca4350499 172 unsigned char ubx_cfg_nav5[]={0xFF, 0xFF, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10, 0x27, 0x00, 0x00,
bqam 18:7adca4350499 173 0x0A, 0x00, 0xFA, 0x00,0xFA, 0x00, EXTRACT_BYTE(0, FIRST_BYTE, acc), EXTRACT_BYTE(1, SECOND_BYTE, acc),
bqam 18:7adca4350499 174 0x5E, 0x01, 0x00, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00};
Bilal Qamar 12:a04f7eeece23 175
Bilal Qamar 12:a04f7eeece23 176 while(conf)
Bilal Qamar 12:a04f7eeece23 177 {
Bilal Qamar 12:a04f7eeece23 178 length = GnssSerial::sendUbx(0x06, 0x24, ubx_cfg_nav5, sizeof(ubx_cfg_nav5));
Bilal Qamar 12:a04f7eeece23 179 if(length >= (int)(sizeof(ubx_cfg_nav5) + UBX_FRAME_SIZE))
Bilal Qamar 12:a04f7eeece23 180 {
fahim.alavi@u-blox.com 16:cb9861f0f4d8 181 SEND_LOGGING_MESSAGE("ubx_cfg_nav5 was enabled\r\n");
wajahat.abbas@u-blox.com 19:119e7c15ff97 182 wait(1);
Bilal Qamar 12:a04f7eeece23 183 break;
Bilal Qamar 12:a04f7eeece23 184 }
Bilal Qamar 12:a04f7eeece23 185 else
Bilal Qamar 12:a04f7eeece23 186 {
fahim.alavi@u-blox.com 16:cb9861f0f4d8 187 SEND_LOGGING_MESSAGE("enabling ubx_cfg_nav5...\r\n");
Bilal Qamar 12:a04f7eeece23 188 conf = conf - 1;
Bilal Qamar 12:a04f7eeece23 189 }
Bilal Qamar 12:a04f7eeece23 190 }
Bilal Qamar 12:a04f7eeece23 191
Bilal Qamar 12:a04f7eeece23 192 return (conf == 0) ? 0 : 1;
Bilal Qamar 12:a04f7eeece23 193 }
Bilal Qamar 12:a04f7eeece23 194
Bilal Qamar 12:a04f7eeece23 195 /**
Bilal Qamar 12:a04f7eeece23 196 * Enabling UBX-ODOMETER using UBX-CFG-ODO
Bilal Qamar 12:a04f7eeece23 197 * @param return SUCCESS: 1
Bilal Qamar 12:a04f7eeece23 198 * FAILURE: 0
Bilal Qamar 12:a04f7eeece23 199 *
Bilal Qamar 12:a04f7eeece23 200 */
Bilal Qamar 12:a04f7eeece23 201 int GnssOperations::enable_ubx_odo()
Bilal Qamar 12:a04f7eeece23 202 {
Bilal Qamar 12:a04f7eeece23 203 int conf = RETRY;
Bilal Qamar 12:a04f7eeece23 204 unsigned char ubx_cfg_odo[]={0x00, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x19, 0x46, 0x19, 0x66, 0x0A, 0x32, 0x00,
Bilal Qamar 12:a04f7eeece23 205 0x00, 0x99, 0x4C, 0x00, 0x00};
Bilal Qamar 12:a04f7eeece23 206 conf = RETRY;
Bilal Qamar 12:a04f7eeece23 207 int length =0;
Bilal Qamar 12:a04f7eeece23 208
Bilal Qamar 12:a04f7eeece23 209 while(conf)
Bilal Qamar 12:a04f7eeece23 210 {
Bilal Qamar 12:a04f7eeece23 211 length = GnssSerial::sendUbx(0x06, 0x1E, ubx_cfg_odo, sizeof(ubx_cfg_odo));
Bilal Qamar 12:a04f7eeece23 212 if(length >= (int)(sizeof(ubx_cfg_odo) + UBX_FRAME_SIZE))
Bilal Qamar 12:a04f7eeece23 213 {
fahim.alavi@u-blox.com 16:cb9861f0f4d8 214 SEND_LOGGING_MESSAGE("UBX-ODO was enabled\r\n");
wajahat.abbas@u-blox.com 19:119e7c15ff97 215 wait(1);
Bilal Qamar 12:a04f7eeece23 216 break;
Bilal Qamar 12:a04f7eeece23 217 }
Bilal Qamar 12:a04f7eeece23 218 else
Bilal Qamar 12:a04f7eeece23 219 {
fahim.alavi@u-blox.com 16:cb9861f0f4d8 220 SEND_LOGGING_MESSAGE("enabling UBX-ODO...\r\n");
Bilal Qamar 12:a04f7eeece23 221 conf = conf - 1;
Bilal Qamar 12:a04f7eeece23 222 }
Bilal Qamar 12:a04f7eeece23 223 }
Bilal Qamar 12:a04f7eeece23 224
Bilal Qamar 12:a04f7eeece23 225 return (conf == 0) ? 0 : 1;
Bilal Qamar 12:a04f7eeece23 226 }
Bilal Qamar 12:a04f7eeece23 227
Bilal Qamar 12:a04f7eeece23 228 int GnssOperations::disable_ubx_odo()
Bilal Qamar 12:a04f7eeece23 229 {
Bilal Qamar 12:a04f7eeece23 230 int conf = RETRY;
Bilal Qamar 12:a04f7eeece23 231 unsigned char ubx_cfg_odo[]={0x00, 0x00, 0x00, 0x00, 0x0E, 0x00, 0x00, 0x00, 0x19, 0x46, 0x19, 0x66, 0x0A, 0x32, 0x00,
Bilal Qamar 12:a04f7eeece23 232 0x00, 0x99, 0x4C, 0x00, 0x00};
Bilal Qamar 12:a04f7eeece23 233 conf = RETRY;
Bilal Qamar 12:a04f7eeece23 234 int length =0;
Bilal Qamar 12:a04f7eeece23 235
Bilal Qamar 12:a04f7eeece23 236 while(conf)
Bilal Qamar 12:a04f7eeece23 237 {
Bilal Qamar 12:a04f7eeece23 238 length = GnssSerial::sendUbx(0x06, 0x1E, ubx_cfg_odo, sizeof(ubx_cfg_odo));
Bilal Qamar 12:a04f7eeece23 239 if(length >= (int)(sizeof(ubx_cfg_odo) + UBX_FRAME_SIZE))
Bilal Qamar 12:a04f7eeece23 240 {
fahim.alavi@u-blox.com 16:cb9861f0f4d8 241 SEND_LOGGING_MESSAGE("UBX-ODO was disabled\r\n");
Bilal Qamar 12:a04f7eeece23 242 wait(5);
Bilal Qamar 12:a04f7eeece23 243 break;
Bilal Qamar 12:a04f7eeece23 244 }
Bilal Qamar 12:a04f7eeece23 245 else
Bilal Qamar 12:a04f7eeece23 246 {
fahim.alavi@u-blox.com 16:cb9861f0f4d8 247 SEND_LOGGING_MESSAGE("disabling UBX-ODO...\r\n");
Bilal Qamar 12:a04f7eeece23 248 conf = conf - 1;
Bilal Qamar 12:a04f7eeece23 249 }
Bilal Qamar 12:a04f7eeece23 250 }
Bilal Qamar 12:a04f7eeece23 251
Bilal Qamar 12:a04f7eeece23 252 return (conf == 0) ? 0 : 1;
Bilal Qamar 12:a04f7eeece23 253 }
Bilal Qamar 12:a04f7eeece23 254 /**
Bilal Qamar 12:a04f7eeece23 255 * Enabling UBX-NAV-ODO messages using UBX-CFG-MSG
Bilal Qamar 12:a04f7eeece23 256 * @param return SUCCESS: 1
Bilal Qamar 12:a04f7eeece23 257 * FAILURE: 0
Bilal Qamar 12:a04f7eeece23 258 *
Bilal Qamar 12:a04f7eeece23 259 */
Bilal Qamar 12:a04f7eeece23 260 int GnssOperations::enable_ubx_nav_odo()
Bilal Qamar 12:a04f7eeece23 261 {
Bilal Qamar 12:a04f7eeece23 262 int conf = RETRY;
Bilal Qamar 12:a04f7eeece23 263 unsigned char ubx_nav_odo[]={0x01, 0x09, 0x01};
Bilal Qamar 12:a04f7eeece23 264 conf = RETRY;
Bilal Qamar 12:a04f7eeece23 265 int length =0;
Bilal Qamar 12:a04f7eeece23 266
Bilal Qamar 12:a04f7eeece23 267 while(conf)
Bilal Qamar 12:a04f7eeece23 268 {
Bilal Qamar 12:a04f7eeece23 269 length = GnssSerial::sendUbx(0x06, 0x01, ubx_nav_odo, sizeof(ubx_nav_odo));
Bilal Qamar 12:a04f7eeece23 270 if(length >= (int)(sizeof(ubx_nav_odo) + UBX_FRAME_SIZE))
Bilal Qamar 12:a04f7eeece23 271 {
fahim.alavi@u-blox.com 16:cb9861f0f4d8 272 SEND_LOGGING_MESSAGE("UBX-NAV-ODO was enabled\r\n");
wajahat.abbas@u-blox.com 19:119e7c15ff97 273 wait(1);
Bilal Qamar 12:a04f7eeece23 274 break;
Bilal Qamar 12:a04f7eeece23 275 }
Bilal Qamar 12:a04f7eeece23 276 else
Bilal Qamar 12:a04f7eeece23 277 {
fahim.alavi@u-blox.com 16:cb9861f0f4d8 278 SEND_LOGGING_MESSAGE("enabling UBX-NAV-ODO...\r\n");
Bilal Qamar 12:a04f7eeece23 279 conf = conf - 1;
Bilal Qamar 12:a04f7eeece23 280 }
Bilal Qamar 12:a04f7eeece23 281 }
Bilal Qamar 12:a04f7eeece23 282
Bilal Qamar 12:a04f7eeece23 283 return (conf == 0) ? 0 : 1;
Bilal Qamar 12:a04f7eeece23 284 }
Bilal Qamar 12:a04f7eeece23 285
Bilal Qamar 12:a04f7eeece23 286 /**
Bilal Qamar 12:a04f7eeece23 287 * Disabling UBX-NAV-ODO messages using UBX-CFG-MSG
Bilal Qamar 12:a04f7eeece23 288 * @param return SUCCESS: 1
Bilal Qamar 12:a04f7eeece23 289 * FAILURE: 0
Bilal Qamar 12:a04f7eeece23 290 *
Bilal Qamar 12:a04f7eeece23 291 */
Bilal Qamar 12:a04f7eeece23 292 int GnssOperations::disable_ubx_nav_odo()
Bilal Qamar 12:a04f7eeece23 293 {
Bilal Qamar 12:a04f7eeece23 294 int conf = RETRY;
Bilal Qamar 12:a04f7eeece23 295 unsigned char ubx_nav_odo[]={0x01, 0x09, 0x00};
Bilal Qamar 12:a04f7eeece23 296 conf = RETRY;
Bilal Qamar 12:a04f7eeece23 297 int length =0;
Bilal Qamar 12:a04f7eeece23 298
Bilal Qamar 12:a04f7eeece23 299 while(conf)
Bilal Qamar 12:a04f7eeece23 300 {
Bilal Qamar 12:a04f7eeece23 301 length = GnssSerial::sendUbx(0x06, 0x01, ubx_nav_odo, sizeof(ubx_nav_odo));
Bilal Qamar 12:a04f7eeece23 302 if(length >= (int)(sizeof(ubx_nav_odo) + UBX_FRAME_SIZE))
Bilal Qamar 12:a04f7eeece23 303 {
fahim.alavi@u-blox.com 16:cb9861f0f4d8 304 SEND_LOGGING_MESSAGE("UBX-NAV-ODO was disabled\r\n");
Bilal Qamar 12:a04f7eeece23 305 wait(5);
Bilal Qamar 12:a04f7eeece23 306 break;
Bilal Qamar 12:a04f7eeece23 307 }
Bilal Qamar 12:a04f7eeece23 308 else
Bilal Qamar 12:a04f7eeece23 309 {
fahim.alavi@u-blox.com 16:cb9861f0f4d8 310 SEND_LOGGING_MESSAGE("disabling UBX-NAV-ODO...\r\n");
Bilal Qamar 12:a04f7eeece23 311 conf = conf - 1;
Bilal Qamar 12:a04f7eeece23 312 }
Bilal Qamar 12:a04f7eeece23 313 }
Bilal Qamar 12:a04f7eeece23 314
Bilal Qamar 12:a04f7eeece23 315 return (conf == 0) ? 0 : 1;
Bilal Qamar 12:a04f7eeece23 316 }
Bilal Qamar 12:a04f7eeece23 317
Bilal Qamar 12:a04f7eeece23 318 int GnssOperations::enable_ubx_batch_feature()
Bilal Qamar 12:a04f7eeece23 319 {
Bilal Qamar 12:a04f7eeece23 320 int conf = RETRY;
Bilal Qamar 12:a04f7eeece23 321 unsigned char enable_ubx_log_batch[]={0x00, 0x0D, 0x0A, 0x00, 0x07, 0x00, 0x00, 0x01};
Bilal Qamar 12:a04f7eeece23 322 conf = RETRY;
Bilal Qamar 12:a04f7eeece23 323 int length =0;
Bilal Qamar 12:a04f7eeece23 324
Bilal Qamar 12:a04f7eeece23 325 //Disable NAV-ODO and NAV-PVT
Bilal Qamar 12:a04f7eeece23 326 disable_ubx_nav_odo();
Bilal Qamar 12:a04f7eeece23 327 disable_ubx_nav_pvt();
Bilal Qamar 12:a04f7eeece23 328
Bilal Qamar 12:a04f7eeece23 329 while(conf)
Bilal Qamar 12:a04f7eeece23 330 {
Bilal Qamar 12:a04f7eeece23 331 length = GnssSerial::sendUbx(0x06, 0x93, enable_ubx_log_batch, sizeof(enable_ubx_log_batch));
Bilal Qamar 12:a04f7eeece23 332 if(length >= (int)(sizeof(enable_ubx_log_batch) + UBX_FRAME_SIZE))
Bilal Qamar 12:a04f7eeece23 333 {
fahim.alavi@u-blox.com 16:cb9861f0f4d8 334 SEND_LOGGING_MESSAGE("UBX_LOG_BATCH was enabled\r\n");
wajahat.abbas@u-blox.com 19:119e7c15ff97 335 wait(1);
Bilal Qamar 12:a04f7eeece23 336 break;
Bilal Qamar 12:a04f7eeece23 337 }
Bilal Qamar 12:a04f7eeece23 338 else
Bilal Qamar 12:a04f7eeece23 339 {
fahim.alavi@u-blox.com 16:cb9861f0f4d8 340 SEND_LOGGING_MESSAGE("enable ubx_batch_log...\r\n");
Bilal Qamar 12:a04f7eeece23 341 conf = conf - 1;
Bilal Qamar 12:a04f7eeece23 342 }
Bilal Qamar 12:a04f7eeece23 343 }
Bilal Qamar 12:a04f7eeece23 344 return (conf == 0) ? 0 : 1;
Bilal Qamar 12:a04f7eeece23 345 }
Bilal Qamar 12:a04f7eeece23 346
Bilal Qamar 12:a04f7eeece23 347 int GnssOperations::disable_ubx_batch_feature()
Bilal Qamar 12:a04f7eeece23 348 {
Bilal Qamar 12:a04f7eeece23 349 int conf = RETRY;
Bilal Qamar 12:a04f7eeece23 350 unsigned char enable_ubx_log_batch[]={0x00, 0x0C, 0x0A, 0x00, 0x07, 0x00, 0x00, 0x01};
Bilal Qamar 12:a04f7eeece23 351 conf = RETRY;
Bilal Qamar 12:a04f7eeece23 352 int length =0;
Bilal Qamar 12:a04f7eeece23 353
Bilal Qamar 12:a04f7eeece23 354 //Enable NAV-ODO and NAV-PVT
Bilal Qamar 12:a04f7eeece23 355 enable_ubx_nav_odo();
Bilal Qamar 12:a04f7eeece23 356 enable_ubx_nav_pvt();
Bilal Qamar 12:a04f7eeece23 357
Bilal Qamar 12:a04f7eeece23 358 while(conf)
Bilal Qamar 12:a04f7eeece23 359 {
Bilal Qamar 12:a04f7eeece23 360 length = GnssSerial::sendUbx(0x06, 0x93, enable_ubx_log_batch, sizeof(enable_ubx_log_batch));
Bilal Qamar 12:a04f7eeece23 361 if(length >= (int)(sizeof(enable_ubx_log_batch) + UBX_FRAME_SIZE))
Bilal Qamar 12:a04f7eeece23 362 {
fahim.alavi@u-blox.com 16:cb9861f0f4d8 363 SEND_LOGGING_MESSAGE("UBX_LOG_BATCH was enabled\r\n");
Bilal Qamar 12:a04f7eeece23 364 wait(5);
Bilal Qamar 12:a04f7eeece23 365 break;
Bilal Qamar 12:a04f7eeece23 366 }
Bilal Qamar 12:a04f7eeece23 367 else
Bilal Qamar 12:a04f7eeece23 368 {
fahim.alavi@u-blox.com 16:cb9861f0f4d8 369 SEND_LOGGING_MESSAGE("enable ubx_batch_log...\r\n");
Bilal Qamar 12:a04f7eeece23 370 conf = conf - 1;
Bilal Qamar 12:a04f7eeece23 371 }
Bilal Qamar 12:a04f7eeece23 372 }
Bilal Qamar 12:a04f7eeece23 373 return (conf == 0) ? 0 : 1;
Bilal Qamar 12:a04f7eeece23 374 }
Bilal Qamar 12:a04f7eeece23 375
Bilal Qamar 12:a04f7eeece23 376 /**
Bilal Qamar 12:a04f7eeece23 377 *
Bilal Qamar 12:a04f7eeece23 378 * Configuring UBX-LOG-BATCH with UBX-CFG-BATCH
Bilal Qamar 12:a04f7eeece23 379 *
Bilal Qamar 12:a04f7eeece23 380 * @param obj struct containing the data to be send in payload
Bilal Qamar 12:a04f7eeece23 381 * @param return SUCCESS: 1
Bilal Qamar 12:a04f7eeece23 382 * FAIL: 0
Bilal Qamar 12:a04f7eeece23 383 *
Bilal Qamar 12:a04f7eeece23 384 */
Bilal Qamar 12:a04f7eeece23 385 int GnssOperations::cfg_batch_feature(tUBX_CFG_BATCH *obj)
Bilal Qamar 12:a04f7eeece23 386 {
Bilal Qamar 12:a04f7eeece23 387 int length =0;
Bilal Qamar 12:a04f7eeece23 388 const unsigned char cfg_batch_feature[] = {0x00, 0x01, EXTRACT_BYTE(0, FIRST_BYTE, obj->bufSize),
Bilal Qamar 12:a04f7eeece23 389 EXTRACT_BYTE(1, SECOND_BYTE, obj->bufSize), EXTRACT_BYTE(0, FIRST_BYTE, obj->notifThrs),
Bilal Qamar 12:a04f7eeece23 390 EXTRACT_BYTE(1, SECOND_BYTE, obj->notifThrs), obj->pioId, 0x00};
Bilal Qamar 12:a04f7eeece23 391
Bilal Qamar 12:a04f7eeece23 392 length = GnssSerial::sendUbx(0x06, 0x93, cfg_batch_feature, sizeof(cfg_batch_feature));
Bilal Qamar 12:a04f7eeece23 393
Bilal Qamar 12:a04f7eeece23 394 return (length >= (int)(sizeof(cfg_batch_feature) + UBX_FRAME_SIZE)) ? 1 : 0;
Bilal Qamar 12:a04f7eeece23 395 }
Bilal Qamar 12:a04f7eeece23 396
Bilal Qamar 12:a04f7eeece23 397 /*
Bilal Qamar 12:a04f7eeece23 398 * Power mode configuration for GNSS receiver
Bilal Qamar 12:a04f7eeece23 399 *
Bilal Qamar 12:a04f7eeece23 400 * Pending: Need to send extended power management configuration messages (UBX-CFG-PM2)
Bilal Qamar 12:a04f7eeece23 401 *
Bilal Qamar 12:a04f7eeece23 402 *
Bilal Qamar 12:a04f7eeece23 403 */
fahim.alavi@u-blox.com 27:405a5e611635 404 int GnssOperations::cfg_power_mode(Powermodes power_mode, bool minimumAcqTimeZero)
Bilal Qamar 12:a04f7eeece23 405 {
Bilal Qamar 12:a04f7eeece23 406 int length = 0;
fahim.alavi@u-blox.com 27:405a5e611635 407 const int minimumAcqTime_index = 22;
Bilal Qamar 12:a04f7eeece23 408 unsigned char semi_continuous_pms[] = {0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
Bilal Qamar 12:a04f7eeece23 409 unsigned char semi_continuous_pm2[] = {0x02, 0x06, 0x00, 0x00, 0x02, 0x00, 0x43, 0x01, 0x10, 0x27, 0x00, 0x00, 0x10,
Bilal Qamar 12:a04f7eeece23 410 0x27, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2C, 0x01, 0x2C, 0x01, 0x00, 0x00, 0xCF, 0x40, 0x00,
Bilal Qamar 12:a04f7eeece23 411 0x00, 0x87, 0x5A, 0xA4, 0x46, 0xFE, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
Bilal Qamar 12:a04f7eeece23 412 unsigned char semi_continuous_rate[] = {0xE8, 0x03, 0x01, 0x00, 0x01, 0x00};
Bilal Qamar 12:a04f7eeece23 413
Bilal Qamar 12:a04f7eeece23 414 unsigned char aggresive_continuous_pms[] = {0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
Bilal Qamar 12:a04f7eeece23 415 unsigned char aggresive_continuous_pm2[] = {0x02, 0x06, 0x00, 0x00, 0x02, 0x00, 0x43, 0x01, 0xE8, 0x03, 0x00, 0x00,
Bilal Qamar 12:a04f7eeece23 416 0x10, 0x27, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2C, 0x01, 0x2C, 0x01, 0x00, 0x00, 0xCF, 0x40,
Bilal Qamar 12:a04f7eeece23 417 0x00, 0x00, 0x87, 0x5A, 0xA4, 0x46, 0xFE, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
Bilal Qamar 12:a04f7eeece23 418 unsigned char aggressive_continuous_rate[] = {0xE8, 0x03, 0x01, 0x00, 0x01, 0x00};
Bilal Qamar 12:a04f7eeece23 419
Bilal Qamar 12:a04f7eeece23 420 unsigned char conservative_continuous_pms[] = {0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
Bilal Qamar 12:a04f7eeece23 421 unsigned char conservative_continuous_pm2[] = {0x02, 0x06, 0x00, 0x00, 0x00, 0x00, 0x43, 0x01, 0xE8, 0x03, 0x00, 0x00,
Bilal Qamar 12:a04f7eeece23 422 0x10, 0x27, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2C, 0x01, 0x2C, 0x01, 0x00, 0x00, 0xCF, 0x41,
Bilal Qamar 12:a04f7eeece23 423 0x00, 0x00, 0x88, 0x6A, 0xA4, 0x46, 0xFE, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
Bilal Qamar 12:a04f7eeece23 424 unsigned char conservative_continuous_rate[] = {0xE8, 0x03, 0x01, 0x00, 0x01, 0x00};
Bilal Qamar 12:a04f7eeece23 425
Bilal Qamar 12:a04f7eeece23 426 unsigned char full_power_pms[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
bqam 18:7adca4350499 427 unsigned char full_power_rate[] = {0xE8, 0x03, 0x01, 0x00, 0x01, 0x00};
bqam 18:7adca4350499 428
bqam 18:7adca4350499 429 unsigned char full_power_block_level_pms[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
bqam 18:7adca4350499 430 unsigned char full_power_block_level_rate[] = {0xE8, 0x03, 0x01, 0x00, 0x01, 0x00};
bqam 18:7adca4350499 431
bqam 18:7adca4350499 432 unsigned char full_power_building_level_pms[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
bqam 18:7adca4350499 433 unsigned char full_power_building_level_rate[] = {0xE8, 0x03, 0x01, 0x00, 0x01, 0x00};
Bilal Qamar 12:a04f7eeece23 434
Bilal Qamar 12:a04f7eeece23 435 switch (power_mode)
Bilal Qamar 12:a04f7eeece23 436 {
Bilal Qamar 12:a04f7eeece23 437 case SEMI_CONTINOUS:
fahim.alavi@u-blox.com 16:cb9861f0f4d8 438 SEND_LOGGING_MESSAGE("Configuring SEMI_CONTINOUS");
Bilal Qamar 12:a04f7eeece23 439 length = GnssSerial::sendUbx(0x06, 0x86, semi_continuous_pms, sizeof(semi_continuous_pms));
wajahat.abbas@u-blox.com 19:119e7c15ff97 440 wait(1);
fahim.alavi@u-blox.com 27:405a5e611635 441
fahim.alavi@u-blox.com 27:405a5e611635 442 if(minimumAcqTimeZero) {
fahim.alavi@u-blox.com 27:405a5e611635 443 semi_continuous_pm2[minimumAcqTime_index] = 0x00;
fahim.alavi@u-blox.com 27:405a5e611635 444 semi_continuous_pm2[minimumAcqTime_index + 1] = 0x00;
fahim.alavi@u-blox.com 27:405a5e611635 445 }
fahim.alavi@u-blox.com 27:405a5e611635 446
Bilal Qamar 12:a04f7eeece23 447 length = GnssSerial::sendUbx(0x06, 0x3B, semi_continuous_pm2, sizeof(semi_continuous_pm2));
wajahat.abbas@u-blox.com 19:119e7c15ff97 448 wait(1);
Bilal Qamar 12:a04f7eeece23 449 length = GnssSerial::sendUbx(0x06, 0x08, semi_continuous_rate, sizeof(semi_continuous_rate));
fahim.alavi@u-blox.com 20:bc678f383db1 450 wait(1);
Bilal Qamar 12:a04f7eeece23 451 break;
Bilal Qamar 12:a04f7eeece23 452
Bilal Qamar 12:a04f7eeece23 453 case AGGRESSIVE_CONTINUOS:
fahim.alavi@u-blox.com 16:cb9861f0f4d8 454 SEND_LOGGING_MESSAGE("Configuring AGGRESSIVE_CONTINUOS");
Bilal Qamar 12:a04f7eeece23 455 length = GnssSerial::sendUbx(0x06, 0x86, aggresive_continuous_pms, sizeof(aggresive_continuous_pms));
wajahat.abbas@u-blox.com 19:119e7c15ff97 456 wait(1);
fahim.alavi@u-blox.com 27:405a5e611635 457
fahim.alavi@u-blox.com 27:405a5e611635 458 if(minimumAcqTimeZero) {
fahim.alavi@u-blox.com 27:405a5e611635 459 semi_continuous_pm2[minimumAcqTime_index] = 0x00;
fahim.alavi@u-blox.com 27:405a5e611635 460 semi_continuous_pm2[minimumAcqTime_index + 1] = 0x00;
fahim.alavi@u-blox.com 27:405a5e611635 461 }
fahim.alavi@u-blox.com 27:405a5e611635 462
Bilal Qamar 12:a04f7eeece23 463 length = GnssSerial::sendUbx(0x06, 0x3B, aggresive_continuous_pm2, sizeof(aggresive_continuous_pm2));
wajahat.abbas@u-blox.com 19:119e7c15ff97 464 wait(1);
Bilal Qamar 12:a04f7eeece23 465 length = GnssSerial::sendUbx(0x06, 0x08, aggressive_continuous_rate, sizeof(aggressive_continuous_rate));
fahim.alavi@u-blox.com 20:bc678f383db1 466 wait(1);
Bilal Qamar 12:a04f7eeece23 467 break;
Bilal Qamar 12:a04f7eeece23 468
Bilal Qamar 12:a04f7eeece23 469 case CONSERVATIVE_CONTINOUS:
fahim.alavi@u-blox.com 16:cb9861f0f4d8 470 SEND_LOGGING_MESSAGE("Configuring CONSERVATIVE_CONTINOUS");
Bilal Qamar 12:a04f7eeece23 471 length = GnssSerial::sendUbx(0x06, 0x86, conservative_continuous_pms, sizeof(conservative_continuous_pms));
wajahat.abbas@u-blox.com 19:119e7c15ff97 472 wait(1);
fahim.alavi@u-blox.com 27:405a5e611635 473
fahim.alavi@u-blox.com 27:405a5e611635 474 if(minimumAcqTimeZero) {
fahim.alavi@u-blox.com 27:405a5e611635 475 semi_continuous_pm2[minimumAcqTime_index] = 0x00;
fahim.alavi@u-blox.com 27:405a5e611635 476 semi_continuous_pm2[minimumAcqTime_index + 1] = 0x00;
fahim.alavi@u-blox.com 27:405a5e611635 477 }
fahim.alavi@u-blox.com 27:405a5e611635 478
Bilal Qamar 12:a04f7eeece23 479 length = GnssSerial::sendUbx(0x06, 0x3B, conservative_continuous_pm2, sizeof(conservative_continuous_pm2));
wajahat.abbas@u-blox.com 19:119e7c15ff97 480 wait(1);
Bilal Qamar 12:a04f7eeece23 481 length = GnssSerial::sendUbx(0x06, 0x08, conservative_continuous_rate, sizeof(conservative_continuous_rate));
fahim.alavi@u-blox.com 20:bc678f383db1 482 wait(1);
Bilal Qamar 12:a04f7eeece23 483 break;
Bilal Qamar 12:a04f7eeece23 484
Bilal Qamar 12:a04f7eeece23 485 case FULL_POWER:
fahim.alavi@u-blox.com 16:cb9861f0f4d8 486 SEND_LOGGING_MESSAGE("Configuring FULL_POWER");
Bilal Qamar 12:a04f7eeece23 487 length = GnssSerial::sendUbx(0x06, 0x86, full_power_pms, sizeof(full_power_pms));
wajahat.abbas@u-blox.com 19:119e7c15ff97 488 wait(1);
Bilal Qamar 12:a04f7eeece23 489 length = GnssSerial::sendUbx(0x06, 0x08, full_power_rate, sizeof(full_power_rate));
fahim.alavi@u-blox.com 20:bc678f383db1 490 wait(1);
Bilal Qamar 12:a04f7eeece23 491 break;
bqam 18:7adca4350499 492 case FULL_POWER_BLOCK_LEVEL:
bqam 18:7adca4350499 493 SEND_LOGGING_MESSAGE("Configuring FULL_POWER_BLOCK_LEVEL");
bqam 18:7adca4350499 494 length = GnssSerial::sendUbx(0x06, 0x86, full_power_block_level_pms, sizeof(full_power_block_level_pms));
wajahat.abbas@u-blox.com 19:119e7c15ff97 495 wait(1);
bqam 18:7adca4350499 496 length = GnssSerial::sendUbx(0x06, 0x08, full_power_block_level_rate, sizeof(full_power_block_level_rate));
fahim.alavi@u-blox.com 20:bc678f383db1 497 wait(1);
bqam 18:7adca4350499 498 break;
bqam 18:7adca4350499 499 case FULL_POWER_BUILDING_LEVEL:
bqam 18:7adca4350499 500 SEND_LOGGING_MESSAGE("Configuring FULL_POWER_BUILDING_LEVEL");
bqam 18:7adca4350499 501 length = GnssSerial::sendUbx(0x06, 0x86, full_power_building_level_pms, sizeof(full_power_building_level_pms));
wajahat.abbas@u-blox.com 19:119e7c15ff97 502 wait(1);
bqam 18:7adca4350499 503 length = GnssSerial::sendUbx(0x06, 0x08, full_power_building_level_rate, sizeof(full_power_building_level_rate));
fahim.alavi@u-blox.com 20:bc678f383db1 504 wait(1);
bqam 18:7adca4350499 505 break;
Bilal Qamar 12:a04f7eeece23 506 }
fahim.alavi@u-blox.com 20:bc678f383db1 507
Bilal Qamar 12:a04f7eeece23 508 return (length >= (int)(sizeof(semi_continuous_pms) + UBX_FRAME_SIZE)) ? 1 : 0;
Bilal Qamar 12:a04f7eeece23 509 }
Bilal Qamar 12:a04f7eeece23 510
fahim.alavi@u-blox.com 20:bc678f383db1 511 bool GnssOperations::verify_gnss_mode() {
fahim.alavi@u-blox.com 20:bc678f383db1 512
fahim.alavi@u-blox.com 20:bc678f383db1 513 unsigned char CFG_PMS[] = {0xB5, 0x62, 0x06, 0x86, 0x00, 0x00, 0x8c, 0xAA};
fahim.alavi@u-blox.com 20:bc678f383db1 514 unsigned char CFG_PM2[] = {0xB5, 0x62, 0x06, 0x3B, 0x00, 0x00, 0x41, 0xC9};
fahim.alavi@u-blox.com 20:bc678f383db1 515 unsigned char CFG_RATE[] = {0xB5, 0x62, 0x06, 0x08, 0x00, 0x00, 0x0E, 0x30};
fahim.alavi@u-blox.com 20:bc678f383db1 516 unsigned char CFG_NAV5[] = {0xB5, 0x62, 0x06, 0x24, 0x00, 0x00, 0x2A, 0x84};
fahim.alavi@u-blox.com 20:bc678f383db1 517
fahim.alavi@u-blox.com 20:bc678f383db1 518 this->_send(CFG_PMS, sizeof(CFG_PMS));
fahim.alavi@u-blox.com 20:bc678f383db1 519 wait(1);
fahim.alavi@u-blox.com 20:bc678f383db1 520
fahim.alavi@u-blox.com 20:bc678f383db1 521 this->_send(CFG_PM2, sizeof(CFG_PM2));
fahim.alavi@u-blox.com 20:bc678f383db1 522 wait(1);
fahim.alavi@u-blox.com 20:bc678f383db1 523
fahim.alavi@u-blox.com 20:bc678f383db1 524 this->_send(CFG_RATE, sizeof(CFG_RATE));
fahim.alavi@u-blox.com 20:bc678f383db1 525 wait(1);
fahim.alavi@u-blox.com 20:bc678f383db1 526
fahim.alavi@u-blox.com 20:bc678f383db1 527 this->_send(CFG_NAV5, sizeof(CFG_NAV5));
fahim.alavi@u-blox.com 20:bc678f383db1 528 wait(1);
fahim.alavi@u-blox.com 20:bc678f383db1 529
fahim.alavi@u-blox.com 20:bc678f383db1 530 return true;
fahim.alavi@u-blox.com 20:bc678f383db1 531 }
fahim.alavi@u-blox.com 20:bc678f383db1 532
Bilal Qamar 12:a04f7eeece23 533 /**
Bilal Qamar 12:a04f7eeece23 534 * GNSS start modes (Hot/Warm/Cold start)
Bilal Qamar 12:a04f7eeece23 535 *
Bilal Qamar 12:a04f7eeece23 536 * @param return SUCCESS: 1
Bilal Qamar 12:a04f7eeece23 537 * FAILURE: 0
Bilal Qamar 12:a04f7eeece23 538 *
Bilal Qamar 12:a04f7eeece23 539 */
Bilal Qamar 12:a04f7eeece23 540 int GnssOperations::start_mode(int start_mode)
Bilal Qamar 12:a04f7eeece23 541 {
Bilal Qamar 12:a04f7eeece23 542 int length = 0;
Bilal Qamar 12:a04f7eeece23 543 unsigned char hot_start[] = {0x00, 0x00, 0x02, 0x00};
Bilal Qamar 12:a04f7eeece23 544 unsigned char warm_start[] = {0x01, 0x00, 0x02, 0x00};
Bilal Qamar 12:a04f7eeece23 545 unsigned char cold_start[] = {0xFF, 0xFF, 0x02, 0x00};
Bilal Qamar 12:a04f7eeece23 546
Bilal Qamar 12:a04f7eeece23 547 switch (start_mode)
Bilal Qamar 12:a04f7eeece23 548 {
Bilal Qamar 12:a04f7eeece23 549 case HOT:
Bilal Qamar 12:a04f7eeece23 550 length = GnssSerial::sendUbx(0x06, 0x04, hot_start, sizeof(hot_start));
Bilal Qamar 12:a04f7eeece23 551 break;
Bilal Qamar 12:a04f7eeece23 552
Bilal Qamar 12:a04f7eeece23 553 case WARM:
Bilal Qamar 12:a04f7eeece23 554 length = GnssSerial::sendUbx(0x06, 0x04, warm_start, sizeof(warm_start));
Bilal Qamar 12:a04f7eeece23 555 break;
Bilal Qamar 12:a04f7eeece23 556
Bilal Qamar 12:a04f7eeece23 557 case COLD:
Bilal Qamar 12:a04f7eeece23 558 length = GnssSerial::sendUbx(0x06, 0x04, cold_start, sizeof(cold_start));
Bilal Qamar 12:a04f7eeece23 559 break;
Bilal Qamar 12:a04f7eeece23 560 }
Bilal Qamar 12:a04f7eeece23 561
Bilal Qamar 12:a04f7eeece23 562 return (length >= (int)(sizeof(hot_start) + UBX_FRAME_SIZE)) ? 1 : 0;
Bilal Qamar 12:a04f7eeece23 563 }
bqam 14:4b22bd505b93 564
bqam 14:4b22bd505b93 565 void GnssOperations::send_to_gnss(char rChar)
bqam 14:4b22bd505b93 566 {
bqam 14:4b22bd505b93 567 GnssSerial::putc(rChar);
bqam 14:4b22bd505b93 568 }
bqam 14:4b22bd505b93 569
bqam 14:4b22bd505b93 570 void GnssOperations::power_on_gnss()
bqam 14:4b22bd505b93 571 {
bqam 14:4b22bd505b93 572 GnssSerial::_powerOn();
bqam 14:4b22bd505b93 573 }