How to treat data with Analysis?

How to treat data with Analysis?

Hello, I did a procedure to receive multiple devices through a single gateway.

But now I need to process the data in Analysis.
I really need help with this.

I didn't find examples, I learn easily, but the documentation has very few examples.

I need to understand how data reception works for:

1- Receive data from devices with MAC + DATA and separate it;
2- Save in different buckets;
3- Save the equipment settings in another bucket (battery level, etc);
4- Read the last 30 data from the bucket to generate a notification;
5- Create a new bucket if you're trying to write to something that doesn't exist.

I tried to read the documentation and searched a lot around here but I didn't find examples of how to do these things.

Could someone help me with basic examples?

Now two questions came to my mind:
1- Why will I use the Serial of the device generated in the link I sent?
2- Will my devices that will communicate through the gateway have "devices" in the tago? Will they only have buckets of data? I don't understand that part, will I need to create devices and something else?