Advice on Struct command

Hi All

This piece of code forms part of a program I have copied that sends data over Wi-Fi.
I am trying to change it for my own purposes.

Firstly I wanted to change the struct to my own variables and names, but I don’t fully understand the code.

Could somebody please explain this bit:-

struct led_command send_data;
send_data.opmode = op_mode;
send_data.data = data;

I don’t understand why there is 2 lots of names after the struct command.
or where send_data.opmode or send_data.data come from as names/declarations.

void sendLedData(uint32_t data, uint8_t op_mode) 
{
 struct led_command send_data;
 send_data.opmode = op_mode; 
 send_data.data = data; 
 for (int i = 0; i < NUMBER_OF_CLIENTS; i++) 
 {
    IPAddress ip(192,168,4,2 + i);
    UDP.beginPacket(ip, 7001); 
    UDP.write((char*)&send_data,sizeof(struct led_command));
    UDP.endPacket();
 }
}

Blue407:
I don't understand why there is 2 lots of names after the struct command.
or where send_data.opmode or send_data.data come from as names/declarations.

They come from the declaration of the struct which is in the code that you did not include in your post.

You have only posted a snippet. We cannot see the information you have hidden from us.

Somewhere in the other code there is a definition of led_command, possibly as a type declaration that includes opmode and data.

Thats what I was missing, thanks.

I didn't see that bit, so hadn't changed the definition before I changed the code.

Thanks!