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-low-power-sleep example-C030-out-of-box-demo example-C030-out-of-box-demo ... more
Revision 16:cb9861f0f4d8, committed 2018-08-01
- Comitter:
- fahim.alavi@u-blox.com
- Date:
- Wed Aug 01 13:14:52 2018 +0500
- Parent:
- 15:105cf3ca48c9
- Child:
- 17:6c226e3e9d61
- Commit message:
- Logging added in SDCard and printing
Changed in this revision
--- a/gnss.cpp Tue Jul 24 16:02:21 2018 +0500 +++ b/gnss.cpp Wed Aug 01 13:14:52 2018 +0500 @@ -23,6 +23,12 @@ #include "ctype.h" #include "gnss.h" +#ifdef UBLOX_WEARABLE_FRAMEWORK +#include "SDCardModel.h" +#else +#define SEND_LOGGING_MESSAGE printf +#endif + GnssParser::GnssParser(void) { // Create the enable pin but set everything to disabled @@ -593,7 +599,9 @@ } int GnssSerial::_send(const void* buf, int len) -{ +{ + GET_SDCARD_INSTANCE->write(logging_file_name, (void *)buf, len); + return put((const char*)buf, len, true/*=blocking*/); }
--- a/gnss_operations.cpp Tue Jul 24 16:02:21 2018 +0500 +++ b/gnss_operations.cpp Wed Aug 01 13:14:52 2018 +0500 @@ -1,5 +1,11 @@ #include "gnss_operations.h" +#ifndef UBLOX_WEARABLE_FRAMEWORK +#define SEND_LOGGING_MESSAGE printf +#else +#include "MessageView.h" +#endif + #define FIRST_BYTE 0x000000FF #define SECOND_BYTE 0x0000FF00 #define THIRD_BYTE 0x00FF0000 @@ -27,14 +33,13 @@ length = GnssSerial::sendUbx(0x06, 0x01, enable_ubx_nav_pvt, sizeof(enable_ubx_nav_pvt)); if(length >= (int)(sizeof(enable_ubx_nav_pvt) + UBX_FRAME_SIZE)) { - printf("UBX-NAV-PVT was enabled\r\n"); - printf("\r\nmessage length: %i\r\n\r\n", length); + SEND_LOGGING_MESSAGE("UBX-NAV-PVT was enabled\r\n"); wait(5); break; } else { - printf("enabling UBX-NAV-PVT...\r\n"); + SEND_LOGGING_MESSAGE("enabling UBX-NAV-PVT...\r\n"); conf = conf - 1; } } @@ -61,14 +66,13 @@ length = GnssSerial::sendUbx(0x06, 0x01, enable_ubx_nav_pvt, sizeof(enable_ubx_nav_pvt)); if(length >= (int)(sizeof(enable_ubx_nav_pvt) + UBX_FRAME_SIZE)) { - printf("UBX-NAV-PVT was disabled\r\n"); - printf("\r\nmessage length: %i\r\n\r\n", length); + SEND_LOGGING_MESSAGE("UBX-NAV-PVT was disabled\r\n"); wait(5); break; } else { - printf("disabling UBX-NAV-PVT...\r\n"); + SEND_LOGGING_MESSAGE("disabling UBX-NAV-PVT...\r\n"); conf = conf - 1; } } @@ -92,13 +96,13 @@ length = GnssSerial::sendUbx(0x06, 0x24, ubx_cfg_nav5, sizeof(ubx_cfg_nav5)); if(length >= (int)(sizeof(ubx_cfg_nav5) + UBX_FRAME_SIZE)) { - printf("ubx_cfg_nav5 was enabled\r\n"); + SEND_LOGGING_MESSAGE("ubx_cfg_nav5 was enabled\r\n"); wait(5); break; } else { - printf("enabling ubx_cfg_nav5...\r\n"); + SEND_LOGGING_MESSAGE("enabling ubx_cfg_nav5...\r\n"); conf = conf - 1; } } @@ -125,13 +129,13 @@ length = GnssSerial::sendUbx(0x06, 0x1E, ubx_cfg_odo, sizeof(ubx_cfg_odo)); if(length >= (int)(sizeof(ubx_cfg_odo) + UBX_FRAME_SIZE)) { - printf("UBX-ODO was enabled\r\n"); + SEND_LOGGING_MESSAGE("UBX-ODO was enabled\r\n"); wait(5); break; } else { - printf("enabling UBX-ODO...\r\n"); + SEND_LOGGING_MESSAGE("enabling UBX-ODO...\r\n"); conf = conf - 1; } } @@ -152,13 +156,13 @@ length = GnssSerial::sendUbx(0x06, 0x1E, ubx_cfg_odo, sizeof(ubx_cfg_odo)); if(length >= (int)(sizeof(ubx_cfg_odo) + UBX_FRAME_SIZE)) { - printf("UBX-ODO was disabled\r\n"); + SEND_LOGGING_MESSAGE("UBX-ODO was disabled\r\n"); wait(5); break; } else { - printf("disabling UBX-ODO...\r\n"); + SEND_LOGGING_MESSAGE("disabling UBX-ODO...\r\n"); conf = conf - 1; } } @@ -183,13 +187,13 @@ length = GnssSerial::sendUbx(0x06, 0x01, ubx_nav_odo, sizeof(ubx_nav_odo)); if(length >= (int)(sizeof(ubx_nav_odo) + UBX_FRAME_SIZE)) { - printf("UBX-NAV-ODO was enabled\r\n"); + SEND_LOGGING_MESSAGE("UBX-NAV-ODO was enabled\r\n"); wait(5); break; } else { - printf("enabling UBX-NAV-ODO...\r\n"); + SEND_LOGGING_MESSAGE("enabling UBX-NAV-ODO...\r\n"); conf = conf - 1; } } @@ -215,13 +219,13 @@ length = GnssSerial::sendUbx(0x06, 0x01, ubx_nav_odo, sizeof(ubx_nav_odo)); if(length >= (int)(sizeof(ubx_nav_odo) + UBX_FRAME_SIZE)) { - printf("UBX-NAV-ODO was disabled\r\n"); + SEND_LOGGING_MESSAGE("UBX-NAV-ODO was disabled\r\n"); wait(5); break; } else { - printf("disabling UBX-NAV-ODO...\r\n"); + SEND_LOGGING_MESSAGE("disabling UBX-NAV-ODO...\r\n"); conf = conf - 1; } } @@ -245,13 +249,13 @@ length = GnssSerial::sendUbx(0x06, 0x93, enable_ubx_log_batch, sizeof(enable_ubx_log_batch)); if(length >= (int)(sizeof(enable_ubx_log_batch) + UBX_FRAME_SIZE)) { - printf("UBX_LOG_BATCH was enabled\r\n"); + SEND_LOGGING_MESSAGE("UBX_LOG_BATCH was enabled\r\n"); wait(5); break; } else { - printf("enable ubx_batch_log...\r\n"); + SEND_LOGGING_MESSAGE("enable ubx_batch_log...\r\n"); conf = conf - 1; } } @@ -274,13 +278,13 @@ length = GnssSerial::sendUbx(0x06, 0x93, enable_ubx_log_batch, sizeof(enable_ubx_log_batch)); if(length >= (int)(sizeof(enable_ubx_log_batch) + UBX_FRAME_SIZE)) { - printf("UBX_LOG_BATCH was enabled\r\n"); + SEND_LOGGING_MESSAGE("UBX_LOG_BATCH was enabled\r\n"); wait(5); break; } else { - printf("enable ubx_batch_log...\r\n"); + SEND_LOGGING_MESSAGE("enable ubx_batch_log...\r\n"); conf = conf - 1; } } @@ -315,7 +319,7 @@ * * */ -int GnssOperations::cfg_power_mode(int power_mode) +int GnssOperations::cfg_power_mode(Powermodes power_mode) { int length = 0; unsigned char semi_continuous_pms[] = {0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; @@ -342,6 +346,7 @@ switch (power_mode) { case SEMI_CONTINOUS: + SEND_LOGGING_MESSAGE("Configuring SEMI_CONTINOUS"); length = GnssSerial::sendUbx(0x06, 0x86, semi_continuous_pms, sizeof(semi_continuous_pms)); wait(5); length = GnssSerial::sendUbx(0x06, 0x3B, semi_continuous_pm2, sizeof(semi_continuous_pm2)); @@ -350,6 +355,7 @@ break; case AGGRESSIVE_CONTINUOS: + SEND_LOGGING_MESSAGE("Configuring AGGRESSIVE_CONTINUOS"); length = GnssSerial::sendUbx(0x06, 0x86, aggresive_continuous_pms, sizeof(aggresive_continuous_pms)); wait(5); length = GnssSerial::sendUbx(0x06, 0x3B, aggresive_continuous_pm2, sizeof(aggresive_continuous_pm2)); @@ -358,6 +364,7 @@ break; case CONSERVATIVE_CONTINOUS: + SEND_LOGGING_MESSAGE("Configuring CONSERVATIVE_CONTINOUS"); length = GnssSerial::sendUbx(0x06, 0x86, conservative_continuous_pms, sizeof(conservative_continuous_pms)); wait(5); length = GnssSerial::sendUbx(0x06, 0x3B, conservative_continuous_pm2, sizeof(conservative_continuous_pm2)); @@ -366,6 +373,7 @@ break; case FULL_POWER: + SEND_LOGGING_MESSAGE("Configuring FULL_POWER"); length = GnssSerial::sendUbx(0x06, 0x86, full_power_pms, sizeof(full_power_pms)); wait(5); length = GnssSerial::sendUbx(0x06, 0x08, full_power_rate, sizeof(full_power_rate));
--- a/gnss_operations.h Tue Jul 24 16:02:21 2018 +0500 +++ b/gnss_operations.h Wed Aug 01 13:14:52 2018 +0500 @@ -29,12 +29,14 @@ /** The operation modes */ enum Powermodes{ - SEMI_CONTINOUS, - AGGRESSIVE_CONTINUOS, - CONSERVATIVE_CONTINOUS, - FULL_POWER, - AVAILABLE_OPERATION - }; + + CONSERVATIVE_CONTINOUS, + AGGRESSIVE_CONTINUOS, + SEMI_CONTINOUS, + FULL_POWER, + AVAILABLE_OPERATION + }; + class GnssOperations : public GnssSerial{ @@ -54,7 +56,7 @@ int enable_ubx_batch_feature(); int disable_ubx_batch_feature(); int cfg_batch_feature(tUBX_CFG_BATCH *obj); - int cfg_power_mode(int power_mode); + int cfg_power_mode(Powermodes power_mode); int start_mode(int start_mode); void send_to_gnss(char);