This is a TCP Socket Server template for the RPI Pico W with features like AES 256 CTR encryption, JSON, Ping System
APACHE-2.0 License
This template includes example code for the following services
WARNING, be careful on how you do your wiring or you might damage something
The current features of this template. For the defaults of the features check the Config
section
FLASH_SERIAL_NUMBER
as HEX
The server.cpp
could stay untouched, for parsing the data you can just check handler.cpp
, after the request is processed the data is sent to the handler along with the client from which you can respond back.
You can keep the connection alive in order to have real time responses
The packet format is number_of_characters;data
e.g. 4;demo
Path: src/config.h
Code:
#ifndef __CONFIG_H__
#define __CONFIG_H__
#include "pico/cyw43_arch.h"
#define COUNTRY_CODE_0 'U'
#define COUNTRY_CODE_1 'S'
#define WIFI_AUTH CYW43_AUTH_WPA2_AES_PSK
#define WIFI_PASSWORD "PASSWORD"
#define FIRMWARE_VERSION "0.1.0" // Your version
#define WIFI_SSID "SSID"
/**
* 1 - Thermostat
* 2 - Desk
*/
#define SERVICE_TYPE 2
// TCP SERVER
#define TCP_SERVER_PORT 8098
#define TCP_SERVER_BUF_SIZE 2048
#define TCP_SERVER_POLL_TIME_S 5
#define TCP_SERVER_MAX_CLIENTS 5
#define TCP_SERVER_INACTIVE_TIME_S 35
// ENCRYPTION
// To disable encryption do not define this variable
#define AES_ENCRYPTION_KEY "32-BYTES-KEY-IN-BASE64"
#endif