Add saving support to network protocol
This commit is contained in:
parent
eade8fea1a
commit
5130f07e21
6 changed files with 50 additions and 0 deletions
|
|
@ -835,6 +835,28 @@ void NetworkClient::SendRequest_RGBController_UpdateMode(unsigned int dev_idx, u
|
|||
send(client_sock, (char *)data, size, MSG_NOSIGNAL);
|
||||
}
|
||||
|
||||
void NetworkClient::SendRequest_RGBController_SaveMode(unsigned int dev_idx, unsigned char * data, unsigned int size)
|
||||
{
|
||||
if(change_in_progress)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
NetPacketHeader request_hdr;
|
||||
|
||||
request_hdr.pkt_magic[0] = 'O';
|
||||
request_hdr.pkt_magic[1] = 'R';
|
||||
request_hdr.pkt_magic[2] = 'G';
|
||||
request_hdr.pkt_magic[3] = 'B';
|
||||
|
||||
request_hdr.pkt_dev_idx = dev_idx;
|
||||
request_hdr.pkt_id = NET_PACKET_ID_RGBCONTROLLER_SAVEMODE;
|
||||
request_hdr.pkt_size = size;
|
||||
|
||||
send(client_sock, (char *)&request_hdr, sizeof(NetPacketHeader), MSG_NOSIGNAL);
|
||||
send(client_sock, (char *)data, size, MSG_NOSIGNAL);
|
||||
}
|
||||
|
||||
void NetworkClient::SendRequest_LoadProfile(std::string profile_name)
|
||||
{
|
||||
NetPacketHeader reply_hdr;
|
||||
|
|
|
|||
|
|
@ -67,6 +67,7 @@ public:
|
|||
void SendRequest_RGBController_SetCustomMode(unsigned int dev_idx);
|
||||
|
||||
void SendRequest_RGBController_UpdateMode(unsigned int dev_idx, unsigned char * data, unsigned int size);
|
||||
void SendRequest_RGBController_SaveMode(unsigned int dev_idx, unsigned char * data, unsigned int size);
|
||||
|
||||
|
||||
std::vector<std::string> * ProcessReply_ProfileList(unsigned int data_size, char * data);
|
||||
|
|
|
|||
|
|
@ -62,4 +62,5 @@ enum
|
|||
|
||||
NET_PACKET_ID_RGBCONTROLLER_SETCUSTOMMODE = 1100, /* RGBController::SetCustomMode() */
|
||||
NET_PACKET_ID_RGBCONTROLLER_UPDATEMODE = 1101, /* RGBController::UpdateMode() */
|
||||
NET_PACKET_ID_RGBCONTROLLER_SAVEMODE = 1102, /* RGBController::SaveMode() */
|
||||
};
|
||||
|
|
|
|||
|
|
@ -690,6 +690,19 @@ void NetworkServer::ListenThreadFunction(NetworkClientInfo * client_info)
|
|||
}
|
||||
break;
|
||||
|
||||
case NET_PACKET_ID_RGBCONTROLLER_SAVEMODE:
|
||||
if(data == NULL)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if(header.pkt_dev_idx < controllers.size())
|
||||
{
|
||||
controllers[header.pkt_dev_idx]->SetModeDescription((unsigned char *)data, client_info->client_protocol_version);
|
||||
controllers[header.pkt_dev_idx]->SaveMode();
|
||||
}
|
||||
break;
|
||||
|
||||
case NET_PACKET_ID_REQUEST_PROFILE_LIST:
|
||||
SendReply_ProfileList(client_sock);
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -79,6 +79,18 @@ void RGBController_Network::DeviceUpdateMode()
|
|||
delete[] data;
|
||||
}
|
||||
|
||||
void RGBController_Network::DeviceSaveMode()
|
||||
{
|
||||
unsigned char * data = GetModeDescription(active_mode, client->GetProtocolVersion());
|
||||
unsigned int size;
|
||||
|
||||
memcpy(&size, &data[0], sizeof(unsigned int));
|
||||
|
||||
client->SendRequest_RGBController_SaveMode(dev_idx, data, size);
|
||||
|
||||
delete[] data;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| This function overrides RGBController::UpdateLEDs()! |
|
||||
| Normally, UpdateLEDs() sets a flag for the updater |
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ public:
|
|||
|
||||
void SetCustomMode();
|
||||
void DeviceUpdateMode();
|
||||
void DeviceSaveMode();
|
||||
|
||||
void UpdateLEDs();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue