fahim alavi / gnss

Dependents:   example-gnss

Fork of gnss by u-blox

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers gnss_operations.cpp Source File

gnss_operations.cpp

00001 #include "gnss_operations.h"
00002 
00003 #ifndef UBLOX_WEARABLE_FRAMEWORK
00004 #define SEND_LOGGING_MESSAGE printf
00005 #else
00006 #include "MessageView.h"
00007 #endif
00008 
00009 #define FIRST_BYTE 0x000000FF
00010 #define SECOND_BYTE 0x0000FF00
00011 #define THIRD_BYTE 0x00FF0000
00012 #define FOURTH_BYTE 0xFF000000
00013 #define RETRY 5
00014 
00015 #define EXTRACT_BYTE(INDEX, BYTE, VALUE) ((VALUE & BYTE) >> (INDEX*8))
00016 
00017 /**
00018  *
00019  * Enable UBX-NAV-PVT using UBX-CFG-MSG
00020  * @param return    SUCCESS: 1
00021  *                  FAILURE: 0
00022  */
00023 int GnssOperations::enable_ubx_nav_pvt()
00024 {
00025     int conf = RETRY;
00026     unsigned char enable_ubx_nav_pvt[]={0x01, 0x07, 0x01};
00027     conf = RETRY;
00028     int length =0;
00029 
00030     while(conf)
00031     {
00032 
00033         length = GnssSerial::sendUbx(0x06, 0x01, enable_ubx_nav_pvt, sizeof(enable_ubx_nav_pvt));
00034         if(length >= (int)(sizeof(enable_ubx_nav_pvt) + UBX_FRAME_SIZE))
00035         {
00036             SEND_LOGGING_MESSAGE("UBX-NAV-PVT was enabled\r\n");
00037             wait(1);
00038             break;
00039         }
00040         else
00041         {
00042             SEND_LOGGING_MESSAGE("enabling UBX-NAV-PVT...\r\n");
00043             conf = conf - 1;
00044         }
00045     }
00046 
00047     return (conf == 0) ? 0 : 1;
00048 }
00049 
00050 int GnssOperations::enable_ubx_nav_status() {
00051     int conf = RETRY;
00052     unsigned char enable_ubx_nav_status[]={0x01, 0x03, 0x01};
00053     conf = RETRY;
00054     int length =0;
00055 
00056     while(conf)
00057     {
00058 
00059         length = GnssSerial::sendUbx(0x06, 0x01, enable_ubx_nav_status, sizeof(enable_ubx_nav_status));
00060         if(length >= (int)(sizeof(enable_ubx_nav_status) + UBX_FRAME_SIZE))
00061         {
00062             SEND_LOGGING_MESSAGE("UBX-NAV-STATUS was enabled\r\n");
00063             wait(1);
00064             break;
00065         }
00066         else
00067         {
00068             SEND_LOGGING_MESSAGE("enabling UBX-NAV-STATUS...\r\n");
00069             conf = conf - 1;
00070         }
00071     }
00072 
00073     return (conf == 0) ? 0 : 1;
00074 
00075 }
00076 
00077 int GnssOperations::enable_ubx_nav_sat() {
00078     int conf = RETRY;
00079     unsigned char enable_ubx_nav_sat[]={0x01, 0x35, 0x01};
00080     conf = RETRY;
00081     int length =0;
00082 
00083     while(conf)
00084     {
00085 
00086         length = GnssSerial::sendUbx(0x06, 0x01, enable_ubx_nav_sat, sizeof(enable_ubx_nav_sat));
00087         if(length >= (int)(sizeof(enable_ubx_nav_sat) + UBX_FRAME_SIZE))
00088         {
00089             SEND_LOGGING_MESSAGE("UBX-NAV-STATUS was enabled\r\n");
00090             wait(1);
00091             break;
00092         }
00093         else
00094         {
00095             SEND_LOGGING_MESSAGE("enabling UBX-NAV-STATUS...\r\n");
00096             conf = conf - 1;
00097         }
00098     }
00099 
00100     return (conf == 0) ? 0 : 1;
00101 
00102 }
00103 
00104 int GnssOperations::enable_ubx_nav_sol() {
00105     int conf = RETRY;
00106     unsigned char enable_ubx_nav_status[]={0x01, 0x06, 0x0A};
00107     conf = RETRY;
00108     int length =0;
00109 
00110     while(conf)
00111     {
00112 
00113         length = GnssSerial::sendUbx(0x06, 0x01, enable_ubx_nav_status, sizeof(enable_ubx_nav_status));
00114         if(length >= (int)(sizeof(enable_ubx_nav_status) + UBX_FRAME_SIZE))
00115         {
00116             SEND_LOGGING_MESSAGE("UBX-NAV-STATUS was enabled\r\n");
00117             wait(1);
00118             break;
00119         }
00120         else
00121         {
00122             SEND_LOGGING_MESSAGE("enabling UBX-NAV-STATUS...\r\n");
00123             conf = conf - 1;
00124         }
00125     }
00126 
00127     return (conf == 0) ? 0 : 1;
00128 
00129 }
00130 
00131 
00132 /**
00133  *
00134  * Disable UBX-NAV-PVT
00135  * @param return    SUCCESS: 1
00136  *                  FAILURE: 0
00137  */
00138 int GnssOperations::disable_ubx_nav_pvt()
00139 {
00140     int conf = RETRY;
00141         unsigned char enable_ubx_nav_pvt[]={0x01, 0x07, 0x00};
00142         conf = RETRY;
00143         int length =0;
00144 
00145         while(conf)
00146         {
00147 
00148             length = GnssSerial::sendUbx(0x06, 0x01, enable_ubx_nav_pvt, sizeof(enable_ubx_nav_pvt));
00149             if(length >= (int)(sizeof(enable_ubx_nav_pvt) + UBX_FRAME_SIZE))
00150             {
00151                 SEND_LOGGING_MESSAGE("UBX-NAV-PVT was disabled\r\n");
00152                 wait(5);
00153                 break;
00154             }
00155             else
00156             {
00157                 SEND_LOGGING_MESSAGE("disabling UBX-NAV-PVT...\r\n");
00158                 conf = conf - 1;
00159             }
00160         }
00161 
00162         return (conf == 0) ? 0 : 1;
00163 }
00164 
00165 int GnssOperations::enable_ubx_nav5(unsigned int acc)
00166 {
00167     int conf = RETRY;
00168     conf = RETRY;
00169     int length =0;
00170     //convert unsigned int acc to hex
00171     //ask if positioning mask or time accuracy mask
00172     unsigned char   ubx_cfg_nav5[]={0xFF, 0xFF, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10, 0x27, 0x00, 0x00,
00173                     0x0A, 0x00, 0xFA, 0x00,0xFA, 0x00, EXTRACT_BYTE(0, FIRST_BYTE, acc), EXTRACT_BYTE(1, SECOND_BYTE, acc),
00174                     0x5E, 0x01, 0x00, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00};
00175 
00176     while(conf)
00177     {
00178         length = GnssSerial::sendUbx(0x06, 0x24, ubx_cfg_nav5, sizeof(ubx_cfg_nav5));
00179         if(length >= (int)(sizeof(ubx_cfg_nav5) + UBX_FRAME_SIZE))
00180         {
00181             SEND_LOGGING_MESSAGE("ubx_cfg_nav5 was enabled\r\n");
00182             wait(1);
00183             break;
00184         }
00185         else
00186         {
00187             SEND_LOGGING_MESSAGE("enabling ubx_cfg_nav5...\r\n");
00188             conf = conf - 1;
00189         }
00190     }
00191 
00192     return (conf == 0) ? 0 : 1;
00193 }
00194 
00195 int GnssOperations::enable_ubx_navx5()
00196 {
00197     int conf = RETRY;
00198     conf = RETRY;
00199     int length =0;
00200     //convert unsigned int acc to hex
00201     //ask if positioning mask or time accuracy mask
00202     unsigned char   ubx_cfg_navx5[]={0x28, 0x00, 0x02, 0x00, 0xFF, 0xFF, 0xFF, 0x02, 0x00, 0x00, 0x03, 0x02, 0x03, 0x20, 0x06, 0x00, 0x01, 0x01, 0x00, 0x00, 0x90,
00203             0x07, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x02, 0x64, 0x64, 0x00, 0x00, 0x01, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF9, 0xF7};
00204 
00205     while(conf)
00206     {
00207         length = GnssSerial::sendUbx(0x06, 0x23, ubx_cfg_navx5, sizeof(ubx_cfg_navx5));
00208         if(length >= (int)(sizeof(ubx_cfg_navx5) + UBX_FRAME_SIZE))
00209         {
00210             SEND_LOGGING_MESSAGE("ubx_cfg_navx5 was enabled\r\n");
00211             wait(1);
00212             break;
00213         }
00214         else
00215         {
00216             SEND_LOGGING_MESSAGE("enabling ubx_cfg_navx5...\r\n");
00217             conf = conf - 1;
00218         }
00219     }
00220 
00221     return (conf == 0) ? 0 : 1;
00222 }
00223 
00224 /**
00225  * Enabling UBX-ODOMETER using UBX-CFG-ODO
00226  * @param return    SUCCESS: 1
00227  *                  FAILURE: 0
00228  *
00229  */
00230 int GnssOperations::enable_ubx_odo()
00231 {
00232     int conf = RETRY;
00233     unsigned char ubx_cfg_odo[]={0x00, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x19, 0x46, 0x19, 0x66, 0x0A, 0x32, 0x00,
00234             0x00, 0x99, 0x4C, 0x00, 0x00};
00235     conf = RETRY;
00236     int length =0;
00237 
00238     while(conf)
00239     {
00240         length = GnssSerial::sendUbx(0x06, 0x1E, ubx_cfg_odo, sizeof(ubx_cfg_odo));
00241         if(length >= (int)(sizeof(ubx_cfg_odo) + UBX_FRAME_SIZE))
00242         {
00243             SEND_LOGGING_MESSAGE("UBX-ODO was enabled\r\n");
00244             wait(1);
00245             break;
00246         }
00247         else
00248         {
00249             SEND_LOGGING_MESSAGE("enabling UBX-ODO...\r\n");
00250             conf = conf - 1;
00251         }
00252     }
00253 
00254     return (conf == 0) ? 0 : 1;
00255 }
00256 
00257 int GnssOperations::disable_ubx_odo()
00258 {
00259     int conf = RETRY;
00260     unsigned char ubx_cfg_odo[]={0x00, 0x00, 0x00, 0x00, 0x0E, 0x00, 0x00, 0x00, 0x19, 0x46, 0x19, 0x66, 0x0A, 0x32, 0x00,
00261             0x00, 0x99, 0x4C, 0x00, 0x00};
00262     conf = RETRY;
00263     int length =0;
00264 
00265     while(conf)
00266     {
00267         length = GnssSerial::sendUbx(0x06, 0x1E, ubx_cfg_odo, sizeof(ubx_cfg_odo));
00268         if(length >= (int)(sizeof(ubx_cfg_odo) + UBX_FRAME_SIZE))
00269         {
00270             SEND_LOGGING_MESSAGE("UBX-ODO was disabled\r\n");
00271             wait(5);
00272             break;
00273         }
00274         else
00275         {
00276             SEND_LOGGING_MESSAGE("disabling UBX-ODO...\r\n");
00277             conf = conf - 1;
00278         }
00279     }
00280 
00281     return (conf == 0) ? 0 : 1;
00282 }
00283 /**
00284  * Enabling UBX-NAV-ODO messages using UBX-CFG-MSG
00285  * @param return    SUCCESS: 1
00286  *                  FAILURE: 0
00287  *
00288  */
00289 int GnssOperations::enable_ubx_nav_odo()
00290 {
00291     int conf = RETRY;
00292     unsigned char ubx_nav_odo[]={0x01, 0x09, 0x01};
00293     conf = RETRY;
00294     int length =0;
00295 
00296     while(conf)
00297     {
00298         length = GnssSerial::sendUbx(0x06, 0x01, ubx_nav_odo, sizeof(ubx_nav_odo));
00299         if(length >= (int)(sizeof(ubx_nav_odo) + UBX_FRAME_SIZE))
00300         {
00301             SEND_LOGGING_MESSAGE("UBX-NAV-ODO was enabled\r\n");
00302             wait(1);
00303             break;
00304         }
00305         else
00306         {
00307             SEND_LOGGING_MESSAGE("enabling UBX-NAV-ODO...\r\n");
00308             conf = conf - 1;
00309         }
00310     }
00311 
00312     return (conf == 0) ? 0 : 1;
00313 }
00314 
00315 /**
00316  * Disabling UBX-NAV-ODO messages using UBX-CFG-MSG
00317  * @param return    SUCCESS: 1
00318  *                  FAILURE: 0
00319  *
00320  */
00321 int GnssOperations::disable_ubx_nav_odo()
00322 {
00323     int conf = RETRY;
00324     unsigned char ubx_nav_odo[]={0x01, 0x09, 0x00};
00325     conf = RETRY;
00326     int length =0;
00327 
00328     while(conf)
00329     {
00330         length = GnssSerial::sendUbx(0x06, 0x01, ubx_nav_odo, sizeof(ubx_nav_odo));
00331         if(length >= (int)(sizeof(ubx_nav_odo) + UBX_FRAME_SIZE))
00332         {
00333             SEND_LOGGING_MESSAGE("UBX-NAV-ODO was disabled\r\n");
00334             wait(5);
00335             break;
00336         }
00337         else
00338         {
00339             SEND_LOGGING_MESSAGE("disabling UBX-NAV-ODO...\r\n");
00340             conf = conf - 1;
00341         }
00342     }
00343 
00344     return (conf == 0) ? 0 : 1;
00345 }
00346 
00347 int GnssOperations::enable_ubx_batch_feature()
00348 {
00349     int conf = RETRY;
00350     unsigned char enable_ubx_log_batch[]={0x00, 0x0D, 0x0A, 0x00, 0x07, 0x00, 0x00, 0x01};
00351     conf = RETRY;
00352     int length =0;
00353 
00354     //Disable NAV-ODO and NAV-PVT
00355     disable_ubx_nav_odo();
00356     disable_ubx_nav_pvt();
00357 
00358     while(conf)
00359     {
00360         length = GnssSerial::sendUbx(0x06, 0x93, enable_ubx_log_batch, sizeof(enable_ubx_log_batch));
00361         if(length >= (int)(sizeof(enable_ubx_log_batch) + UBX_FRAME_SIZE))
00362         {
00363             SEND_LOGGING_MESSAGE("UBX_LOG_BATCH was enabled\r\n");
00364             wait(1);
00365             break;
00366         }
00367         else
00368         {
00369             SEND_LOGGING_MESSAGE("enable ubx_batch_log...\r\n");
00370             conf = conf - 1;
00371         }
00372     }
00373     return (conf == 0) ? 0 : 1;
00374 }
00375 
00376 int GnssOperations::disable_ubx_batch_feature()
00377 {
00378     int conf = RETRY;
00379     unsigned char enable_ubx_log_batch[]={0x00, 0x0C, 0x0A, 0x00, 0x07, 0x00, 0x00, 0x01};
00380     conf = RETRY;
00381     int length =0;
00382 
00383     //Enable NAV-ODO and NAV-PVT
00384     enable_ubx_nav_odo();
00385     enable_ubx_nav_pvt();
00386 
00387     while(conf)
00388     {
00389         length = GnssSerial::sendUbx(0x06, 0x93, enable_ubx_log_batch, sizeof(enable_ubx_log_batch));
00390         if(length >= (int)(sizeof(enable_ubx_log_batch) + UBX_FRAME_SIZE))
00391         {
00392             SEND_LOGGING_MESSAGE("UBX_LOG_BATCH was enabled\r\n");
00393             wait(5);
00394             break;
00395         }
00396         else
00397         {
00398             SEND_LOGGING_MESSAGE("enable ubx_batch_log...\r\n");
00399             conf = conf - 1;
00400         }
00401     }
00402     return (conf == 0) ? 0 : 1;
00403 }
00404 
00405 /**
00406  *
00407  * Configuring UBX-LOG-BATCH with UBX-CFG-BATCH
00408  *
00409  * @param obj struct containing the data to be send in payload
00410  * @param return    SUCCESS: 1
00411  *                  FAIL:    0
00412  *
00413  */
00414 int GnssOperations::cfg_batch_feature(tUBX_CFG_BATCH *obj)
00415 {
00416     int length =0;
00417     const unsigned char cfg_batch_feature[] = {0x00, 0x01, EXTRACT_BYTE(0, FIRST_BYTE, obj->bufSize),
00418                         EXTRACT_BYTE(1, SECOND_BYTE, obj->bufSize), EXTRACT_BYTE(0, FIRST_BYTE, obj->notifThrs),
00419                         EXTRACT_BYTE(1, SECOND_BYTE, obj->notifThrs), obj->pioId, 0x00};
00420 
00421     length = GnssSerial::sendUbx(0x06, 0x93, cfg_batch_feature, sizeof(cfg_batch_feature));
00422 
00423     return (length >= (int)(sizeof(cfg_batch_feature) + UBX_FRAME_SIZE)) ? 1 : 0;
00424 }
00425 
00426 /*
00427  *  Power mode configuration for GNSS receiver
00428  *
00429  *  Pending: Need to send extended power management configuration messages (UBX-CFG-PM2)
00430  *
00431  *
00432  */
00433 int GnssOperations::cfg_power_mode(Powermodes power_mode, bool minimumAcqTimeZero)
00434 {
00435     int length = 0;
00436     const int minimumAcqTime_index = 22;
00437     unsigned char semi_continuous_pms[] = {0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
00438     unsigned char semi_continuous_pm2[] = {0x02, 0x06, 0x00, 0x00, 0x02, 0x00, 0x43, 0x01, 0x10, 0x27, 0x00, 0x00, 0x10,
00439             0x27, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2C, 0x01, 0x2C, 0x01, 0x00, 0x00, 0xCF, 0x40, 0x00,
00440             0x00, 0x87, 0x5A, 0xA4, 0x46, 0xFE, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
00441     unsigned char semi_continuous_rate[] = {0xE8, 0x03, 0x01, 0x00, 0x01, 0x00};
00442 
00443     unsigned char aggresive_continuous_pms[] = {0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
00444     unsigned char aggresive_continuous_pm2[] = {0x02, 0x06, 0x00, 0x00, 0x02, 0x00, 0x43, 0x01, 0xE8, 0x03, 0x00, 0x00,
00445             0x10, 0x27, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2C, 0x01, 0x2C, 0x01, 0x00, 0x00, 0xCF, 0x40,
00446             0x00, 0x00, 0x87, 0x5A, 0xA4, 0x46, 0xFE, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
00447     unsigned char aggressive_continuous_rate[] = {0xE8, 0x03, 0x01, 0x00, 0x01, 0x00};
00448 
00449     unsigned char conservative_continuous_pms[] = {0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
00450     unsigned char conservative_continuous_pm2[] = {0x02, 0x06, 0x00, 0x00, 0x00, 0x00, 0x43, 0x01, 0xE8, 0x03, 0x00, 0x00,
00451             0x10, 0x27, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2C, 0x01, 0x2C, 0x01, 0x00, 0x00, 0xCF, 0x41,
00452             0x00, 0x00, 0x88, 0x6A, 0xA4, 0x46, 0xFE, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
00453     unsigned char conservative_continuous_rate[] = {0xE8, 0x03, 0x01, 0x00, 0x01, 0x00};
00454 
00455     unsigned char full_power_pms[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
00456     unsigned char full_power_rate[] = {0xE8, 0x03, 0x01, 0x00, 0x01, 0x00};
00457 
00458     unsigned char full_power_block_level_pms[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
00459     unsigned char full_power_block_level_rate[] = {0xE8, 0x03, 0x01, 0x00, 0x01, 0x00};
00460 
00461     unsigned char full_power_building_level_pms[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
00462     unsigned char full_power_building_level_rate[] = {0xE8, 0x03, 0x01, 0x00, 0x01, 0x00};
00463 
00464     switch (power_mode)
00465     {
00466     case SEMI_CONTINOUS:
00467         SEND_LOGGING_MESSAGE("Configuring SEMI_CONTINOUS");
00468         length = GnssSerial::sendUbx(0x06, 0x86, semi_continuous_pms, sizeof(semi_continuous_pms));
00469         wait(1);
00470 
00471         if(minimumAcqTimeZero) {
00472             semi_continuous_pm2[minimumAcqTime_index] = 0x00;
00473             semi_continuous_pm2[minimumAcqTime_index + 1] = 0x00;
00474         }
00475 
00476         length = GnssSerial::sendUbx(0x06, 0x3B, semi_continuous_pm2, sizeof(semi_continuous_pm2));
00477         wait(1);
00478         length = GnssSerial::sendUbx(0x06, 0x08, semi_continuous_rate, sizeof(semi_continuous_rate));
00479         wait(1);
00480         break;
00481 
00482     case AGGRESSIVE_CONTINUOS:
00483         SEND_LOGGING_MESSAGE("Configuring AGGRESSIVE_CONTINUOS");
00484         length = GnssSerial::sendUbx(0x06, 0x86, aggresive_continuous_pms, sizeof(aggresive_continuous_pms));
00485         wait(1);
00486 
00487         if(minimumAcqTimeZero) {
00488             semi_continuous_pm2[minimumAcqTime_index] = 0x00;
00489             semi_continuous_pm2[minimumAcqTime_index + 1] = 0x00;
00490         }
00491 
00492         length = GnssSerial::sendUbx(0x06, 0x3B, aggresive_continuous_pm2, sizeof(aggresive_continuous_pm2));
00493         wait(1);
00494         length = GnssSerial::sendUbx(0x06, 0x08, aggressive_continuous_rate, sizeof(aggressive_continuous_rate));
00495         wait(1);
00496         break;
00497 
00498     case CONSERVATIVE_CONTINOUS:
00499         SEND_LOGGING_MESSAGE("Configuring CONSERVATIVE_CONTINOUS");
00500         length = GnssSerial::sendUbx(0x06, 0x86, conservative_continuous_pms, sizeof(conservative_continuous_pms));
00501         wait(1);
00502 
00503         if(minimumAcqTimeZero) {
00504             semi_continuous_pm2[minimumAcqTime_index] = 0x00;
00505             semi_continuous_pm2[minimumAcqTime_index + 1] = 0x00;
00506         }
00507 
00508         length = GnssSerial::sendUbx(0x06, 0x3B, conservative_continuous_pm2, sizeof(conservative_continuous_pm2));
00509         wait(1);
00510         length = GnssSerial::sendUbx(0x06, 0x08, conservative_continuous_rate, sizeof(conservative_continuous_rate));
00511         wait(1);
00512         break;
00513 
00514     case FULL_POWER:
00515         SEND_LOGGING_MESSAGE("Configuring FULL_POWER");
00516         length = GnssSerial::sendUbx(0x06, 0x86, full_power_pms, sizeof(full_power_pms));
00517         wait(1);
00518         length = GnssSerial::sendUbx(0x06, 0x08, full_power_rate, sizeof(full_power_rate));
00519         wait(1);
00520         break;
00521     case FULL_POWER_BLOCK_LEVEL:
00522         SEND_LOGGING_MESSAGE("Configuring FULL_POWER_BLOCK_LEVEL");
00523         length = GnssSerial::sendUbx(0x06, 0x86, full_power_block_level_pms, sizeof(full_power_block_level_pms));
00524         wait(1);
00525         length = GnssSerial::sendUbx(0x06, 0x08, full_power_block_level_rate, sizeof(full_power_block_level_rate));
00526         wait(1);
00527         break;
00528     case FULL_POWER_BUILDING_LEVEL:
00529         SEND_LOGGING_MESSAGE("Configuring FULL_POWER_BUILDING_LEVEL");
00530         length = GnssSerial::sendUbx(0x06, 0x86, full_power_building_level_pms, sizeof(full_power_building_level_pms));
00531         wait(1);
00532         length = GnssSerial::sendUbx(0x06, 0x08, full_power_building_level_rate, sizeof(full_power_building_level_rate));
00533         wait(1);
00534         break;
00535     }
00536 
00537     return (length >= (int)(sizeof(semi_continuous_pms) + UBX_FRAME_SIZE)) ? 1 : 0;
00538 }
00539 
00540 bool GnssOperations::verify_gnss_mode() {
00541 
00542     unsigned char CFG_PMS[] = {0xB5, 0x62, 0x06, 0x86, 0x00, 0x00, 0x8c, 0xAA};
00543     unsigned char CFG_PM2[] = {0xB5, 0x62, 0x06, 0x3B, 0x00, 0x00, 0x41, 0xC9};
00544     unsigned char CFG_RATE[] = {0xB5, 0x62, 0x06, 0x08, 0x00, 0x00, 0x0E, 0x30};
00545     unsigned char CFG_NAV5[] = {0xB5, 0x62, 0x06, 0x24, 0x00, 0x00, 0x2A, 0x84};
00546     unsigned char CFG_NAVX5[] = {0xB5, 0x62, 0x06, 0x24, 0x00, 0x00, 0x29, 0x81};
00547 
00548     this->_send(CFG_PMS, sizeof(CFG_PMS));
00549     wait(1);
00550 
00551     this->_send(CFG_PM2, sizeof(CFG_PM2));
00552     wait(1);
00553 
00554     this->_send(CFG_RATE, sizeof(CFG_RATE));
00555     wait(1);
00556 
00557     this->_send(CFG_NAV5, sizeof(CFG_NAV5));
00558     wait(1);
00559 
00560     this->_send(CFG_NAVX5, sizeof(CFG_NAVX5));
00561     wait(1);
00562 
00563     return true;
00564 }
00565 
00566 /**
00567  *  GNSS start modes (Hot/Warm/Cold start)
00568  *
00569  *  @param return   SUCCESS: 1
00570  *                  FAILURE:    0
00571  *
00572  */
00573 int GnssOperations::start_mode(int start_mode)
00574 {
00575     int length = 0;
00576     unsigned char hot_start[] = {0x00, 0x00, 0x02, 0x00};
00577     unsigned char warm_start[] = {0x01, 0x00, 0x02, 0x00};
00578     unsigned char cold_start[] = {0xFF, 0xFF, 0x02, 0x00};
00579 
00580     switch (start_mode)
00581     {
00582     case HOT:
00583         length = GnssSerial::sendUbx(0x06, 0x04, hot_start, sizeof(hot_start));
00584         break;
00585 
00586     case WARM:
00587         length = GnssSerial::sendUbx(0x06, 0x04, warm_start, sizeof(warm_start));
00588         break;
00589 
00590     case COLD:
00591         length = GnssSerial::sendUbx(0x06, 0x04, cold_start, sizeof(cold_start));
00592         break;
00593     }
00594 
00595     return (length >= (int)(sizeof(hot_start) + UBX_FRAME_SIZE)) ? 1 : 0;
00596 }
00597 
00598 void GnssOperations::send_to_gnss(char rChar)
00599 {
00600     GnssSerial::putc(rChar);
00601 }
00602 
00603 void GnssOperations::power_on_gnss()
00604 {
00605     GnssSerial::_powerOn();
00606 }