disable sensor detection - temporary solution
This commit is contained in:
2
.vscode/settings.json
vendored
2
.vscode/settings.json
vendored
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"C_Cpp.intelliSenseEngine": "default",
|
"C_Cpp.intelliSenseEngine": "default",
|
||||||
"idf.espIdfPath": "/home/bruno/esp/master/esp-idf",
|
"idf.espIdfPath": "/home/bruno/esp/v5.4.1/esp-idf",
|
||||||
"idf.pythonInstallPath": "/usr/bin/python",
|
"idf.pythonInstallPath": "/usr/bin/python",
|
||||||
"idf.openOcdConfigs": [
|
"idf.openOcdConfigs": [
|
||||||
"board/esp32s3-builtin.cfg"
|
"board/esp32s3-builtin.cfg"
|
||||||
|
@@ -2,7 +2,7 @@ dependencies:
|
|||||||
idf:
|
idf:
|
||||||
source:
|
source:
|
||||||
type: idf
|
type: idf
|
||||||
version: 5.5.0
|
version: 5.4.1
|
||||||
k0i05/esp_bme680:
|
k0i05/esp_bme680:
|
||||||
component_hash: 2df0cb14d4425565a8745d4a96bfaa8ff7e90bbec3e208a073821406dded23c8
|
component_hash: 2df0cb14d4425565a8745d4a96bfaa8ff7e90bbec3e208a073821406dded23c8
|
||||||
dependencies:
|
dependencies:
|
||||||
|
@@ -191,7 +191,7 @@ void process_uplink_packet(uint8_t *data, uint8_t len, uint64_t missionTimer)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ESP_LOGI(TAG, "Got uplink packet of type %d, index %d", uplinkPacket.packetType, uplinkPacket.packetIndex);
|
ESP_LOGI(TAG, "Got uplink packet of type %d, index %ld", uplinkPacket.packetType, uplinkPacket.packetIndex);
|
||||||
|
|
||||||
uint8_t *payload = data + sizeof(UplinkPacket);
|
uint8_t *payload = data + sizeof(UplinkPacket);
|
||||||
|
|
||||||
@@ -200,13 +200,13 @@ void process_uplink_packet(uint8_t *data, uint8_t len, uint64_t missionTimer)
|
|||||||
uint32_t crc = esp_rom_crc32_le(0, payload, payloadRXLen);
|
uint32_t crc = esp_rom_crc32_le(0, payload, payloadRXLen);
|
||||||
|
|
||||||
if (crc != uplinkPacket.CRCCheck) {
|
if (crc != uplinkPacket.CRCCheck) {
|
||||||
ESP_LOGE(TAG, "Received BAD CRC for packet %d, crc is %ld, should be %ld", uplinkPacket.packetIndex, crc, uplinkPacket.CRCCheck);
|
ESP_LOGE(TAG, "Received BAD CRC for packet %ld, crc is %ld, should be %ld", uplinkPacket.packetIndex, crc, uplinkPacket.CRCCheck);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (uplinkPacket.packetType == UplinkPacketType_ACK)
|
if (uplinkPacket.packetType == UplinkPacketType_ACK)
|
||||||
{
|
{
|
||||||
ESP_LOGI(TAG, "Received ACK for packet %d", uplinkPacket.packetIndex);
|
ESP_LOGI(TAG, "Received ACK for packet %ld", uplinkPacket.packetIndex);
|
||||||
ackReceived = true;
|
ackReceived = true;
|
||||||
lastAckIndex = uplinkPacket.packetIndex;
|
lastAckIndex = uplinkPacket.packetIndex;
|
||||||
return;
|
return;
|
||||||
@@ -247,12 +247,12 @@ void process_uplink_packet(uint8_t *data, uint8_t len, uint64_t missionTimer)
|
|||||||
}
|
}
|
||||||
else if (uplinkPacket.packetIndex > packetIndexRX + 1)
|
else if (uplinkPacket.packetIndex > packetIndexRX + 1)
|
||||||
{
|
{
|
||||||
ESP_LOGW(TAG, "Skipped %d packets", uplinkPacket.packetIndex - (packetIndexRX + 1));
|
ESP_LOGW(TAG, "Skipped %ld packets", uplinkPacket.packetIndex - (packetIndexRX + 1));
|
||||||
packetIndexRX = uplinkPacket.packetIndex;
|
packetIndexRX = uplinkPacket.packetIndex;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ESP_LOGW(TAG, "Duplicate packet: %d", (packetIndexRX + 1) - uplinkPacket.packetIndex);
|
ESP_LOGW(TAG, "Duplicate packet: %ld", (packetIndexRX + 1) - uplinkPacket.packetIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -289,9 +289,9 @@ void lora_comms_task(void *pvParameters)
|
|||||||
|
|
||||||
ESP_LOGI(TAG, "lora_comms_task started");
|
ESP_LOGI(TAG, "lora_comms_task started");
|
||||||
|
|
||||||
while (foundDevices[0] != 2) {
|
// while (foundDevices[0] != 2) {
|
||||||
vTaskDelay(10);
|
// vTaskDelay(10);
|
||||||
}
|
// }
|
||||||
|
|
||||||
// Initialize the semaphore for radio access (binary semaphore, 1 = available)
|
// Initialize the semaphore for radio access (binary semaphore, 1 = available)
|
||||||
loraRadioMutex = xSemaphoreCreateMutex();
|
loraRadioMutex = xSemaphoreCreateMutex();
|
||||||
|
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
#define BLINK_GPIO 2
|
#define BLINK_GPIO 2
|
||||||
|
|
||||||
//uint8_t powerMode = LOW_POWER_MODE;
|
// uint8_t powerMode = LOW_POWER_MODE;
|
||||||
uint8_t powerMode = HIGH_POWER_MODE;
|
uint8_t powerMode = HIGH_POWER_MODE;
|
||||||
|
|
||||||
static uint8_t s_led_state = 0;
|
static uint8_t s_led_state = 0;
|
||||||
@@ -59,11 +59,14 @@ void setPowerMode(uint8_t powerModeIn)
|
|||||||
powerMode = powerModeIn;
|
powerMode = powerModeIn;
|
||||||
if (foundDevices[0] == 2)
|
if (foundDevices[0] == 2)
|
||||||
{
|
{
|
||||||
if (powerMode == HIGH_POWER_MODE) {
|
if (powerMode == HIGH_POWER_MODE)
|
||||||
|
{
|
||||||
mcp23018_set_pin(MCP23018_DEV_HANDLE, MCP_CCS811_WAKE, 0);
|
mcp23018_set_pin(MCP23018_DEV_HANDLE, MCP_CCS811_WAKE, 0);
|
||||||
mcp23018_set_pin(MCP23018_DEV_HANDLE, MCP_CCS811_POWER, 1);
|
mcp23018_set_pin(MCP23018_DEV_HANDLE, MCP_CCS811_POWER, 1);
|
||||||
mcp23018_set_pin(MCP23018_DEV_HANDLE, MCP_MICS_POWER, 1);
|
mcp23018_set_pin(MCP23018_DEV_HANDLE, MCP_MICS_POWER, 1);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
mcp23018_set_pin(MCP23018_DEV_HANDLE, MCP_CCS811_WAKE, 1);
|
mcp23018_set_pin(MCP23018_DEV_HANDLE, MCP_CCS811_WAKE, 1);
|
||||||
mcp23018_set_pin(MCP23018_DEV_HANDLE, MCP_CCS811_POWER, 0);
|
mcp23018_set_pin(MCP23018_DEV_HANDLE, MCP_CCS811_POWER, 0);
|
||||||
mcp23018_set_pin(MCP23018_DEV_HANDLE, MCP_MICS_POWER, 0);
|
mcp23018_set_pin(MCP23018_DEV_HANDLE, MCP_MICS_POWER, 0);
|
||||||
@@ -97,7 +100,7 @@ void init_connected()
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case CCS811_ADDRESS:
|
case CCS811_ADDRESS:
|
||||||
ret = ccs811_init();
|
ret = ccs811_init();
|
||||||
/* code */
|
/* code */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -136,13 +139,13 @@ void i2c_sensors_task(void *pvParameters)
|
|||||||
memset(foundDevices, 0, sizeof(foundDevices));
|
memset(foundDevices, 0, sizeof(foundDevices));
|
||||||
memset(prevDevices, 0, sizeof(prevDevices));
|
memset(prevDevices, 0, sizeof(prevDevices));
|
||||||
|
|
||||||
// bme680b_init();
|
bme680b_init();
|
||||||
// mpu9250_init();
|
mpu9250_init();
|
||||||
// ccs811_init();
|
ccs811_init();
|
||||||
// ina260_init();
|
ina260_init();
|
||||||
|
|
||||||
update_devices();
|
// update_devices();
|
||||||
init_connected();
|
// init_connected();
|
||||||
// initialize the xLastWakeTime variable with the current time.
|
// initialize the xLastWakeTime variable with the current time.
|
||||||
const int64_t interval_us = 50000; // 50 ms
|
const int64_t interval_us = 50000; // 50 ms
|
||||||
int64_t start_time, end_time, elapsed;
|
int64_t start_time, end_time, elapsed;
|
||||||
@@ -172,86 +175,68 @@ void i2c_sensors_task(void *pvParameters)
|
|||||||
{
|
{
|
||||||
start_time = esp_timer_get_time(); // µs since boot
|
start_time = esp_timer_get_time(); // µs since boot
|
||||||
|
|
||||||
uint8_t presentDevices = 0;
|
uint8_t presentDevices = 0xFF;
|
||||||
update_devices();
|
// update_devices();
|
||||||
init_connected();
|
// init_connected();
|
||||||
|
|
||||||
//
|
//
|
||||||
// handle sensor
|
// handle sensor
|
||||||
|
|
||||||
if (foundDevices[BME680_ADDRESS] == 2)
|
presentDevices |= BME680_PRESENT_BIT;
|
||||||
|
|
||||||
|
if (BME680_DEV_HANDLE)
|
||||||
{
|
{
|
||||||
|
esp_err_t result = bme680_get_data(BME680_DEV_HANDLE, &bmeData);
|
||||||
presentDevices |= BME680_PRESENT_BIT;
|
if (result != ESP_OK)
|
||||||
|
|
||||||
if (BME680_DEV_HANDLE)
|
|
||||||
{
|
{
|
||||||
esp_err_t result = bme680_get_data(BME680_DEV_HANDLE, &bmeData);
|
ESP_LOGE(TAG_BME, "bme680 device read failed (%s)", esp_err_to_name(result));
|
||||||
if (result != ESP_OK)
|
|
||||||
{
|
|
||||||
ESP_LOGE(TAG_BME, "bme680 device read failed (%s)", esp_err_to_name(result));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
bmeData.barometric_pressure = bmeData.barometric_pressure / 100;
|
|
||||||
ESP_LOGI(TAG_BME, "dewpoint temperature:%.2f °C", bmeData.dewpoint_temperature);
|
|
||||||
ESP_LOGI(TAG_BME, "air temperature: %.2f °C", bmeData.air_temperature);
|
|
||||||
ESP_LOGI(TAG_BME, "relative humidity: %.2f %%", bmeData.relative_humidity);
|
|
||||||
ESP_LOGI(TAG_BME, "barometric pressure: %.2f hPa", bmeData.barometric_pressure);
|
|
||||||
ccs811_set_env_data(bmeData.air_temperature, bmeData.relative_humidity);
|
|
||||||
ESP_LOGI(TAG_BME, "gas resistance: %.2f kOhms", bmeData.gas_resistance / 1000);
|
|
||||||
ESP_LOGI(TAG_BME, "iaq score: %u (%s)", bmeData.iaq_score, bme680_air_quality_to_string(bmeData.iaq_score));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
bme680b_init();
|
bmeData.barometric_pressure = bmeData.barometric_pressure / 100;
|
||||||
|
ESP_LOGI(TAG_BME, "dewpoint temperature:%.2f °C", bmeData.dewpoint_temperature);
|
||||||
|
ESP_LOGI(TAG_BME, "air temperature: %.2f °C", bmeData.air_temperature);
|
||||||
|
ESP_LOGI(TAG_BME, "relative humidity: %.2f %%", bmeData.relative_humidity);
|
||||||
|
ESP_LOGI(TAG_BME, "barometric pressure: %.2f hPa", bmeData.barometric_pressure);
|
||||||
|
ccs811_set_env_data(bmeData.air_temperature, bmeData.relative_humidity);
|
||||||
|
ESP_LOGI(TAG_BME, "gas resistance: %.2f kOhms", bmeData.gas_resistance / 1000);
|
||||||
|
ESP_LOGI(TAG_BME, "iaq score: %u (%s)", bmeData.iaq_score, bme680_air_quality_to_string(bmeData.iaq_score));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
if (foundDevices[CCS811_ADDRESS] == 2)
|
|
||||||
{
|
{
|
||||||
presentDevices |= CCS811_PRESENT_BIT;
|
bme680b_init();
|
||||||
ccs811_get_data(&eCO2, &tvoc, ¤tCCS, &rawData);
|
|
||||||
ESP_LOGI(TAG_CCS, "eCO₂: %d ppm, TVOC: %d ppb", eCO2, tvoc);
|
|
||||||
ESP_LOGI(TAG_CCS, "Current: %d μA, Raw voltage: %d V", currentCCS, rawData);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (foundDevices[MPU9250_ADDRESS] == 2)
|
presentDevices |= CCS811_PRESENT_BIT;
|
||||||
|
ccs811_get_data(&eCO2, &tvoc, ¤tCCS, &rawData);
|
||||||
|
ESP_LOGI(TAG_CCS, "eCO₂: %d ppm, TVOC: %d ppb", eCO2, tvoc);
|
||||||
|
ESP_LOGI(TAG_CCS, "Current: %d μA, Raw voltage: %d V", currentCCS, rawData);
|
||||||
|
|
||||||
|
presentDevices |= MPU9250_PRESENT_BIT;
|
||||||
|
if (mpu9250_read_sensor_data(MPU9250_DEV_HANDLE, accel, gyro, &temp, magnet) == ESP_OK)
|
||||||
{
|
{
|
||||||
|
mpu9250_convert_data(accel, gyro, temp, magnet, accel_f, gyro_f, &temp_f, magnet_f);
|
||||||
|
|
||||||
presentDevices |= MPU9250_PRESENT_BIT;
|
ESP_LOGI(TAG_MPU, "Accel: X=%.2f g, Y=%.2f g, Z=%.2f g", accel_f[0], accel_f[1], accel_f[2]);
|
||||||
if (mpu9250_read_sensor_data(MPU9250_DEV_HANDLE, accel, gyro, &temp, magnet) == ESP_OK)
|
ESP_LOGI(TAG_MPU, "Gyro: X=%.2f°/s, Y=%.2f°/s, Z=%.2f°/s", gyro_f[0], gyro_f[1], gyro_f[2]);
|
||||||
{
|
ESP_LOGI(TAG_MPU, "Magnet: X=%.2fμT, Y=%.2fμT, Z=%.2fμT", magnet_f[0], magnet_f[1], magnet_f[2]);
|
||||||
mpu9250_convert_data(accel, gyro, temp, magnet, accel_f, gyro_f, &temp_f, magnet_f);
|
ESP_LOGI(TAG_MPU, "Temperature: %.2f °C", temp_f);
|
||||||
|
}
|
||||||
ESP_LOGI(TAG_MPU, "Accel: X=%.2f g, Y=%.2f g, Z=%.2f g", accel_f[0], accel_f[1], accel_f[2]);
|
else
|
||||||
ESP_LOGI(TAG_MPU, "Gyro: X=%.2f°/s, Y=%.2f°/s, Z=%.2f°/s", gyro_f[0], gyro_f[1], gyro_f[2]);
|
{
|
||||||
ESP_LOGI(TAG_MPU, "Magnet: X=%.2fμT, Y=%.2fμT, Z=%.2fμT", magnet_f[0], magnet_f[1], magnet_f[2]);
|
ESP_LOGE(TAG_MPU, "Failed to read sensor data");
|
||||||
ESP_LOGI(TAG_MPU, "Temperature: %.2f °C", temp_f);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ESP_LOGE(TAG_MPU, "Failed to read sensor data");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (foundDevices[INA260_ADDRESS] == 2)
|
presentDevices |= INA260_PRESENT_BIT;
|
||||||
{
|
ina260_readParams(&volts, ¤t, &power);
|
||||||
|
ina260_printParams(volts, current, power);
|
||||||
|
|
||||||
presentDevices |= INA260_PRESENT_BIT;
|
presentDevices |= MCP23018_PRESENT_BIT;
|
||||||
ina260_readParams(&volts, ¤t, &power);
|
float VREFVoltage = 2.5;
|
||||||
ina260_printParams(volts, current, power);
|
ADCData = mcp3550_read_all(VREFVoltage);
|
||||||
}
|
|
||||||
|
|
||||||
if (foundDevices[MCP23018_ADDRESS] == 2)
|
log_mics_adc_values(&ADCData);
|
||||||
{
|
|
||||||
presentDevices |= MCP23018_PRESENT_BIT;
|
|
||||||
float VREFVoltage = 2.5;
|
|
||||||
ADCData = mcp3550_read_all(VREFVoltage);
|
|
||||||
|
|
||||||
log_mics_adc_values(&ADCData);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (packetReadiness == 0)
|
if (packetReadiness == 0)
|
||||||
{
|
{
|
||||||
|
@@ -49,7 +49,7 @@ void gps_task(void *arg)
|
|||||||
line[line_pos] = '\0';
|
line[line_pos] = '\0';
|
||||||
|
|
||||||
if (line[0] == '$') {
|
if (line[0] == '$') {
|
||||||
ESP_LOGV(TAG, "Received NMEA: %s", line);
|
ESP_LOGI(TAG, "Received NMEA: %s", line);
|
||||||
|
|
||||||
if (strstr(line, "$GPGGA") == line) {
|
if (strstr(line, "$GPGGA") == line) {
|
||||||
parse_gpgga(line);
|
parse_gpgga(line);
|
||||||
@@ -72,8 +72,7 @@ void gps_task(void *arg)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void parse_gpgga(const char *nmea)
|
void parse_gpgga(const char *nmea) {
|
||||||
{
|
|
||||||
char *fields[15];
|
char *fields[15];
|
||||||
char temp[GPS_LINE_MAX_LEN];
|
char temp[GPS_LINE_MAX_LEN];
|
||||||
strncpy(temp, nmea, GPS_LINE_MAX_LEN);
|
strncpy(temp, nmea, GPS_LINE_MAX_LEN);
|
||||||
@@ -108,12 +107,11 @@ void parse_gpgga(const char *nmea)
|
|||||||
// Altitude
|
// Altitude
|
||||||
const char *altitude = fields[9];
|
const char *altitude = fields[9];
|
||||||
|
|
||||||
ESP_LOGI(TAG, "[GPGGA] Time: %s, Lat: %s %s, Lon: %s %s, Fix: %s, Sats: %s, Alt: %sm",
|
printf("[GPGGA] Time: %s, Lat: %s %s, Lon: %s %s, Fix: %s, Sats: %s, Alt: %sm\n",
|
||||||
utc_time, lat, lat_dir, lon, lon_dir, fix_quality, num_satellites, altitude);
|
utc_time, lat, lat_dir, lon, lon_dir, fix_quality, num_satellites, altitude);
|
||||||
}
|
}
|
||||||
|
|
||||||
void parse_gprmc(const char *nmea)
|
void parse_gprmc(const char *nmea) {
|
||||||
{
|
|
||||||
char *fields[13];
|
char *fields[13];
|
||||||
char temp[GPS_LINE_MAX_LEN];
|
char temp[GPS_LINE_MAX_LEN];
|
||||||
strncpy(temp, nmea, GPS_LINE_MAX_LEN);
|
strncpy(temp, nmea, GPS_LINE_MAX_LEN);
|
||||||
@@ -137,8 +135,8 @@ void parse_gprmc(const char *nmea)
|
|||||||
const char *speed_knots = fields[7];
|
const char *speed_knots = fields[7];
|
||||||
const char *date = fields[9];
|
const char *date = fields[9];
|
||||||
|
|
||||||
ESP_LOGI(TAG, "[GPRMC] Date: %s, Time: %s, Lat: %s %s, Lon: %s %s, Speed: %s knots, Status: %s",
|
printf("[GPRMC] Date: %s, Time: %s, Lat: %s %s, Lon: %s %s, Speed: %s knots, Status: %s\n",
|
||||||
date, utc_time, lat, lat_dir, lon, lon_dir, speed_knots, status);
|
date, utc_time, lat, lat_dir, lon, lon_dir, speed_knots, status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -154,29 +152,34 @@ static uint32_t time_to_seconds_struct(const char *time_str) {
|
|||||||
// Function to convert DMS (degrees minutes.decimalminutes) to centi-degrees
|
// Function to convert DMS (degrees minutes.decimalminutes) to centi-degrees
|
||||||
static int32_t dms_to_centi_degrees_struct(const char *dms_str, const char *direction) {
|
static int32_t dms_to_centi_degrees_struct(const char *dms_str, const char *direction) {
|
||||||
if (dms_str == NULL || direction == NULL || strlen(dms_str) < 7) return 0;
|
if (dms_str == NULL || direction == NULL || strlen(dms_str) < 7) return 0;
|
||||||
char degrees_str[4] = {0};
|
char data_str[20] = {0};
|
||||||
char minutes_decimal_str[10] = {0};
|
char *dataStr = data_str;
|
||||||
strncpy(degrees_str, dms_str, 2);
|
for (int i = 0; i < 20; i++) {
|
||||||
strncpy(minutes_decimal_str, dms_str + 2, strlen(dms_str) - 2);
|
if (dms_str[i] == 0) {
|
||||||
double degrees = atof(degrees_str);
|
break;
|
||||||
double minutes = atof(minutes_decimal_str);
|
}
|
||||||
double decimal_degrees = degrees + (minutes / 60.0);
|
if (dms_str[i] == '.') {
|
||||||
if (direction[0] == 'S' || direction[0] == 'W') {
|
continue;
|
||||||
decimal_degrees *= -1.0;
|
}
|
||||||
|
*(dataStr++) = dms_str[i];
|
||||||
}
|
}
|
||||||
return (int32_t)(decimal_degrees * 10000);
|
int32_t degrees = atoi(data_str);
|
||||||
|
if (direction[0] == 'S' || direction[0] == 'W') {
|
||||||
|
degrees *= -1;
|
||||||
|
}
|
||||||
|
return degrees;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Function to convert altitude string to centi-meters
|
// Function to convert altitude string to centi-meters
|
||||||
static int16_t altitude_to_centi_meters_struct(const char *alt_str) {
|
static int16_t altitude_to_centi_meters_struct(const char *alt_str) {
|
||||||
if (alt_str == NULL) return 0;
|
if (alt_str == NULL) return 0;
|
||||||
return (int16_t)(atof(alt_str) * 100);
|
return (int16_t) (atof(alt_str) * 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Function to convert speed from knots to centi-knots
|
// Function to convert speed from knots to centi-knots
|
||||||
static uint16_t speed_to_centi_knots_struct(const char *speed_str) {
|
static uint16_t speed_to_centi_knots_struct(const char *speed_str) {
|
||||||
if (speed_str == NULL) return 0;
|
if (speed_str == NULL) return 0;
|
||||||
return (uint16_t)(atof(speed_str) * 100);
|
return (uint16_t) (atof(speed_str) * 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Function to convert date string (ddmmyy) to yymmdd integer
|
// Function to convert date string (ddmmyy) to yymmdd integer
|
||||||
@@ -190,8 +193,7 @@ static uint16_t date_to_yyddmm_struct(const char *date_str) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Function to parse GPGGA NMEA string and return the struct
|
// Function to parse GPGGA NMEA string and return the struct
|
||||||
void parse_gpgga_to_struct(const char *nmea, gps_binary_struct_t *data)
|
void parse_gpgga_to_struct(const char *nmea, gps_binary_struct_t *data) {
|
||||||
{
|
|
||||||
char *fields[15];
|
char *fields[15];
|
||||||
char temp[GPS_LINE_MAX_LEN];
|
char temp[GPS_LINE_MAX_LEN];
|
||||||
strncpy(temp, nmea, GPS_LINE_MAX_LEN);
|
strncpy(temp, nmea, GPS_LINE_MAX_LEN);
|
||||||
@@ -212,13 +214,12 @@ void parse_gpgga_to_struct(const char *nmea, gps_binary_struct_t *data)
|
|||||||
data->num_satellites = atoi(fields[7]);
|
data->num_satellites = atoi(fields[7]);
|
||||||
data->altitude_centi_meters = altitude_to_centi_meters_struct(fields[9]);
|
data->altitude_centi_meters = altitude_to_centi_meters_struct(fields[9]);
|
||||||
} else {
|
} else {
|
||||||
ESP_LOGW(TAG, "GPGGA: Not enough fields to parse struct");
|
printf("GPGGA: Not enough fields to parse struct");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Function to parse GPRMC NMEA string and return the struct
|
// Function to parse GPRMC NMEA string and return the struct
|
||||||
void parse_gprmc_to_struct(const char *nmea, gps_binary_struct_t *data)
|
void parse_gprmc_to_struct(const char *nmea, gps_binary_struct_t *data) {
|
||||||
{
|
|
||||||
char *fields[13];
|
char *fields[13];
|
||||||
char temp[GPS_LINE_MAX_LEN];
|
char temp[GPS_LINE_MAX_LEN];
|
||||||
strncpy(temp, nmea, GPS_LINE_MAX_LEN);
|
strncpy(temp, nmea, GPS_LINE_MAX_LEN);
|
||||||
@@ -239,6 +240,6 @@ void parse_gprmc_to_struct(const char *nmea, gps_binary_struct_t *data)
|
|||||||
data->speed_centi_knots = speed_to_centi_knots_struct(fields[7]);
|
data->speed_centi_knots = speed_to_centi_knots_struct(fields[7]);
|
||||||
// Fix quality and num_satellites are typically in GPGGA, so they might be 0 here.
|
// Fix quality and num_satellites are typically in GPGGA, so they might be 0 here.
|
||||||
} else {
|
} else {
|
||||||
ESP_LOGW(TAG, "GPRMC: Not enough fields to parse struct");
|
printf("GPRMC: Not enough fields to parse struct");
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -62,6 +62,8 @@ void app_main(void)
|
|||||||
/* scan i2c devices on i2c master bus 0 and print results */
|
/* scan i2c devices on i2c master bus 0 and print results */
|
||||||
ESP_ERROR_CHECK(i2c_master_bus_detect_devices(i2c0_bus_hdl));
|
ESP_ERROR_CHECK(i2c_master_bus_detect_devices(i2c0_bus_hdl));
|
||||||
|
|
||||||
|
mcp23018_init();
|
||||||
|
|
||||||
void servoControllerInit();
|
void servoControllerInit();
|
||||||
|
|
||||||
ESP_LOGI(TAG, "BEGIN ESP TASKS");
|
ESP_LOGI(TAG, "BEGIN ESP TASKS");
|
||||||
|
Reference in New Issue
Block a user