Add SDK command to rescan devices

This commit is contained in:
Adam Honse
2025-07-02 14:32:03 -05:00
parent b6d4ded29a
commit 0cfe5ae0bb
4 changed files with 20 additions and 0 deletions

View File

@@ -51,6 +51,7 @@ The following IDs represent different SDK commands. Each ID packet has a certai
| 40 | [NET_PACKET_ID_REQUEST_PROTOCOL_VERSION](#net_packet_id_request_protocol_version) | Request OpenRGB SDK protocol version from server | 1* |
| 50 | [NET_PACKET_ID_SET_CLIENT_NAME](#net_packet_id_set_client_name) | Send client name string to server | 0 |
| 100 | [NET_PACKET_ID_DEVICE_LIST_UPDATED](#net_packet_id_device_list_updated) | Indicate to clients that device list has updated | 1 |
| 140 | [NET_PACKET_ID_REQUEST_RESCAN_DEVICES](#net_packet_id_request_rescan_devices) | Request server to rescan devices | 5 |
| 150 | [NET_PACKET_ID_REQUEST_PROFILE_LIST](#net_packet_id_request_profile_list) | Request profile list | 2 |
| 151 | [NET_PACKET_ID_REQUEST_SAVE_PROFILE](#net_packet_id_request_save_profile) | Save current configuration in a new profile | 2 |
| 152 | [NET_PACKET_ID_REQUEST_LOAD_PROFILE](#net_packet_id_request_load_profile) | Load a given profile | 2 |
@@ -218,6 +219,12 @@ The client uses this ID to send the client's null-terminated name string to the
The server uses this ID to notify a client that the server's device list has been updated. Upon receiving this packet, clients should synchronize their local device lists with the server by requesting size and controller data again. This packet contains no data.
## NET_PACKET_ID_REQUEST_RESCAN_DEVICES
### Client Only [Size: 0]
The client uses this ID to request the server rescan its devices.
## NET_PACKET_ID_REQUEST_PROFILE_LIST
### Request [Size: 0]

View File

@@ -63,6 +63,8 @@ enum
NET_PACKET_ID_DEVICE_LIST_UPDATED = 100, /* Indicate to clients that device list has updated */
NET_PACKET_ID_REQUEST_RESCAN_DEVICES = 140, /* Request rescan of devices */
NET_PACKET_ID_REQUEST_PROFILE_LIST = 150, /* Request profile list */
NET_PACKET_ID_REQUEST_SAVE_PROFILE = 151, /* Save current configuration in a new profile */
NET_PACKET_ID_REQUEST_LOAD_PROFILE = 152, /* Load a given profile */

View File

@@ -668,6 +668,10 @@ void NetworkServer::ListenThreadFunction(NetworkClientInfo * client_info)
ProcessRequest_ClientString(client_sock, header.pkt_size, data);
break;
case NET_PACKET_ID_REQUEST_RESCAN_DEVICES:
ProcessRequest_RescanDevices();
break;
case NET_PACKET_ID_RGBCONTROLLER_RESIZEZONE:
if(data == NULL)
{
@@ -1046,6 +1050,11 @@ void NetworkServer::ProcessRequest_ClientString(SOCKET client_sock, unsigned int
ClientInfoChanged();
}
void NetworkServer::ProcessRequest_RescanDevices()
{
ResourceManager::get()->DetectDevices();
}
void NetworkServer::SendReply_ControllerCount(SOCKET client_sock)
{
NetPacketHeader reply_hdr;

View File

@@ -18,6 +18,7 @@
#include "NetworkProtocol.h"
#include "net_port.h"
#include "ProfileManager.h"
#include "ResourceManager.h"
#define MAXSOCK 32
#define TCP_TIMEOUT_SECONDS 5
@@ -82,6 +83,7 @@ public:
void ProcessRequest_ClientProtocolVersion(SOCKET client_sock, unsigned int data_size, char * data);
void ProcessRequest_ClientString(SOCKET client_sock, unsigned int data_size, char * data);
void ProcessRequest_RescanDevices();
void SendReply_ControllerCount(SOCKET client_sock);
void SendReply_ControllerData(SOCKET client_sock, unsigned int dev_idx, unsigned int protocol_version);