add sensor types to components, (1)
This commit is contained in:
parent
aa557e2a56
commit
f83d534542
19 changed files with 192 additions and 66 deletions
|
|
@ -345,10 +345,25 @@ static const std::map<std::string, FnCreateI2CDriver> I2cFactory = {
|
|||
}}}; ///< I2C driver factory
|
||||
|
||||
static const std::map<const char *, std::vector<uint16_t>>
|
||||
map_address_to_driver = {
|
||||
{"aht20", {0x38}}, {"bme280", {0x76, 0x77}}, {"bme680", {0x76, 0x77}}};
|
||||
map_address_to_driver = {{"aht20", {0x38}},
|
||||
{"bme280", {0x76, 0x77}},
|
||||
{"bme680", {0x76, 0x77}},
|
||||
{"sht3x", {0x44, 0x45}},
|
||||
{"adt7410", {0x48, 0x49, 0x4A, 0x4B}},
|
||||
{"sht3x", {0x44, 0x45}},
|
||||
{"bh1750", {0x23, 0x5c}},
|
||||
{"bmp280", {0x76, 0x77}},
|
||||
{"bmp388", {0x76, 0x77}},
|
||||
{"bmp390", {0x76, 0x77}},
|
||||
{"dps310", {0x76, 0x77}},
|
||||
{"ds2484", {0x18}},
|
||||
{"ens160", {0x52, 0x53}},
|
||||
{"hts2221", {0x5F}},
|
||||
{"htu21d", {0x40}},
|
||||
{"ina219", {0x40, 0x41, 0x44, 0x45}},
|
||||
};
|
||||
|
||||
std::vector<const char *> getDriversForAddress(uint16_t addr) {
|
||||
std::vector<const char *> GetDriversForAddress(uint16_t addr) {
|
||||
std::vector<const char *> result;
|
||||
|
||||
for (const auto &[driver, addresses] : map_address_to_driver) {
|
||||
|
|
@ -631,7 +646,7 @@ bool I2cController::Handle_I2cDeviceAddOrReplace(pb_istream_t *stream) {
|
|||
WS_DEBUG_PRINT("Getting drivers for address: ");
|
||||
WS_DEBUG_PRINTLN(device_descriptor.i2c_device_address);
|
||||
std::vector<const char *> candidate_drivers =
|
||||
getDriversForAddress(device_descriptor.i2c_device_address);
|
||||
GetDriversForAddress(device_descriptor.i2c_device_address);
|
||||
|
||||
// Probe each candidate to see if it communicates
|
||||
for (const char *driverName : candidate_drivers) {
|
||||
|
|
@ -653,7 +668,8 @@ bool I2cController::Handle_I2cDeviceAddOrReplace(pb_istream_t *stream) {
|
|||
drv->SetSensorTypes(true);
|
||||
drv->SetPeriod(0);
|
||||
// TODO: Add driver information to FS
|
||||
// WsV2._fileSystemV2->AddI2cDeviceToFileConfig(device_descriptor.i2c_device_address, driverName);
|
||||
// WsV2._fileSystemV2->AddI2cDeviceToFileConfig(device_descriptor.i2c_device_address,
|
||||
// driverName);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -760,6 +776,10 @@ uint32_t I2cController::GetScanDeviceAddress(int index) {
|
|||
return _scan_results.i2c_bus_found_devices[index].i2c_device_address;
|
||||
}
|
||||
|
||||
size_t I2cController::GetScanDeviceCount() {
|
||||
return _scan_results.i2c_bus_found_devices_count;
|
||||
}
|
||||
|
||||
void I2cController::PrintScanResults() {
|
||||
WS_DEBUG_PRINT("[i2c] # of Scanned Devices: ");
|
||||
WS_DEBUG_PRINTLN(_scan_results.i2c_bus_found_devices_count);
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ public:
|
|||
bool IsDeviceScanned(uint32_t address);
|
||||
void PrintScanResults();
|
||||
uint32_t GetScanDeviceAddress(int index);
|
||||
|
||||
size_t GetScanDeviceCount();
|
||||
private:
|
||||
I2cModel *_i2c_model; ///< Pointer to an I2C model object
|
||||
I2cHardware *_i2c_bus_default; ///< Pointer to the default I2C bus
|
||||
|
|
|
|||
|
|
@ -79,6 +79,14 @@ public:
|
|||
return true;
|
||||
}
|
||||
|
||||
void ConfigureDefaultSensorTypes() override {
|
||||
_default_sensor_types_count = 2;
|
||||
_default_sensor_types[0] =
|
||||
wippersnapper_sensor_SensorType_SENSOR_TYPE_AMBIENT_TEMPERATURE;
|
||||
_default_sensor_types[1] =
|
||||
wippersnapper_sensor_SensorType_SENSOR_TYPE_AMBIENT_TEMPERATURE_FAHRENHEIT;
|
||||
}
|
||||
|
||||
protected:
|
||||
Adafruit_ADT7410 *_ADT7410; ///< Pointer to ADT7410 temperature sensor object
|
||||
};
|
||||
|
|
|
|||
|
|
@ -106,18 +106,22 @@ public:
|
|||
return true;
|
||||
}
|
||||
|
||||
void ConfigureDefaultSensorTypes() override {
|
||||
_default_sensor_types_count = 3;
|
||||
_default_sensor_types[0] =
|
||||
wippersnapper_sensor_SensorType_SENSOR_TYPE_AMBIENT_TEMPERATURE;
|
||||
_default_sensor_types[1] =
|
||||
wippersnapper_sensor_SensorType_SENSOR_TYPE_AMBIENT_TEMPERATURE_FAHRENHEIT;
|
||||
_default_sensor_types[2] =
|
||||
wippersnapper_sensor_SensorType_SENSOR_TYPE_RELATIVE_HUMIDITY;
|
||||
}
|
||||
|
||||
protected:
|
||||
Adafruit_AHTX0 *_aht; ///< Pointer to an AHTX0 object
|
||||
Adafruit_Sensor *_aht_temp =
|
||||
NULL; ///< Holds data for the AHTX0's temperature sensor
|
||||
Adafruit_Sensor *_aht_humidity =
|
||||
NULL; ///< Holds data for the AHTX0's humidity sensor
|
||||
wippersnapper_sensor_SensorType _default_sensor_types[3] = {
|
||||
wippersnapper_sensor_SensorType_SENSOR_TYPE_AMBIENT_TEMPERATURE,
|
||||
wippersnapper_sensor_SensorType_SENSOR_TYPE_AMBIENT_TEMPERATURE_FAHRENHEIT,
|
||||
wippersnapper_sensor_SensorType_SENSOR_TYPE_RELATIVE_HUMIDITY}; ///< Default
|
||||
///< sensor
|
||||
///< types
|
||||
};
|
||||
|
||||
#endif // drvAhtx0
|
||||
|
|
@ -55,6 +55,7 @@ public:
|
|||
_has_alt_i2c_bus = false;
|
||||
strcpy(_pin_scl, "default");
|
||||
strcpy(_pin_sda, "default");
|
||||
_default_sensor_types_count = 0;
|
||||
}
|
||||
|
||||
/*******************************************************************************/
|
||||
|
|
@ -166,16 +167,30 @@ public:
|
|||
wippersnapper_sensor_SensorType *sensor_types = nullptr,
|
||||
size_t sensor_types_count = 0) {
|
||||
if (use_default_types) {
|
||||
// set sensor_types_count to # of elements within _default_sensor_types
|
||||
sensor_types_count =
|
||||
sizeof(_default_sensor_types) / sizeof(_default_sensor_types[0]);
|
||||
}
|
||||
_sensors_count = sensor_types_count;
|
||||
for (size_t i = 0; i < _sensors_count; i++) {
|
||||
_sensors[i] = sensor_types[i];
|
||||
// Configure the driver's sensor types with values from the driver
|
||||
// NOTE: This is used only for auto-configured sensors
|
||||
ConfigureDefaultSensorTypes();
|
||||
_sensors_count = _default_sensor_types_count;
|
||||
// load sensor_types with default sensor types
|
||||
for (size_t i = 0; i < _sensors_count; i++) {
|
||||
_sensors[i] = _default_sensor_types[i];
|
||||
}
|
||||
} else {
|
||||
// Load the driver's sensor types with user-defined sensor types
|
||||
_sensors_count = sensor_types_count;
|
||||
for (size_t i = 0; i < _sensors_count; i++) {
|
||||
_sensors[i] = sensor_types[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************/
|
||||
/*!
|
||||
@brief Configures a driver with the default SensorType(s) for the
|
||||
device.
|
||||
/*******************************************************************************/
|
||||
virtual void ConfigureDefaultSensorTypes() { return; }
|
||||
|
||||
/*******************************************************************************/
|
||||
/*!
|
||||
@brief Gets the number of enabled sensors.
|
||||
|
|
@ -738,6 +753,7 @@ protected:
|
|||
ulong _sensor_period_prv; ///< The sensor's previous period, in milliseconds.
|
||||
size_t _sensors_count; ///< Number of sensors on the device.
|
||||
wippersnapper_sensor_SensorType
|
||||
_default_sensor_types[1]; ///< Default sensor types
|
||||
_default_sensor_types[15]; ///< Default sensor types
|
||||
size_t _default_sensor_types_count;
|
||||
};
|
||||
#endif // DRV_BASE_H
|
||||
|
|
@ -96,6 +96,11 @@ public:
|
|||
return true;
|
||||
}
|
||||
|
||||
void ConfigureDefaultSensorTypes() override {
|
||||
_default_sensor_types_count = 1;
|
||||
_default_sensor_types[0] = wippersnapper_sensor_SensorType_SENSOR_TYPE_LIGHT;
|
||||
}
|
||||
|
||||
protected:
|
||||
hp_BH1750 *_bh1750; ///< Pointer to BH1750 light sensor object
|
||||
};
|
||||
|
|
|
|||
|
|
@ -137,6 +137,15 @@ public:
|
|||
return true;
|
||||
}
|
||||
|
||||
void ConfigureDefaultSensorTypes() override {
|
||||
_default_sensor_types_count = 5;
|
||||
_default_sensor_types[0] = wippersnapper_sensor_SensorType_SENSOR_TYPE_AMBIENT_TEMPERATURE;
|
||||
_default_sensor_types[1] = wippersnapper_sensor_SensorType_SENSOR_TYPE_AMBIENT_TEMPERATURE_FAHRENHEIT;
|
||||
_default_sensor_types[2] = wippersnapper_sensor_SensorType_SENSOR_TYPE_RELATIVE_HUMIDITY;
|
||||
_default_sensor_types[3] = wippersnapper_sensor_SensorType_SENSOR_TYPE_PRESSURE;
|
||||
_default_sensor_types[4] = wippersnapper_sensor_SensorType_SENSOR_TYPE_ALTITUDE;
|
||||
}
|
||||
|
||||
protected:
|
||||
Adafruit_BME280 *_bme; ///< BME280 object
|
||||
Adafruit_Sensor *_bme_temp =
|
||||
|
|
@ -145,20 +154,6 @@ protected:
|
|||
NULL; ///< Ptr to an adafruit_sensor representing the pressure
|
||||
Adafruit_Sensor *_bme_humidity =
|
||||
NULL; ///< Ptr to an adafruit_sensor representing the humidity
|
||||
uint16_t potential_addresses[2] = {
|
||||
0x76, 0x77}; ///< BME280 I2C addresses, used for auto-config
|
||||
wippersnapper_sensor_SensorType sensor_types[5] = {
|
||||
wippersnapper_sensor_SensorType_SENSOR_TYPE_AMBIENT_TEMPERATURE,
|
||||
wippersnapper_sensor_SensorType_SENSOR_TYPE_AMBIENT_TEMPERATURE_FAHRENHEIT,
|
||||
wippersnapper_sensor_SensorType_SENSOR_TYPE_PRESSURE,
|
||||
wippersnapper_sensor_SensorType_SENSOR_TYPE_RELATIVE_HUMIDITY,
|
||||
wippersnapper_sensor_SensorType_SENSOR_TYPE_ALTITUDE}; ///< Let's store
|
||||
///< the sensor
|
||||
///< types for the
|
||||
///< specific
|
||||
///< driver within
|
||||
///< the driver
|
||||
///< itself!
|
||||
};
|
||||
|
||||
#endif // drvBme280
|
||||
|
|
@ -178,6 +178,16 @@ public:
|
|||
return true;
|
||||
}
|
||||
|
||||
void ConfigureDefaultSensorTypes() override {
|
||||
_default_sensor_types_count = 6;
|
||||
_default_sensor_types[0] = wippersnapper_sensor_SensorType_SENSOR_TYPE_AMBIENT_TEMPERATURE;
|
||||
_default_sensor_types[1] = wippersnapper_sensor_SensorType_SENSOR_TYPE_AMBIENT_TEMPERATURE_FAHRENHEIT;
|
||||
_default_sensor_types[2] = wippersnapper_sensor_SensorType_SENSOR_TYPE_RELATIVE_HUMIDITY;
|
||||
_default_sensor_types[3] = wippersnapper_sensor_SensorType_SENSOR_TYPE_PRESSURE;
|
||||
_default_sensor_types[4] = wippersnapper_sensor_SensorType_SENSOR_TYPE_ALTITUDE;
|
||||
_default_sensor_types[5] = wippersnapper_sensor_SensorType_SENSOR_TYPE_GAS_RESISTANCE;
|
||||
}
|
||||
|
||||
protected:
|
||||
Adafruit_BME680 *_bme; ///< BME680 object
|
||||
};
|
||||
|
|
|
|||
|
|
@ -127,6 +127,14 @@ public:
|
|||
return true;
|
||||
}
|
||||
|
||||
void ConfigureDefaultSensorTypes() override {
|
||||
_default_sensor_types_count = 4;
|
||||
_default_sensor_types[0] = wippersnapper_sensor_SensorType_SENSOR_TYPE_AMBIENT_TEMPERATURE;
|
||||
_default_sensor_types[1] = wippersnapper_sensor_SensorType_SENSOR_TYPE_AMBIENT_TEMPERATURE_FAHRENHEIT;
|
||||
_default_sensor_types[2] = wippersnapper_sensor_SensorType_SENSOR_TYPE_PRESSURE;
|
||||
_default_sensor_types[3] = wippersnapper_sensor_SensorType_SENSOR_TYPE_ALTITUDE;
|
||||
}
|
||||
|
||||
protected:
|
||||
Adafruit_BMP280 *_bmp; ///< BMP280 object
|
||||
Adafruit_Sensor *_bmp_temp =
|
||||
|
|
|
|||
|
|
@ -129,6 +129,14 @@ public:
|
|||
return true;
|
||||
}
|
||||
|
||||
void ConfigureDefaultSensorTypes() override {
|
||||
_default_sensor_types_count = 4;
|
||||
_default_sensor_types[0] = wippersnapper_sensor_SensorType_SENSOR_TYPE_AMBIENT_TEMPERATURE;
|
||||
_default_sensor_types[1] = wippersnapper_sensor_SensorType_SENSOR_TYPE_AMBIENT_TEMPERATURE_FAHRENHEIT;
|
||||
_default_sensor_types[2] = wippersnapper_sensor_SensorType_SENSOR_TYPE_PRESSURE;
|
||||
_default_sensor_types[3] = wippersnapper_sensor_SensorType_SENSOR_TYPE_ALTITUDE;
|
||||
}
|
||||
|
||||
protected:
|
||||
Adafruit_BMP3XX *_bmp3xx; ///< BMP3XX object
|
||||
};
|
||||
|
|
|
|||
|
|
@ -151,6 +151,13 @@ public:
|
|||
return true;
|
||||
}
|
||||
|
||||
void ConfigureDefaultSensorTypes() override {
|
||||
_default_sensor_types_count = 3;
|
||||
_default_sensor_types[0] = wippersnapper_sensor_SensorType_SENSOR_TYPE_AMBIENT_TEMPERATURE;
|
||||
_default_sensor_types[1] = wippersnapper_sensor_SensorType_SENSOR_TYPE_AMBIENT_TEMPERATURE_FAHRENHEIT;
|
||||
_default_sensor_types[2] = wippersnapper_sensor_SensorType_SENSOR_TYPE_PRESSURE;
|
||||
}
|
||||
|
||||
protected:
|
||||
sensors_event_t _temp_event = {
|
||||
0}; ///< DPS310 sensor event for temperature readings
|
||||
|
|
|
|||
|
|
@ -152,6 +152,12 @@ public:
|
|||
return processTemperatureEvent(tempEvent);
|
||||
}
|
||||
|
||||
void ConfigureDefaultSensorTypes() override {
|
||||
_default_sensor_types_count = 2;
|
||||
_default_sensor_types[0] = wippersnapper_sensor_SensorType_SENSOR_TYPE_AMBIENT_TEMPERATURE;
|
||||
_default_sensor_types[1] = wippersnapper_sensor_SensorType_SENSOR_TYPE_AMBIENT_TEMPERATURE_FAHRENHEIT;
|
||||
}
|
||||
|
||||
protected:
|
||||
Adafruit_DS248x *_ds2484; ///< DS2484 driver object
|
||||
uint8_t _rom[8]; ///< DS18B20 ROM
|
||||
|
|
|
|||
|
|
@ -133,6 +133,12 @@ public:
|
|||
return true;
|
||||
}
|
||||
|
||||
void ConfigureDefaultSensorTypes() override {
|
||||
_default_sensor_types_count = 2;
|
||||
_default_sensor_types[0] = wippersnapper_sensor_SensorType_SENSOR_TYPE_RAW;
|
||||
_default_sensor_types[1] = wippersnapper_sensor_SensorType_SENSOR_TYPE_TVOC;
|
||||
}
|
||||
|
||||
protected:
|
||||
ScioSense_ENS160 *_ens160; ///< ENS160 object
|
||||
};
|
||||
|
|
|
|||
|
|
@ -99,6 +99,13 @@ public:
|
|||
return _hts221_humidity->getEvent(humidEvent);
|
||||
}
|
||||
|
||||
void ConfigureDefaultSensorTypes() override {
|
||||
_default_sensor_types_count = 3;
|
||||
_default_sensor_types[0] = wippersnapper_sensor_SensorType_SENSOR_TYPE_AMBIENT_TEMPERATURE;
|
||||
_default_sensor_types[1] = wippersnapper_sensor_SensorType_SENSOR_TYPE_AMBIENT_TEMPERATURE_FAHRENHEIT;
|
||||
_default_sensor_types[1] = wippersnapper_sensor_SensorType_SENSOR_TYPE_RELATIVE_HUMIDITY;
|
||||
}
|
||||
|
||||
protected:
|
||||
Adafruit_HTS221 *_hts221; ///< Pointer to an HTS221 object
|
||||
Adafruit_Sensor *_hts221_temp =
|
||||
|
|
|
|||
|
|
@ -86,6 +86,13 @@ public:
|
|||
return true;
|
||||
}
|
||||
|
||||
void ConfigureDefaultSensorTypes() override {
|
||||
_default_sensor_types_count = 3;
|
||||
_default_sensor_types[0] = wippersnapper_sensor_SensorType_SENSOR_TYPE_AMBIENT_TEMPERATURE;
|
||||
_default_sensor_types[1] = wippersnapper_sensor_SensorType_SENSOR_TYPE_AMBIENT_TEMPERATURE_FAHRENHEIT;
|
||||
_default_sensor_types[1] = wippersnapper_sensor_SensorType_SENSOR_TYPE_RELATIVE_HUMIDITY;
|
||||
}
|
||||
|
||||
protected:
|
||||
Adafruit_HTU21DF *_htu21d; ///< Pointer to an HTU21D object
|
||||
};
|
||||
|
|
|
|||
|
|
@ -101,6 +101,12 @@ public:
|
|||
return true;
|
||||
}
|
||||
|
||||
void ConfigureDefaultSensorTypes() override {
|
||||
_default_sensor_types_count = 2;
|
||||
_default_sensor_types[0] = wippersnapper_sensor_SensorType_SENSOR_TYPE_VOLTAGE;
|
||||
_default_sensor_types[1] = wippersnapper_sensor_SensorType_SENSOR_TYPE_CURRENT;
|
||||
}
|
||||
|
||||
protected:
|
||||
Adafruit_INA219 *_ina219; ///< Pointer to INA219 sensor object
|
||||
};
|
||||
|
|
|
|||
|
|
@ -68,6 +68,16 @@ public:
|
|||
return _sht3x->setAccuracy(SHTSensor::SHT_ACCURACY_HIGH);
|
||||
}
|
||||
|
||||
void ConfigureDefaultSensorTypes() override {
|
||||
_default_sensor_types_count = 3;
|
||||
_default_sensor_types[0] =
|
||||
wippersnapper_sensor_SensorType_SENSOR_TYPE_AMBIENT_TEMPERATURE;
|
||||
_default_sensor_types[1] =
|
||||
wippersnapper_sensor_SensorType_SENSOR_TYPE_AMBIENT_TEMPERATURE_FAHRENHEIT;
|
||||
_default_sensor_types[2] =
|
||||
wippersnapper_sensor_SensorType_SENSOR_TYPE_RELATIVE_HUMIDITY;
|
||||
}
|
||||
|
||||
/*******************************************************************************/
|
||||
/*!
|
||||
@brief Gets the SHT3X's current temperature.
|
||||
|
|
|
|||
|
|
@ -731,38 +731,40 @@ bool ws_sdcard::ParseFileConfig() {
|
|||
// TODO: This is only using the first device found in the scan, we should
|
||||
// make this dynamic once it works properly Add each device found in the I2C
|
||||
// scan to the shared buffer
|
||||
WS_DEBUG_PRINTLN("[SD] Configuring I2C Device PB...");
|
||||
wippersnapper_signal_BrokerToDevice msg_signal =
|
||||
wippersnapper_signal_BrokerToDevice_init_default;
|
||||
wippersnapper_i2c_I2cDeviceAddOrReplace msg_i2c_add_replace =
|
||||
wippersnapper_i2c_I2cDeviceAddOrReplace_init_default;
|
||||
msg_signal.which_payload =
|
||||
wippersnapper_signal_BrokerToDevice_i2c_device_add_replace_tag;
|
||||
// TODO: The index is hardcoded to 0 here, this should be dynamic
|
||||
WS_DEBUG_PRINT("[SD] Adding I2C device at address: ");
|
||||
msg_i2c_add_replace.i2c_device_description.i2c_device_address =
|
||||
WsV2._i2c_controller->GetScanDeviceAddress(0);
|
||||
WS_DEBUG_PRINTLN(
|
||||
msg_i2c_add_replace.i2c_device_description.i2c_device_address, HEX);
|
||||
// TODO: Detect UNKNOWN_SCAN_DEVICEs in controller
|
||||
strcpy(msg_i2c_add_replace.i2c_device_name, "UNKNOWN_SCAN");
|
||||
// TODO: Maybe create a default i2c period
|
||||
msg_i2c_add_replace.i2c_device_period = 30.0;
|
||||
// TODO: Do we need to fill these? Probably not! Or not yet
|
||||
msg_i2c_add_replace.has_i2c_device_description = true;
|
||||
strcpy(msg_i2c_add_replace.i2c_device_description.i2c_bus_scl, "default");
|
||||
strcpy(msg_i2c_add_replace.i2c_device_description.i2c_bus_sda, "default");
|
||||
msg_i2c_add_replace.i2c_device_description.i2c_mux_address = 0x00;
|
||||
msg_i2c_add_replace.i2c_device_description.i2c_mux_channel = 0xFFFF;
|
||||
// TODO: Do we need to add the i2c_device_sensor_types?
|
||||
msg_signal.payload.i2c_device_add_replace = msg_i2c_add_replace;
|
||||
WS_DEBUG_PRINTLN("[SD] Adding I2C device to shared buffer...");
|
||||
if (!AddSignalMessageToSharedBuffer(msg_signal)) {
|
||||
WS_DEBUG_PRINTLN("[SD] Runtime Error: Unable to add signal message(s) "
|
||||
"to shared buffer!");
|
||||
return false;
|
||||
for (size_t i = 0; i < WsV2._i2c_controller->GetScanDeviceCount(); i++) {
|
||||
WS_DEBUG_PRINTLN("[SD] Configuring I2C Device PB...");
|
||||
wippersnapper_signal_BrokerToDevice msg_signal =
|
||||
wippersnapper_signal_BrokerToDevice_init_default;
|
||||
wippersnapper_i2c_I2cDeviceAddOrReplace msg_i2c_add_replace =
|
||||
wippersnapper_i2c_I2cDeviceAddOrReplace_init_default;
|
||||
msg_signal.which_payload =
|
||||
wippersnapper_signal_BrokerToDevice_i2c_device_add_replace_tag;
|
||||
// TODO: The index is hardcoded to 0 here, this should be dynamic
|
||||
WS_DEBUG_PRINT("[SD] Adding I2C device at address: ");
|
||||
msg_i2c_add_replace.i2c_device_description.i2c_device_address =
|
||||
WsV2._i2c_controller->GetScanDeviceAddress(i);
|
||||
WS_DEBUG_PRINTLN(
|
||||
msg_i2c_add_replace.i2c_device_description.i2c_device_address, HEX);
|
||||
// TODO: Detect UNKNOWN_SCAN_DEVICEs in controller
|
||||
strcpy(msg_i2c_add_replace.i2c_device_name, "UNKNOWN_SCAN");
|
||||
// TODO: Maybe create a default i2c period
|
||||
msg_i2c_add_replace.i2c_device_period = 30.0;
|
||||
// TODO: Do we need to fill these? Probably not! Or not yet
|
||||
msg_i2c_add_replace.has_i2c_device_description = true;
|
||||
strcpy(msg_i2c_add_replace.i2c_device_description.i2c_bus_scl, "default");
|
||||
strcpy(msg_i2c_add_replace.i2c_device_description.i2c_bus_sda, "default");
|
||||
msg_i2c_add_replace.i2c_device_description.i2c_mux_address = 0x00;
|
||||
msg_i2c_add_replace.i2c_device_description.i2c_mux_channel = 0xFFFF;
|
||||
// TODO: Do we need to add the i2c_device_sensor_types?
|
||||
msg_signal.payload.i2c_device_add_replace = msg_i2c_add_replace;
|
||||
WS_DEBUG_PRINTLN("[SD] Adding I2C device to shared buffer...");
|
||||
if (!AddSignalMessageToSharedBuffer(msg_signal)) {
|
||||
WS_DEBUG_PRINTLN("[SD] Runtime Error: Unable to add signal message(s) "
|
||||
"to shared buffer!");
|
||||
return false;
|
||||
}
|
||||
WS_DEBUG_PRINTLN("[SD] I2C device added to shared buffer!");
|
||||
}
|
||||
WS_DEBUG_PRINTLN("[SD] I2C device added to shared buffer!");
|
||||
}
|
||||
WS_DEBUG_PRINTLN("[SD] I2C scan and JSON doc comparison complete!");
|
||||
|
||||
|
|
|
|||
|
|
@ -486,7 +486,8 @@ bool Wippersnapper_FS::AddSDCSPinToFileConfig(uint8_t pin) {
|
|||
@returns True if the device was successfully added, False otherwise.
|
||||
*/
|
||||
/********************************************************************************/
|
||||
bool Wippersnapper_FS::AddI2cDeviceToFileConfig(uint32_t address, const char *driver_name) {
|
||||
bool Wippersnapper_FS::AddI2cDeviceToFileConfig(uint32_t address,
|
||||
const char *driver_name) {
|
||||
if (!wipperFatFs_v2.exists("/config.json")) {
|
||||
HaltFilesystem("ERROR: Could not find expected config.json file on the "
|
||||
"WIPPER volume!");
|
||||
|
|
|
|||
Loading…
Reference in a new issue