bool setNavPosLLH(){ uint8_t buf[]={0x06, 0x01, 0x08, 0x00, 0x01, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00}; CK_A = 0x00, CK_B = 0x00; for(int x=0;x<12;x++) { CK_A = CK_A + buf[x]; CK_B = CK_B + CK_A; } uint8_t setport[] = {0xB5, 0x62, 0x06, 0x01, 0x08, 0x00, 0x01, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, CK_A, CK_B};//don't forget to calculate checksum (page84) then add that to end of array - done unsigned long starttime = millis(); while(!gps_set_success) { /* if (millis() - starttime > gps_timeout){ gps_set_success=0; return false; }*/ sendUBX(setport, sizeof(setport)/sizeof(uint8_t)); gps_set_success=getUBX_ACK(setport); } gps_set_success=0; return true; }
// // Exported functions // void gps_setup() { int gps_success = 0; strcpy(gps_time, "000000"); strcpy(gps_aprs_lat, "0000.00N"); strcpy(gps_aprs_lon, "00000.00E"); #ifdef GPS_USING_UBLOX // Setup for the uBLOX MAX-6/7/8 // Check to see if we need to power up the GPS #ifdef GPS_POWER_PIN pinMode(GPS_POWER_PIN, OUTPUT); pin_write(GPS_POWER_PIN, LOW); #endif #ifdef GPS_POWER_SLEEP_TIME // Add a bit of a delay here to allow the GPS a chance to wake up // (even if we aren't powering it via a digital pin) delay(GPS_POWER_SLEEP_TIME); #endif #ifdef GPS_LED_PIN // LED for GPS Status pinMode(GPS_LED_PIN, OUTPUT); pin_write(GPS_LED_PIN, LOW); #endif // Set MAX-6 to flight mode int setup_attempts_remaining = 120; while (!gps_success && (setup_attempts_remaining--) >= 0) { sendUBX(setNav, sizeof(setNav)/sizeof(uint8_t)); gps_success = getUBX_ACK(setNav); if (!gps_success) { // Should find a better way to indicate a problem? #ifdef GPS_LED_PIN pin_write(GPS_LED_PIN, HIGH); #endif delay(500); } } #ifdef GPS_LED_PIN pin_write(GPS_LED_PIN, LOW); #endif // Finally turn off any NMEA sentences we don't need (in this case it's // everything except GGA and RMC) sendUBX(setGLL, sizeof(setGLL)/sizeof(uint8_t)); // Disable GGL sendUBX(setGSA, sizeof(setGSA)/sizeof(uint8_t)); // Disable GSA sendUBX(setGSV, sizeof(setGSV)/sizeof(uint8_t)); // Disable GSV sendUBX(setVTG, sizeof(setVTG)/sizeof(uint8_t)); // Disable VTG #endif }
void setGPS_MaxPerformanceMode(void) { //Set GPS for Max Performance Mode int gps_set_sucess = 0; uint32_t len; uint8_t setMax[] = { 0xB5, 0x62, 0x06, 0x11, 0x02, 0x00, 0x08, 0x00, 0x21, 0x91 }; // Setup for Max Power Mode len = sizeof(setMax) / sizeof(uint8_t); while (!gps_set_sucess) { bcm8235_i2cbb_puts(&gpsi2c, setMax, len); delay(100); gps_set_sucess = getUBX_ACK(setMax); } }
void setGPS_PowerSaveMode(void) { // Power Save Mode int gps_set_sucess = 0; uint32_t len; uint8_t setPSM[] = { 0xB5, 0x62, 0x06, 0x11, 0x02, 0x00, 0x08, 0x01, 0x22, 0x92 }; // Setup for Power Save Mode (Default Cyclic 1s) len = sizeof(setPSM) / sizeof(uint8_t); while (!gps_set_sucess) { bcm8235_i2cbb_puts(&gpsi2c, setPSM, len); delay(100); gps_set_sucess = getUBX_ACK(setPSM); } }
void resetGPS(void) { int gps_set_sucess = 0; uint32_t len; uint8_t set_reset[] = { 0xB5, 0x62, 0x06, 0x04, 0x04, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x0C, 0x5D }; printf("enter reset\n"); len = sizeof(set_reset) / sizeof(uint8_t); while (!gps_set_sucess) { bcm8235_i2cbb_puts(&gpsi2c, set_reset, len); delay(500); gps_set_sucess = getUBX_ACK(set_reset); gps_set_sucess = 1; } printf("reset success\n"); }
void setGPS_DynamicModel3(void) { int gps_set_sucess = 0; uint32_t len; uint8_t setdm3[] = { 0xB5, 0x62, 0x06, 0x24, 0x24, 0x00, 0xFF, 0xFF, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10, 0x27, 0x00, 0x00, 0x05, 0x00, 0xFA, 0x00, 0xFA, 0x00, 0x64, 0x00, 0x2C, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x13, 0x76 }; len = sizeof(setdm3) / sizeof(uint8_t); while (!gps_set_sucess) { bcm8235_i2cbb_puts(&gpsi2c, setdm3, len); delay(100); gps_set_sucess = getUBX_ACK(setdm3); } }
void setGPS_NMEAoff(void) { int gps_set_sucess = 0; uint32_t len; uint8_t setNMEAoff[] = { 0xB5, 0x62, 0x06, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA2, 0xA6 }; len = sizeof(setNMEAoff) / sizeof(uint8_t); //printf("enter NMEAoff\n"); while (!gps_set_sucess) { bcm8235_i2cbb_puts(&gpsi2c, setNMEAoff, len); delay(500); gps_set_sucess = getUBX_ACK(setNMEAoff); } //printf("NMEA switched off\n"); }
void setGPS_DynamicModel6(void) { int gps_set_sucess = 0; uint32_t len; uint8_t setdm6[] = { 0xB5, 0x62, 0x06, 0x24, 0x24, 0x00, 0xFF, 0xFF, 0x06, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10, 0x27, 0x00, 0x00, 0x05, 0x00, 0xFA, 0x00, 0xFA, 0x00, 0x64, 0x00, 0x2C, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, 0xDC }; len = sizeof(setdm6) / sizeof(uint8_t); while (!gps_set_sucess) { bcm8235_i2cbb_puts(&gpsi2c, setdm6, len); delay(100); gps_set_sucess = getUBX_ACK(setdm6); } printf("Flight mode set\n"); }
uint8_t gps_check_nav(void) { // check gps navigation mode (needs to return 6 for high altitude mode) uint8_t request[] = { 0xB5, 0x62, 0x06, 0x24, 0x00, 0x00, 0x2A, 0x84 }; uint8_t data[45]; uint16_t len; bcm8235_i2cbb_puts(&gpsi2c, request, 8); delay(50); // Get the message back from the GPS len = fromGPS(); //printf("nav mode returned %i bytes \n", len); bcm8235_i2cbb_gets(&gpsi2c, data, 44); getUBX_ACK(request); // Return the navigation mode and let the caller analyse it return (uint8_t) *(data + 8); }
bool setSeaMode(){ uint8_t B[]={0x06, 0x24, 0x24, 0x00, 0xFF, 0xFF, 0x05, 0x01, 0x00, 0x00, 0x00, 0x00, 0x10, 0x27, 0x00, 0x00, 0x05, 0x00, 0xFA, 0x00, 0xFA, 0x00, 0x64, 0x00, 0x2C, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; CK_A = 0x00, CK_B = 0x00; for(int I=0;I<40;I++) { CK_A = CK_A + B[I]; CK_B = CK_B + CK_A; } uint8_t setNav[] = {0xB5, 0x62, 0x06, 0x24, 0x24, 0x00, 0xFF, 0xFF, 0x05, 0x01, 0x00, 0x00, 0x00, 0x00, 0x10, 0x27, 0x00, 0x00, 0x05, 0x00, 0xFA, 0x00, 0xFA, 0x00, 0x64, 0x00, 0x2C, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, CK_A, CK_B }; unsigned long starttime = millis(); while(!gps_set_success) { /*if (millis() - starttime > gps_timeout){ gps_set_success=0; return false; }*/ sendUBX(setNav, sizeof(setNav)/sizeof(uint8_t)); gps_set_success=getUBX_ACK(setNav); } gps_set_success=0; Serial.println("Sea mode set."); return true; }