move examples -> tutorials

This commit is contained in:
Sergio R. Caprile committed 2025-02-28 13:55:57 -03:00
1 parent 024078ae33
commit 306c0b6096
24 files changed
+141 -236

No files matched your search

+41
View File
@@ -0,0 +1,41 @@
# Mongoose Network Library tutorials and example code
The fastest way to quickly get Mongoose running on your hardware is to follow our [Tutorials](https://mongoose.ws/documentation/#tutorials):
- Browse for your desired protocol and function, read the tutorial
- For embedded hardware specifics, browse to your desired board, or the closest one. You'll find links to different IDE, RTOS, and TCP/IP stack options, and a link to our [Wizard](https://mongoose.ws/documentation/#mongoose-wizard), a tool that generates UI code for you.
## Navigating this tree
Steps to get the most out of this code base:
- Most code here has a README.md file that points to a verbose tutorial describing how to get the intended functionality out of Mongoose Network Library. Code there runs as is in Windows, Ubuntu Linux, and Mac (very few cases don't run in Windows).
- Navigate your way to the desired protocol or function, read the README.md file
- Follow the linked tutorial
- In cases were there is no tutorial:
- Follow the [Build Tools](https://mongoose.ws/documentation/tutorials/tools/) tutorial to setup your development environment.
- run `make all`
- Embedded hardware tutorials are conveniently linked from OS tutorials, or grouped by vendor and board.
- Navigate your way to the desired board or the closest one, read the README.md file. In most cases you'll find a link to our [Wizard](https://mongoose.ws/wizard/); for others, there is a link to a [Tutorial](https://mongoose.ws/documentation/#tutorials), as described at the top of this text. The Wizard will also link you to the tutorials you'll need.
- In cases were there you don't find a link to a tutorial:
- Follow the [Build Tools](https://mongoose.ws/documentation/tutorials/tools/) tutorial to setup your development environment.
- run `make build`
- Once you have a running example close to your needs, you can start developing your application
- Please read our [User Guide](https://mongoose.ws/documentation/#user-guide)
## Contributing
Rules for creating a new example:
- Makefile golden reference for desktop/server examples: [http-server](http/http-server/)
- Makefile golden reference for embedded examples: [stm32/nucleo-f746zg-baremetal-builtin-rndis](stm32/nucleo-f746zg-baremetal-builtin-rndis/)
- Examples must build on Windows, Mac and Ubuntu Linux systems
- Assume that users installed their tools according to the [Build Tools](https://mongoose.ws/documentation/tutorials/tools/) tutorial
- Makefiles must not include other Makefiles
- Use `CFLAGS` for system-specific compilation options
- Use `CFLAGS_MONGOOSE` for Mongoose-specific compilation options
- Use `$(CFLAGS) $(CFLAGS_MONGOOSE) $(CFLAGS_EXTRA)` to compile
- If an external repository is required, download it on demand using git shallow clone. See the embedded examples golden reference
- Keep Makefiles as short as possible, but verbose to understand them easily
- Symlink files when required, like `mongoose.c`, `ca.pem`, etc. Make no copies
- Examples README.md files should contain only the title and the link to the corresponding mongoose.ws tutorial page
+8 -8
View File
@@ -12,7 +12,7 @@ const char *mg_unpack(const char *, size_t *, time_t *);
#endif
static const unsigned char v1[] = {
31, 139, 8, 8, 6, 78, 191, 103, 0, 3, 105, 110, // .....N.g..in
31, 139, 8, 8, 67, 234, 193, 103, 0, 3, 105, 110, // ....C..g..in
100, 101, 120, 46, 104, 116, 109, 108, 0, 93, 144, 177, // dex.html.]..
78, 196, 48, 12, 134, 247, 123, 138, 144, 153, 180, 176, // N.0...{.....
49, 36, 149, 208, 245, 6, 38, 24, 64, 130, 49, 77, // 1$....&.@.1M
@@ -37,7 +37,7 @@ static const unsigned char v1[] = {
130, 117, 1, 0, 0, 0 // .u...
};
static const unsigned char v2[] = {
31, 139, 8, 8, 6, 78, 191, 103, 0, 3, 109, 97, // .....N.g..ma
31, 139, 8, 8, 67, 234, 193, 103, 0, 3, 109, 97, // ....C..g..ma
105, 110, 46, 106, 115, 0, 181, 88, 109, 111, 219, 70, // in.js..Xmo.F
18, 254, 174, 95, 49, 80, 125, 37, 121, 165, 72, 43, // ..._1P}%y.H+
113, 225, 131, 44, 235, 144, 6, 45, 112, 135, 38, 233, // q..,...-p.&.
@@ -204,7 +204,7 @@ static const unsigned char v2[] = {
154, 248, 11, 218, 252, 214, 171, 12, 23, 0, 0, 0 // ...........
};
static const unsigned char v3[] = {
31, 139, 8, 8, 6, 78, 191, 103, 0, 3, 112, 114, // .....N.g..pr
31, 139, 8, 8, 67, 234, 193, 103, 0, 3, 112, 114, // ....C..g..pr
101, 97, 99, 116, 46, 109, 105, 110, 46, 106, 115, 0, // eact.min.js.
157, 91, 123, 119, 219, 182, 146, 255, 127, 63, 69, 164, // .[{w.....?E.
211, 163, 18, 43, 68, 177, 147, 182, 187, 75, 5, 213, // ...+D....K..
@@ -650,7 +650,7 @@ static const unsigned char v3[] = {
138, 51, 0, 0, 0 // .3..
};
static const unsigned char v4[] = {
31, 139, 8, 8, 6, 78, 191, 103, 0, 3, 115, 116, // .....N.g..st
31, 139, 8, 8, 67, 234, 193, 103, 0, 3, 115, 116, // ....C..g..st
121, 108, 101, 46, 99, 115, 115, 0, 149, 85, 193, 142, // yle.css..U..
155, 48, 16, 189, 231, 43, 92, 173, 42, 181, 171, 192, // .0...+..*...
134, 16, 96, 33, 151, 222, 250, 17, 85, 15, 6, 155, // ..`!....U...
@@ -727,10 +727,10 @@ static const struct packed_file {
size_t size;
time_t mtime;
} packed_files[] = {
{"/web_root/index.html.gz", v1, sizeof(v1), 1740590598},
{"/web_root/main.js.gz", v2, sizeof(v2), 1740590598},
{"/web_root/preact.min.js.gz", v3, sizeof(v3), 1740590598},
{"/web_root/style.css.gz", v4, sizeof(v4), 1740590598},
{"/web_root/index.html.gz", v1, sizeof(v1), 1740761667},
{"/web_root/main.js.gz", v2, sizeof(v2), 1740761667},
{"/web_root/preact.min.js.gz", v3, sizeof(v3), 1740761667},
{"/web_root/style.css.gz", v4, sizeof(v4), 1740761667},
{NULL, NULL, 0, 0}
};
@@ -0,0 +1,29 @@
BOARD = xmc4700
IDE = GCC+make
RTOS = baremetal
WIZARD_URL ?= http://mongoose.ws/wizard
all build example: firmware.bin
firmware.bin: wizard
make -C wizard CFLAGS_EXTRA=$(CFLAGS_EXTRA) && mv wizard/firmware.bin ./
wizard:
hash=$$(curl -s -X POST -H "Content-Type: application/json" -d '{"build":{"board":"$(BOARD)","ide":"$(IDE)","rtos":"$(RTOS)"}}' $(WIZARD_URL)/api/hash | jq -r '.hash') \
&& curl -s $(WIZARD_URL)/api/zip/$(BOARD)/$(IDE)/$(RTOS)/$$hash -o wizard.zip
unzip wizard.zip
cd wizard ; rm mongoose.[ch] ; ln -s ../../../../mongoose.c ; ln -s ../../../../mongoose.h
# Automated remote test. Requires env variable VCON_API_KEY set. See https://vcon.io/automated-firmware-tests/
DEVICE_URL ?= https://dash.vcon.io/api/v3/devices/??
update: firmware.bin
curl --fail-with-body -su :$(VCON_API_KEY) $(DEVICE_URL)/ota --data-binary @$<
test update: CFLAGS_EXTRA ="-DUART_DEBUG=USART1"
test: update
curl --fail-with-body -su :$(VCON_API_KEY) $(DEVICE_URL)/tx?t=15 | tee /tmp/output.txt
grep 'READY, IP:' /tmp/output.txt # Check for network init
clean:
rm -rf firmware.* wizard*
@@ -0,0 +1 @@
See [Wizard](https://mongoose.ws/wizard/#/output?board=xmc4700&ide=GCC+make&rtos=baremetal&file=README.md)
@@ -0,0 +1,29 @@
BOARD = xmc4400
IDE = GCC+make
RTOS = baremetal
WIZARD_URL ?= http://mongoose.ws/wizard
all build example: firmware.bin
firmware.bin: wizard
make -C wizard CFLAGS_EXTRA=$(CFLAGS_EXTRA) && mv wizard/firmware.bin ./
wizard:
hash=$$(curl -s -X POST -H "Content-Type: application/json" -d '{"build":{"board":"$(BOARD)","ide":"$(IDE)","rtos":"$(RTOS)"}}' $(WIZARD_URL)/api/hash | jq -r '.hash') \
&& curl -s $(WIZARD_URL)/api/zip/$(BOARD)/$(IDE)/$(RTOS)/$$hash -o wizard.zip
unzip wizard.zip
cd wizard ; rm mongoose.[ch] ; ln -s ../../../../mongoose.c ; ln -s ../../../../mongoose.h
# Automated remote test. Requires env variable VCON_API_KEY set. See https://vcon.io/automated-firmware-tests/
DEVICE_URL ?= https://dash.vcon.io/api/v3/devices/??
update: firmware.bin
curl --fail-with-body -su :$(VCON_API_KEY) $(DEVICE_URL)/ota --data-binary @$<
test update: CFLAGS_EXTRA ="-DUART_DEBUG=USART1"
test: update
curl --fail-with-body -su :$(VCON_API_KEY) $(DEVICE_URL)/tx?t=15 | tee /tmp/output.txt
grep 'READY, IP:' /tmp/output.txt # Check for network init
clean:
rm -rf firmware.* wizard*
@@ -0,0 +1 @@
See [Wizard](https://mongoose.ws/wizard/#/output?board=xmc4400&ide=GCC+make&rtos=baremetal&file=README.md)
+1 -1
View File
@@ -1 +1 @@
../../../examples/device-dashboard/net.c
../../http/device-dashboard/net.c
+1 -1
View File
@@ -1 +1 @@
../../../examples/device-dashboard/net.h
../../http/device-dashboard/net.h
+1 -1
View File
@@ -1 +1 @@
../../../examples/device-dashboard/packed_fs.c
../../http/device-dashboard/packed_fs.c