Skip to content

Conversation

@mattjperez
Copy link
Contributor

@mattjperez mattjperez commented Mar 24, 2025

@npmenard @gvaradarajan tagging here since I can only add one reviewer

@mattjperez mattjperez requested a review from stevebriskin March 24, 2025 18:52
src/lib.rs Outdated
Comment on lines 22 to 25
/// Global handle to I2C bus
static mut I2C_BUS: i2c_bus_handle_t = std::ptr::null_mut();
/// Global handle to BME280 device
static mut BME280: bme280_handle_t = std::ptr::null_mut();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these cause compilation warnings about static mut references (to be deprecated). I'm not sure what I should use instead. Looking online there's references to a const_mut compiler feature, but it isn't stable just yet.

src/lib.rs Outdated
Comment on lines 61 to 68
esp!(bme280_read_temperature(
BME280,
&mut temperature as &mut f32
))?;
log::debug!("bme280 - reading pressure...");
esp!(bme280_read_pressure(BME280, &mut pressure as &mut f32))?;
log::debug!("bme280 - reading humidity...");
esp!(bme280_read_humidity(BME280, &mut humidity as &mut f32))?;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

an error from any of the three readings will cause get_readings to return an error.

@mattjperez mattjperez requested review from npmenard and stevebriskin and removed request for npmenard and stevebriskin March 24, 2025 19:22
Copy link
Collaborator

@stevebriskin stevebriskin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a readme and license file. approving assuming that is done.
all comments are minor, address as you wish.

const I2C_MODE_MASTER: u32 = 0x1;

pub fn register_models(registry: &mut ComponentRegistry) -> Result<(), RegistryError> {
registry.register_sensor("bme280", &Bme280::from_config)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as discussed, see if you can make this a triplet. not a blocker for merging.

Copy link

@gvaradarajan gvaradarajan Mar 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not possible without an adjustment to registration logic in micro-RDK, see here: https://viam.atlassian.net/browse/RSDK-7822

src/lib.rs Outdated
log::info!("initializing BME280: {:?}", BME280);
BME280 = bme280_create(I2C_BUS, BME280_I2C_ADDRESS_DEFAULT.try_into().unwrap());
log::info!("initialized BME280 to : {:?}", BME280);
esp!(bme280_default_init(BME280))?;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: you have before/after log statements for everything but this init step, for consistency log here too

src/lib.rs Outdated
log::info!("initializing I2C_BUS: {:?}", I2C_BUS);
I2C_BUS = i2c_bus_create(bus_no, &config);
log::info!("initialized I2C_BUS to : {:?}", I2C_BUS);
log::info!("initializing BME280: {:?}", BME280);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: create and init are different things for the bme280. be clear with logging....this log should probably read "creating"

@stevebriskin
Copy link
Collaborator

Also...what is the consequence of having the micrordk dependency in Cargo.toml be on the RC? Can that be a "0.4.0+"?

@mattjperez
Copy link
Contributor Author

mattjperez commented Mar 24, 2025

Just realized I didn't add the corresponding drop logic to destroy the bme280 and i2c_bus.
will add before merging

@mattjperez mattjperez merged commit 1151c57 into main Mar 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants