Update Readme

This commit is contained in:
glax 2024-02-01 23:07:48 +01:00
parent 65059f66ed
commit f939e79e69

View File

@ -7,45 +7,40 @@ Library to interact with Shock-Collars that are remotely controllable via ESP32-
```csharp ```csharp
public static void Main(string[] args){ public static void Main(string[] args){
List<string> shockerIds = new();
IntensityRange intensityRange = new IntensityRange(30, 50); IntensityRange intensityRange = new IntensityRange(30, 50);
DurationRange durationRange = new DurationRange(1000, 2000); DurationRange durationRange = new DurationRange(1000, 2000);
string apiKey = ":)"; string apiKey = ":)";
OpenShockHttp openShockHttp = new OpenShockHttp(shockerIds, intensityRange, durationRange, apiKey);
openShockHttp.ShockerIds.AddRange(openShockHttp.GetShockers());
string username = "username"; OpenShockHttp openShockHttp = new (intensityRange, durationRange, apiKey);
string shareCode = "sharecode"; OpenShockShocker shocker1 = openShockHttp.GetShockers(apiKey).First();
PiShockHttp piShockHttp = new PiShockHttp(shockerIds, intensityRange, durationRange, apiKey, username, shareCode, apiUri); shocker1.Control(ControlAction.Vibrate, 20, 1000);
ControlAction action = ControlAction.Shock; shocker1.Dispose();
openShockHttp.Control(action, shockerIds.First(), 20, 1000);
piShockHttp.Control(action); List<SerialPortInfo> serialPorts = SerialHelper.GetSerialPorts();
int selectedPort = 1;
OpenShockSerial openShockSerial = new(intensityRange, durationRange, serialPorts[selectedPort], apiKey);
OpenShockShocker shocker2 = openShockSerial.GetShockers(apiKey).First();
shocker2.Control(ControlAction.Vibrate, 20, 1000);
shocker2.Dispose();
} }
``` ```
## `Shocker.Control` ## `Shocker.Control`
```csharp ```csharp
Control(ControlAction action, string? shockerId = null, int? intensity = null, int? duration = null) Control(ControlAction action, int? intensity = null, int? duration = null)
``` ```
If `shockerId` is `null`, all IDs will be used. If `intensity` or `duration` are `null`, a random value within the If `intensity` or `duration` are `null`, a random value within the
configured range will be used. configured range will be used.
### ControlAction ### ControlAction
From [here](https://github.com/C9Glax/CShocker/blob/master/CShocker/Shockers/ControlAction.cs) From [here](https://github.com/C9Glax/CShocker/blob/master/CShocker/Devices/Additional/ControlActionEnum.cs)
## Variables ## Variables
### ApiKey ### ApiKey
- For OpenShock (HTTP) get token [here](https://shocklink.net/#/dashboard/tokens) - For OpenShock (HTTP) get token [here](https://shocklink.net/#/dashboard/tokens)
- For PiShock (HTTP) get information [here](https://apidocs.pishock.com/#header-authenticating)
### ShockerIds
List of Shocker-Ids, comma seperated.
`[ "ID-1-asdasd", "ID-2-fghfgh" ]`
OpenShockHttp also can retrieve IDs automatically.
### Intensity Range ### Intensity Range
in percent in percent
@ -57,8 +52,9 @@ in ms
- `0-30000` OpenShock - `0-30000` OpenShock
- `0-15000` PiShock - `0-15000` PiShock
### Username (PiShockHttp only) ## Future
For PiShock (HTTP) get information [here](https://apidocs.pishock.com/#header-authenticating) ### ~~Username (PiShockHttp only)~~
~~For PiShock (HTTP) get information [here](https://apidocs.pishock.com/#header-authenticating)~~
### Sharecode (PiShockHttp only) ### ~~Sharecode (PiShockHttp only)~~
For PiShock (HTTP) get information [here](https://apidocs.pishock.com/#header-authenticating) ~~For PiShock (HTTP) get information [here](https://apidocs.pishock.com/#header-authenticating)~~