mirror of
https://github.com/CalcProgrammer1/OpenRGB.git
synced 2025-12-23 23:37:48 -05:00
* SDK Protocol
* Server sends its name to client
* ProfileManager
* Rename existing profile commands
* Add Upload Profile, Download Profile, and Get Active Profile commands
* SettingsManager
* Add Get, Set, and Save Settings commands
* NetworkServer
* Formatting cleanup
* Use per-controller threads for handling NetworkServer controller-specific packets to avoid delays from controller mutexes
* NetworkClient
* Formatting cleanup
117 lines
7.8 KiB
C
117 lines
7.8 KiB
C
/*---------------------------------------------------------*\
|
|
| NetworkProtocol.h |
|
|
| |
|
|
| OpenRGB SDK network protocol |
|
|
| |
|
|
| Adam Honse (CalcProgrammer1) 09 May 2020 |
|
|
| |
|
|
| This file is part of the OpenRGB project |
|
|
| SPDX-License-Identifier: GPL-2.0-or-later |
|
|
\*---------------------------------------------------------*/
|
|
|
|
#pragma once
|
|
|
|
/*---------------------------------------------------------------------*\
|
|
| OpenRGB SDK protocol version |
|
|
| |
|
|
| 0: Initial (unversioned) protocol |
|
|
| 1: Add versioning, vendor string (Release 0.5) |
|
|
| 2: Add profile controls (Release 0.6) |
|
|
| 3: Add brightness field to modes (Release 0.7) |
|
|
| 4: Add segments field to zones, network plugins (Release 0.9) |
|
|
| 5: Zone flags, controller flags, resizable effects-only zones |
|
|
| (Release Candidate 1.0rc2) |
|
|
| 6: Server name, Features TBD (Release 1.0) |
|
|
\*---------------------------------------------------------------------*/
|
|
#define OPENRGB_SDK_PROTOCOL_VERSION 6
|
|
|
|
/*-----------------------------------------------------*\
|
|
| Default Interface to bind to. |
|
|
\*-----------------------------------------------------*/
|
|
#define OPENRGB_SDK_HOST "0.0.0.0"
|
|
|
|
/*-----------------------------------------------------*\
|
|
| Default OpenRGB SDK port is 6742 |
|
|
| This is "ORGB" on a phone keypad |
|
|
\*-----------------------------------------------------*/
|
|
#define OPENRGB_SDK_PORT 6742
|
|
|
|
/*-----------------------------------------------------*\
|
|
| OpenRGB SDK Magic Value "ORGB" |
|
|
\*-----------------------------------------------------*/
|
|
#define OPENRGB_SDK_MAGIC_SIZE 4
|
|
extern const char openrgb_sdk_magic[OPENRGB_SDK_MAGIC_SIZE];
|
|
|
|
typedef struct NetPacketHeader
|
|
{
|
|
char pkt_magic[4]; /* Magic value "ORGB" identifies beginning of packet */
|
|
unsigned int pkt_dev_idx; /* Device index */
|
|
unsigned int pkt_id; /* Packet ID */
|
|
unsigned int pkt_size; /* Packet size */
|
|
} NetPacketHeader;
|
|
|
|
enum
|
|
{
|
|
/*----------------------------------------------------------------------------------------------------------*\
|
|
| Network requests |
|
|
\*----------------------------------------------------------------------------------------------------------*/
|
|
NET_PACKET_ID_REQUEST_CONTROLLER_COUNT = 0, /* Request RGBController device count from server */
|
|
NET_PACKET_ID_REQUEST_CONTROLLER_DATA = 1, /* Request RGBController data block */
|
|
|
|
NET_PACKET_ID_REQUEST_PROTOCOL_VERSION = 40, /* Request OpenRGB SDK protocol version from server */
|
|
|
|
NET_PACKET_ID_SET_CLIENT_NAME = 50, /* Send client name string to server */
|
|
NET_PACKET_ID_SET_SERVER_NAME = 51, /* Send server name string to client */
|
|
|
|
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 */
|
|
|
|
/*----------------------------------------------------------------------------------------------------------*\
|
|
| ProfileManager functions |
|
|
\*----------------------------------------------------------------------------------------------------------*/
|
|
NET_PACKET_ID_PROFILEMANAGER_GET_PROFILE_LIST = 150, /* Get profile list */
|
|
NET_PACKET_ID_PROFILEMANAGER_SAVE_PROFILE = 151, /* Save current configuration in a new profile */
|
|
NET_PACKET_ID_PROFILEMANAGER_LOAD_PROFILE = 152, /* Load a given profile */
|
|
NET_PACKET_ID_PROFILEMANAGER_DELETE_PROFILE = 153, /* Delete a given profile */
|
|
NET_PACKET_ID_PROFILEMANAGER_UPLOAD_PROFILE = 154, /* Upload a profile to the server in JSON format */
|
|
NET_PACKET_ID_PROFILEMANAGER_DOWNLOAD_PROFILE = 155, /* Download a profile from the server in JSON format*/
|
|
NET_PACKET_ID_PROFILEMANAGER_GET_ACTIVE_PROFILE = 156, /* Get the active profile name */
|
|
|
|
/*----------------------------------------------------------------------------------------------------------*\
|
|
| PluginManager functions |
|
|
\*----------------------------------------------------------------------------------------------------------*/
|
|
NET_PACKET_ID_PLUGINMANAGER_GET_PLUGIN_LIST = 200, /* Get list of plugins */
|
|
NET_PACKET_ID_PLUGINMANAGER_PLUGIN_SPECIFIC = 201, /* Interact with a plugin */
|
|
|
|
/*----------------------------------------------------------------------------------------------------------*\
|
|
| SettingsManager functions |
|
|
\*----------------------------------------------------------------------------------------------------------*/
|
|
NET_PACKET_ID_SETTINGSMANAGER_GET_SETTINGS = 250, /* Get settings for a given key in JSON format */
|
|
NET_PACKET_ID_SETTINGSMANAGER_SET_SETTINGS = 251, /* Set settings for a given key in JSON format */
|
|
NET_PACKET_ID_SETTINGSMANAGER_SAVE_SETTINGS = 252, /* Save settings */
|
|
|
|
/*----------------------------------------------------------------------------------------------------------*\
|
|
| RGBController functions |
|
|
\*----------------------------------------------------------------------------------------------------------*/
|
|
NET_PACKET_ID_RGBCONTROLLER_RESIZEZONE = 1000, /* RGBController::ResizeZone() */
|
|
NET_PACKET_ID_RGBCONTROLLER_CLEARSEGMENTS = 1001, /* RGBController::ClearSegments() */
|
|
NET_PACKET_ID_RGBCONTROLLER_ADDSEGMENT = 1002, /* RGBController::AddSegment() */
|
|
|
|
NET_PACKET_ID_RGBCONTROLLER_UPDATELEDS = 1050, /* RGBController::UpdateLEDs() */
|
|
NET_PACKET_ID_RGBCONTROLLER_UPDATEZONELEDS = 1051, /* RGBController::UpdateZoneLEDs() */
|
|
NET_PACKET_ID_RGBCONTROLLER_UPDATESINGLELED = 1052, /* RGBController::UpdateSingleLED() */
|
|
|
|
NET_PACKET_ID_RGBCONTROLLER_SETCUSTOMMODE = 1100, /* RGBController::SetCustomMode() */
|
|
NET_PACKET_ID_RGBCONTROLLER_UPDATEMODE = 1101, /* RGBController::UpdateMode() */
|
|
NET_PACKET_ID_RGBCONTROLLER_SAVEMODE = 1102, /* RGBController::SaveMode() */
|
|
};
|
|
|
|
void InitNetPacketHeader
|
|
(
|
|
NetPacketHeader * pkt_hdr,
|
|
unsigned int pkt_dev_idx,
|
|
unsigned int pkt_id,
|
|
unsigned int pkt_size
|
|
);
|