Skip to content

Commit 90872af

Browse files
Dev (#6)
* feat: local server for development without board * fix (server): add logging and timing * redacted the api specs (mostly) * updated api config endpoint * Got rid of AsyncElegantOTA, lost some weight, temporary cheap ui for file input testing (web ota) * Added description of the replica control api (not implemented yet) * Added version api ressource, little refactor of configuration module, rearanged build flow (yes, not the right branch for that, meh) * Added the handlers for replica components API * refactored components to use only static methods and members * replica component apis now working * Fixed some hhtp return codes end reinforced selector state api * Added unlimited wifi capability, and updated api readme * feat (server): Update local server specification * feat: UI v2.0.1 * fix: remove unused files * feat: REAME V2 * Fix (readme): add developers * style (readme): add escape tags * fix (readme): use svg to diplay advanced html * Implemented "enable precocking" and "uncock after x seconds" * fixed a little bug on saving config * Add node_modules to .gitignore * added missing api ressources in readme Co-authored-by: Zao Soula <[email protected]>
1 parent 3f053ed commit 90872af

33 files changed

+2764
-996
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
.vscode/c_cpp_properties.json
44
.vscode/launch.json
55
.vscode/ipch
6+
node_modules/

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"string": "cpp",
77
"vector": "cpp",
88
"unordered_map": "cpp",
9-
"regex": "cpp"
9+
"regex": "cpp",
10+
"functional": "cpp"
1011
}
1112
}

README.md

Lines changed: 106 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,106 @@
1-
# openmosfet
21

3-
OpenMosfet is a high quality open source airsoft mosfet based on arduino (currently esp32 board).
2+
[![Open Source? Yes!](https://badgen.net/badge/Open%20Source%20%3F/Yes%21/green?icon=github)](https://github.com/simonjamain/openmosfet)
3+
[![Maintenance](https://badgen.net/badge/Maintained%20%3F/Yes%21/green?icon=github)](https://github.com/simonjamain/openmosfet/graphs/commit-activity)
4+
![GitHub tag (latest SemVer)](https://img.shields.io/github/v/tag/simonjamain/openmosfet)
5+
6+
<br/>
7+
<p align="center">
8+
<a href="https://github.com/othneildrew/Best-README-Template">
9+
<img src="doc/assets/images/logo.png" alt="Logo" width="80" height="80">
10+
</a>
11+
12+
<h3 align="center">OpenMosfet</h3>
13+
14+
<p align="center">
15+
An high quality open source <strong>airsoft mosfet</strong><br> based on arduino.
16+
<br/><br/>
17+
<a href="#"><strong>Explore the docs »</strong></a>
18+
<br />
19+
<br />
20+
<a href="https://github.com/simonjamain/openmosfet/issues">Report Bug</a>
21+
·
22+
<a href="https://github.com/simonjamain/openmosfet/issues">Request Feature</a>
23+
</p>
24+
</p>
25+
26+
<details open="open">
27+
<summary>Table of Contents</summary>
28+
<ol>
29+
<li>
30+
<a href="#about-the-project">About The Project</a>
31+
<ul>
32+
<li>
33+
<a href="#the-team">The team</a>
34+
<ul>
35+
<li><a href="#developers">Developers</a></li>
36+
</ul>
37+
</li>
38+
</ul>
39+
</li>
40+
<li>
41+
<a href="#getting-started">Getting Started</a>
42+
<ul>
43+
<li><a href="#installation-and-build">Installation and build</a></li>
44+
<li><a href="#replica-interface-types">Replica interface types</a></li>
45+
<li><a href="#custom-replica-interface-pinout">Custom replica interface pinout</a></li>
46+
</ul>
47+
</li>
48+
<li>
49+
<a href="#development">Development</a>
50+
<ul>
51+
<li>
52+
<a href="#local-ui-without-board">Local UI (without board)</a>
53+
<ul>
54+
<li><a href="#install-and-serve">Install and serve</a></li>
55+
</ul>
56+
</li>
57+
</ul>
58+
</li>
59+
<li><a href="#usage">Development</a></li>
60+
<li><a href="#roadmap">Roadmap</a></li>
61+
<li><a href="#contributing">Contributing</a></li>
62+
<li><a href="#todo">To-Do</a></li>
63+
</ol>
64+
</details>
65+
66+
## About the project
67+
68+
69+
OpenMosfet is an high quality open source airsoft mosfet based on arduino (currently esp32 board).
470

571
The software is meant to be modular and to allow different sensors configurations.
672

773
The hardware provides all the electronics needed and allows different boards to be created.
874

9-
## the current team
10-
The team is composed of a programmer ([Simon](https://github.com/simonjamain)) and two electronitians (Romain & Marcellin), all french airsofters.
75+
The web dashboard allows full and easy controls over every settings as well an update manager.
1176

12-
## installation and build
77+
![OpenMosfet Web Dashboard](doc/assets/images/ui.png)
78+
79+
### The team
80+
81+
82+
The team is composed of two developers ([Simon](https://github.com/simonjamain) and [Zao Soula](https://github.com/zaosoula)) and two electronitians (Romain and Marcellin), all french airsofters.
83+
84+
#### Developers
85+
86+
<img src="doc/assets/images/developers.svg" alt="Logo" width="100%">
87+
88+
89+
## Getting started
90+
### Installation and build
1391
- Install platformio
1492
- "open" the project
1593
- for building the ui (mandatory) :
1694
- install node.js
1795
- inside the `ui` folder, run `npm install`
1896
- *Note : `ui.h` is recompiled by running the command `npm run build` inside the `ui` folder. this is done automaticaly before each platformio build (see platformio.ini and build_ui.py)*
19-
- OTA upload is enabled by default, if your board hasnt ota enabled or you want to upload with serial, uncomment that following parameters in `platformio.ini`
97+
- OTA upload is enabled by default, if your board hasn't ota enabled or you want to upload with serial, comment that following parameters in `platformio.ini`
2098
- `upload_protocol`
2199
- `upload_port`
100+
- default password for access point is "password"
22101
- I think thats about it...
23102

24-
### replica interface types
103+
### Replica interface types
25104
Depending on your replica and the way you connect the mosfet, the signals received are not the same.
26105

27106
ex : the original input plate on the G&G TR 16 can be used but the signals are very specific.
@@ -36,7 +115,7 @@ Here is a table (work in progress) listing the different configuration available
36115
---------------------|---------------|--------------
37116
1 | `OM_DEFAULT_FIRINGGROUP_PIN` grounded when : trigger is pressed AND safety is off AND mag is not empty<br>`OM_DEFAULT_CUTOFF_PIN` grounded when cutoff is pressed<br>`OM_DEFAULT_SELECTOR_PIN` grounded when selector is on full auto position | G&G tr16 original input plate
38117

39-
### custom replica interface pinout
118+
### Custom replica interface pinout
40119
For developpement reasons or other, you can change the default settings for the replica interface with the following flags :
41120

42121
- `OM_DEFAULT_MOTOR_PIN`
@@ -47,26 +126,25 @@ For developpement reasons or other, you can change the default settings for the
47126
*Note: it is not recommended that you change this value in the source file, but rather as a build flag in platformio.ini for example.*
48127
*Note: for example, the ESP32DEVKIT V1 doesnt have the pin 10 exposed, which is the default pin used on the board for the selector input.*
49128

50-
## hardware
129+
### http rest-like API
130+
131+
Got to the [API documentation](/doc/api).
132+
133+
## Development
134+
135+
### Local UI (without board)
136+
To serve the UI locally on your computer, we provide a fake server to simulate the board behavior.
137+
138+
#### Install and serve
139+
- inside the `/src/ui/` folder, run `npm install`
140+
- run `npm run serve-dev`
141+
- open http://localhost:3000/ in your browser
142+
- you can now edit ``src/`` without having to re-launch the server
143+
144+
*Note: The configuration is loaded from ``defaultConf.json`` and can be updated as long as the server is running.
145+
Once it stops the updated configuration is lost*
51146

52-
## contribute
147+
## Contributing
53148
Don't hesitate to contact us via github, or your can come and talk with us on our [discord server](https://discord.gg/XuzSSbgE).
54-
We are french but we can chat in english no prob.
55-
56-
## TODO
57-
- ~~launch in AP mode when wifi router is not available~~
58-
- ~~implement sleep modes to prevent battery over-discharge~~
59-
- ~~ability to cut wifi off after X sec to save power~~
60-
- ~~deep sleep when inactive for two long~~
61-
- add buzzer ?
62-
- implement motor vibration
63-
- create an example module
64-
- implement all battery protection types :
65-
- auto
66-
- predefined
67-
- manual
68-
- none
69-
- ~~change max ssid and password length to 32 chars instead of 16 : https://serverfault.com/questions/45439/what-is-the-maximum-length-of-a-wifi-access-points-ssid~~
70-
- add "try to connect now" button next to external wifi settings
71-
- check if wifi cutoff current saving is reliable
72149

150+
We are french but we can chat in english without problems.

doc/api/README.md

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
## Endpoints
2+
3+
For now, all endpoints doesn't require any Authentication.
4+
5+
### Firmware
6+
7+
- **Updates** : `/api/core/update/`
8+
- `POST` : auto-update replica from the github releases
9+
*Note: be carefull of timeout, this usually take 70-80 secs*
10+
- `PUT` : upload a .bin to update the firmware
11+
- parameters *multipart/form-data*
12+
- `firmware` *application/octet-stream* : the binary file
13+
- **Firmware version** : `/api/core/version/`
14+
- `GET` :
15+
- parameters *application/json*
16+
- *string* : the current version (semver, see [releases](https://github.com/simonjamain/openmosfet/releases))
17+
18+
### Configuration
19+
20+
This is closely linked to [configuration.h](/src/configuration.h)
21+
22+
- **global configuration** : `/api/config/`
23+
- `GET` : reads the global configuration
24+
- parameters *application/json*
25+
- `appSsid` *string [8-32]* : Access point ssid
26+
- `appPasswd` *string [8-16]* : Access point password
27+
- `connectToNetworkIfAvailable` *boolean* : Will try to connect at startup
28+
- `availableNetworkAppSsid` *string [8-32]* : External network ssid
29+
- `availableNetworkAppPasswd` *string [8-16]* : External network password
30+
- `wifiShutdownDelayMinutes` *int* : delay for wifi shutdown after last network activity (0 = never shuts down)
31+
- `deepSleepDelayMinutes` *int* : delay for sleep mode after replica inactivity
32+
- `useBatteryProtection` *boolean* : Will monitor battery voltage
33+
- `batteryNominalVoltage` *float* : Honestly I don't precisely know yet what to do with that
34+
- `batteryLowVoltage` *float* : Will alert the user below this voltage
35+
- `batteryShutdownVoltage` *float* : Will disable the replica below this voltage
36+
- `useActiveBreaking` *float* : Duh.
37+
- `enablePrecocking` *boolean* : Enable precocking based on values specified for each firemode
38+
- `fireModes` *object array* :
39+
- `burstMode` *int [0-2]* : Burst mode, 0=interruptible, 1=normal, 2=extendible
40+
- `burstLength` *int* :
41+
normal burstmode : Number of shot fired when trigger pulled
42+
interruptible burstmode : Maximum number of shot fired during trigger pull
43+
extendible burstmode : Minimum number of shot fired when trigger pulled
44+
- `precockDuration_ms` *int* : Amount of precocking time after cycle in milliseconds (may be replaced with a %)
45+
- `motorPower` *float [0-1]* : Percentage of battery power delivered to the motor (with pwm)
46+
- `timeBetweenShots_ms` : Time between each shots, can be used for RoF control or dmr setup
47+
- `decockAfter_s` *float* : If the trigger is maintained pressed for set ammount of time after end of burst, cycle and decock ⚠this fires a bb⚠. (0 = no decocking)
48+
- `POST` : Set the global configuration and retrieve the saved values in response
49+
- parameters *application/json*
50+
same data format as `GET`
51+
52+
### Replica
53+
54+
This is closely linked to [components.h](/src/components.h)
55+
56+
- **Trigger state** : `/api/components/trigger/state`
57+
- `GET,POST` : set/read the trigger state
58+
- parameters *application/json*
59+
- *boolean* : [true, false] true for pulling the trigger, false for releasing
60+
- **Trigger short pull** : `/api/components/trigger/bump`
61+
- `POST` : pull and release the trigger
62+
- **Selector state** : `/api/components/selector/state`
63+
- `GET,POST` : set/read the selector state
64+
- parameters *application/json*
65+
- *int* : [`0`, `1`, `2`]
66+
- **Gearbox uncocking** : `/api/components/gearbox/uncock`
67+
- `POST` : uncock the piston (if cocked) ⚠Be careful, this will eventully fire a BB⚠
68+
69+
--------------
70+
71+
*inspired by https://github.com/jamescooke/restapidocs/*

doc/assets/images/developers.svg

Lines changed: 26 additions & 0 deletions
Loading

doc/assets/images/logo.png

4.96 KB
Loading

doc/assets/images/ui.png

599 KB
Loading

0 commit comments

Comments
 (0)