Jump to content
View in the app

A better way to browse. Learn more.

Tinkerunity

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Geschrieben

Hello !

I'm trying to get the data from a Outdoor Weather bricklet using the C/C++ bindings from uC.
I want to use `tf_outdoor_weather_get_station_data` instead of the callback methods. For this I first need to get the station identifier using `tf_outdoor_weather_get_station_identifiers` but I'm unable to get it to work.

uint8_t * stations_id;
uint16_t * station_nb;
tf_outdoor_weather_get_station_identifiers(&ow, stations_id, station_nb);
tf_hal_printf("nb: %I16u - station 1: %I16u\n", station_nb, stations_id);

Returns 0 for both the values.
I get correct values when using the callback methods so the communication is working.

Any clue on what I'm doing wrong ?
 

Geschrieben
  • Autor

I finally got it working :

uint8_t stations_id[255];
uint16_t station_nb;
tf_outdoor_weather_get_station_identifiers(&this->ow, stations_id, &station_nb);

I think it can be done in a better way using a pointer instead of a array of 255 uint8_t elements but my C++ skills are still limited.

Geschrieben
On 8/13/2022 at 8:18 PM, Loïc G. said:

I think it can be done in a better way using a pointer instead of a array of 255 uint8_t elements

Nope, you have to pass a buffer with enough space for 256(!) entries. The station IDs are collected in this buffer and the Bricklet can detect up to 256 stations.

Theoretically you cound call

tf_outdoor_weather_get_station_identifiers(&this->ow, nullptr, &station_nb);

first to get the number of stations and then creating a buffer that is large enough, for example with

uint8_t *stations_id = (uint8_t*) malloc(stations_nb * sizeof(uint8_t));

However this is dangerous, as the Bricklet could receive another new station after the call to get the number of stations, but before the second call to get the station IDs. So don't do this!

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Gast
Reply to this topic...

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.