Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can the ds18b20_device_t struct definition be moved from ds18b20.c to a header file ? (BSP-487) #323

Open
1 task done
michal-olszanowski opened this issue Apr 28, 2024 · 2 comments
Labels
Type: Feature request New feature or request

Comments

@michal-olszanowski
Copy link

Related area

Component espressif/ds18b20

Hardware specification

esp32c3

Is your feature request related to a problem?

I'd like to use the ds18b20_device_hande_t type definition (the addr member) in my code, however, the struct is defined in .c and not .h:

ds18b20_device_handle_t sensor = ds18b20_sensors[i];
onewire_device_address_t address = sensor->addr;

ESP_LOGI( log_tag(), "Sensor %08" PRIx32 "%08" PRIx32 " (%s) reports %.3f°C",
(uint32_t)(address >> 32),
(uint32_t)address,
"DS18B20",
measured_temps[ i]);

The compiler is reporting:

C:/Users/m/Dev/esp/pump-driver/components/SensorService/SensorService.cpp:112:54: error: invalid use of incomplete type 'struct ds18b20_device_t'
112 | onewire_device_address_t address = sensor->addr;
| ^~
In file included from C:/Users/m/Dev/esp/pump-driver/components/SensorService/SensorService.h:14,
from C:/Users/m/Dev/esp/pump-driver/components/SensorService/SensorService.cpp:1:
C:/Users/m/Dev/esp/pump-driver/managed_components/espressif__ds18b20/include/ds18b20.h:19:16: note: forward declaration of 'struct ds18b20_device_t'
19 | typedef struct ds18b20_device_t *ds18b20_device_handle_t;
| ^~~~~~~~~~~~~~~~

Describe the solution you'd like

Add to ds18b20_types.h:

typedef struct ds18b20_device_t {
onewire_bus_handle_t bus;
onewire_device_address_t addr;
uint8_t th_user1;
uint8_t tl_user2;
ds18b20_resolution_t resolution;
} ds18b20_device_t;

Describe alternatives you've considered

I modifed the header locally in my project but would like to relay fully on the official ds18b20 component release. I do not know other workarounds, I'd appreciate any suggestions as an alternative.

Additional context

No response

I have checked existing list of Feature requests and the Contribution Guide

  • I confirm I have checked existing list of Feature requests and Contribution Guide.
@michal-olszanowski michal-olszanowski added the Type: Feature request New feature or request label Apr 28, 2024
@github-actions github-actions bot changed the title Can the ds18b20_device_t struct definition be moved from ds18b20.c to a header file ? Can the ds18b20_device_t struct definition be moved from ds18b20.c to a header file ? (BSP-487) Apr 28, 2024
@suda-morris
Copy link
Collaborator

@michal-olszanowski What information do you want to be exposed from the ds18b20_device_t? The address? You can get the device address from onewire_device_t::address

@michal-olszanowski
Copy link
Author

Yes, I'm looking for the device address.
Correct me if I'm wrong, but one_wire_device_t::address is only available when we are scanning the onewire bus using the onewire_device_iter_handle_t. At this point we are adding a onewire_device_t to ds18b20_device_handle_t devices[] and to make use of the device address we would need to add the device to an array of onewire_device_t devices[], which seems unnecessary, given the address is also available in ds18b20_device_t. I need an address later when we read temperatures for the devices in ds18b20_device_handle_t[].

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Feature request New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants