Request updated controller mode from server after sending a Set Custom Mode command
This commit is contained in:
parent
97e1c3e913
commit
5ce6ec9ea7
3 changed files with 30 additions and 1 deletions
|
|
@ -425,6 +425,20 @@ listen_done:
|
|||
ClientInfoChanged();
|
||||
}
|
||||
|
||||
void NetworkClient::WaitOnControllerData()
|
||||
{
|
||||
for(int i = 0; i < 1000; i++)
|
||||
{
|
||||
if(controller_data_received)
|
||||
{
|
||||
break;
|
||||
}
|
||||
std::this_thread::sleep_for(1ms);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void NetworkClient::ProcessReply_ControllerCount(unsigned int data_size, char * data)
|
||||
{
|
||||
if(data_size == sizeof(unsigned int))
|
||||
|
|
@ -441,7 +455,15 @@ void NetworkClient::ProcessReply_ControllerData(unsigned int data_size, char * d
|
|||
|
||||
printf("Received controller: %s\r\n", new_controller->name.c_str());
|
||||
|
||||
server_controllers.push_back(new_controller);
|
||||
if(dev_idx >= server_controllers.size())
|
||||
{
|
||||
server_controllers.push_back(new_controller);
|
||||
}
|
||||
else
|
||||
{
|
||||
server_controllers[dev_idx]->active_mode = new_controller->active_mode;
|
||||
delete new_controller;
|
||||
}
|
||||
|
||||
controller_data_received = true;
|
||||
}
|
||||
|
|
@ -483,6 +505,8 @@ void NetworkClient::SendRequest_ControllerData(unsigned int dev_idx)
|
|||
{
|
||||
NetPacketHeader reply_hdr;
|
||||
|
||||
controller_data_received = false;
|
||||
|
||||
reply_hdr.pkt_magic[0] = 'O';
|
||||
reply_hdr.pkt_magic[1] = 'R';
|
||||
reply_hdr.pkt_magic[2] = 'G';
|
||||
|
|
|
|||
|
|
@ -41,6 +41,8 @@ public:
|
|||
void ConnectionThreadFunction();
|
||||
void ListenThreadFunction();
|
||||
|
||||
void WaitOnControllerData();
|
||||
|
||||
void ProcessReply_ControllerCount(unsigned int data_size, char * data);
|
||||
void ProcessReply_ControllerData(unsigned int data_size, char * data, unsigned int dev_idx);
|
||||
|
||||
|
|
|
|||
|
|
@ -62,6 +62,9 @@ void RGBController_Network::UpdateSingleLED(int led)
|
|||
void RGBController_Network::SetCustomMode()
|
||||
{
|
||||
client->SendRequest_RGBController_SetCustomMode(dev_idx);
|
||||
|
||||
client->SendRequest_ControllerData(dev_idx);
|
||||
client->WaitOnControllerData();
|
||||
}
|
||||
|
||||
void RGBController_Network::DeviceUpdateMode()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue