6 Commits

Author SHA1 Message Date
kenji 722a9b489b suppress HID messages when device is disconnected 2026-05-08 12:25:54 -04:00
kenji e3620971b1 add schematic 2025-09-11 12:28:02 -04:00
kenji 8082191d4e Add original Pico support 2025-09-06 12:15:42 -04:00
kenji cc57b02d8c Fix WebSocket extended length 2025-09-06 11:30:48 -04:00
kenji 1414d915a4 minor UI and adaptive lighting tweaks 2025-08-28 21:46:44 -04:00
kenji dc961ce480 cleanup 2025-08-27 08:13:20 -04:00
15 changed files with 15621 additions and 763 deletions
+2 -2
View File
@@ -1,2 +1,2 @@
/build/**/* /*/**/*
/external/**/* !/html/**/*
+9 -2
View File
@@ -2,7 +2,9 @@ set(PROJECT aw410k_rgb)
cmake_minimum_required(VERSION 3.13) cmake_minimum_required(VERSION 3.13)
set(PICO_SDK_PATH /home/kenji/programming/pico/c/pico-sdk) set(PICO_SDK_PATH /home/kenji/programming/pico/c/pico-sdk)
set(PICO_PIO_USB_PATH /home/kenji/programming/pico/c/Pico-PIO-USB) set(PICO_PIO_USB_PATH /home/kenji/programming/pico/c/Pico-PIO-USB)
set(PICO_BOARD pico2) if (NOT DEFINED PICO_BOARD)
set(PICO_BOARD pico)
endif()
set(TUSB_NETWORKING_PATH ${PICO_SDK_PATH}/lib/tinyusb/lib/networking) set(TUSB_NETWORKING_PATH ${PICO_SDK_PATH}/lib/tinyusb/lib/networking)
include (${PICO_SDK_PATH}/external/pico_sdk_import.cmake) include (${PICO_SDK_PATH}/external/pico_sdk_import.cmake)
project(${PROJECT} C CXX ASM) project(${PROJECT} C CXX ASM)
@@ -49,7 +51,10 @@ target_compile_options(${PROJECT} PRIVATE ) #-Wall -Wextra
target_compile_definitions(${PROJECT} PRIVATE PIO_USB_USE_TINYUSB) target_compile_definitions(${PROJECT} PRIVATE PIO_USB_USE_TINYUSB)
# needed so tinyusb can find tusb_config.h # needed so tinyusb can find tusb_config.h
target_include_directories(${PROJECT} PRIVATE ${CMAKE_CURRENT_LIST_DIR} ${TUSB_NETWORKING_PATH}) target_include_directories(${PROJECT} PRIVATE
${CMAKE_CURRENT_LIST_DIR}
${TUSB_NETWORKING_PATH}
)
target_link_libraries(${PROJECT} PRIVATE target_link_libraries(${PROJECT} PRIVATE
pico_lwip pico_lwip
@@ -65,5 +70,7 @@ target_link_libraries(${PROJECT} PRIVATE
hardware_adc hardware_adc
) )
set_target_properties(${PROJECT} PROPERTIES OUTPUT_NAME "${PROJECT}-${PICO_BOARD}")
pico_add_extra_outputs(${PROJECT}) pico_add_extra_outputs(${PROJECT})
+17 -13
View File
@@ -2,34 +2,38 @@
This project provides control to the RGB lighting on an Alienware AW410K This project provides control to the RGB lighting on an Alienware AW410K
keyboard based on ADC readings from an attached light dependent resistor using keyboard based on ADC readings from an attached light dependent resistor using
a webpage served by a Raspberry Pi Pico 2. Each key on the keyboard is a webpage served by a Raspberry Pi Pico (2). Each key on the keyboard is
individually configurable from the webpage and can be set to automatically individually configurable from the webpage and can be set to automatically
adjust brightness based off the ambient lighting. adjust brightness based off the ambient lighting.
![Keyboard lighting changing with light on a LDR](ambient.gif) ![Keyboard lighting changing with light on a LDR](ambient.gif)
[YouTube Video](https://youtu.be/uY1V1W5CdWM)
## Setup ## Setup
### Hardware ### Hardware
You will need the following hardware to make the device: You will need the following hardware to make the device:
- Raspberry Pi Pico 2 - Raspberry Pi Pico or Raspbery Pi Pico 2
- USB extension cable - USB extension cable
- light dependent resistor such as GL5528 (specific part number may vary) - light dependent resistor such as GL5528 (specific part number may vary)
- 10k ohm resistor (resistance value may vary) - 10k ohm resistor (resistance value may vary)
![Wiring schematic](schematic.svg)
You will need to cut the USB extension in half and connect the wires from the You will need to cut the USB extension in half and connect the wires from the
female end to the Raspberry Pi Pico 2. The default configuration is to attach female end to the Raspberry Pi Pico (2). The default configuration is to attach
the USB's green wire to pin 1/GP0 and USB's white wire to pin 2/GP1. You will the USB's green wire to pin 1/GP0 and USB's white wire to pin 2/GP1. You will
also need to connect the red to 5V VBUS/VSYS (since you'll be powering from the also need to connect the red to 5V VBUS/VSYS (since you'll be powering from the
USB host device, VBUS should be fine) and the black to any ground pin. Pin 38 USB host device, VBUS should be fine) and the black to any ground pin. Pin 38
is the closest and most convenient. While you can connect the Raspberry Pi Pico is the closest and most convenient. While you can connect the Raspberry Pi Pico
to the host device using the micro USB port and a micro USB cable, since (2) to the host device using the micro USB port and a micro USB cable, since
you have already sacrificed half of the USB extension cable, you might as well you have already sacrificed half of the USB extension cable, you might as well
use the male half to create a standard USB-A connection. If you wish to do so, use the male half to create a standard USB-A connection. If you wish to do so,
then simply connect the red and black wires of the male connector end to then simply connect the red and black wires of the male connector end to
VBUS (5V) and GND, respectively. For the data wires, you can solder them to the VBUS (5V) and GND, respectively. For the data wires, you can solder them to the
two test points TP2 and TP3 on the back of the Raspberry Pi Pico 2. The white two test points TP2 and TP3 on the back of the Raspberry Pi Pico (2). The white
cable goes to TP2 and the green cable to TP3. cable goes to TP2 and the green cable to TP3.
![Back of Raspberry Pi Pico with USB connections to TP2 and TP3](back.jpg) ![Back of Raspberry Pi Pico with USB connections to TP2 and TP3](back.jpg)
@@ -43,8 +47,8 @@ the following.
The individual wires on the USB can be fragile, so hot glue or other strain The individual wires on the USB can be fragile, so hot glue or other strain
relief is a good idea. There is also a [model for a 3D printed relief is a good idea. There is also a [model for a 3D printed
enclosure](pico-usb-ldr.stl) that you can use to place the Pico inside with a enclosure](pico-usb-ldr.stl) that you can use to place the Pico (2) inside with
hole for the LDR to detect ambient light. a hole for the LDR to detect ambient light.
![3D printed enclosure with finished device](enclosure.jpg) ![3D printed enclosure with finished device](enclosure.jpg)
@@ -52,8 +56,8 @@ hole for the LDR to detect ambient light.
Flash the aw410k_rgb.uf2 file found from the latest Flash the aw410k_rgb.uf2 file found from the latest
[release](https://git.kkozai.com/kenji/aw410k_rgb/releases) to the Raspberry Pi [release](https://git.kkozai.com/kenji/aw410k_rgb/releases) to the Raspberry Pi
Pico 2, and connect the keyboard to the female USB port and insert the male USB Pico (2), and connect the keyboard to the female USB port and insert the male
connector of the device into your host device such as PC. USB connector of the device into your host device such as PC.
To load the UI for configuring the RGB lighting, open a browser to the page To load the UI for configuring the RGB lighting, open a browser to the page
at http://aw410k.usb, or if that doesn't load, to http://192.168.40.1. From the at http://aw410k.usb, or if that doesn't load, to http://192.168.40.1. From the
@@ -64,10 +68,10 @@ selected key(s), click on the "Set Color" button.
![Interface for setting the color of individual keys](ui.jpg) ![Interface for setting the color of individual keys](ui.jpg)
To save the lighting configuration to the Pico 2 so that it loads the next time To save the lighting configuration to the Pico (2) so that it loads the next
it is powered on, click on the "Save" button under the "Flash Memory" section. time it is powered on, click on the "Save" button under the "Flash Memory"
If you make unsaved changes and want to reload the configuration from memory, section. If you make unsaved changes and want to reload the configuration from
you can also click the "Load" button to reset to the last saved setting. memory, you can also click the "Load" button to reset to the last saved setting.
If the checkbox next to "Adaptive" is selected when setting the color, the key's If the checkbox next to "Adaptive" is selected when setting the color, the key's
brightness will automatically adjust with the ambient lighting, as determined by brightness will automatically adjust with the ambient lighting, as determined by
+38 -26
View File
@@ -1,4 +1,5 @@
#include <stdlib.h> #include <stdlib.h>
#include <math.h>
#include "pico/stdlib.h" #include "pico/stdlib.h"
#include "pico/multicore.h" #include "pico/multicore.h"
@@ -13,7 +14,7 @@
static absolute_time_t lastSend; static absolute_time_t lastSend;
static absolute_time_t lastRead; static absolute_time_t lastRead;
static uint16_t adc_value = 0; static uint8_t adc_value = 0;
static bool mute = false; static bool mute = false;
static unsigned char buf[BUF_SIZE]; static unsigned char buf[BUF_SIZE];
@@ -29,7 +30,8 @@ static void send_color(uint8_t dev_addr);
static void send_initial(uint8_t dev_addr); static void send_initial(uint8_t dev_addr);
static struct key * find_key(char * name); static struct key * find_key(char * name);
static void set_color(char * name, uint8_t red, uint8_t green, uint8_t blue, uint8_t mode); static void set_color(char * name, uint8_t red, uint8_t green, uint8_t blue, uint8_t mode);
static void set_color_all(uint8_t red, uint8_t green, uint8_t blue, uint8_t mode); static uint8_t hexint (const char c);
static uint8_t hexbyte (const char * s);
static struct key key_list[NUM_KEYS] = static struct key key_list[NUM_KEYS] =
{ {
@@ -144,9 +146,8 @@ static struct key key_list[NUM_KEYS] =
void get_light() { void get_light() {
// get ADC reading from LDR every 500ms // get ADC reading from LDR every 500ms
// if above threshold, set backlight to off
if ( absolute_time_diff_us(lastRead, get_absolute_time()) >= 500000) { if ( absolute_time_diff_us(lastRead, get_absolute_time()) >= 500000) {
adc_value = adc_read(); adc_value = log2(adc_read());
} }
} }
@@ -188,9 +189,9 @@ static void send_color(uint8_t dev_addr) {
buf[buf_idx+5] = 0x0A; buf[buf_idx+5] = 0x0A;
switch (key_list[key_idx].mode) { switch (key_list[key_idx].mode) {
case RGB_MODE_ADAPTIVE: // adjust brightness based on LDR ADC reading case RGB_MODE_ADAPTIVE: // adjust brightness based on LDR ADC reading
buf[buf_idx+6] = (ADC_MAX-adc_value)*key_list[key_idx].red/ADC_MAX; buf[buf_idx+6] = (ADC_MAX_LOG2-adc_value)*key_list[key_idx].red/ADC_MAX_LOG2;
buf[buf_idx+7] = (ADC_MAX-adc_value)*key_list[key_idx].green/ADC_MAX; buf[buf_idx+7] = (ADC_MAX_LOG2-adc_value)*key_list[key_idx].green/ADC_MAX_LOG2;
buf[buf_idx+8] = (ADC_MAX-adc_value)*key_list[key_idx].blue/ADC_MAX; buf[buf_idx+8] = (ADC_MAX_LOG2-adc_value)*key_list[key_idx].blue/ADC_MAX_LOG2;
break; break;
case RGB_MODE_MUTE: case RGB_MODE_MUTE:
if (mute) { if (mute) {
@@ -316,20 +317,6 @@ static void set_color(char * name, uint8_t red, uint8_t green, uint8_t blue, uin
} }
} }
// set RGB color for all keys
static void set_color_all(uint8_t red, uint8_t green, uint8_t blue, uint8_t mode) {
for (uint8_t i=0; i<NUM_KEYS; i++) {
key_list[i].red = red;
key_list[i].green = green;
key_list[i].blue = blue;
// don't change modes on MUTE only to preserve toggling behavior
// user can set manually from GUI if desired
if (key_list[i].val != KEY_MUTE) {
key_list[i].mode = mode;
}
}
}
// parse color request from webpage and update keyboard colors // parse color request from webpage and update keyboard colors
void parse_colors(char * data, uint16_t len) { void parse_colors(char * data, uint16_t len) {
(void) len; (void) len;
@@ -341,7 +328,9 @@ void parse_colors(char * data, uint16_t len) {
if (token != NULL) { if (token != NULL) {
// first string is the RGB color code // first string is the RGB color code
uint8_t red, green, blue; uint8_t red, green, blue;
sscanf(token, "%02x%02x%02x", &red, &green, &blue); red = hexbyte(token);
green = hexbyte(token+2);
blue = hexbyte(token+4);
token = strtok(NULL, ","); token = strtok(NULL, ",");
if (token != NULL) { if (token != NULL) {
@@ -387,12 +376,17 @@ void startADC() {
// forward HID report after processing // forward HID report after processing
bool forward_report(uint8_t instance, uint8_t const* report, uint16_t len) { bool forward_report(uint8_t instance, uint8_t const* report, uint16_t len) {
// toggle mute button color if mute button is pressed // forward only if device is connected
if ( instance == 0x02 && report[0] == 0x02 && (report[2] & 0x01) ) { if (device_state == DEVICE_ACTIVE) {
mute = !mute; // toggle mute button color if mute button is pressed
if ( instance == 0x02 && report[0] == 0x02 && (report[2] & 0x01) ) {
mute = !mute;
}
return tud_hid_n_report(instance, 0, report, len);
} }
return tud_hid_n_report(instance, 0, report, len); return true;
} }
// save RGB configuration to flash // save RGB configuration to flash
@@ -447,3 +441,21 @@ bool load_rgb_config(void) {
tud_cdc_write_str("Configuration failed to load\n"); tud_cdc_write_str("Configuration failed to load\n");
return false; return false;
} }
// simple helper to convert hex char to uint8_t value
static uint8_t hexint (const char c) {
if (c >= '0' && c <= '9') {
return c - '0';
} else if ( c >= 'a' && c <= 'f') {
return c - 'a' + 10;
} else if (c >= 'A' && c <= 'F') {
return c- 'A' + 10;
} else {
return 0;
}
}
// simple helper to convert 2 hex characters into a byte (uint8_t)
static uint8_t hexbyte (const char * s) {
return (hexint(s[0]) << 4) | (hexint(s[1]));
}
+8 -1
View File
@@ -11,6 +11,7 @@
#define NUM_KEYS 107 #define NUM_KEYS 107
#define BUF_SIZE 64 #define BUF_SIZE 64
#define ADC_MAX 4096 #define ADC_MAX 4096
#define ADC_MAX_LOG2 log2(ADC_MAX)
enum { enum {
RGG_MODE_INVALID=0, RGG_MODE_INVALID=0,
@@ -150,6 +151,12 @@ bool load_rgb_config(void);
#define CFG_SIGNATURE 0xa22e #define CFG_SIGNATURE 0xa22e
#define FLASH_TARGET_OFFSET (PICO_FLASH_SIZE_BYTES - FLASH_BLOCK_SIZE - FLASH_SECTOR_SIZE) #if PICO_RP2040
#define FLASH_TARGET_OFFSET (PICO_FLASH_SIZE_BYTES - FLASH_SECTOR_SIZE)
#elif PICO_RP2350
#define FLASH_TARGET_OFFSET (PICO_FLASH_SIZE_BYTES - FLASH_BLOCK_SIZE - FLASH_SECTOR_SIZE)
#else
#error "Unsupported device. Expected RP2040 or RP2350."
#endif
#endif #endif
+12 -6
View File
@@ -142,7 +142,7 @@ const keyboard_list = [
{id: "Numpad7", label: "Home<br>7"}, {id: "Numpad7", label: "Home<br>7"},
{id: "Numpad8", label: "Up<br>8"}, {id: "Numpad8", label: "Up<br>8"},
{id: "Numpad9", label: "PgUp<br>9"}, {id: "Numpad9", label: "PgUp<br>9"},
{id: "NumpadAdd", label: "+", height: 2} {id: "NumpadAdd", label: "+", height: 2.2}
], ],
[ [
{id: "CapsLock", label: "Caps<br>Lock", width: 2}, {id: "CapsLock", label: "Caps<br>Lock", width: 2},
@@ -157,8 +157,8 @@ const keyboard_list = [
{id: "KeyL", label: "L"}, {id: "KeyL", label: "L"},
{id: "Semicolon", label: ":<br>;"}, {id: "Semicolon", label: ":<br>;"},
{id: "Quote", label: "\"<br>\'"}, {id: "Quote", label: "\"<br>\'"},
{id: "Enter", label: "Enter", width: 2.3}, {id: "Enter", label: "Enter", width: 2.2},
{id: "", label: "", width: 3.4}, {id: "", label: "", width: 3.55},
{id: "Numpad4", label: "Left<br>4"}, {id: "Numpad4", label: "Left<br>4"},
{id: "Numpad5", label: "5"}, {id: "Numpad5", label: "5"},
{id: "Numpad6", label: "Right<br>6"} {id: "Numpad6", label: "Right<br>6"}
@@ -182,7 +182,7 @@ const keyboard_list = [
{id: "Numpad1", label: "End<br>1"}, {id: "Numpad1", label: "End<br>1"},
{id: "Numpad2", label: "Down<br>2"}, {id: "Numpad2", label: "Down<br>2"},
{id: "Numpad3", label: "PgDn<br>3"}, {id: "Numpad3", label: "PgDn<br>3"},
{id: "NumpadEnter", label: "Enter", height: 2} {id: "NumpadEnter", label: "Enter", height: 2.2}
], ],
[ [
{id: "ControlLeft", label: "Control", width: 2}, {id: "ControlLeft", label: "Control", width: 2},
@@ -192,11 +192,11 @@ const keyboard_list = [
{id: "AltRight", label: "Alt", width: 2}, {id: "AltRight", label: "Alt", width: 2},
{id: "MetaRight", label: "FN"}, {id: "MetaRight", label: "FN"},
{id: "ContextMenu", label:"Menu"}, {id: "ContextMenu", label:"Menu"},
{id: "ControlRight", label: "Control", width: 1.7}, {id: "ControlRight", label: "Control", width: 1.6},
{id: "ArrowLeft", label: "Left"}, {id: "ArrowLeft", label: "Left"},
{id: "ArrowDown", label: "Down"}, {id: "ArrowDown", label: "Down"},
{id: "ArrowRight", label: "Right"}, {id: "ArrowRight", label: "Right"},
{id: "Numpad0", label: "Ins<br>0", width: 2}, {id: "Numpad0", label: "Ins<br>0", width: 2.2},
{id: "NumpadDecimal", label: "Del<br>."} {id: "NumpadDecimal", label: "Del<br>."}
], ],
]; ];
@@ -339,6 +339,12 @@ function updateColor() {
channel.value = 255; channel.value = 255;
} else if (parseInt(channel.value) < 0) { } else if (parseInt(channel.value) < 0) {
channel.value = 0; channel.value = 0;
} else if ( isNaN(parseInt(channel.value)) ) {
// non-numerical value entered, set to default
channel.value = 128;
} else {
// make sure that value in box reflects what parser thinks
channel.value = parseInt(channel.value);
} }
} }
+715 -690
View File
File diff suppressed because it is too large Load Diff
+14802
View File
File diff suppressed because it is too large Load Diff

After

Width:  |  Height:  |  Size: 268 KiB

-4
View File
@@ -96,10 +96,6 @@
#define CFG_TUD_HID_EP_BUFSIZE 64 #define CFG_TUD_HID_EP_BUFSIZE 64
// NCM settings
//#define CFG_TUD_NCM_OUT_MAX_DATAGRAMS_PER_NTB 1
//#define CFG_TUD_NCM_IN_MAX_DATAGRAMS_PER_NTB 1
//-------------------------------------------------------------------- //--------------------------------------------------------------------
// HOST CONFIGURATION // HOST CONFIGURATION
//-------------------------------------------------------------------- //--------------------------------------------------------------------
BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 58 KiB

After

Width:  |  Height:  |  Size: 89 KiB

+11 -12
View File
@@ -73,24 +73,23 @@ void usb_device_main(void) {
device_state = DEVICE_INACTIVE; device_state = DEVICE_INACTIVE;
usb_device_init(); usb_device_init();
// start the web server on USB
usb_server_init(); usb_server_init();
while (true) { while (true) {
switch ( device_state ) { switch ( device_state ) {
case DEVICE_ACTIVE: case DEVICE_ACTIVE:
if (!tud_mounted()) {
device_state = DEVICE_INACTIVE;
}
break; break;
case DEVICE_INACTIVE: case DEVICE_INACTIVE:
break; break;
case DEVICE_RESTART: case DEVICE_RESTART:
if (tud_disconnect()) { if (tud_disconnect()) {
device_state = DEVICE_INACTIVE;
sleep_ms(10); sleep_ms(10);
if (tud_connect()) { tud_connect();
if ( host_state == HOST_INACTIVE ) {
device_state = DEVICE_INACTIVE;
} else {
device_state = DEVICE_ACTIVE;
}
}
} }
break; break;
default: default:
@@ -242,6 +241,11 @@ uint16_t tud_hid_get_report_cb(uint8_t instance, uint8_t report_id, hid_report_t
return 0; return 0;
} }
// Invoked when device is mounted
void tud_mount_cb(void) {
device_state = DEVICE_ACTIVE;
}
// print message to CDC in raw hex // print message to CDC in raw hex
void cdc_print_hex(uint8_t const* msg, uint16_t msg_len) { void cdc_print_hex(uint8_t const* msg, uint16_t msg_len) {
(void) msg; (void) msg;
@@ -252,8 +256,3 @@ void cdc_print_hex(uint8_t const* msg, uint16_t msg_len) {
} }
tud_cdc_write_str("\n"); tud_cdc_write_str("\n");
} }
// print message to CDC
void cdc_print(uint8_t const* msg, uint16_t msg_len) {
tud_cdc_write(msg, msg_len);
}
-1
View File
@@ -37,7 +37,6 @@ extern device_state_t device_state;
void usb_device_main(void); void usb_device_main(void);
void cdc_print_hex(uint8_t const* msg, uint16_t msg_len); void cdc_print_hex(uint8_t const* msg, uint16_t msg_len);
void cdc_print(uint8_t const* msg, uint16_t msg_len);
#endif #endif
+1 -1
View File
@@ -251,7 +251,7 @@ static void report_desc_init(struct report_desc *descriptor) {
descriptor->next = NULL; descriptor->next = NULL;
} }
// free memory and teardown usb->bt report ID mappings for report descriptor struct // free memory for report descriptor struct
static void report_desc_free(struct report_desc *descriptor) { static void report_desc_free(struct report_desc *descriptor) {
if (descriptor != NULL) { if (descriptor != NULL) {
if (descriptors == descriptor) { if (descriptors == descriptor) {
+5 -4
View File
@@ -354,12 +354,14 @@ static err_t ws_read(struct altcp_pcb *pcb, struct ws_state *wss, struct pbuf *p
uint8_t masked = data[1] & 0x80; uint8_t masked = data[1] & 0x80;
uint16_t msg_len = data[1] & 0x7F; uint16_t msg_len = data[1] & 0x7F;
uint8_t *msg; uint8_t *msg;
uint8_t *mask;
switch (msg_len) { switch (msg_len) {
case 126: // next two bytes are length case 126: // next two bytes are length
memcpy(&msg_len, &data[2], 2); msg_len = ( (uint16_t)data[2] << 8) | data[3];
if (len >= 8) { if (len >= 8) {
msg = &data[8]; msg = &data[8];
mask = &data[4];
} }
break; break;
case 127: // next four bytes are length case 127: // next four bytes are length
@@ -369,6 +371,7 @@ static err_t ws_read(struct altcp_pcb *pcb, struct ws_state *wss, struct pbuf *p
default: default:
if (len >= 6) { if (len >= 6) {
msg = &data[6]; msg = &data[6];
mask = &data[2];
} }
break; break;
} }
@@ -382,8 +385,6 @@ static err_t ws_read(struct altcp_pcb *pcb, struct ws_state *wss, struct pbuf *p
if (msg && ws_receive_cb != NULL) { if (msg && ws_receive_cb != NULL) {
// unmask the data if mask bit is received // unmask the data if mask bit is received
if (masked) { if (masked) {
uint8_t *mask = &data[2];
for (int i=0; i<msg_len; i++) { for (int i=0; i<msg_len; i++) {
msg[i] ^= mask[i % 4]; msg[i] ^= mask[i % 4];
} }
+1 -1
View File
@@ -7,7 +7,7 @@
#define WS_MAX_RETRIES 10 #define WS_MAX_RETRIES 10
#define WS_POLL_INTERVAL 60 // WS_POLL_INTERVAL/2 seconds #define WS_POLL_INTERVAL 60 // WS_POLL_INTERVAL/2 seconds
#define WS_MAX_CONN 4 #define WS_MAX_CONN 4
#define WS_BUFFER_SIZE 512 #define WS_BUFFER_SIZE 1024
#define OP_CONT 0x00 #define OP_CONT 0x00
#define OP_TEXT 0x01 #define OP_TEXT 0x01