Notifications best use

hello, im new to FreeRTOS i used to do bare metal

and my question as follows:

im notifying a task from different tasks … setting a bit for each notification (i’ve 32bits) so i can have 32 boolean messages from different tasks …

inside the notified task … im reading the notifications from various places like this

* task that gets notifications from various tasks
   //stack stuff init
   uint32_t ulNotificationValue;
     // long code
     if (xTaskNotifyWait(0x0, 1<<0 , &ulNotificationValue, 10) == pdTrue){
           if (ulNotificationValue & (1<<0)){
                   //do somthing

    /// long code again
         if (xTaskNotifyWait(0x0, 1<<1 , &ulNotificationValue, 10) == pdTrue){
           if (ulNotificationValue & (1<<1)){
                   //do somthing else

my problem is that xTaskNotifyWait will update that index notification state to taskNOT_WAITING_NOTIFICATION … and the second xTasknotifyWait will never be read … is its waiting for the state to be taskNOTIFICATION_RECEIVED

in all other tasks im using the following:
xTaskNotify(H_task_thread_notified, (1<<0) ,eSetValueWithOverwrite);

and on some other code/task
xTaskNotify(H_task_thread_notified, (1<<1) ,eSetValueWithOverwrite);

so what is the best practice to use 32bit value to send 32 different msgs … and read them from different places inside a task …

You’ve to wait ONCE for all (used) bits and process each bit set in ulNotificationValue.
e.g. similiar to this tiny example:

const uint32_t EventMask = 0xFFFFFFFF;
while (true)
    uint32_t Events = 0;
    xTaskNotifyWait( 0, EventMask, &Events, pdMS_TO_TICKS(10) );
    if ( Events & (1 << 0) ) 
    // ...
    else if ( Events & (1 << 1) ) 
    // ...

Hi … i know this from the examples … but it just wont work for me …

The way im using notifications is to do delays … and wait for events from other threads … thats why i need multiple notification poll inside my loop …

Hmm … then I didn’t and don’t understand the bigger problem you want to solve.

There are some delays inside the task…
Some of them are pure time delay done with vTaskDelay and some of them depend on other tasks …
For example in the task im waiting to fill a tank with water … so i do following:

xTaskNotify(hFillingTask, …)
And then somewhere else i need to make sure tank is full or timeout i do following
xTaskNotifyWait(0x0,(1<<0), unotifVal,timout)

Inside of the filling task of course i notify with 1<<0

Now because of the dalays … i need to implement xNotifyWait in various places and check if other tasks notified the current one …

I understand i can use semaphore and clear the bit my self … but i felt i can do everything with notification … its cleaner code …

I also can use indexed notification … but thats alot for what im trying to achieve i dont think im using the best practice …

My only problem is that reading notifications will set its state from recieved to pending …

The clearing of.a Notification is sort of part of the definition of them. The task was notified, and it goes away.
Maybe you should look at Event Groups, those can be set and left set until something explicitly clears it.