-
Notifications
You must be signed in to change notification settings - Fork 8
/
ublox.cpp
47 lines (43 loc) · 1.74 KB
/
ublox.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include "ublox.h";
#include <SoftwareSerial.h>
#include <Arduino.h>
#include "util.h";
Ublox::Ublox(SoftwareSerial *port){
_gps = port;
}
void Ublox::sendUBX(uint8_t *UBXmsg, uint8_t msgLength) {
for(int i = 0; i < msgLength; i++) {
_gps->write(UBXmsg[i]);
_gps->flush();
}
_gps->println();
_gps->flush();
}
void Ublox::setupGPS(){
uint8_t powerSettings[] = {
0xB5, 0x62, 0x06, 0x3B, 0x2C, 0x00, 0x01, 0x06, 0x00, 0x00, 0x00, 0x90, 0x42, 0x01, 0xE8, 0x03, 0x00, 0x00,
0x10, 0x27, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x2C, 0x01, 0x00, 0x00, 0x4F, 0xC1,
0x03, 0x00, 0x87, 0x02, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x64, 0x40, 0x01, 0x00, 0x8F, 0xDF
};
Ublox::sendUBX(powerSettings, sizeof(powerSettings));
uint8_t navSettings[] = {
0xB5, 0x62, 0x06, 0x24, 0x24, 0x00, 0xFF, 0xFF, 0x04, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10, 0x27, 0x00, 0x00,
0x05, 0x00, 0xFA, 0x00, 0xFA, 0x00, 0x64, 0x00, 0x2C, 0x01, 0x00, 0x00, 0x00, 0x10, 0x27, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x4B, 0x97
};
Ublox::sendUBX(navSettings, sizeof(navSettings));
uint8_t rateSettings[] = {0xB5, 0x62, 0x06, 0x08, 0x06, 0x00, 0xF4, 0x01, 0x01, 0x00, 0x01, 0x00, 0x0B, 0x77};
sendUBX(rateSettings, sizeof(rateSettings));
_gps->flush();
delay(100);
}
void Ublox::sleepyGPS(){
uint8_t powerSettings[] = {
0xB5, 0x62, 0x06, 0x3B, 0x2C, 0x00, 0x01, 0x06, 0x00, 0x00, 0x00, 0x90, 0x40, 0x01, 0x80, 0xEE, 0x36, 0x00,
0x10, 0x27, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x2C, 0x01, 0x00, 0x00, 0x4F, 0xC1,
0x03, 0x00, 0x87, 0x02, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x64, 0x40, 0x01, 0x00, 0x8F, 0xDF
};
Ublox::sendUBX(powerSettings, sizeof(powerSettings));
delay(100);
_gps->flush();
}