mirror of
https://github.com/SlimeVR/SlimeVR-Tracker-ESP.git
synced 2026-04-06 02:01:57 +02:00
51 lines
1.6 KiB
C++
51 lines
1.6 KiB
C++
#ifndef _UDP_CLIENT_H_
|
|
#define _UDP_CLIENT_H_
|
|
|
|
#include <ESP8266WiFi.h>
|
|
#include <WiFiUdp.h>
|
|
#include <Arduino.h>
|
|
#include "quat.h"
|
|
#include "configuration.h"
|
|
|
|
#define PACKET_ROTATION 1
|
|
#define PACKET_GYRO 2
|
|
#define PACKET_HANDSHAKE 3
|
|
#define PACKET_ACCEL 4
|
|
#define PACKET_MAG 5
|
|
#define PACKET_RAW_CALIBRATION_DATA 6
|
|
#define PACKET_GYRO_CALIBRATION_DATA 7
|
|
#define PACKET_CONFIG 8
|
|
#define PACKET_RAW_MAGENTOMETER 9
|
|
#define PACKET_PING_PONG 10
|
|
#define PACKET_SERIAL 11
|
|
#define PACKET_BATTERY_LEVEL 12
|
|
|
|
#define PACKET_RECIEVE_HEARTBEAT 1
|
|
#define PACKET_RECIEVE_VIBRATE 2
|
|
#define PACKET_RECIEVE_HANDSHAKE 3
|
|
#define PACKET_RECIEVE_COMMAND 4
|
|
|
|
#define COMMAND_CALLIBRATE 1
|
|
#define COMMAND_SEND_CONFIG 2
|
|
#define COMMAND_BLINK 3
|
|
|
|
typedef void (* configRecievedCallback)(DeviceConfig const newConfig);
|
|
typedef void (* commandRecievedCallback)(int command, void * const commandData, int commandDataLength);
|
|
|
|
void connectClient();
|
|
void clientUpdate();
|
|
void sendQuat(float * const quaternion, int type);
|
|
void sendQuat(Quat * const quaternion, int type);
|
|
void sendVector(float * const result, int type);
|
|
void sendConfig(DeviceConfig * const config, int type);
|
|
void sendFloat(float const value, int type);
|
|
void sendRawCalibrationData(int * const data, int type);
|
|
void setConfigRecievedCallback(configRecievedCallback);
|
|
void setCommandRecievedCallback(commandRecievedCallback);
|
|
void setUpWiFi(DeviceConfig * const config);
|
|
bool isConnected();
|
|
|
|
template<typename T> T convert_chars(unsigned char* src);
|
|
template<typename T> unsigned char* convert_to_chars(T src, unsigned char* target);
|
|
|
|
#endif // _UDP_CLIENT_H_
|