Skip to content

Commit

Permalink
[SensorBHI260AP] Added get available sensors
Browse files Browse the repository at this point in the history
  • Loading branch information
lewisxhe committed Jan 31, 2025
1 parent 59e7db5 commit 8a9cf49
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/SensorBHI260AP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,15 @@ void SensorBHI260AP::setUpdateProcessCallback(ProcessCallback callback, void *us
_process_callback = callback;
}

/**
* @brief availableSensorNums
* @note Get the number of available sensors
* @retval available sensors
*/
const uint8_t SensorBHI260AP::availableSensorNums()
{
return _sensor_available_nums;
}

/**
* @brief bootFromFlash
Expand Down Expand Up @@ -1094,6 +1103,7 @@ bool SensorBHI260AP::initImpl(bhy2_intf interface)
// Only register valid sensor IDs
for (uint8_t i = 0; i < BHY2_SENSOR_ID_MAX; i++) {
if (bhy2_is_sensor_available(i, _bhy2.get())) {
_sensor_available_nums++;
bhy2_register_fifo_parse_callback(i, BoschParseStatic::parseData, this, _bhy2.get());
}
}
Expand Down
8 changes: 8 additions & 0 deletions src/SensorBHI260AP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,13 @@ class SensorBHI260AP : public BoschVirtualSensor, BoschParseBase
*/
void setUpdateProcessCallback(ProcessCallback callback, void *user_data = nullptr);

/**
* @brief availableSensorNums
* @note Get the number of available sensors
* @retval available sensors
*/
const uint8_t availableSensorNums();

protected:

void parseData(const struct bhy2_fifo_parse_data_info *fifo, void *user_data) override;
Expand Down Expand Up @@ -508,6 +515,7 @@ class SensorBHI260AP : public BoschVirtualSensor, BoschParseBase
SensorEventCallback _event_callback;
SensorDebugMessageCallback _debug_callback;
BoschParseCallbackManager _callback_manager;
uint8_t _sensor_available_nums;
char _err_buffer[128];

};

0 comments on commit 8a9cf49

Please sign in to comment.