test
This commit is contained in:
@@ -91,6 +91,8 @@ typedef struct __attribute__((packed))
|
||||
int16_t currentServoB; //148
|
||||
int16_t targetServoB; //150
|
||||
|
||||
uint8_t presentDevices;
|
||||
|
||||
uint8_t telemetryIndex; //151
|
||||
|
||||
} TelemetryPacket;
|
||||
|
@@ -6,11 +6,13 @@
|
||||
#include "string.h"
|
||||
#include "esp_timer.h"
|
||||
#include "esp_rom_crc.h"
|
||||
#include <hw/buscfg.h>
|
||||
#include "sensors.h"
|
||||
|
||||
#define TAG "LoRa"
|
||||
|
||||
#define ACK_TIMEOUT_MS 500 // Wait 300ms for ACK
|
||||
#define MAX_RETRIES 3
|
||||
#define ACK_TIMEOUT_MS 250 // Wait 300ms for ACK
|
||||
#define MAX_RETRIES 1
|
||||
|
||||
uint32_t packetIndexTX = 0;
|
||||
uint32_t packetIndexRX = 0;
|
||||
@@ -44,10 +46,10 @@ void setup_lora(void)
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t spreadingFactor = 7;
|
||||
uint8_t spreadingFactor = 8;
|
||||
uint8_t bandwidth = SX126X_LORA_BW_250_0;
|
||||
uint8_t codingRate = SX126X_LORA_CR_4_8;
|
||||
uint16_t preambleLength = 8;
|
||||
uint16_t preambleLength = 4;
|
||||
bool crcOn = true;
|
||||
bool invertIrq = false;
|
||||
|
||||
@@ -65,6 +67,23 @@ static void prepare_downbound_packet(DownBoundPacket *packet, uint8_t type, uint
|
||||
strcpy(packet->syncPhrase, "PlechDole");
|
||||
}
|
||||
|
||||
static void send_packet_without_retries(uint8_t *data, uint16_t size)
|
||||
{
|
||||
if (xSemaphoreTake(loraRadioMutex, portMAX_DELAY) == pdTRUE)
|
||||
{
|
||||
if (!LoRaSend(data, size, SX126x_TXMODE_SYNC))
|
||||
{
|
||||
ESP_LOGW(TAG, "LoRaSend failed");
|
||||
xSemaphoreGive(loraRadioMutex);
|
||||
}
|
||||
else
|
||||
{
|
||||
ESP_LOGI(TAG, "%d byte packet sent", size);
|
||||
xSemaphoreGive(loraRadioMutex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void send_packet_with_retries(uint8_t *data, uint16_t size)
|
||||
{
|
||||
for (int retry = 0; retry <= MAX_RETRIES; retry++)
|
||||
@@ -116,7 +135,7 @@ void prepare_and_send_telemetry(uint64_t missionTimer)
|
||||
memcpy(bufOut + offset, &telemetryPacket, sizeof(telemetryPacket));
|
||||
offset += sizeof(telemetryPacket);
|
||||
|
||||
send_packet_with_retries(bufOut, offset);
|
||||
send_packet_without_retries(bufOut, offset);
|
||||
packetReadiness = 0;
|
||||
}
|
||||
|
||||
@@ -208,6 +227,7 @@ void process_uplink_packet(uint8_t *data, uint8_t len, uint64_t missionTimer)
|
||||
{
|
||||
SystemControlPacket sysCtrl;
|
||||
memcpy(&sysCtrl, data + sizeof(UplinkPacket), sizeof(SystemControlPacket));
|
||||
setPowerMode(sysCtrl.powerMode);
|
||||
// TODO: Process sysCtrl
|
||||
}
|
||||
else
|
||||
@@ -265,13 +285,18 @@ void lora_receive_task(void *pvParameters)
|
||||
void lora_comms_task(void *pvParameters)
|
||||
{
|
||||
|
||||
|
||||
|
||||
ESP_LOGI(TAG, "lora_comms_task started");
|
||||
|
||||
while (foundDevices[0] != 2) {
|
||||
vTaskDelay(10);
|
||||
}
|
||||
|
||||
// Initialize the semaphore for radio access (binary semaphore, 1 = available)
|
||||
loraRadioMutex = xSemaphoreCreateMutex();
|
||||
xSemaphoreGive(loraRadioMutex); // Set semaphore as available
|
||||
|
||||
const int64_t interval_us = 400000; // 400 ms
|
||||
|
||||
setup_lora();
|
||||
xTaskCreate(
|
||||
lora_receive_task,
|
||||
@@ -291,6 +316,8 @@ void lora_comms_task(void *pvParameters)
|
||||
prepare_and_send_telemetry(start_time);
|
||||
}
|
||||
|
||||
const int64_t interval_us = ((powerMode == HIGH_POWER_MODE) ? 10000 : 10000000); // 10 ms or 10 000 ms
|
||||
|
||||
int64_t end_time = esp_timer_get_time();
|
||||
int64_t elapsed = end_time - start_time;
|
||||
|
||||
@@ -299,50 +326,4 @@ void lora_comms_task(void *pvParameters)
|
||||
vTaskDelay(pdMS_TO_TICKS((interval_us - elapsed) / 1000));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// void lora_comms_task(void *pvParameters)
|
||||
// {
|
||||
// const int64_t interval_us = 400000; // 100 ms
|
||||
// int64_t start_time, end_time, elapsed;
|
||||
|
||||
// setup_lora();
|
||||
|
||||
// uint8_t bufIn[256];
|
||||
|
||||
// while (1)
|
||||
// {
|
||||
// start_time = esp_timer_get_time();
|
||||
|
||||
// if (packetReadiness)
|
||||
// {
|
||||
// ESP_LOGI(TAG, "Preparing telemetry");
|
||||
// prepare_and_send_telemetry(start_time);
|
||||
// }
|
||||
|
||||
// uint8_t rxLen = LoRaReceive(bufIn, sizeof(bufIn));
|
||||
// if (rxLen > 0)
|
||||
// {
|
||||
// ESP_LOGI(TAG, "%d byte packet received", rxLen);
|
||||
// process_uplink_packet(bufIn, rxLen, start_time);
|
||||
|
||||
// int8_t rssi, snr;
|
||||
// GetPacketStatus(&rssi, &snr);
|
||||
// ESP_LOGI(TAG, "rssi=%d[dBm], snr=%d[dB]", rssi, snr);
|
||||
// }
|
||||
|
||||
// int lost = GetPacketLost();
|
||||
// if (lost != 0)
|
||||
// {
|
||||
// ESP_LOGW(TAG, "%d packets lost", lost);
|
||||
// }
|
||||
|
||||
// end_time = esp_timer_get_time();
|
||||
// elapsed = end_time - start_time;
|
||||
|
||||
// if (elapsed < interval_us)
|
||||
// {
|
||||
// vTaskDelay(pdMS_TO_TICKS((interval_us - elapsed) / 1000));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
@@ -6,12 +6,18 @@
|
||||
|
||||
#define BLINK_GPIO 2
|
||||
|
||||
//uint8_t powerMode = LOW_POWER_MODE;
|
||||
uint8_t powerMode = HIGH_POWER_MODE;
|
||||
|
||||
static uint8_t s_led_state = 0;
|
||||
|
||||
uint8_t telemetryIndex = 1;
|
||||
|
||||
uint8_t foundDevices[128];
|
||||
uint8_t prevDevices[128];
|
||||
const uint8_t expectedAdressesCount = 5;
|
||||
const uint8_t expectedAdresses[] = {MCP23018_ADDRESS, BME680_ADDRESS, CCS811_ADDRESS, MPU9250_ADDRESS, INA260_ADDRESS};
|
||||
|
||||
uint8_t foundDevices[5];
|
||||
uint8_t prevDevices[5];
|
||||
|
||||
static void configure_led(void)
|
||||
{
|
||||
@@ -19,93 +25,131 @@ static void configure_led(void)
|
||||
gpio_set_direction(BLINK_GPIO, GPIO_MODE_OUTPUT);
|
||||
}
|
||||
|
||||
// void update_devices() {
|
||||
// memcpy(prevDevices, foundDevices, sizeof(prevDevices));
|
||||
// memset(foundDevices, 0, sizeof(foundDevices));
|
||||
// for (uint8_t i = 0; i < 128; i++)
|
||||
// {
|
||||
// fflush(stdout);
|
||||
|
||||
// esp_err_t ret = i2c_master_probe(i2c0_bus_hdl, i, 20);
|
||||
|
||||
// if (ret == ESP_OK)
|
||||
// {
|
||||
// foundDevices[i] = 1;
|
||||
// printf("Found device at 0x%02X\n", i);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
void update_devices()
|
||||
{
|
||||
memcpy(prevDevices, foundDevices, sizeof(prevDevices));
|
||||
for (uint8_t i = 0; i < expectedAdressesCount; i++)
|
||||
{
|
||||
fflush(stdout);
|
||||
|
||||
// void init_connected() {
|
||||
// for (uint8_t i = 0; i < 128; i++) {
|
||||
// if (foundDevices[i] != prevDevices[i]) {
|
||||
// if (foundDevices[i]) {
|
||||
// switch (i)
|
||||
// {
|
||||
// case MCP23018_ADDRESS:
|
||||
// /* code */
|
||||
// if (mcp23018_init() == ESP_OK) {
|
||||
// foundDevices[i] = 2;
|
||||
// }
|
||||
// break;
|
||||
esp_err_t ret = i2c_master_probe(i2c0_bus_hdl, expectedAdresses[i], 20);
|
||||
|
||||
// case INA260_ADDRESS:
|
||||
// if (ina260_init() == ESP_OK) {
|
||||
// foundDevices[i] = 2;
|
||||
// }
|
||||
// /* code */
|
||||
// break;
|
||||
if (ret == ESP_OK)
|
||||
{
|
||||
if (foundDevices[i] == 0)
|
||||
{
|
||||
foundDevices[i] = 1;
|
||||
}
|
||||
// printf("Found device at 0x%02X\n", i);
|
||||
}
|
||||
else
|
||||
{
|
||||
foundDevices[i] = 0;
|
||||
if (i == 1 && powerMode != HIGH_POWER_MODE)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
printf("Not found device at 0x%02X\n", expectedAdresses[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// case CCS811_ADDRESS:
|
||||
// if (ccs811_init() == ESP_OK) {
|
||||
// foundDevices[i] = 2;
|
||||
// }
|
||||
// /* code */
|
||||
// break;
|
||||
void setPowerMode(uint8_t powerModeIn)
|
||||
{
|
||||
powerMode = powerModeIn;
|
||||
if (foundDevices[0] == 2)
|
||||
{
|
||||
if (powerMode == HIGH_POWER_MODE) {
|
||||
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_MICS_POWER, 1);
|
||||
} else {
|
||||
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_MICS_POWER, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// case MPU9250_ADDRESS:
|
||||
// if (mpu9250_init() == ESP_OK) {
|
||||
// foundDevices[i] = 2;
|
||||
// }
|
||||
// /* code */
|
||||
// break;
|
||||
void init_connected()
|
||||
{
|
||||
|
||||
// case BME680_ADDRESS:
|
||||
// if (bme680b_init() == ESP_OK) {
|
||||
// foundDevices[i] = 2;
|
||||
// }
|
||||
// /* code */
|
||||
// break;
|
||||
|
||||
// default:
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
for (uint8_t i = 0; i < expectedAdressesCount; i++)
|
||||
{
|
||||
if (foundDevices[i] != prevDevices[i])
|
||||
{
|
||||
if (foundDevices[i])
|
||||
{
|
||||
esp_err_t ret = ESP_FAIL;
|
||||
bool foundUsed = true;
|
||||
switch (i)
|
||||
{
|
||||
case MCP23018_ADDRESS:
|
||||
/* code */
|
||||
ret = mcp23018_init();
|
||||
setPowerMode(powerMode);
|
||||
mcp3550_spi_init();
|
||||
break;
|
||||
|
||||
case INA260_ADDRESS:
|
||||
ret = ina260_init();
|
||||
/* code */
|
||||
break;
|
||||
|
||||
case CCS811_ADDRESS:
|
||||
ret = ccs811_init();
|
||||
/* code */
|
||||
break;
|
||||
|
||||
case MPU9250_ADDRESS:
|
||||
ret = mpu9250_init();
|
||||
/* code */
|
||||
break;
|
||||
|
||||
case BME680_ADDRESS:
|
||||
ret = bme680b_init();
|
||||
/* code */
|
||||
break;
|
||||
|
||||
default:
|
||||
foundUsed = false;
|
||||
break;
|
||||
}
|
||||
if (foundUsed)
|
||||
{
|
||||
if (ret == ESP_OK)
|
||||
{
|
||||
foundDevices[i] = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Device init error at 0x%02X - %s\n", expectedAdresses[i], esp_err_to_name(ret));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void i2c_sensors_task(void *pvParameters)
|
||||
{
|
||||
memset(foundDevices, 0, sizeof(foundDevices));
|
||||
memset(prevDevices, 0, sizeof(prevDevices));
|
||||
|
||||
bme680b_init();
|
||||
mpu9250_init();
|
||||
ccs811_init();
|
||||
ina260_init();
|
||||
|
||||
// bme680b_init();
|
||||
// mpu9250_init();
|
||||
// ccs811_init();
|
||||
// ina260_init();
|
||||
|
||||
// update_devices();
|
||||
// init_connected();
|
||||
update_devices();
|
||||
init_connected();
|
||||
// initialize the xLastWakeTime variable with the current time.
|
||||
const int64_t interval_us = 100000; // 100 ms
|
||||
const int64_t interval_us = 50000; // 50 ms
|
||||
int64_t start_time, end_time, elapsed;
|
||||
|
||||
//
|
||||
// initialize i2c device configuration
|
||||
|
||||
mcp3550_spi_init();
|
||||
configure_led();
|
||||
|
||||
int16_t accel[3], gyro[3], temp, magnet[3];
|
||||
@@ -121,82 +165,96 @@ void i2c_sensors_task(void *pvParameters)
|
||||
uint16_t power;
|
||||
|
||||
bme680_data_t bmeData;
|
||||
|
||||
mics_adc_data_t ADCData;
|
||||
// task loop entry point
|
||||
for (;;)
|
||||
{
|
||||
start_time = esp_timer_get_time(); // µs since boot
|
||||
|
||||
uint8_t presentDevices = 0;
|
||||
update_devices();
|
||||
init_connected();
|
||||
|
||||
//
|
||||
// handle sensor
|
||||
|
||||
if (BME680_DEV_HANDLE)
|
||||
if (foundDevices[BME680_ADDRESS] == 2)
|
||||
{
|
||||
esp_err_t result = bme680_get_data(BME680_DEV_HANDLE, &bmeData);
|
||||
if (result != ESP_OK)
|
||||
|
||||
presentDevices |= BME680_PRESENT_BIT;
|
||||
|
||||
if (BME680_DEV_HANDLE)
|
||||
{
|
||||
ESP_LOGE(TAG_BME, "bme680 device read failed (%s)", esp_err_to_name(result));
|
||||
esp_err_t result = bme680_get_data(BME680_DEV_HANDLE, &bmeData);
|
||||
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
|
||||
{
|
||||
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));
|
||||
bme680b_init();
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
if (foundDevices[CCS811_ADDRESS] == 2)
|
||||
{
|
||||
bme680b_init();
|
||||
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);
|
||||
}
|
||||
|
||||
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 (mpu9250_read_sensor_data(MPU9250_DEV_HANDLE, accel, gyro, &temp, magnet) == ESP_OK)
|
||||
if (foundDevices[MPU9250_ADDRESS] == 2)
|
||||
{
|
||||
mpu9250_convert_data(accel, gyro, temp, magnet, accel_f, gyro_f, &temp_f, magnet_f);
|
||||
|
||||
ESP_LOGI(TAG_MPU, "Accel: X=%.2f g, Y=%.2f g, Z=%.2f g", accel_f[0], accel_f[1], accel_f[2]);
|
||||
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_LOGI(TAG_MPU, "Temperature: %.2f °C", temp_f);
|
||||
}
|
||||
else
|
||||
{
|
||||
ESP_LOGE(TAG_MPU, "Failed to read sensor data");
|
||||
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);
|
||||
|
||||
ESP_LOGI(TAG_MPU, "Accel: X=%.2f g, Y=%.2f g, Z=%.2f g", accel_f[0], accel_f[1], accel_f[2]);
|
||||
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_LOGI(TAG_MPU, "Temperature: %.2f °C", temp_f);
|
||||
}
|
||||
else
|
||||
{
|
||||
ESP_LOGE(TAG_MPU, "Failed to read sensor data");
|
||||
}
|
||||
}
|
||||
|
||||
ina260_readParams(&volts, ¤t, &power);
|
||||
ina260_printParams(volts, current, power);
|
||||
|
||||
float VREFVoltage = 2.5;
|
||||
|
||||
// mics_adc_data_t ADCData;
|
||||
// memset(&ADCData, 0, sizeof(ADCData));
|
||||
mics_adc_data_t ADCData = mcp3550_read_all(VREFVoltage);
|
||||
|
||||
log_mics_adc_values(&ADCData);
|
||||
|
||||
//int32_t nh3val = mcp3550_read(MCP_CS_ADC_NH3);
|
||||
|
||||
//ESP_LOGI(TAG_BME, "MICS NH3: %ld -> %fV", nh3val, mcp3550_to_voltage(nh3val, VREFVoltage));
|
||||
|
||||
//gpio_set_level(BLINK_GPIO, s_led_state);
|
||||
mcp23018_set_pin(MCP23018_DEV_HANDLE, MCP_CS_ADC_UVC, s_led_state);
|
||||
/* Toggle the LED state */
|
||||
s_led_state = !s_led_state;
|
||||
end_time = esp_timer_get_time();
|
||||
elapsed = end_time - start_time;
|
||||
|
||||
if (elapsed < interval_us)
|
||||
if (foundDevices[INA260_ADDRESS] == 2)
|
||||
{
|
||||
vTaskDelay(pdMS_TO_TICKS((interval_us - elapsed) / 1000));
|
||||
|
||||
presentDevices |= INA260_PRESENT_BIT;
|
||||
ina260_readParams(&volts, ¤t, &power);
|
||||
ina260_printParams(volts, current, power);
|
||||
}
|
||||
if (packetReadiness == 0) {
|
||||
|
||||
if (foundDevices[MCP23018_ADDRESS] == 2)
|
||||
{
|
||||
presentDevices |= MCP23018_PRESENT_BIT;
|
||||
float VREFVoltage = 2.5;
|
||||
ADCData = mcp3550_read_all(VREFVoltage);
|
||||
|
||||
log_mics_adc_values(&ADCData);
|
||||
}
|
||||
|
||||
if (packetReadiness == 0)
|
||||
{
|
||||
memset(&telemetryPacket, 0, sizeof(telemetryPacket));
|
||||
telemetryPacket.accelerationX = accel[0];
|
||||
telemetryPacket.accelerationY = accel[1];
|
||||
@@ -221,7 +279,6 @@ void i2c_sensors_task(void *pvParameters)
|
||||
telemetryPacket.current = current;
|
||||
telemetryPacket.power = power;
|
||||
|
||||
|
||||
telemetryPacket.temperature = bmeData.raw_data.temperature;
|
||||
telemetryPacket.humidity = bmeData.raw_data.humidity;
|
||||
telemetryPacket.pressure = bmeData.raw_data.pressure;
|
||||
@@ -244,7 +301,7 @@ void i2c_sensors_task(void *pvParameters)
|
||||
telemetryPacket.NO2 = ADCData.raw_no2;
|
||||
telemetryPacket.UVC = ADCData.raw_uvc;
|
||||
|
||||
//TODO MOVE THIS TO A BETTER PLACE FOR SYNC
|
||||
// TODO MOVE THIS TO A BETTER PLACE FOR SYNC
|
||||
telemetryPacket.time_seconds = gpsDataOut.time_seconds;
|
||||
telemetryPacket.latitude_centi_degrees = gpsDataOut.latitude_centi_degrees;
|
||||
telemetryPacket.longitude_centi_degrees = gpsDataOut.longitude_centi_degrees;
|
||||
@@ -263,11 +320,20 @@ void i2c_sensors_task(void *pvParameters)
|
||||
telemetryPacket.currentServoA = servoState.currentServoA;
|
||||
telemetryPacket.currentServoB = servoState.currentServoB;
|
||||
|
||||
telemetryPacket.presentDevices = presentDevices;
|
||||
|
||||
telemetryPacket.telemetryIndex = telemetryIndex++;
|
||||
|
||||
|
||||
}
|
||||
packetReadiness = 1;
|
||||
|
||||
s_led_state = !s_led_state;
|
||||
end_time = esp_timer_get_time();
|
||||
elapsed = end_time - start_time;
|
||||
|
||||
if (elapsed < interval_us)
|
||||
{
|
||||
vTaskDelay(pdMS_TO_TICKS((interval_us - elapsed) / 1000));
|
||||
}
|
||||
}
|
||||
//
|
||||
// free resources
|
||||
|
@@ -18,9 +18,17 @@
|
||||
#include "../hw/mpu9250.h"
|
||||
#include "esp_log.h"
|
||||
|
||||
#define LOW_POWER_MODE 0
|
||||
#define HIGH_POWER_MODE 1
|
||||
extern uint8_t powerMode;
|
||||
|
||||
extern uint8_t foundDevices[128];
|
||||
extern uint8_t prevDevices[128];
|
||||
|
||||
extern uint8_t foundDevices[5];
|
||||
extern uint8_t prevDevices[5];
|
||||
|
||||
void init_connected();
|
||||
void update_devices();
|
||||
void setPowerMode(uint8_t powerModeIn);
|
||||
|
||||
void i2c_sensors_task(void *pvParameters);
|
||||
|
||||
|
Reference in New Issue
Block a user