Compare commits

..
201 Commits
Author SHA1 Message Date
Sergio R. Caprile 6bb40e6ec9 update version 2024-05-20 11:21:09 -03:00
Sergio R. Caprile 94efcc83a1 update version 2024-05-20 10:54:40 -03:00
Sergey Lyubka 03402cf359 Add pack.js 2024-05-19 15:45:03 +01:00
Sergey Lyubka a473cf99b5 More complete MQTT example 2024-05-18 12:09:59 +01:00
Sergio R. Caprile c26bd2ffe8 Merge pull request #2757 from cesanta/wolf
fix WolfSSL
2024-05-17 18:11:30 -03:00
Sergio R. Caprile 9dc3d09981 fix WolfSSL 2024-05-17 17:54:52 -03:00
Sergio R. Caprile 76b4c9a6ff Merge pull request #2756 from cesanta/silwf
momentarily silence WolfSSL tests
2024-05-16 15:18:55 -03:00
Sergio R. Caprile 41add69294 momentarily silence WolfSSL tests 2024-05-16 15:17:19 -03:00
Sergio R. Caprile c911c9ad19 Merge pull request #2752 from cesanta/strip
add mg_str_to_num
2024-05-16 10:58:54 -03:00
Sergio R. Caprile dd883c0563 Merge pull request #2755 from cesanta/mbed
unbreak MbedTLS in Linux
2024-05-16 10:09:59 -03:00
Sergio R. Caprile 16a0c89d5f unbreak MbedTLS in Linux 2024-05-16 09:55:01 -03:00
Sergey Lyubka ac0e6f3377 Squash warnings on gcc 9.4 2024-05-16 11:13:21 +01:00
Sergey Lyubka 68f7be7a1a Merge pull request #2745 from cesanta/tls
Fix mbedTLS binding for 3.x
2024-05-16 10:45:46 +01:00
Sergey Lyubka b796e33ede Fix mbedTLS binding for 3.x 2024-05-16 10:45:11 +01:00
Sergey Lyubka 1051ba77c0 Merge pull request #2753 from julek-wolfssl/wolfssl
Add wolfSSL support
2024-05-16 10:18:38 +01:00
Juliusz Sosinowicz cb5b6b972a Turn off hanging test
Signed-off-by: Juliusz Sosinowicz <juliusz@wolfssl.com>
2024-05-16 10:37:31 +02:00
Juliusz Sosinowicz 925f21aca4 Update nightly
Signed-off-by: Juliusz Sosinowicz <juliusz@wolfssl.com>
2024-05-16 10:37:31 +02:00
Juliusz Sosinowicz dc09851ac8 Add wolfSSL support
- Added Makefile wolfSSL build option with `SSL=WOLFSSL`
- Fixed missing BIO symbol errors
- Rename `fe` to `mg_fe` as it collides with `fe` defined in `wolfssl/wolfcrypt/fe_operations.h`
- byte variable name shadows the wolfSSL byte type

Tested with `make test`

Signed-off-by: Juliusz Sosinowicz <juliusz@wolfssl.com>
2024-05-16 10:37:31 +02:00
Sergey Lyubka 323ba9d90c Merge pull request #2754 from cesanta/s390
Fix endianness issues in X25519 code
2024-05-15 22:01:53 +01:00
Sergey Lyubka c6ff8ab6dc Fix endianness issues in X25519 code 2024-05-15 21:56:47 +01:00
Sergio R. Caprile b5443f10c5 add mg_str_to_num 2024-05-15 16:46:31 -03:00
Sergio R. Caprile 3ae1a0f82a Merge pull request #2750 from cesanta/gbephy
fix LAN87x
2024-05-13 16:29:17 -03:00
Sergio R. Caprile 81f0f8a7c2 fix LAN87x 2024-05-13 16:12:51 -03:00
Sergey Lyubka 50963df42f Update mongoose.c 2024-05-11 13:29:40 +01:00
Sergio R. Caprile b316989378 Merge pull request #2749 from cesanta/strip
silence fuzzer
2024-05-10 12:14:59 -03:00
Sergio R. Caprile 23c68e2677 silence fuzzer 2024-05-10 11:12:12 -03:00
Sergio R. Caprile b46bee0540 Merge pull request #2737 from cesanta/strip
cleanup 'str' API
2024-05-09 14:43:39 -03:00
Sergio R. Caprile 4c6c27d8f6 fix 573f13c 2024-05-09 14:38:57 -03:00
Sergio R. Caprile 3c531897b6 cleanup 'str' API 2024-05-09 14:10:27 -03:00
Sergio R. Caprile 6c7672f4af Merge pull request #2747 from cesanta/t2
Reduce stack usage in mg_tls_hexdump()
2024-05-09 11:54:55 -03:00
Sergey Lyubka 2def6e867d Reduce stack usage in mg_tls_hexdump() 2024-05-09 15:48:55 +01:00
Sergey Lyubka 573f13c1ed Add mg_now() 2024-05-08 14:23:17 +01:00
Sergey Lyubka b7f9e5c947 Fix path 2024-05-08 14:07:20 +01:00
Sergey Lyubka da85affe5c Refactor OTA API 2024-05-08 05:38:13 +01:00
Sergio R. Caprile 3168a2aca0 Merge pull request #2743 from cesanta/warn
Squash warning
2024-05-07 17:08:07 -03:00
Sergio R. Caprile 1f5feaa103 Merge pull request #2744 from cesanta/certs
regenerate certs
2024-05-07 15:13:07 -03:00
Sergio R. Caprile 4be3dfd52b Fix nomadic brew 2024-05-07 14:56:48 -03:00
Sergio R. Caprile 1e26983263 Merge pull request #2742 from cesanta/esp32ota
Add MG_OTA_ESP32
2024-05-07 14:31:14 -03:00
Sergey Lyubka a620419b59 Add MG_OTA_ESP32 2024-05-07 18:15:32 +01:00
Sergey Lyubka ffdc9b0d3a Squash warning 2024-05-07 15:41:09 +01:00
Sergey Lyubka 379e047289 regenerate certs 2024-05-07 15:40:13 +01:00
Sergio R. Caprile 8e420406b9 Merge pull request #2740 from cesanta/newskeleton
move to new skeleton
2024-05-01 15:19:08 -03:00
Sergio R. Caprile fc0364b321 move to new skeleton 2024-05-01 15:17:39 -03:00
Sergio R. Caprile ea4986dec5 Merge pull request #2739 from cesanta/newskeleton
move to new skeleton
2024-05-01 14:44:15 -03:00
Sergio R. Caprile 2be30a3193 move to new skeleton 2024-05-01 14:42:21 -03:00
Sergio R. Caprile 81f90c7b51 Merge pull request #2738 from cesanta/newskeleton
move to new skeleton
2024-05-01 14:19:16 -03:00
Sergio R. Caprile 205a564482 move to new skeleton 2024-05-01 14:16:43 -03:00
Sergio R. Caprile 497df68de1 Merge pull request #2735 from cesanta/newskeleton
move to new skeleton
2024-04-29 13:47:14 -03:00
Sergio R. Caprile eaf8e24d4c move to new skeleton 2024-04-29 13:45:20 -03:00
Sergio R. Caprile 1721fb0484 Merge pull request #2734 from cesanta/newskeleton
move to new skeleton
2024-04-29 11:26:00 -03:00
Sergio R. Caprile fe0b144b84 move to new skeleton 2024-04-29 11:23:00 -03:00
Sergio R. Caprile d391bca2d3 Merge pull request #2733 from cesanta/newskeleton
move to new skeleton
2024-04-29 11:02:31 -03:00
Sergio R. Caprile a0b6e70ff8 move to new skeleton 2024-04-29 10:58:43 -03:00
robert 4f15392440 Patched XMC7 eth 2024-04-29 07:18:52 -04:00
Sergey Lyubka 959fcfdf1d Fix paths 2024-04-28 13:26:53 +01:00
Sergio R. Caprile 57f90d200d Merge pull request #2731 from cesanta/newskeleton
move to new skeleton
2024-04-26 17:01:58 -03:00
Sergio R. Caprile 663c645cf1 move to new skeleton 2024-04-26 16:58:58 -03:00
Sergio R. Caprile 972b255a48 Merge pull request #2729 from cesanta/newskeleton
move to new skeleton
2024-04-26 13:47:39 -03:00
Sergio R. Caprile 8c5dfa4227 move to new skeleton 2024-04-26 13:46:18 -03:00
Sergio R. Caprile 290d48e1aa Merge pull request #2727 from cesanta/newskeleton
move to new skeleton
2024-04-25 17:09:13 -03:00
Sergio R. Caprile 4eb3a1c978 move to new skeleton 2024-04-25 16:54:28 -03:00
Sergio R. Caprile b4a36a8303 Merge pull request #2726 from cesanta/newskeleton
move to new skeleton
2024-04-25 15:21:35 -03:00
Sergio R. Caprile d08ee4e63a move to new skeleton 2024-04-25 15:18:59 -03:00
Sergio R. Caprile 42f5802e47 Merge pull request #2725 from cesanta/newskeleton
move to new skeleton
2024-04-25 14:46:57 -03:00
Sergio R. Caprile 120ffb0b1f move to new skeleton 2024-04-25 14:45:28 -03:00
Sergey Lyubka d3a3ba0a32 Linkify mongoose.{c,h} 2024-04-25 11:32:57 +01:00
Sergio R. Caprile 79eebc14bb Merge pull request #2723 from cesanta/newskeleton
move to new skeleton
2024-04-24 17:12:17 -03:00
Sergey Lyubka 6fc41e2a3c Merge pull request #2720 from cesanta/tlsblues
TLS corner cases
2024-04-24 20:44:57 +01:00
Sergio R. Caprile 4843323f87 move to new skeleton 2024-04-24 16:09:24 -03:00
Sergio R. Caprile 04c6f3e6ef Merge pull request #2722 from cesanta/newskeleton
start moving to new skeleton
2024-04-24 12:03:10 -03:00
Sergio R. Caprile 5345c7260e start moving to new skeleton 2024-04-24 11:57:53 -03:00
Sergio R. Caprile 71a48ccde0 Merge pull request #2721 from cesanta/leftovers
track recent changes
2024-04-23 16:31:30 -03:00
Sergio R. Caprile 41e24d7733 track recent changes 2024-04-23 15:12:40 -03:00
Sergio R. Caprile f888b30863 TLS corner cases 2024-04-23 11:24:47 -03:00
Sergey Lyubka 10029d6a8d Merge pull request #2718 from cesanta/pathissane
change mg_path_is_sane()
2024-04-22 20:58:02 +01:00
Sergio R. Caprile 6697a2cfaa change mg_path_is_sane() 2024-04-22 11:27:22 -03:00
Sergey Lyubka 59020e0d5d Merge pull request #2717 from cesanta/xmc7
XMC7 full working example
2024-04-22 09:42:42 +01:00
robert 70abd1f98d XMC7 full working example 2024-04-22 03:15:10 -04:00
Sergey Lyubka 312ca8e978 Tiny nit - fix dependencies 2024-04-20 18:24:41 +01:00
Sergey Lyubka e1ccdc0570 Merge pull request #2657 from cesanta/xmc-eth
Added ethernet driver for Infineon XMC4 boards
2024-04-20 14:58:12 +01:00
Sergey Lyubka c7f9fe4a03 Merge pull request #2714 from cesanta/Makefly
move Makefile to test/
2024-04-20 08:12:23 +01:00
Sergio R. Caprile 89aaf1c30c move Makefile to test/ 2024-04-19 18:53:25 -03:00
Sergio R. Caprile 601af780c9 Merge pull request #2713 from cesanta/nodetemb
move Mongoose options to mongoose_config
2024-04-19 10:50:05 -03:00
Sergio R. Caprile 93477c8db4 move Mongoose options to mongoose_config 2024-04-19 10:47:16 -03:00
Sergey Lyubka ec5531dbf4 Merge pull request #2711 from cesanta/nodetemb
remove arch autodetection for embedded
2024-04-19 06:04:27 +01:00
Sergio R. Caprile 157f87f01a remove arch autodetection for embedded 2024-04-18 17:28:40 -03:00
Sergio R. Caprile 0f4ca8d010 Merge pull request #2710 from cesanta/2650plus
fix fuzzer
2024-04-18 10:15:00 -03:00
Sergio R. Caprile 0a168b6791 fix fuzzer 2024-04-18 10:05:41 -03:00
Sergey Lyubka a025577b30 Merge pull request #2709 from cesanta/bye_http_match_uri
remove http_match_uri()
2024-04-17 21:52:54 +01:00
Sergio R. Caprile ef61d6ea48 remove http_match_uri() 2024-04-17 16:13:10 -03:00
Sergey Lyubka e6bf658271 Fix #2685 - squash warnings in tls_builtin 2024-04-17 07:32:51 +01:00
Sergio R. Caprile 9cccb9839b Merge pull request #2691 from cesanta/mqtt12
add simple API support for app MQTT pub retries
2024-04-16 19:18:11 -03:00
Sergio R. Caprile 2bd188f3d6 add simple API support for app MQTT pub retries 2024-04-16 19:17:37 -03:00
Sergio R. Caprile 9fa840c1c7 Merge pull request #2650 from cesanta/str
Fix #2612 - struct mg_str::ptr -> buf
2024-04-16 19:12:03 -03:00
Sergey Lyubka e0e599ffa1 Fix #2612 - struct mg_str::ptr -> buf 2024-04-16 22:42:45 +01:00
Sergey Lyubka e93d18d200 Merge pull request #2707 from cesanta/mgcfg
Rename mongoose_custom as mongoose_config
2024-04-16 22:07:13 +01:00
Sergio R. Caprile 34150f3f71 Rename mongoose_custom as mongoose_config 2024-04-16 17:28:31 -03:00
Sergio R. Caprile db6730c8a3 Merge pull request #2706 from cesanta/tlspoll
poll TLS to process outstanding data in receive buffer
2024-04-15 14:24:22 -03:00
Sergio R. Caprile 08cac802a4 poll TLS to process outstanding data in receive buffer 2024-04-15 12:13:31 -03:00
Sergio R. Caprile af6a52e060 Merge pull request #2704 from cesanta/gbephy
Add support for DP83867
2024-04-15 11:58:47 -03:00
Sergio R. Caprile 1c63645254 Add support for DP83867 2024-04-12 17:11:10 -03:00
Sergey Lyubka be5d8b1d4f Merge pull request #2702 from cesanta/zlw
Allow zero-length 'last-will' messages
2024-04-12 08:12:28 +01:00
Sergio R. Caprile 2ac3552e6e Allow zero-length 'last-will' messages 2024-04-11 11:20:46 -03:00
Sergio R. Caprile 3c3c775213 Merge pull request #2699 from cesanta/rewact
increase builtin TLS test coverage
2024-04-10 17:17:10 -03:00
Sergio R. Caprile a24b7043ed increase builtin TLS test coverage 2024-04-10 17:07:12 -03:00
Sergio R. Caprile 7b621d7b5b Merge pull request #2697 from cesanta/ft
update to MG_EV_HTTP_HDRS
2024-04-10 14:38:15 -03:00
Sergio R. Caprile 8a335a8cea update to MG_EV_HTTP_HDRS 2024-04-10 12:20:33 -03:00
Sergio R. Caprile 355c292dbf Merge pull request #2696 from cesanta/rewact
fix missing install
2024-04-09 11:00:13 -03:00
Sergio R. Caprile 2511d747ae fix missing install 2024-04-09 10:57:52 -03:00
Sergey Lyubka 03c326a04e Add driver init for IMXRT 2024-04-09 12:07:36 +02:00
Sergio R. Caprile b3312f3761 Merge pull request #2690 from cesanta/rewact
fix Valgrind dependencies
2024-04-05 15:59:14 -03:00
Sergio R. Caprile 2e250ee7aa fix Valgrind dependencies 2024-04-05 15:56:50 -03:00
Sergey Lyubka 924984dde1 Merge pull request #2682 from sasha0552/patch-1
fix typo
2024-04-05 10:17:56 +01:00
Sergio R. Caprile 33b7bb91d9 Merge pull request #2688 from cesanta/rewact
improve test coverage and run time
2024-04-04 17:21:49 -03:00
Sergio R. Caprile f68fe0fb5c improve test coverage and run time 2024-04-04 17:16:38 -03:00
Sergio R. Caprile e6663ec186 Merge pull request #2687 from cesanta/shh
Keepup with Zephyr project's enjoyment of changing headers
2024-04-04 12:55:01 -03:00
Sergio R. Caprile 6ff0f9ccd8 Keepup with Zephyr project's enjoyment of changing headers 2024-04-04 12:49:37 -03:00
sasha0552 48830aa9a9 fix typo 2024-04-03 22:14:47 +00:00
Sergio R. Caprile 9276f764e0 Merge pull request #2681 from cesanta/ub
keep embedded-friendly config API
2024-04-03 15:53:02 -03:00
Sergio R. Caprile 7876d464f2 keep embedded-friendly config API 2024-04-03 15:48:57 -03:00
Sergio R. Caprile 5d0d01c2c1 Merge pull request #2678 from cesanta/noscrsh
no screenshots
2024-04-02 18:12:31 -03:00
Sergio R. Caprile 393418d50d no screenshots 2024-04-02 18:11:11 -03:00
Sergio R. Caprile 23bb912eb5 Merge pull request #2677 from cesanta/noscrsh
no screenshots
closes #2611
2024-04-02 16:38:16 -03:00
Sergio R. Caprile 1d5b5296da no screenshots 2024-04-02 16:37:14 -03:00
Sergey Lyubka 655f5db996 Merge pull request #2675 from dvosully/esp32_device_dashboard_firmware_update
Implement firmware update in ESP32 device-dashboard example
2024-04-02 05:12:26 +01:00
dvosully c20cc4ae09 Implement firmware update in ESP32 device-dashboard example using espressif OTA APIs 2024-03-31 19:40:44 +10:00
Sergey Lyubka 7581229bbf Merge pull request #2669 from cesanta/tls
Squash warnings
2024-03-27 09:05:31 +00:00
Sergey Lyubka d094e090ff Squash warnings 2024-03-27 08:58:48 +00:00
robert c7a13025e4 Added ethernet driver for Infineon XMC4 boards 2024-03-26 10:21:09 -04:00
Sergey Lyubka e4cd6bd824 Cleanup debugging leftovers 2024-03-26 11:33:59 +00:00
Sergio R. Caprile f3ad0572e2 Merge pull request #2667 from cesanta/rewact
code .remove MbedTLS from essentials. Add tests in full
2024-03-25 18:36:53 -03:00
Sergio R. Caprile 406d6cc305 remove MbedTLS from essentials. Add tests in full 2024-03-25 18:35:46 -03:00
Sergio R. Caprile d042697b10 Merge pull request #2663 from cesanta/tls
TLS client implementation
2024-03-25 16:56:43 -03:00
Sergey Lyubka ba678b9ad1 TLS client implementation 2024-03-25 19:20:40 +00:00
Sergio R. Caprile 7a5cf118e9 Merge pull request #2666 from cesanta/ra
silence pedantic new versions
2024-03-25 10:43:37 -03:00
Sergio R. Caprile e9a2da61ef silence pedantic new versions 2024-03-25 10:35:30 -03:00
Sergio R. Caprile d3fe1ef681 Merge pull request #2665 from cesanta/rewact
add RA6 and RT1170 build tests
2024-03-25 09:48:49 -03:00
Sergio R. Caprile 9725bca966 add RA6 and RT1170 build tests 2024-03-25 09:47:27 -03:00
Sergio R. Caprile 1f627e4263 Merge pull request #2664 from cesanta/rewact
add RA6 and RT1170 build tests
2024-03-25 09:41:08 -03:00
Sergio R. Caprile 7ac0c5fc2a add RA6 and RT1170 build tests 2024-03-25 09:34:56 -03:00
Sergey Lyubka 091ebd8a98 Update readme 2024-03-25 08:52:59 +00:00
Sergey Lyubka d9a6e85b65 Merge pull request #2658 from cesanta/rt1170
RT1170
2024-03-23 05:33:46 +00:00
Sergio R. Caprile 7cc3d89980 Add RT1170 example 2024-03-22 13:44:01 -03:00
Sergio R. Caprile f58b90f7ea Merge pull request #2655 from cesanta/z
Zephyr fcntl
2024-03-21 14:03:03 -03:00
Sergio R. Caprile fd84109c1d Zephyr fcntl 2024-03-21 13:57:10 -03:00
Sergio R. Caprile 626f605835 Support RT11, fix RTL PHY, fix RA err cntr 2024-03-20 10:35:05 -03:00
Sergio R. Caprile 943a8a2708 fix references to RM 2024-03-20 10:35:05 -03:00
Sergio R. Caprile d7b2b3f42e Merge pull request #2648 from cesanta/autoinit
Refactor autoinit code
2024-03-17 14:22:25 -03:00
Sergey Lyubka fafc5c8348 Refactor autoinit code 2024-03-15 20:23:37 +00:00
Sergio R. Caprile 15bd8b4fe9 Merge pull request #2647 from cesanta/phy
Split PHY code into phy.{c,h}
2024-03-15 11:04:45 -03:00
Sergio R. Caprile 928aed4342 Split PHY code into phy.{c,h}; add PHY config to STM32H driver 2024-03-15 10:37:54 -03:00
Sergey Lyubka 98782e44c2 Nit changes to the fleet dashboard 2024-03-13 13:41:22 +00:00
Sergio R. Caprile 65b23777b2 Merge pull request #2642 from cesanta/autoinit
Add driver init to mg_mgr_init()
2024-03-12 20:36:59 -03:00
Sergio R. Caprile c8fd3d6d25 Add driver init to mg_mgr_init() 2024-03-12 15:55:35 -03:00
Sergey Lyubka 01e7cd5f13 Merge pull request #2646 from cesanta/tls
Fix #2619 - use mg_tls_pending() API to check for buffered TLS data
2024-03-12 08:49:32 +00:00
Sergey Lyubka 3ac9bd0468 Fix #2619 - use mg_tls_pending() API to check for buffered TLS data 2024-03-12 08:30:04 +00:00
Sergio R. Caprile 9f498d2eea Merge pull request #2645 from cesanta/mp
tie Micropython examples to a stable release
2024-03-11 11:09:39 -03:00
Sergio R. Caprile 2d2d9ad277 tie Micropython examples to a stable release 2024-03-11 11:07:18 -03:00
Sergey Lyubka 2cc18a8ea3 Snippets 2024-03-10 19:00:32 +00:00
Sergey Lyubka 25036d5f48 Link to mongoose.ws 2024-03-10 18:59:02 +00:00
Sergey Lyubka defee39ef9 Link to mongoose.ws 2024-03-10 18:58:14 +00:00
Sergey Lyubka c78afb12a3 Remove dead link 2024-03-10 18:53:02 +00:00
Sergey Lyubka f72b0b5056 Merge pull request #2632 from cesanta/reorg
Reorg skeleton
2024-03-09 16:04:35 +00:00
Sergey Lyubka d46e505a80 Reorg skeleton 2024-03-09 16:01:06 +00:00
Sergey Lyubka 4027bcf7ea Update readme 2024-03-09 10:29:14 +00:00
Sergey Lyubka 2905392665 Update readme 2024-03-09 10:28:43 +00:00
Sergio R. Caprile 98db3360df Merge pull request #2641 from cesanta/aes
prefix macros in tls_aes128
2024-03-06 12:06:09 -03:00
Sergio R. Caprile f26c713482 prefix macros in tls_aes128 2024-03-06 11:59:12 -03:00
Sergey Lyubka 05e55334fc Fix vc98 build 2024-03-06 00:57:31 +00:00
Sergey Lyubka 01fe61276e Add unit test for semicolon in value 2024-03-06 00:49:55 +00:00
Sergey Lyubka 219253ad71 Merge pull request #2636 from cesanta/mg_http_upload
Increase local file buffer size in mg_http_upload()
2024-03-05 06:05:36 +00:00
Sergey Lyubka 7b125558cb Merge pull request #2639 from cesanta/ack2
Better acks
2024-03-05 06:05:20 +00:00
Sergey Lyubka 02120e24b6 Better acks 2024-03-03 10:59:31 +00:00
Sergey Lyubka 91bc79c14c Merge pull request #2638 from cesanta/ack
restart timer when acking
2024-03-02 20:59:04 +00:00
Sergio R. Caprile 5ca552cf1c restart timer when acking 2024-03-02 15:25:02 -03:00
Sergio R. Caprile 2066304b14 Merge pull request #2637 from cesanta/ack
Sending ACK when about to exhaust TCP WIN1
2024-03-02 12:50:29 -03:00
Sergey Lyubka 1c6f8b95eb Sending ACK when about to exhaust TCP WIN1 2024-03-02 15:44:08 +00:00
Sergio R. Caprile 5384591f5b Merge pull request #2635 from cesanta/uploads
Enhance upload example - write uploaded file
2024-03-02 11:21:55 -03:00
Sergey Lyubka 309668ccbc Increase local file buffer size in mg_http_upload() 2024-03-02 10:56:06 +00:00
Sergey Lyubka 06a9fb3f53 Enhance upload example 2024-03-02 10:12:43 +00:00
Sergio R. Caprile 00db56f7d7 Merge pull request #2634 from cesanta/MG_EV_HTTP_HDRS
Introduce MG_EV_HTTP_HDRS
2024-03-01 20:50:57 -03:00
Sergey Lyubka cec06eb25c Introduce MG_EV_HTTP_HDRS 2024-03-01 23:29:12 +00:00
Sergey Lyubka 73a3897e1b Merge pull request #2630 from cesanta/2593-mongoose-closes-the-connection-without-responding-to-post-requests-that-dont-have-explicit-lengths
HTTP: respond to messages which have no explicit lengths
2024-02-28 19:21:06 +00:00
Sergey Lyubka 100c4c15ce 2024 2024-02-28 18:16:00 +00:00
robert c59bf6613a HTTP: respond to messages which have no explicit lengths 2024-02-28 04:01:39 -05:00
Sergio R. Caprile ac435bcb91 Merge pull request #2629 from cesanta/z
Satisfy new Zephyr config
2024-02-27 11:51:45 -03:00
Sergio R. Caprile 5d0bfccbc7 Satisfy new Zephyr config 2024-02-27 11:32:16 -03:00
Sergio R. Caprile 813489dc2f Merge pull request #2627 from cesanta/z
update
2024-02-26 16:59:16 -03:00
Sergio R. Caprile 828f31d5e6 update 2024-02-26 16:58:04 -03:00
Sergio R. Caprile 8130f7f25f Merge pull request #2625 from cesanta/c89
Make net_builtin C89 friendly
2024-02-26 09:20:42 -03:00
Sergey Lyubka 943e1c5f77 Adopt arch_freertos.h for CCRH compiler 2024-02-26 12:05:35 +00:00
Sergey Lyubka ecb3301bcb Make net_builtin C89 friendly 2024-02-25 12:21:06 +00:00
Sergio R. Caprile a0f33aebf7 Merge pull request #2624 from cesanta/2620
test returned content-type for custom 404
2024-02-23 09:15:45 -03:00
Sergio R. Caprile 6862981640 test returned content-type for user page404 2024-02-23 09:11:42 -03:00
Sergey Lyubka f61f2d2e9f Merge pull request #2620 from cesanta/2617
fix wrong MIME type for custom 404
2024-02-23 01:50:02 +00:00
Sergey Lyubka 1743e175cd Merge pull request #2623 from cesanta/r2d2
Add support for RA6M4
2024-02-23 00:45:47 +00:00
Sergio R. Caprile a027f58744 Add support for RA6M4 2024-02-22 20:51:01 -03:00
Sergio R. Caprile c98886402b Merge pull request #2621 from cesanta/ccrh
Adopt CCRH compiler
2024-02-22 20:18:15 -03:00
Sergey Lyubka 112a1e908a Adopt CCRH compiler 2024-02-22 17:53:15 +00:00
Sergey Lyubka 01ae80ecd1 Fix fuzzer call for mg_span() 2024-02-22 08:36:25 +00:00
Sergio R. Caprile 1c114a279e fix wrong MIME type for custom 404 2024-02-20 19:08:07 -03:00
708 changed files with 16257 additions and 7255 deletions

No files matched your search

+1 -1
View File
@@ -9,7 +9,7 @@ jobs:
Fuzzing: Fuzzing:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
with: { fetch-depth: 2 } with: { fetch-depth: 2 }
- run: if ./test/match_changed_files.sh '^src/' ; then echo GO=1 >> $GITHUB_ENV ; fi - run: if ./test/match_changed_files.sh '^src/' ; then echo GO=1 >> $GITHUB_ENV ; fi
- name: Build Fuzzers - name: Build Fuzzers
+2 -2
View File
@@ -25,8 +25,8 @@ jobs:
with: with:
languages: cpp languages: cpp
- run: | - run: |
make test CC=gcc ASAN= ASAN_OPTIONS= make -C test test CC=gcc ASAN= ASAN_OPTIONS=
./test/setup_ga_network.sh && make mip_test CC=gcc ASAN= ASAN_OPTIONS= ./test/setup_ga_network.sh && make -C test mip_test CC=gcc ASAN= ASAN_OPTIONS=
- name: Perform CodeQL Analysis - name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2 uses: github/codeql-action/analyze@v2
+224 -56
View File
@@ -14,7 +14,7 @@ jobs:
matrix: matrix:
cc: [gcc, clang, g++, clang++] cc: [gcc, clang, g++, clang++]
target: [test, mip_test] target: [test, mip_test]
ssl: ["", MBEDTLS, OPENSSL] ssl: ["", BUILTIN, MBEDTLS, OPENSSL, WOLFSSL]
select: ["-DMG_ENABLE_POLL=0 -DMG_ENABLE_EPOLL=0", "-DMG_ENABLE_POLL=1 -DMG_ENABLE_EPOLL=0", "-DMG_ENABLE_POLL=0 -DMG_ENABLE_EPOLL=1"] select: ["-DMG_ENABLE_POLL=0 -DMG_ENABLE_EPOLL=0", "-DMG_ENABLE_POLL=1 -DMG_ENABLE_EPOLL=0", "-DMG_ENABLE_POLL=0 -DMG_ENABLE_EPOLL=1"]
exclude: exclude:
- ssl: MBEDTLS - ssl: MBEDTLS
@@ -25,118 +25,263 @@ jobs:
select: "-DMG_ENABLE_POLL=0 -DMG_ENABLE_EPOLL=0" select: "-DMG_ENABLE_POLL=0 -DMG_ENABLE_EPOLL=0"
- ssl: OPENSSL - ssl: OPENSSL
select: "-DMG_ENABLE_POLL=1 -DMG_ENABLE_EPOLL=0" select: "-DMG_ENABLE_POLL=1 -DMG_ENABLE_EPOLL=0"
- ssl: WOLFSSL
select: "-DMG_ENABLE_POLL=0 -DMG_ENABLE_EPOLL=0"
- ssl: WOLFSSL
select: "-DMG_ENABLE_POLL=1 -DMG_ENABLE_EPOLL=0"
name: linux ${{ matrix.target }} CC=${{ matrix.cc }} SSL=${{ matrix.ssl }} TFLAGS=${{ matrix.select }} name: linux ${{ matrix.target }} CC=${{ matrix.cc }} SSL=${{ matrix.ssl }} TFLAGS=${{ matrix.select }}
env: env:
CC: ${{ matrix.cc }} CC: ${{ matrix.cc }}
SSL: ${{ matrix.ssl }} SSL: ${{ matrix.ssl }}
TFLAGS: ${{ matrix.select }} TFLAGS: ${{ matrix.select }}
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
with: { fetch-depth: 2 } with: { fetch-depth: 2 }
- run: ./test/setup_ga_network.sh && sudo apt -y update ; sudo apt -y install libmbedtls-dev && make ${{ matrix.target }} - run: ./test/setup_ga_network.sh && sudo apt -y update ; sudo apt -y install libmbedtls-dev libwolfssl-dev && make -C test ${{ matrix.target }}
s390: s390:
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
ssl: ["", BUILTIN]
name: S390 SSL=${{ matrix.ssl }}
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
with: { fetch-depth: 2 } with: { fetch-depth: 2 }
- run: sudo apt -y update ; sudo apt -y install qemu binfmt-support qemu-user-static && docker run --rm --privileged multiarch/qemu-user-static --reset -p yes && make s390 - run: sudo apt -y update ; sudo apt -y install qemu binfmt-support qemu-user-static && docker run --rm --privileged multiarch/qemu-user-static --reset -p yes && make -C test s390 SSL=${{ matrix.ssl }}
armhf: armhf:
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
ssl: ["", BUILTIN]
name: ArmHF SSL=${{ matrix.ssl }}
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
with: { fetch-depth: 2 } with: { fetch-depth: 2 }
- run: sudo apt -y update ; sudo apt -y install qemu binfmt-support qemu-user-static && docker run --rm --privileged multiarch/qemu-user-static --reset -p yes && make armhf - run: sudo apt -y update ; sudo apt -y install qemu binfmt-support qemu-user-static && docker run --rm --privileged multiarch/qemu-user-static --reset -p yes && make -C test armhf SSL=${{ matrix.ssl }}
linux2: unamalgamated-mg_prefix:
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
ssl: ["", BUILTIN, MBEDTLS, OPENSSL, WOLFSSL]
name: unamalgamated-mg_prefix SSL=${{ matrix.ssl }}
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
with: { fetch-depth: 2 } with: { fetch-depth: 2 }
- run: sudo apt -y update ; sudo apt -y install libmbedtls-dev valgrind - run: sudo apt -y update ; sudo apt -y install libmbedtls-dev libwolfssl-dev
- run: make unamalgamated && make valgrind && make mg_prefix - run: make -C test unamalgamated && make -C test mg_prefix
valgrind:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
ssl: ["", BUILTIN, MBEDTLS, OPENSSL, WOLFSSL]
name: Valgrind SSL=${{ matrix.ssl }}
steps:
- uses: actions/checkout@v4
with: { fetch-depth: 2 }
- run: sudo apt -y update ; sudo apt -y install libmbedtls-dev libwolfssl-dev valgrind
- run: make -C test valgrind SSL=${{ matrix.ssl }}
macos: macos:
runs-on: macos-latest runs-on: macos-latest
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
ssl: ["", MBEDTLS, OPENSSL] ssl: ["", BUILTIN, MBEDTLS, OPENSSL, WOLFSSL]
select: [-DMG_ENABLE_POLL=0, -DMG_ENABLE_POLL=1] select: [-DMG_ENABLE_POLL=0, -DMG_ENABLE_POLL=1]
exclude: exclude:
- ssl: MBEDTLS - ssl: MBEDTLS
select: -DMG_ENABLE_POLL=0 select: -DMG_ENABLE_POLL=0
- ssl: OPENSSL - ssl: OPENSSL
select: -DMG_ENABLE_POLL=0 select: -DMG_ENABLE_POLL=0
- ssl: WOLFSSL
select: -DMG_ENABLE_POLL=0
name: macos SSL=${{ matrix.ssl }} TFLAGS=${{ matrix.select }} name: macos SSL=${{ matrix.ssl }} TFLAGS=${{ matrix.select }}
env: env:
SSL: ${{ matrix.ssl }} SSL: ${{ matrix.ssl }}
TFLAGS: ${{ matrix.select }} -DNO_SNTP_CHECK -Wno-sign-conversion # Workaround for MbedTLS 3.5.0 TFLAGS: ${{ matrix.select }} -DNO_SNTP_CHECK -Wno-sign-conversion # Workaround for MbedTLS 3.5.0
HOMEBREW_NO_AUTO_UPDATE: 1 HOMEBREW_NO_AUTO_UPDATE: 1
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
with: { fetch-depth: 2 } with: { fetch-depth: 2 }
- run: brew install jq mbedtls openssl - run: brew install mbedtls wolfssl # jq openssl already pre-installed
- run: make test ASAN_OPTIONS= MBEDTLS=`echo /usr/local/Cellar/mbedtls*/*` OPENSSL=`echo /usr/local/Cellar/openssl*/*` - run: make -C test test ASAN_OPTIONS= MBEDTLS=$(echo $(brew --cellar)/mbedtls*/*) OPENSSL=$(echo $(brew --cellar)/openssl*/*) WOLFSSL=$(echo $(brew --cellar)/wolfssl*/*)
- run: make mg_prefix
windows: windows:
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy: strategy:
fail-fast: false fail-fast: false
max-parallel: 1 # no parallel runs, to minimize MQTT errors
matrix: matrix:
target: [vc98, vc17, vc22, mingw, mingw++] target: [vc98, vc17, vc22, mingw, mingw++]
ssl: ["", BUILTIN]
select: [-DMG_ENABLE_POLL=0, -DMG_ENABLE_POLL=1] select: [-DMG_ENABLE_POLL=0, -DMG_ENABLE_POLL=1]
exclude: exclude:
- target: vc98 - target: vc98
select: -DMG_ENABLE_POLL=1 select: -DMG_ENABLE_POLL=1
name: windows ${{ matrix.target }} TFLAGS=${{ matrix.select }} name: windows ${{ matrix.target }} SSL=${{ matrix.ssl }} TFLAGS=${{ matrix.select }}
env: env:
SSL: SSL=${{ matrix.ssl }}
TFLAGS: ${{ matrix.select }} TFLAGS: ${{ matrix.select }}
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
with: { fetch-depth: 2 } with: { fetch-depth: 2 }
- run: make ${{ matrix.target }} - run: make -C test ${{ matrix.target }}
arm: arm:
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
ssl: ["", BUILTIN]
name: Arm SSL=${{ matrix.ssl }}
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
- run: make arm - run: make -C test arm SSL=${{ matrix.ssl }}
riscv: riscv:
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
ssl: ["", BUILTIN]
name: RISC-V SSL=${{ matrix.ssl }}
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
- run: make riscv - run: make -C test riscv SSL=${{ matrix.ssl }}
examples: examples:
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
ssl: ["", -DMG_TLS=MG_TLS_BUILTIN]
name: examples ${{ matrix.ssl }}
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
- run: sudo apt -y install libmbedtls-dev libpcap-dev - run: sudo apt -y install libpcap-dev
- run: make examples - run: make -C test examples CFLAGS_EXTRA="${{ matrix.ssl }}"
- run: make clean - run: make -C test clean_examples
examples_win: examples_win:
runs-on: windows-latest runs-on: windows-latest
strategy:
fail-fast: false
matrix:
ssl: ["", -DMG_TLS=MG_TLS_BUILTIN]
name: examples_win ${{ matrix.ssl }}
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
# - uses: egor-tensin/setup-mingw@v2 # - uses: egor-tensin/setup-mingw@v2
# with: # with:
# platform: x64 # platform: x64
- name: test they build - name: test they build
run: make examples_win run: make -C test examples_win CFLAGS_EXTRA="${{ matrix.ssl }}"
shell: cmd shell: cmd
- name: test they clean - name: test they clean
run: make clean_examples_win run: make -C test clean_examples_win
shell: cmd shell: cmd
examples_mac: examples_mac:
runs-on: macos-latest runs-on: macos-latest
env: { HOMEBREW_NO_AUTO_UPDATE: 1 } env: { HOMEBREW_NO_AUTO_UPDATE: 1 }
strategy:
fail-fast: false
matrix:
ssl: ["", -DMG_TLS=MG_TLS_BUILTIN]
name: examples_mac ${{ matrix.ssl }}
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
- run: make examples_mac - run: make -C test examples_mac CFLAGS_EXTRA="${{ matrix.ssl }}"
- run: make clean_examples_mac - run: make -C test clean_examples_mac
refprojs:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
ssl: ["", -DMG_TLS=MG_TLS_BUILTIN]
name: reference-projects ${{ matrix.ssl }}
steps:
- uses: actions/checkout@v4
- run: make -C test refprojs CFLAGS_EXTRA="${{ matrix.ssl }}"
- run: make -C test clean_refprojs
refprojs_win:
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
ssl: ["", -DMG_TLS=MG_TLS_BUILTIN]
name: reference-projects_win ${{ matrix.ssl }}
steps:
- uses: actions/checkout@v4
# - uses: egor-tensin/setup-mingw@v2
# with:
# platform: x64
- name: test they build
run: make -C test refprojs_win CFLAGS_EXTRA="${{ matrix.ssl }}"
shell: cmd
- name: test they clean
run: make -C test clean_refprojs_win
shell: cmd
refprojs_mac:
runs-on: macos-latest
env: { HOMEBREW_NO_AUTO_UPDATE: 1 }
strategy:
fail-fast: false
matrix:
ssl: ["", -DMG_TLS=MG_TLS_BUILTIN]
name: reference-projects_mac ${{ matrix.ssl }}
steps:
- uses: actions/checkout@v4
- run: make -C test refprojs CFLAGS_EXTRA="${{ matrix.ssl }}"
- run: make -C test clean_refprojs
tutorials:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
ssl: ["", -DMG_TLS=MG_TLS_BUILTIN]
name: tutorials ${{ matrix.ssl }}
steps:
- uses: actions/checkout@v4
- run: sudo apt -y install libpcap-dev
- run: make -C test tutorials CFLAGS_EXTRA="${{ matrix.ssl }}"
- run: make -C test clean_tutorials
tutorials_win:
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
ssl: ["", -DMG_TLS=MG_TLS_BUILTIN]
name: tutorials_win ${{ matrix.ssl }}
steps:
- uses: actions/checkout@v4
# - uses: egor-tensin/setup-mingw@v2
# with:
# platform: x64
- name: test they build
run: make -C test tutorials_win CFLAGS_EXTRA="${{ matrix.ssl }}"
shell: cmd
- name: test they clean
run: make -C test clean_tutorials_win
shell: cmd
tutorials_mac:
runs-on: macos-latest
env: { HOMEBREW_NO_AUTO_UPDATE: 1 }
strategy:
fail-fast: false
matrix:
ssl: ["", -DMG_TLS=MG_TLS_BUILTIN]
name: tutorials_mac ${{ matrix.ssl }}
steps:
- uses: actions/checkout@v4
- run: make -C test tutorials_mac CFLAGS_EXTRA="${{ matrix.ssl }}"
- run: make -C test clean_tutorials_mac
arduino: arduino:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
with: { fetch-depth: 2 } with: { fetch-depth: 2 }
- run: echo # nothing specific to install or do - run: echo # nothing specific to install or do
- run: make -C examples/arduino arduino-xiao - run: make -C examples/arduino arduino-xiao
@@ -157,7 +302,7 @@ jobs:
env: env:
GO: 0 GO: 0
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
with: { fetch-depth: 2 } with: { fetch-depth: 2 }
- run: if ./test/match_changed_files.sh '^src|^examples/${{ matrix.example.path }}'; then echo GO=1 >> $GITHUB_ENV ; fi - run: if ./test/match_changed_files.sh '^src|^examples/${{ matrix.example.path }}'; then echo GO=1 >> $GITHUB_ENV ; fi
- run: echo # nothing specific to install or do - run: echo # nothing specific to install or do
@@ -198,7 +343,7 @@ jobs:
- path: ti/ek-tm4c1294xl-make-baremetal-builtin-rndis - path: ti/ek-tm4c1294xl-make-baremetal-builtin-rndis
name: ${{ matrix.example.path }} name: ${{ matrix.example.path }}
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
with: { fetch-depth: 2 } with: { fetch-depth: 2 }
- run: sudo apt -y update && sudo apt -y install gcc-arm-none-eabi - run: sudo apt -y update && sudo apt -y install gcc-arm-none-eabi
- run: make -C examples/${{ matrix.example.path }} build - run: make -C examples/${{ matrix.example.path }} build
@@ -212,7 +357,7 @@ jobs:
- path: esp32/device-dashboard - path: esp32/device-dashboard
name: ${{ matrix.example.path }} name: ${{ matrix.example.path }}
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
with: { fetch-depth: 2 } with: { fetch-depth: 2 }
- run: echo # nothing specific to install or do - run: echo # nothing specific to install or do
- run: make -C examples/${{ matrix.example.path }} build - run: make -C examples/${{ matrix.example.path }} build
@@ -222,12 +367,15 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
ssl: ["", -DMG_TLS=MG_TLS_BUILTIN]
example: example:
- path: microchip/same54-xpro/device-dashboard - path: microchip/same54-xpro/device-dashboard
- path: nxp/rt1020-evk-make-baremetal-builtin - path: nxp/rt1020-evk-make-baremetal-builtin
- path: nxp/rt1020-evk-make-freertos-builtin - path: nxp/rt1020-evk-make-freertos-builtin
- path: nxp/rt1060-evk-make-baremetal-builtin - path: nxp/rt1060-evk-make-baremetal-builtin
- path: nxp/rt1060-evk-make-freertos-builtin - path: nxp/rt1060-evk-make-freertos-builtin
- path: nxp/rt1170-evk-make-baremetal-builtin
- path: renesas/ek-ra6m4-make-baremetal-builtin
- path: rp2040/pico-rndis-dashboard - path: rp2040/pico-rndis-dashboard
- path: rp2040/pico-w - path: rp2040/pico-w
- path: rp2040/pico-w5500 - path: rp2040/pico-w5500
@@ -246,12 +394,12 @@ jobs:
- path: stm32/stm32h573i-dk-make-freertos-builtin - path: stm32/stm32h573i-dk-make-freertos-builtin
- path: ti/ek-tm4c1294xl-make-baremetal-builtin - path: ti/ek-tm4c1294xl-make-baremetal-builtin
- path: ti/ek-tm4c1294xl-make-freertos-builtin - path: ti/ek-tm4c1294xl-make-freertos-builtin
name: ${{ matrix.example.path }} name: ${{ matrix.example.path }} ${{ matrix.ssl }}
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
with: { fetch-depth: 2 } with: { fetch-depth: 2 }
- run: sudo apt -y update && sudo apt -y install gcc-arm-none-eabi - run: sudo apt -y update && sudo apt -y install gcc-arm-none-eabi
- run: make -C examples/${{ matrix.example.path }} build - run: make -C examples/${{ matrix.example.path }} build CFLAGS_EXTRA="${{ matrix.ssl }}"
# mqtt_dashboard_examples: # mqtt_dashboard_examples:
# runs-on: ubuntu-latest # runs-on: ubuntu-latest
@@ -262,7 +410,7 @@ jobs:
# - path: # - path:
# name: ${{ matrix.example.path }} # name: ${{ matrix.example.path }}
# steps: # steps:
# - uses: actions/checkout@v3 # - uses: actions/checkout@v4
# with: { fetch-depth: 2 } # with: { fetch-depth: 2 }
# - run: echo # nothing specific to install or do # - run: echo # nothing specific to install or do
# - run: make -C examples/${{ matrix.example.path }} build # - run: make -C examples/${{ matrix.example.path }} build
@@ -276,7 +424,7 @@ jobs:
- path: rp2040/pico-rndis-device - path: rp2040/pico-rndis-device
name: ${{ matrix.example.path }} name: ${{ matrix.example.path }}
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
with: { fetch-depth: 2 } with: { fetch-depth: 2 }
- run: sudo apt -y update && sudo apt -y install gcc-arm-none-eabi - run: sudo apt -y update && sudo apt -y install gcc-arm-none-eabi
- run: make -C examples/${{ matrix.example.path }} build - run: make -C examples/${{ matrix.example.path }} build
@@ -290,7 +438,7 @@ jobs:
# - path: # - path:
# name: ${{ matrix.example.path }} # name: ${{ matrix.example.path }}
# steps: # steps:
# - uses: actions/checkout@v3 # - uses: actions/checkout@v4
# with: { fetch-depth: 2 } # with: { fetch-depth: 2 }
# - run: echo # nothing specific to install or do # - run: echo # nothing specific to install or do
# - run: make -C examples/${{ matrix.example.path }} device_dashboard # - run: make -C examples/${{ matrix.example.path }} device_dashboard
@@ -305,7 +453,7 @@ jobs:
- path: stm32/nucleo-h723zg-make-baremetal-builtin - path: stm32/nucleo-h723zg-make-baremetal-builtin
name: ${{ matrix.example.path }} name: ${{ matrix.example.path }}
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
with: { fetch-depth: 2 } with: { fetch-depth: 2 }
- run: sudo apt -y update && sudo apt -y install gcc-arm-none-eabi - run: sudo apt -y update && sudo apt -y install gcc-arm-none-eabi
- run: make -C examples/${{ matrix.example.path }} device_dashboard - run: make -C examples/${{ matrix.example.path }} device_dashboard
@@ -314,7 +462,7 @@ jobs:
cube_examples: cube_examples:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
with: { fetch-depth: 2 } with: { fetch-depth: 2 }
- run: echo # nothing specific to install or do - run: echo # nothing specific to install or do
- run: cd test/cube && make - run: cd test/cube && make
@@ -322,7 +470,7 @@ jobs:
zephyr_examples: zephyr_examples:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
with: { fetch-depth: 2 } with: { fetch-depth: 2 }
- run: sudo apt -y update && sudo apt -y install gcc-arm-none-eabi - run: sudo apt -y update && sudo apt -y install gcc-arm-none-eabi
- run: make -C examples/zephyr init - run: make -C examples/zephyr init
@@ -340,7 +488,7 @@ jobs:
test_f7: test_f7:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
with: { fetch-depth: 2 } with: { fetch-depth: 2 }
- name: baremetal - name: baremetal
run: sudo apt -y update && sudo apt -y install gcc-arm-none-eabi run: sudo apt -y update && sudo apt -y install gcc-arm-none-eabi
@@ -356,7 +504,7 @@ jobs:
test_f4: test_f4:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
with: { fetch-depth: 2 } with: { fetch-depth: 2 }
- name: baremetal - name: baremetal
run: sudo apt -y update && sudo apt -y install gcc-arm-none-eabi run: sudo apt -y update && sudo apt -y install gcc-arm-none-eabi
@@ -371,7 +519,7 @@ jobs:
test_h743: test_h743:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
with: { fetch-depth: 3 } with: { fetch-depth: 3 }
- name: baremetal - name: baremetal
run: sudo apt -y update && sudo apt -y install gcc-arm-none-eabi run: sudo apt -y update && sudo apt -y install gcc-arm-none-eabi
@@ -385,7 +533,7 @@ jobs:
test_h723: test_h723:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
with: { fetch-depth: 3 } with: { fetch-depth: 3 }
- name: baremetal - name: baremetal
run: sudo apt -y update && sudo apt -y install gcc-arm-none-eabi run: sudo apt -y update && sudo apt -y install gcc-arm-none-eabi
@@ -395,7 +543,7 @@ jobs:
test_h5: test_h5:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
with: { fetch-depth: 3 } with: { fetch-depth: 3 }
- name: baremetal - name: baremetal
run: sudo apt -y update && sudo apt -y install gcc-arm-none-eabi run: sudo apt -y update && sudo apt -y install gcc-arm-none-eabi
@@ -405,7 +553,7 @@ jobs:
test_rt1020: test_rt1020:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
with: { fetch-depth: 3 } with: { fetch-depth: 3 }
- name: baremetal - name: baremetal
run: sudo apt -y update && sudo apt -y install gcc-arm-none-eabi run: sudo apt -y update && sudo apt -y install gcc-arm-none-eabi
@@ -415,17 +563,37 @@ jobs:
test_rt1060: test_rt1060:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
with: { fetch-depth: 3 } with: { fetch-depth: 3 }
- name: baremetal - name: baremetal
run: sudo apt -y update && sudo apt -y install gcc-arm-none-eabi run: sudo apt -y update && sudo apt -y install gcc-arm-none-eabi
- run: make -C examples/nxp/rt1060-evk-make-baremetal-builtin test VCON_API_KEY=${{secrets.VCON_API_KEY}} - run: make -C examples/nxp/rt1060-evk-make-baremetal-builtin test VCON_API_KEY=${{secrets.VCON_API_KEY}}
- run: make -C examples/nxp/rt1060-evk-make-freertos-builtin test VCON_API_KEY=${{secrets.VCON_API_KEY}} - run: make -C examples/nxp/rt1060-evk-make-freertos-builtin test VCON_API_KEY=${{secrets.VCON_API_KEY}}
test_rt1170:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with: { fetch-depth: 3 }
- name: baremetal
run: sudo apt -y update && sudo apt -y install gcc-arm-none-eabi
- run: make -C examples/nxp/rt1170-evk-make-baremetal-builtin test VCON_API_KEY=${{secrets.VCON_API_KEY}}
# - run: make -C examples/nxp/rt1170-evk-make-freertos-builtin test VCON_API_KEY=${{secrets.VCON_API_KEY}}
test_ra6m4:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with: { fetch-depth: 3 }
- name: baremetal
run: sudo apt -y update && sudo apt -y install gcc-arm-none-eabi
- run: make -C examples/renesas/ek-ra6m4-make-baremetal-builtin test VCON_API_KEY=${{secrets.VCON_API_KEY}}
# - run: make -C examples/renesas/ek-ra6m4-make-freertos-builtin test VCON_API_KEY=${{secrets.VCON_API_KEY}}
test_tm4c: test_tm4c:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
with: { fetch-depth: 2 } with: { fetch-depth: 2 }
- name: baremetal - name: baremetal
run: sudo apt -y update && sudo apt -y install gcc-arm-none-eabi run: sudo apt -y update && sudo apt -y install gcc-arm-none-eabi
@@ -435,7 +603,7 @@ jobs:
test_same54: test_same54:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
with: { fetch-depth: 2 } with: { fetch-depth: 2 }
- name: baremetal - name: baremetal
run: sudo apt -y update && sudo apt -y install gcc-arm-none-eabi run: sudo apt -y update && sudo apt -y install gcc-arm-none-eabi
@@ -445,7 +613,7 @@ jobs:
test_pico_w5500: test_pico_w5500:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
with: { fetch-depth: 2 } with: { fetch-depth: 2 }
- name: SDK - name: SDK
run: sudo apt -y update && sudo apt -y install gcc-arm-none-eabi run: sudo apt -y update && sudo apt -y install gcc-arm-none-eabi
+159 -79
View File
@@ -15,64 +15,58 @@ jobs:
matrix: matrix:
cc: [gcc, clang++] cc: [gcc, clang++]
target: [test, mip_test] target: [test, mip_test]
ssl: ["", MBEDTLS] ssl: ["", BUILTIN]
name: linux ${{ matrix.target }} CC=${{ matrix.cc }} SSL=${{ matrix.ssl }}} name: linux ${{ matrix.target }} CC=${{ matrix.cc }} SSL=${{ matrix.ssl }}
env: env:
CC: ${{ matrix.cc }} CC: ${{ matrix.cc }}
SSL: ${{ matrix.ssl }} SSL: ${{ matrix.ssl }}
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
with: { fetch-depth: 2 } with: { fetch-depth: 2 }
- run: if ./test/match_changed_files.sh '^test|^src/.*.[ch]' ; then echo GO=1 >> $GITHUB_ENV ; fi - run: if ./test/match_changed_files.sh '^test|^src/.*.[ch]' ; then echo GO=1 >> $GITHUB_ENV ; fi
- if: ${{ env.GO == 1 }} - if: ${{ env.GO == 1 }}
run: ./test/setup_ga_network.sh && sudo apt -y update ; sudo apt -y install libmbedtls-dev && make ${{ matrix.target }} run: ./test/setup_ga_network.sh && make -C test ${{ matrix.target }}
s390: s390:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
with: { fetch-depth: 2 } with: { fetch-depth: 2 }
- run: if ./test/match_changed_files.sh '^test|^src/.*.[ch]' ; then echo GO=1 >> $GITHUB_ENV ; fi - run: if ./test/match_changed_files.sh '^test|^src/.*.[ch]' ; then echo GO=1 >> $GITHUB_ENV ; fi
- if: ${{ env.GO == 1 }} - if: ${{ env.GO == 1 }}
run: sudo apt -y update ; sudo apt -y install qemu binfmt-support qemu-user-static && docker run --rm --privileged multiarch/qemu-user-static --reset -p yes && make s390 run: sudo apt -y update ; sudo apt -y install qemu binfmt-support qemu-user-static && docker run --rm --privileged multiarch/qemu-user-static --reset -p yes && make -C test s390
armhf: armhf:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
with: { fetch-depth: 2 } with: { fetch-depth: 2 }
- run: if ./test/match_changed_files.sh '^test|^src/.*.[ch]' ; then echo GO=1 >> $GITHUB_ENV ; fi - run: if ./test/match_changed_files.sh '^test|^src/.*.[ch]' ; then echo GO=1 >> $GITHUB_ENV ; fi
- if: ${{ env.GO == 1 }} - if: ${{ env.GO == 1 }}
run: sudo apt -y update ; sudo apt -y install qemu binfmt-support qemu-user-static && docker run --rm --privileged multiarch/qemu-user-static --reset -p yes && make armhf run: sudo apt -y update ; sudo apt -y install qemu binfmt-support qemu-user-static && docker run --rm --privileged multiarch/qemu-user-static --reset -p yes && make -C test armhf
linux2: unamalgamated-mg_prefix:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
with: { fetch-depth: 2 } with: { fetch-depth: 2 }
- run: if ./test/match_changed_files.sh '^test|^src/.*.[ch]' ; then echo GO=1 >> $GITHUB_ENV ; fi - run: if ./test/match_changed_files.sh '^test|^src/.*.[ch]' ; then echo GO=1 >> $GITHUB_ENV ; fi
- if: ${{ env.GO == 1 }} - if: ${{ env.GO == 1 }}
run: sudo apt -y update ; sudo apt -y install libmbedtls-dev valgrind run: make -C test unamalgamated && make -C test mg_prefix
- if: ${{ env.GO == 1 }}
run: make unamalgamated && make valgrind && make mg_prefix
macos: macos:
runs-on: macos-latest runs-on: macos-latest
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
ssl: ["", MBEDTLS] ssl: ["", BUILTIN]
name: macos SSL=${{ matrix.ssl }} name: macos SSL=${{ matrix.ssl }}
env: env:
SSL: ${{ matrix.ssl }} SSL: ${{ matrix.ssl }}
TFLAGS: -DNO_SNTP_CHECK -Wno-sign-conversion # Workaround for MbedTLS 3.5.0 TFLAGS: -DNO_SNTP_CHECK
HOMEBREW_NO_AUTO_UPDATE: 1 HOMEBREW_NO_AUTO_UPDATE: 1
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
with: { fetch-depth: 2 } with: { fetch-depth: 2 }
- run: if ./test/match_changed_files.sh '^test|^src/.*.[ch]' ; then echo GO=1 >> $GITHUB_ENV ; fi - run: if ./test/match_changed_files.sh '^test|^src/.*.[ch]' ; then echo GO=1 >> $GITHUB_ENV ; fi
- if: ${{ env.GO == 1 }} - if: ${{ env.GO == 1 }}
run: brew install jq mbedtls openssl run: make -C test test ASAN_OPTIONS=
- if: ${{ env.GO == 1 }}
run: make test ASAN_OPTIONS= MBEDTLS=`echo /usr/local/Cellar/mbedtls*/*` OPENSSL=`echo /usr/local/Cellar/openssl*/*`
- if: ${{ env.GO == 1 }}
run: make mg_prefix
windows: windows:
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy: strategy:
@@ -81,75 +75,102 @@ jobs:
target: [vc98, vc22, mingw++] target: [vc98, vc22, mingw++]
name: windows ${{ matrix.target }} name: windows ${{ matrix.target }}
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
with: { fetch-depth: 2 } with: { fetch-depth: 2 }
- run: if ./test/match_changed_files.sh '^test|^src/.*.[ch]' ; then echo GO=1 >> $GITHUB_ENV ; fi - run: if ./test/match_changed_files.sh '^test|^src/.*.[ch]' ; then echo GO=1 >> $GITHUB_ENV ; fi
- if: ${{ env.GO == 1 }} - if: ${{ env.GO == 1 }}
run: make ${{ matrix.target }} run: make -C test ${{ matrix.target }}
arm: arm:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
- run: make arm - run: make -C test arm
riscv: riscv:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
- run: make riscv - run: make -C test riscv
examples: examples:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
- run: sudo apt -y install libmbedtls-dev libpcap-dev - run: make -C test examples_essential
- run: make examples - run: make -C test clean_examples_essential
- run: make clean
examples_win: examples_win:
runs-on: windows-latest runs-on: windows-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
# - uses: egor-tensin/setup-mingw@v2 # - uses: egor-tensin/setup-mingw@v2
# with: # with:
# platform: x64 # platform: x64
- name: test they build - name: test they build
run: make examples_win run: make -C test examples_win
shell: cmd shell: cmd
- name: test they clean - name: test they clean
run: make clean_examples_win run: make -C test clean_examples_win
shell: cmd shell: cmd
examples_mac: examples_mac:
runs-on: macos-latest runs-on: macos-latest
env: { HOMEBREW_NO_AUTO_UPDATE: 1 } env: { HOMEBREW_NO_AUTO_UPDATE: 1 }
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
- run: make examples_mac - run: make -C test examples_mac
- run: make clean_examples_mac - run: make -C test clean_examples_mac
refprojs:
arduino:
runs-on: ubuntu-latest runs-on: ubuntu-latest
env:
GO: 0
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
with: { fetch-depth: 2 } - run: make -C test refprojs
- run: | - run: make -C test clean_refprojs
if ./test/match_changed_files.sh "^src|examples/device-dashboard|examples/arduino" ; then refprojs_win:
echo GO=1 >> $GITHUB_ENV runs-on: windows-latest
# nothing specific to install or do steps:
fi - uses: actions/checkout@v4
- if: ${{ env.GO == 1 }} # - uses: egor-tensin/setup-mingw@v2
run: | # with:
if ./test/match_changed_files.sh '^src|examples/arduino'; then # platform: x64
make -C examples/arduino arduino-xiao - name: test they build
fi run: make -C test refprojs_win
# - if: ${{ env.GO == 1 }} shell: cmd
# run: | - name: test they clean
# if ./test/match_changed_files.sh '^src|examples/arduino'; then run: make -C test clean_refprojs_win
# make -C examples/arduino arduino-nano shell: cmd
# fi refprojs_mac:
- if: ${{ env.GO == 1 }} runs-on: macos-latest
run: make -C examples/arduino clean env: { HOMEBREW_NO_AUTO_UPDATE: 1 }
steps:
- uses: actions/checkout@v4
- run: make -C test refprojs
- run: make -C test clean_refprojs
tutorials:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: make -C test tutorials_essential
- run: make -C test clean_tutorials_essential
tutorials_win:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
# - uses: egor-tensin/setup-mingw@v2
# with:
# platform: x64
- name: test they build
run: make -C test tutorials_win
shell: cmd
- name: test they clean
run: make -C test clean_tutorials_win
shell: cmd
tutorials_mac:
runs-on: macos-latest
env: { HOMEBREW_NO_AUTO_UPDATE: 1 }
steps:
- uses: actions/checkout@v4
- run: make -C test tutorials_mac
- run: make -C test clean_tutorials_mac
generic_examples: generic_examples:
@@ -164,7 +185,7 @@ jobs:
env: env:
GO: 0 GO: 0
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
with: { fetch-depth: 2 } with: { fetch-depth: 2 }
- run: if ./test/match_changed_files.sh '^src|^examples/${{ matrix.example.path }}'; then echo GO=1 >> $GITHUB_ENV ; fi - run: if ./test/match_changed_files.sh '^src|^examples/${{ matrix.example.path }}'; then echo GO=1 >> $GITHUB_ENV ; fi
- if: ${{ env.GO == 1 }} - if: ${{ env.GO == 1 }}
@@ -185,7 +206,7 @@ jobs:
env: env:
GO: 0 GO: 0
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
with: { fetch-depth: 2 } with: { fetch-depth: 2 }
- run: if ./test/match_changed_files.sh '^src|^examples/${{ matrix.example.path }}'; then echo GO=1 >> $GITHUB_ENV ; fi - run: if ./test/match_changed_files.sh '^src|^examples/${{ matrix.example.path }}'; then echo GO=1 >> $GITHUB_ENV ; fi
- if: ${{ env.GO == 1 }} - if: ${{ env.GO == 1 }}
@@ -204,7 +225,7 @@ jobs:
env: env:
GO: 0 GO: 0
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
with: { fetch-depth: 2 } with: { fetch-depth: 2 }
- run: | - run: |
if ./test/match_changed_files.sh '^src|examples/device-dashboard|^examples/${{ matrix.example.path }}'; then if ./test/match_changed_files.sh '^src|examples/device-dashboard|^examples/${{ matrix.example.path }}'; then
@@ -225,6 +246,8 @@ jobs:
- path: nxp/rt1020-evk-make-freertos-builtin - path: nxp/rt1020-evk-make-freertos-builtin
- path: nxp/rt1060-evk-make-baremetal-builtin - path: nxp/rt1060-evk-make-baremetal-builtin
- path: nxp/rt1060-evk-make-freertos-builtin - path: nxp/rt1060-evk-make-freertos-builtin
- path: nxp/rt1170-evk-make-baremetal-builtin
- path: renesas/ek-ra6m4-make-baremetal-builtin
- path: rp2040/pico-rndis-dashboard - path: rp2040/pico-rndis-dashboard
- path: rp2040/pico-w - path: rp2040/pico-w
- path: rp2040/pico-w5500 - path: rp2040/pico-w5500
@@ -247,7 +270,7 @@ jobs:
env: env:
GO: 0 GO: 0
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
with: { fetch-depth: 2 } with: { fetch-depth: 2 }
- run: | - run: |
if ./test/match_changed_files.sh '^src|examples/device-dashboard|^examples/${{ matrix.example.path }}'; then if ./test/match_changed_files.sh '^src|examples/device-dashboard|^examples/${{ matrix.example.path }}'; then
@@ -268,7 +291,7 @@ jobs:
# env: # env:
# GO: 0 # GO: 0
# steps: # steps:
# - uses: actions/checkout@v3 # - uses: actions/checkout@v4
# with: { fetch-depth: 2 } # with: { fetch-depth: 2 }
# - run: | # - run: |
# if ./test/match_changed_files.sh '^src|examples/mqtt-dashboard/device|^examples/${{ matrix.example.path }}'; then # if ./test/match_changed_files.sh '^src|examples/mqtt-dashboard/device|^examples/${{ matrix.example.path }}'; then
@@ -289,7 +312,7 @@ jobs:
env: env:
GO: 0 GO: 0
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
with: { fetch-depth: 2 } with: { fetch-depth: 2 }
- run: | - run: |
if ./test/match_changed_files.sh '^src|examples/mqtt-dashboard/device|^examples/${{ matrix.example.path }}'; then if ./test/match_changed_files.sh '^src|examples/mqtt-dashboard/device|^examples/${{ matrix.example.path }}'; then
@@ -310,7 +333,7 @@ jobs:
# env: # env:
# GO: 0 # GO: 0
# steps: # steps:
# - uses: actions/checkout@v3 # - uses: actions/checkout@v4
# with: { fetch-depth: 2 } # with: { fetch-depth: 2 }
# - run: | # - run: |
# if ./test/match_changed_files.sh '^src|examples/device-dashboard|examples/mqtt-dashboard/device|^examples/${{ matrix.example.path }}'; then # if ./test/match_changed_files.sh '^src|examples/device-dashboard|examples/mqtt-dashboard/device|^examples/${{ matrix.example.path }}'; then
@@ -339,7 +362,7 @@ jobs:
env: env:
GO: 0 GO: 0
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
with: { fetch-depth: 2 } with: { fetch-depth: 2 }
- run: | - run: |
if ./test/match_changed_files.sh '^src|examples/device-dashboard|examples/mqtt-dashboard/device|^examples/${{ matrix.example.path }}'; then if ./test/match_changed_files.sh '^src|examples/device-dashboard|examples/mqtt-dashboard/device|^examples/${{ matrix.example.path }}'; then
@@ -362,7 +385,7 @@ jobs:
env: env:
GO: 0 GO: 0
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
with: { fetch-depth: 2 } with: { fetch-depth: 2 }
- run: | - run: |
if ./test/match_changed_files.sh '^src|examples/stm32/nucleo-*-cube-*'; then if ./test/match_changed_files.sh '^src|examples/stm32/nucleo-*-cube-*'; then
@@ -377,7 +400,7 @@ jobs:
env: env:
GO: 0 GO: 0
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
with: { fetch-depth: 2 } with: { fetch-depth: 2 }
- name: baremetal - name: baremetal
run: | run: |
@@ -387,6 +410,7 @@ jobs:
fi fi
# always run baremetal on core or dashboard or specific example changes; other examples only on specific example changes # always run baremetal on core or dashboard or specific example changes; other examples only on specific example changes
- if: ${{ env.GO == 1 }} - if: ${{ env.GO == 1 }}
continue-on-error: true # continue so next test has a chance to re-flash and exit from collisions and flash failures
run: | run: |
if ./test/match_changed_files.sh '^src|examples/device-dashboard|examples/stm32/nucleo-f746zg-make-baremetal-builtin'; then if ./test/match_changed_files.sh '^src|examples/device-dashboard|examples/stm32/nucleo-f746zg-make-baremetal-builtin'; then
make -C examples/stm32/nucleo-f746zg-make-baremetal-builtin test VCON_API_KEY=${{secrets.VCON_API_KEY}} make -C examples/stm32/nucleo-f746zg-make-baremetal-builtin test VCON_API_KEY=${{secrets.VCON_API_KEY}}
@@ -430,7 +454,7 @@ jobs:
env: env:
GO: 0 GO: 0
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
with: { fetch-depth: 2 } with: { fetch-depth: 2 }
- name: baremetal - name: baremetal
run: | run: |
@@ -439,6 +463,7 @@ jobs:
sudo apt -y update && sudo apt -y install gcc-arm-none-eabi sudo apt -y update && sudo apt -y install gcc-arm-none-eabi
fi fi
- if: ${{ env.GO == 1 }} - if: ${{ env.GO == 1 }}
continue-on-error: true
run: | run: |
if ./test/match_changed_files.sh '^src|examples/device-dashboard|examples/stm32/nucleo-f429zi-make-baremetal-builtin'; then if ./test/match_changed_files.sh '^src|examples/device-dashboard|examples/stm32/nucleo-f429zi-make-baremetal-builtin'; then
make -C examples/stm32/nucleo-f429zi-make-baremetal-builtin test VCON_API_KEY=${{secrets.VCON_API_KEY}} make -C examples/stm32/nucleo-f429zi-make-baremetal-builtin test VCON_API_KEY=${{secrets.VCON_API_KEY}}
@@ -476,7 +501,7 @@ jobs:
env: env:
GO: 0 GO: 0
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
with: { fetch-depth: 3 } with: { fetch-depth: 3 }
- name: baremetal - name: baremetal
run: | run: |
@@ -485,6 +510,7 @@ jobs:
sudo apt -y update && sudo apt -y install gcc-arm-none-eabi sudo apt -y update && sudo apt -y install gcc-arm-none-eabi
fi fi
- if: ${{ env.GO == 1 }} - if: ${{ env.GO == 1 }}
continue-on-error: true
run: | run: |
if ./test/match_changed_files.sh '^src|examples/device-dashboard|examples/stm32/nucleo-h743zi-make-baremetal-builtin'; then if ./test/match_changed_files.sh '^src|examples/device-dashboard|examples/stm32/nucleo-h743zi-make-baremetal-builtin'; then
make -C examples/stm32/nucleo-h743zi-make-baremetal-builtin test VCON_API_KEY=${{secrets.VCON_API_KEY}} make -C examples/stm32/nucleo-h743zi-make-baremetal-builtin test VCON_API_KEY=${{secrets.VCON_API_KEY}}
@@ -517,7 +543,7 @@ jobs:
env: env:
GO: 0 GO: 0
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
with: { fetch-depth: 3 } with: { fetch-depth: 3 }
- name: baremetal - name: baremetal
run: | run: |
@@ -526,6 +552,7 @@ jobs:
sudo apt -y update && sudo apt -y install gcc-arm-none-eabi sudo apt -y update && sudo apt -y install gcc-arm-none-eabi
fi fi
- if: ${{ env.GO == 1 }} - if: ${{ env.GO == 1 }}
continue-on-error: true
run: | run: |
if ./test/match_changed_files.sh '^src|examples/device-dashboard|examples/stm32/nucleo-h723zg-make-baremetal-builtin'; then if ./test/match_changed_files.sh '^src|examples/device-dashboard|examples/stm32/nucleo-h723zg-make-baremetal-builtin'; then
make -C examples/stm32/nucleo-h723zg-make-baremetal-builtin test VCON_API_KEY=${{secrets.VCON_API_KEY}} make -C examples/stm32/nucleo-h723zg-make-baremetal-builtin test VCON_API_KEY=${{secrets.VCON_API_KEY}}
@@ -541,7 +568,7 @@ jobs:
env: env:
GO: 0 GO: 0
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
with: { fetch-depth: 3 } with: { fetch-depth: 3 }
- name: baremetal - name: baremetal
run: | run: |
@@ -550,6 +577,7 @@ jobs:
sudo apt -y update && sudo apt -y install gcc-arm-none-eabi sudo apt -y update && sudo apt -y install gcc-arm-none-eabi
fi fi
- if: ${{ env.GO == 1 }} - if: ${{ env.GO == 1 }}
continue-on-error: true
run: | run: |
if ./test/match_changed_files.sh '^src|examples/device-dashboard|examples/stm32/nucleo-h563zi-make-baremetal-builtin'; then if ./test/match_changed_files.sh '^src|examples/device-dashboard|examples/stm32/nucleo-h563zi-make-baremetal-builtin'; then
make -C examples/stm32/nucleo-h563zi-make-baremetal-builtin test VCON_API_KEY=${{secrets.VCON_API_KEY}} make -C examples/stm32/nucleo-h563zi-make-baremetal-builtin test VCON_API_KEY=${{secrets.VCON_API_KEY}}
@@ -565,7 +593,7 @@ jobs:
env: env:
GO: 0 GO: 0
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
with: { fetch-depth: 3 } with: { fetch-depth: 3 }
- name: baremetal - name: baremetal
run: | run: |
@@ -574,6 +602,7 @@ jobs:
sudo apt -y update && sudo apt -y install gcc-arm-none-eabi sudo apt -y update && sudo apt -y install gcc-arm-none-eabi
fi fi
- if: ${{ env.GO == 1 }} - if: ${{ env.GO == 1 }}
continue-on-error: true
run: | run: |
if ./test/match_changed_files.sh '^src|examples/device-dashboard|examples/nxp/rt1020-evk-make-baremetal-builtin'; then if ./test/match_changed_files.sh '^src|examples/device-dashboard|examples/nxp/rt1020-evk-make-baremetal-builtin'; then
make -C examples/nxp/rt1020-evk-make-baremetal-builtin test VCON_API_KEY=${{secrets.VCON_API_KEY}} make -C examples/nxp/rt1020-evk-make-baremetal-builtin test VCON_API_KEY=${{secrets.VCON_API_KEY}}
@@ -589,7 +618,7 @@ jobs:
env: env:
GO: 0 GO: 0
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
with: { fetch-depth: 3 } with: { fetch-depth: 3 }
- name: baremetal - name: baremetal
run: | run: |
@@ -598,6 +627,7 @@ jobs:
sudo apt -y update && sudo apt -y install gcc-arm-none-eabi sudo apt -y update && sudo apt -y install gcc-arm-none-eabi
fi fi
- if: ${{ env.GO == 1 }} - if: ${{ env.GO == 1 }}
continue-on-error: true
run: | run: |
if ./test/match_changed_files.sh '^src|examples/device-dashboard|examples/nxp/rt1060-evk-make-baremetal-builtin'; then if ./test/match_changed_files.sh '^src|examples/device-dashboard|examples/nxp/rt1060-evk-make-baremetal-builtin'; then
make -C examples/nxp/rt1060-evk-make-baremetal-builtin test VCON_API_KEY=${{secrets.VCON_API_KEY}} make -C examples/nxp/rt1060-evk-make-baremetal-builtin test VCON_API_KEY=${{secrets.VCON_API_KEY}}
@@ -608,12 +638,62 @@ jobs:
make -C examples/nxp/rt1060-evk-make-freertos-builtin test VCON_API_KEY=${{secrets.VCON_API_KEY}} make -C examples/nxp/rt1060-evk-make-freertos-builtin test VCON_API_KEY=${{secrets.VCON_API_KEY}}
fi fi
test_rt1170:
runs-on: ubuntu-latest
env:
GO: 0
steps:
- uses: actions/checkout@v4
with: { fetch-depth: 3 }
- name: baremetal
run: |
if ./test/match_changed_files.sh "^src|examples/device-dashboard|examples/nxp/rt1170.*-make-" ; then
echo GO=1 >> $GITHUB_ENV
sudo apt -y update && sudo apt -y install gcc-arm-none-eabi
fi
- if: ${{ env.GO == 1 }}
continue-on-error: true
run: |
if ./test/match_changed_files.sh '^src|examples/device-dashboard|examples/nxp/rt1170-evk-make-baremetal-builtin'; then
make -C examples/nxp/rt1170-evk-make-baremetal-builtin test VCON_API_KEY=${{secrets.VCON_API_KEY}}
fi
# - if: ${{ env.GO == 1 }}
# run: |
# if ./test/match_changed_files.sh 'examples/nxp/rt1170-evk-make-freertos-builtin'; then
# make -C examples/nxp/rt1170-evk-make-freertos-builtin test VCON_API_KEY=${{secrets.VCON_API_KEY}}
# fi
test_ra6m4:
runs-on: ubuntu-latest
env:
GO: 0
steps:
- uses: actions/checkout@v4
with: { fetch-depth: 3 }
- name: baremetal
run: |
if ./test/match_changed_files.sh "^src|examples/device-dashboard|examples/renesas/ek-ra6m4.*-make-" ; then
echo GO=1 >> $GITHUB_ENV
sudo apt -y update && sudo apt -y install gcc-arm-none-eabi
fi
- if: ${{ env.GO == 1 }}
continue-on-error: true
run: |
if ./test/match_changed_files.sh '^src|examples/device-dashboard|examples/renesas/ek-ra6m4-make-baremetal-builtin'; then
make -C examples/renesas/ek-ra6m4-make-baremetal-builtin test VCON_API_KEY=${{secrets.VCON_API_KEY}}
fi
# - if: ${{ env.GO == 1 }}
# run: |
# if ./test/match_changed_files.sh 'examples/renesas/ek-ra6m4-make-freertos-builtin'; then
# make -C examples/renesas/ek-ra6m4-make-freertos-builtin test VCON_API_KEY=${{secrets.VCON_API_KEY}}
# fi
test_tm4c: test_tm4c:
runs-on: ubuntu-latest runs-on: ubuntu-latest
env: env:
GO: 0 GO: 0
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
with: { fetch-depth: 2 } with: { fetch-depth: 2 }
- name: baremetal - name: baremetal
run: | run: |
@@ -637,7 +717,7 @@ jobs:
env: env:
GO: 0 GO: 0
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
with: { fetch-depth: 2 } with: { fetch-depth: 2 }
- name: baremetal - name: baremetal
run: | run: |
@@ -661,7 +741,7 @@ jobs:
env: env:
GO: 0 GO: 0
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
with: { fetch-depth: 2 } with: { fetch-depth: 2 }
- name: SDK - name: SDK
run: | run: |
+1 -1
View File
@@ -1,4 +1,4 @@
name: original workflow, updated name: original workflow, outdated # *** YES, OUTDATED *** kept for hystorical/reference purposes, attachment, etc.
on: on:
workflow_dispatch: workflow_dispatch:
env: env:
+1 -1
View File
@@ -1,5 +1,5 @@
Copyright (c) 2004-2013 Sergey Lyubka Copyright (c) 2004-2013 Sergey Lyubka
Copyright (c) 2013-2023 Cesanta Software Limited Copyright (c) 2013-2024 Cesanta Software Limited
All rights reserved All rights reserved
This software is dual-licensed: you can redistribute it and/or modify This software is dual-licensed: you can redistribute it and/or modify
-196
View File
@@ -1,196 +0,0 @@
SRCS = mongoose.c test/unit_test.c test/packed_fs.c
HDRS = $(wildcard src/*.h) $(wildcard src/drivers/*.h)
DEFS ?= -DMG_MAX_HTTP_HEADERS=7 -DMG_ENABLE_LINES -DMG_ENABLE_PACKED_FS=1 -DMG_ENABLE_SSI=1 -DMG_ENABLE_ASSERT=1
WARN ?= -pedantic -W -Wall -Werror -Wshadow -Wdouble-promotion -fno-common -Wconversion -Wundef
OPTS ?= -O3 -g3
INCS ?= -Isrc -I.
SSL ?=
CWD ?= $(realpath $(CURDIR))
ENV ?= -e Tmp=. -e WINEDEBUG=-all
DOCKER_BIN ?= docker
DOCKER ?= $(DOCKER_BIN) run --platform linux/amd64 --rm $(ENV) -v $(CWD):$(CWD) -w $(CWD)
VCFLAGS = /nologo /W3 /O2 /MD /I. $(DEFS) $(TFLAGS)
IPV6 ?= 1
ASAN ?= -fsanitize=address,undefined,alignment -fno-sanitize-recover=all -fno-omit-frame-pointer -fno-common
ASAN_OPTIONS ?= detect_leaks=1
EXAMPLES := $(dir $(wildcard examples/*/Makefile))
EXAMPLES_MAC := $(filter-out examples/mip-pcap/ examples/mip-tap/ examples/micropython/, $(EXAMPLES))
EXAMPLES_WIN := $(dir $(wildcard examples/device-dashboard/Makefile) $(wildcard examples/file-*/Makefile) $(wildcard examples/http-*/Makefile) $(wildcard examples/mqtt-*/Makefile) $(wildcard examples/websocket-*/Makefile) $(wildcard examples/webui-*/Makefile))
EXAMPLES_EMBEDDED := $(filter-out $(wildcard examples/zephyr/*/), $(dir $(wildcard examples/*/*/Makefile)))
PREFIX ?= /usr/local
LIBDIR ?= $(PREFIX)/lib
INCLUDEDIR ?= $(PREFIX)/include
VERSION ?= $(shell cut -d'"' -f2 src/version.h)
COMMON_CFLAGS ?= $(C_WARN) $(WARN) $(INCS) $(DEFS) -DMG_ENABLE_IPV6=$(IPV6) $(TFLAGS) -pthread
CFLAGS ?= $(OPTS) $(ASAN) $(COMMON_CFLAGS)
VALGRIND_CFLAGS ?= $(OPTS) $(COMMON_CFLAGS)
VALGRIND_RUN ?= valgrind --tool=memcheck --gen-suppressions=all --leak-check=full --show-leak-kinds=all --leak-resolution=high --track-origins=yes --error-exitcode=1 --exit-on-first-error=yes --fair-sched=yes
.PHONY: clean_examples examples mip_test test valgrind
ifeq "$(findstring ++,$(CC))" ""
# $(CC) does not end with ++, i.e. we're using C. Apply C flags
C_WARN ?= -Wmissing-prototypes -Wstrict-prototypes
else
# $(CC) ends with ++, i.e. we're using C++. Apply C++ flags
C_WARN ?= -Wno-deprecated
endif
ifeq "$(SSL)" "MBEDTLS"
MBEDTLS ?= /usr/local
CFLAGS += -DMG_TLS=MG_TLS_MBED -I$(MBEDTLS)/include -I/usr/include
LDFLAGS += -L$(MBEDTLS)/lib -lmbedtls -lmbedcrypto -lmbedx509
endif
ifeq "$(SSL)" "OPENSSL"
OPENSSL ?= /usr/local
CFLAGS += -DMG_TLS=MG_TLS_OPENSSL -I$(OPENSSL)/include
LDFLAGS += -L$(OPENSSL)/lib -lssl -lcrypto
endif
all:
$(MAKE) -C examples/http-server
tall: mg_prefix unamalgamated test mip_test arm examples vc98 vc17 vc22 mingw mingw++ fuzz
mip_test: test/mip_test.c mongoose.c mongoose.h Makefile mip_tap_test
$(CC) test/mip_test.c $(INCS) $(WARN) $(OPTS) $(C_WARN) $(ASAN) -o $@
ASAN_OPTIONS=$(ASAN_OPTIONS) $(RUN) ./$@
mip_tap_test: test/mip_tap_test.c mongoose.c mongoose.h Makefile
$(CC) test/mip_tap_test.c $(INCS) $(WARN) $(OPTS) $(C_WARN) $(ASAN) -o $@
ASAN_OPTIONS=$(ASAN_OPTIONS) $(RUN) ./$@
examples:
@for X in $(EXAMPLES); do test -f $$X/Makefile || continue; $(MAKE) -C $$X example || exit 1; done
clean_examples:
for X in $(EXAMPLES); do test -f $$X/Makefile || continue; $(MAKE) -C $$X clean || exit 1; done
examples_mac:
for X in $(EXAMPLES_MAC); do test -f $$X/Makefile || continue; $(MAKE) -C $$X example || exit 1; done
clean_examples_mac:
for X in $(EXAMPLES_MAC); do test -f $$X/Makefile || continue; $(MAKE) -C $$X clean || exit 1; done
examples_win:
$(foreach X, $(EXAMPLES_WIN), $(MAKE) -C $(X) example &)
clean_examples_win:
$(foreach X, $(EXAMPLES_WIN), $(MAKE) -C $(X) clean &)
test/packed_fs.c: Makefile src/ssi.h test/fuzz.c test/data/a.txt test/data/ca.pem
$(CC) $(CFLAGS) test/pack.c -o pack
$(RUN) ./pack Makefile src/ssi.h test/fuzz.c test/data/a.txt test/data/range.txt test/data/ca.pem > $@
# Check that all external (exported) symbols have "mg_" prefix
mg_prefix: mongoose.c mongoose.h
$(CC) mongoose.c $(CFLAGS) -c -o /tmp/x.o && nm /tmp/x.o | grep ' T ' | grep -v 'mg_' ; test $$? = 1
musl: test
musl: ASAN =
musl: WARN += -Wno-sign-conversion
musl: CC = $(DOCKER) mdashnet/cc1 gcc
musl: RUN = $(DOCKER) mdashnet/cc1
# Make sure we can build from unamalgamated sources.
unamalgamated: CFLAGS += -DMG_ENABLE_MD5=1
unamalgamated: $(HDRS) Makefile test/packed_fs.c
$(CC) src/*.c test/packed_fs.c test/unit_test.c $(CFLAGS) $(LDFLAGS) -g -o unit_test
fuzz: ASAN = -fsanitize=fuzzer,signed-integer-overflow,address,undefined
fuzz: mongoose.c mongoose.h Makefile test/fuzz.c
$(CC) test/fuzz.c $(OPTS) $(WARN) $(INCS) $(TFLAGS) $(ASAN) -o fuzzer
$(RUN) ./fuzzer
FUZZDATA ?= /tmp/fuzzdata
fuzz2: mongoose.c mongoose.h Makefile test/fuzz.c
$(CC) test/fuzz.c -DMAIN $(OPTS) $(WARN) $(ASAN) $(INCS) -o fuzzer
$(RUN) ./fuzzer $(FUZZDATA)
test: Makefile mongoose.h $(SRCS)
$(CC) $(SRCS) $(CFLAGS) $(LDFLAGS) -o unit_test
ASAN_OPTIONS=$(ASAN_OPTIONS) $(RUN) ./unit_test
coverage: CFLAGS += -coverage
coverage: test
gcov -l -n *.gcno | sed '/^$$/d' | sed 'N;s/\n/ /'
gcov -t mongoose.c > mongoose.gcov
upload-coverage: coverage
curl -s https://codecov.io/bash | /bin/bash
valgrind: Makefile mongoose.h mongoose.c
$(CC) $(SRCS) $(VALGRIND_CFLAGS) $(LDFLAGS) -g -o unit_test
$(VALGRIND_RUN) ./unit_test
misra:
cppcheck --addon=misra -DMG_ARCH=MG_ARCH_UNIX -DMG_ENABLE_PACKED_FS=1 -DMG_ENABLE_SSI=1 mongoose.c >/tmp/x 2>&1
cppcheck --addon=misra -DMG_ARCH=MG_ARCH_CUSTOM -DMG_ENABLE_LINES=1 -DTLS=MG_TLS_BUILTIN -DMG_ENABLE_TCPIP=1 mongoose.c >>/tmp/x 2>&1
cppcheck --addon=misra --clang -DMG_ENABLE_LINES=1 -DTLS=MG_TLS_BUILTIN -DMG_ENABLE_TCPIP=1 mongoose.c >>/tmp/x 2>&1
cppcheck --addon=misra --clang -DMG_ENABLE_LINES=1 -DMG_ENABLE_SSI=1 mongoose.c >>/tmp/x 2>&1
less /tmp/x
armhf: ASAN=
armhf: IPV6=0
armhf: CC = $(DOCKER) mdashnet/armhf cc
armhf: RUN = $(DOCKER) mdashnet/armhf
armhf: test
s390: ASAN=
s390: IPV6=0
s390: CC = $(DOCKER) mdashnet/s390 cc
s390: RUN = $(DOCKER) mdashnet/s390
s390: test
arm: DEFS += -DMG_ENABLE_POSIX_FS=0 -DMG_ENABLE_TCPIP=1 -DMG_ARCH=MG_ARCH_NEWLIB
arm: mongoose.h $(SRCS)
$(DOCKER) mdashnet/armgcc arm-none-eabi-gcc -mcpu=cortex-m3 -mthumb $(SRCS) $(OPTS) $(WARN) $(INCS) $(DEFS) $(TFLAGS) -o unit_test -nostartfiles --specs nosys.specs -e 0
riscv: DEFS += -DMG_ENABLE_POSIX_FS=0 -DMG_ENABLE_TCPIP=1 -DMG_ARCH=MG_ARCH_NEWLIB
riscv: mongoose.h $(SRCS)
$(DOCKER) mdashnet/riscv riscv-none-elf-gcc -march=rv32imc -mabi=ilp32 $(SRCS) $(OPTS) $(WARN) $(INCS) $(DEFS) $(TFLAGS) -o unit_test
vc98: Makefile mongoose.h $(SRCS)
$(DOCKER) mdashnet/vc98 wine cl $(SRCS) $(VCFLAGS) ws2_32.lib /Fe$@.exe
$(DOCKER) mdashnet/vc98 wine $@.exe
vc17: Makefile mongoose.h $(SRCS)
$(DOCKER) mdashnet/vc17 wine64 cl $(SRCS) $(VCFLAGS) ws2_32.lib /Fe$@.exe
$(DOCKER) mdashnet/vc17 wine64 $@.exe
vc22: Makefile mongoose.h $(SRCS)
$(DOCKER) mdashnet/vc22 wine64 cl $(SRCS) $(VCFLAGS) ws2_32.lib /Fe$@.exe
$(DOCKER) mdashnet/vc22 wine64 $@.exe
mingw: Makefile mongoose.h $(SRCS)
$(DOCKER) mdashnet/mingw x86_64-w64-mingw32-gcc $(SRCS) -W -Wall -Werror -I. $(DEFS) -lwsock32 -o $@.exe
$(DOCKER) mdashnet/mingw wine64 $@.exe
mingw++: Makefile mongoose.h $(SRCS)
$(DOCKER) mdashnet/mingw x86_64-w64-mingw32-g++ $(SRCS) -W -Wall -Werror -I. $(DEFS) -lwsock32 -o $@.exe
linux-libs: CFLAGS += -fPIC
linux-libs: LDFLAGS += -Wl,-soname,libmongoose.so.$(VERSION)
linux-libs: mongoose.o
$(CC) mongoose.o $(LDFLAGS) -shared -o libmongoose.so.$(VERSION)
$(AR) rcs libmongoose.a mongoose.o
install: linux-libs
install -Dm644 libmongoose.a libmongoose.so.$(VERSION) $(DESTDIR)$(LIBDIR)
ln -s libmongoose.so.$(VERSION) $(DESTDIR)$(LIBDIR)/libmongoose.so
install -Dm644 mongoose.h $(DESTDIR)$(INCLUDEDIR)/mongoose.h
uninstall:
rm -rf $(DESTDIR)$(LIBDIR)/libmongoose.a $(DESTDIR)$(LIBDIR)/libmongoose.so.$(VERSION) $(DESTDIR)$(INCLUDEDIR)/mongoose.h $(DESTDIR)$(LIBDIR)/libmongoose.so
mongoose.c: Makefile $(wildcard src/*.c) $(wildcard src/drivers/*.c)
(export LC_ALL=C ; cat src/license.h; echo; echo '#include "mongoose.h"' ; (for F in src/*.c src/drivers/*.c ; do echo; echo '#ifdef MG_ENABLE_LINES'; echo "#line 1 \"$$F\""; echo '#endif'; cat $$F | sed -e 's,#include ".*,,'; done))> $@
mongoose.h: $(HDRS) Makefile
(cat src/license.h; echo; echo '#ifndef MONGOOSE_H'; echo '#define MONGOOSE_H'; echo; cat src/version.h ; echo; echo '#ifdef __cplusplus'; echo 'extern "C" {'; echo '#endif'; cat src/arch.h src/arch_*.h src/net_ft.h src/net_lwip.h src/net_rl.h src/config.h src/str.h src/queue.h src/fmt.h src/printf.h src/log.h src/timer.h src/fs.h src/util.h src/url.h src/iobuf.h src/base64.h src/md5.h src/sha1.h src/sha256.h src/tls_aes128.h src/tls_uecc.h src/event.h src/net.h src/http.h src/ssi.h src/tls.h src/tls_mbed.h src/tls_openssl.h src/ws.h src/sntp.h src/mqtt.h src/dns.h src/json.h src/rpc.h src/ota.h src/device.h src/net_builtin.h src/profile.h src/drivers/*.h | sed -e '/keep/! s,#include ".*,,' -e 's,^#pragma once,,'; echo; echo '#ifdef __cplusplus'; echo '}'; echo '#endif'; echo '#endif // MONGOOSE_H')> $@
clean: clean_examples clean_embedded
rm -rf $(PROG) *.exe *.o *.dSYM *_test* ut fuzzer *.gcov *.gcno *.gcda *.obj *.exe *.ilk *.pdb slow-unit* _CL_* infer-out data.txt crash-* test/packed_fs.c pack
#find examples -maxdepth 3 -name zephyr -prune -o -name Makefile -print | xargs dirname | xargs -n1 make clean -C
clean_embedded:
for X in $(EXAMPLES_EMBEDDED); do test -f $$X/Makefile || continue; $(MAKE) -C $$X clean || exit 1; done
+73 -37
View File
@@ -1,15 +1,14 @@
# Mongoose - Embedded Web Server / Embedded Networking Library # Mongoose - Embedded Web Server / Embedded Network Library
[![License: GPLv2/Commercial](https://img.shields.io/badge/License-GPLv2%20or%20Commercial-green.svg)](https://opensource.org/licenses/gpl-2.0.php) [![License: GPLv2/Commercial](https://img.shields.io/badge/License-GPLv2%20or%20Commercial-green.svg)](https://opensource.org/licenses/gpl-2.0.php)
[![Build Status]( https://github.com/cesanta/mongoose/workflows/build/badge.svg)](https://github.com/cesanta/mongoose/actions) [![Build Status]( https://github.com/cesanta/mongoose/workflows/build/badge.svg)](https://github.com/cesanta/mongoose/actions)
[![Code Coverage](https://codecov.io/gh/cesanta/mongoose/branch/master/graph/badge.svg)](https://codecov.io/gh/cesanta/mongoose) [![Code Coverage](https://codecov.io/gh/cesanta/mongoose/branch/master/graph/badge.svg)](https://codecov.io/gh/cesanta/mongoose)
[![Fuzzing Status](https://oss-fuzz-build-logs.storage.googleapis.com/badges/mongoose.svg)](https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened&can=1&q=proj:mongoose) [![Fuzzing Status](https://oss-fuzz-build-logs.storage.googleapis.com/badges/mongoose.svg)](https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened&can=1&q=proj:mongoose)
Mongoose is a network library for C/C++. Mongoose is a network library for C/C++. It provides event-driven non-blocking
It implements event-driven APIs for TCP, UDP, HTTP, WebSocket, MQTT, and other protocols. It is designed
non-blocking APIs for TCP, UDP, HTTP, WebSocket, MQTT. It is designed for for connecting devices and bringing them online. On the market since 2004, used
connecting devices and bringing them online. On the market since 2004, used by by vast number of open source and commercial products - it even runs on the
vast number of open source and commercial products - it even runs on the
International Space Station! Mongoose makes embedded network programming fast, International Space Station! Mongoose makes embedded network programming fast,
robust, and easy. Features include: robust, and easy. Features include:
@@ -18,55 +17,57 @@ robust, and easy. Features include:
- works on STM32, NXP, ESP32, NRF52, TI, Microchip, and other - works on STM32, NXP, ESP32, NRF52, TI, Microchip, and other
- write code once - and it'll work everywhere - write code once - and it'll work everywhere
- ideal for the unification of the network infrastructure code across company - ideal for the unification of the network infrastructure code across company
- Built-in protocols: plain TCP/UDP, SNTP, HTTP, MQTT, Websocket - Built-in protocols: plain TCP/UDP, SNTP, HTTP, MQTT, Websocket, and other
- SSL/TLS support for mbedTLS and OpenSSL
- Asynchronous DNS resolver - Asynchronous DNS resolver
- Tiny static and run-time footprint - Tiny static and run-time footprint
- Source code is both ISO C and ISO C++ compliant - Source code is both ISO C and ISO C++ compliant
- Very easy to integrate: just copy `mongoose.c` and `mongoose.h` files to your source tree. See - Easy to integrate: just copy [mongoose.c](https://raw.githubusercontent.com/cesanta/mongoose/master/mongoose.c)
[exact steps](https://mongoose.ws/documentation/#2-minute-integration-guide) and [mongoose.h](https://raw.githubusercontent.com/cesanta/mongoose/master/mongoose.h) files to your source tree
- Works in any environment with socket API, like LwIP, Zephyr, Azure
- Built-in TCP/IP stack with drivers for bare metal or RTOS systems - Built-in TCP/IP stack with drivers for bare metal or RTOS systems
- Available drivers: STM32F, STM32H; NXP RT1xxx; TI TM4C; Microchip SAME54; Wiznet W5500 - Available drivers: STM32F, STM32H; NXP RT1xxx; TI TM4C; Microchip SAME54; Wiznet W5500
- A complete Web device dashboard on bare metal - A complete Web device dashboard on bare metal ST Nucleo boards is only 6 files
[Nucleo-F429ZI](examples/stm32/nucleo-f429zi-baremetal) is only 6 files
- For comparison, a CubeIDE generated HTTP example is 400+ files - For comparison, a CubeIDE generated HTTP example is 400+ files
- Built-in TLS 1.3 server-side support - Can run on top of an existing TCP/IP stack with BSD API, e.g. lwIP, Zephyr, Azure, etc
- Built-in TLS 1.3 ECC stack. Also can use external TLS libraries - mbedTLS, OpenSSL, or other
- Does not depend on any other software to implement networking - Does not depend on any other software to implement networking
- Built-in firmware updates for STM32H5, STM32H7, and more coming - Built-in firmware updates for STM32 H5, STM32 H7
- Detailed [user guide, API reference and tons of tutorials](https://mongoose.ws/documentation/)
## Usage See https://mongoose.ws/ for complete documentation, videos, case studies, etc.
## Usage Examples
Below are quick snippets that should give an idea how simple the API is and
how easy it is to create applications with it.
Create a simple web server that serves a directory. The behavior of the Create a simple web server that serves a directory. The behavior of the
HTTP server is specified by its event handler function: HTTP server is specified by its event handler function:
```c ```c
#include "mongoose.h" #include "mongoose.h" // To build, run: cc main.c mongoose.c
int main(void) {
struct mg_mgr mgr; // Declare event manager
mg_mgr_init(&mgr); // Initialise event manager
mg_http_listen(&mgr, "http://0.0.0.0:8000", fn, NULL); // Setup listener
for (;;) {
mg_mgr_poll(&mgr, 1000); // Run an infinite event loop
}
return 0;
}
// HTTP server event handler function // HTTP server event handler function
void fn(struct mg_connection *c, int ev, void *ev_data) { void ev_handler(struct mg_connection *c, int ev, void *ev_data) {
if (ev == MG_EV_HTTP_MSG) { if (ev == MG_EV_HTTP_MSG) {
struct mg_http_message *hm = (struct mg_http_message *) ev_data; struct mg_http_message *hm = (struct mg_http_message *) ev_data;
struct mg_http_serve_opts opts = { .root_dir = "./web_root/" }; struct mg_http_serve_opts opts = { .root_dir = "./web_root/" };
mg_http_serve_dir(c, hm, &opts); mg_http_serve_dir(c, hm, &opts);
} }
} }
int main(void) {
struct mg_mgr mgr; // Declare event manager
mg_mgr_init(&mgr); // Initialise event manager
mg_http_listen(&mgr, "http://0.0.0.0:8000", ev_handler, NULL); // Setup listener
for (;;) { // Run an infinite event loop
mg_mgr_poll(&mgr, 1000);
}
return 0;
}
``` ```
HTTP server implements a REST API that returns current time. JSON formatting: HTTP server implements a REST API that returns current time. JSON formatting:
```c ```c
static void fn(struct mg_connection *c, int ev, void *ev_data) { static void ev_handler(struct mg_connection *c, int ev, void *ev_data) {
if (ev == MG_EV_HTTP_MSG) { if (ev == MG_EV_HTTP_MSG) {
struct mg_http_message *hm = (struct mg_http_message *) ev_data; struct mg_http_message *hm = (struct mg_http_message *) ev_data;
if (mg_http_match_uri(hm, "/api/time/get")) { if (mg_http_match_uri(hm, "/api/time/get")) {
@@ -78,20 +79,55 @@ static void fn(struct mg_connection *c, int ev, void *ev_data) {
} }
``` ```
MQTT client that subscribes to a topic `aa/bb` and prints all incoming messages: MQTT client that subscribes to a topic `device1/rx` and
echoes incoming messages to `device1/tx`:
```c ```c
static void fn(struct mg_connection *c, int ev, void *ev_data) { #include "mongoose.h"
if (ev == MG_EV_MQTT_OPEN) {
struct mg_mqtt_opts opts = {.qos = 1, .topic = mg_str("aa/bb")}; static const char *s_mqtt_url = "mqtt://broker.hivemq.com:1883";
static struct mg_connection *s_mqtt_conn = NULL;
// MQTT connection event handler function
static void ev_handler(struct mg_connection *c, int ev, void *ev_data) {
if (ev == MG_EV_OPEN) {
MG_INFO(("%lu created, connecting to %s ...", c->id, s_mqtt_url));
} else if (ev == MG_EV_MQTT_OPEN) {
struct mg_mqtt_opts opts = {.qos = 1, .topic = mg_str("device1/rx")};
mg_mqtt_sub(c, &opts); mg_mqtt_sub(c, &opts);
MG_INFO(("%lu connected, subscribing to %s", c->id, opts.topic.buf));
} else if (ev == MG_EV_MQTT_MSG) { } else if (ev == MG_EV_MQTT_MSG) {
char response[100];
struct mg_mqtt_message *mm = (struct mg_mqtt_message *) ev_data; struct mg_mqtt_message *mm = (struct mg_mqtt_message *) ev_data;
printf("Topic: %.*s, Message: %.*s", struct mg_mqtt_opts opts = {.qos = 1, .topic = mg_str("device1/tx")};
mm->topic.len, mm->topic.ptr, mg_snprintf(response, sizeof(response), "Received [%.*s] / [%.*s]",
mm->data.len, mm->data.ptr); mm->topic.len, mm->topic.buf, mm->data.len, mm->data.buf);
opts.message = mg_str(response);
mg_mqtt_pub(c, &opts);
} else if (ev == MG_EV_CLOSE) {
MG_INFO(("%u closing", c->id));
s_mqtt_conn = NULL;
} }
} }
// Reconnection timer function. If we get disconnected, reconnect again
static void timer_fn(void *arg) {
struct mg_mgr *mgr = (struct mg_mgr *) arg;
if (s_mqtt_conn == NULL) {
struct mg_mqtt_opts opts = {.clean = true};
s_mqtt_conn = mg_mqtt_connect(mgr, s_mqtt_url, &opts, ev_handler, NULL);
}
}
int main() {
struct mg_mgr mgr; // Mongoose event manager. Holds all connections
mg_mgr_init(&mgr); // Initialise event manager
mg_timer_add(&mgr, 3000, MG_TIMER_REPEAT | MG_TIMER_RUN_NOW, timer_fn, &mgr);
for (;;) {
mg_mgr_poll(&mgr, 1000); // Infinite event loop
}
return 0;
}
``` ```
## Commercial use ## Commercial use
@@ -32,13 +32,13 @@ static void simple_http_listener(struct mg_connection *c, int ev, void *ev_data)
struct mg_http_message *hm = (struct mg_http_message *) ev_data; struct mg_http_message *hm = (struct mg_http_message *) ev_data;
// If the requested URI is "/api/hi", send a simple JSON response back // If the requested URI is "/api/hi", send a simple JSON response back
if (mg_http_match_uri(hm, "/api/hi")) { if (mg_match(hm->uri, mg_str("/api/hi"), NULL)) {
// Use mg_http_reply() API function to generate JSON response. It adds a // Use mg_http_reply() API function to generate JSON response. It adds a
// Content-Length header automatically. In the response, we show // Content-Length header automatically. In the response, we show
// the requested URI and HTTP body: // the requested URI and HTTP body:
mg_http_reply(c, 200, "", "{%m:%m,%m:%m}\n", // See mg_snprintf doc mg_http_reply(c, 200, "", "{%m:%m,%m:%m}\n", // See mg_snprintf doc
MG_ESC("uri"), mg_print_esc, hm->uri.len, hm->uri.ptr, MG_ESC("uri"), mg_print_esc, hm->uri.len, hm->uri.buf,
MG_ESC("body"), mg_print_esc, hm->body.len, hm->body.ptr); MG_ESC("body"), mg_print_esc, hm->body.len, hm->body.buf);
} else { } else {
// For all other URIs, serve some static content // For all other URIs, serve some static content
mg_http_reply(c, 200, "", "<html>millis: %lu</html>", millis()); mg_http_reply(c, 200, "", "<html>millis: %lu</html>", millis());
@@ -10,6 +10,7 @@
#define MG_ARCH MG_ARCH_CUSTOM #define MG_ARCH MG_ARCH_CUSTOM
#define MG_ENABLE_SOCKET 0 #define MG_ENABLE_SOCKET 0
#define MG_ENABLE_TCPIP 1 #define MG_ENABLE_TCPIP 1
#define MG_ENABLE_DRIVER_W5500 1
#define mkdir(a, b) (-1) #define mkdir(a, b) (-1)
#define MG_IO_SIZE 128 #define MG_IO_SIZE 128
//#define MG_ENABLE_LOG 0 //#define MG_ENABLE_LOG 0
@@ -10,6 +10,7 @@
#define MG_ARCH MG_ARCH_CUSTOM #define MG_ARCH MG_ARCH_CUSTOM
#define MG_ENABLE_SOCKET 0 #define MG_ENABLE_SOCKET 0
#define MG_ENABLE_TCPIP 1 #define MG_ENABLE_TCPIP 1
#define MG_ENABLE_DRIVER_W5500 1
#define mkdir(a, b) (-1) #define mkdir(a, b) (-1)
#define MG_IO_SIZE 512 #define MG_IO_SIZE 512
//#define MG_ENABLE_LOG 0 //#define MG_ENABLE_LOG 0
+2 -2
View File
@@ -26,8 +26,8 @@ static void fn(struct mg_connection *c, int ev, void *ev_data) {
// Received MQTT message // Received MQTT message
struct mg_mqtt_message *mm = (struct mg_mqtt_message *) ev_data; struct mg_mqtt_message *mm = (struct mg_mqtt_message *) ev_data;
MG_INFO(("%lu RECEIVED %.*s <- %.*s", c->id, (int) mm->data.len, MG_INFO(("%lu RECEIVED %.*s <- %.*s", c->id, (int) mm->data.len,
mm->data.ptr, (int) mm->topic.len, mm->topic.ptr)); mm->data.buf, (int) mm->topic.len, mm->topic.buf));
exec_command(mm->data.ptr, mm->data.len); exec_command(mm->data.buf, mm->data.len);
} else if (ev == MG_EV_CLOSE) { } else if (ev == MG_EV_CLOSE) {
MG_INFO(("%lu CLOSED", c->id)); MG_INFO(("%lu CLOSED", c->id));
mqtt_connection = NULL; mqtt_connection = NULL;
-1
View File
@@ -1 +0,0 @@
See detailed tutorial at https://mongoose.ws/tutorials/captive-dns-server/
-1
View File
@@ -1 +0,0 @@
../../mongoose.c
-1
View File
@@ -1 +0,0 @@
../../mongoose.h
-13
View File
@@ -10,17 +10,4 @@ following features:
needing a filesystem to serve it; so being resilient to FS problems needing a filesystem to serve it; so being resilient to FS problems
- All changes are propagated to all connected clients - All changes are propagated to all connected clients
## Screenshots
This is a login screen that prompts for user/password
![](screenshots/login.webp)
## Main dashboard
The main dashboard page shows the interactive console
![](screenshots/dashboard.webp)
See a detailed tutorial at https://mongoose.ws/tutorials/device-dashboard/ See a detailed tutorial at https://mongoose.ws/tutorials/device-dashboard/
+16 -16
View File
@@ -210,7 +210,7 @@ static void handle_firmware_upload(struct mg_connection *c,
mg_http_reply(c, 500, "", "offset and total not set\n"); mg_http_reply(c, 500, "", "offset and total not set\n");
} else if (ofs == 0 && mg_ota_begin((size_t) tot) == false) { } else if (ofs == 0 && mg_ota_begin((size_t) tot) == false) {
mg_http_reply(c, 500, "", "mg_ota_begin(%ld) failed\n", tot); mg_http_reply(c, 500, "", "mg_ota_begin(%ld) failed\n", tot);
} else if (data.len > 0 && mg_ota_write(data.ptr, data.len) == false) { } else if (data.len > 0 && mg_ota_write(data.buf, data.len) == false) {
mg_http_reply(c, 500, "", "mg_ota_write(%lu) @%ld failed\n", data.len, ofs); mg_http_reply(c, 500, "", "mg_ota_write(%lu) @%ld failed\n", data.len, ofs);
mg_ota_end(); mg_ota_end();
} else if (data.len == 0 && mg_ota_end() == false) { } else if (data.len == 0 && mg_ota_end() == false) {
@@ -273,33 +273,33 @@ static void fn(struct mg_connection *c, int ev, void *ev_data) {
struct mg_http_message *hm = (struct mg_http_message *) ev_data; struct mg_http_message *hm = (struct mg_http_message *) ev_data;
struct user *u = authenticate(hm); struct user *u = authenticate(hm);
if (mg_http_match_uri(hm, "/api/#") && u == NULL) { if (mg_match(hm->uri, mg_str("/api/#"), NULL) && u == NULL) {
mg_http_reply(c, 403, "", "Not Authorised\n"); mg_http_reply(c, 403, "", "Not Authorised\n");
} else if (mg_http_match_uri(hm, "/api/login")) { } else if (mg_match(hm->uri, mg_str("/api/login"), NULL)) {
handle_login(c, u); handle_login(c, u);
} else if (mg_http_match_uri(hm, "/api/logout")) { } else if (mg_match(hm->uri, mg_str("/api/logout"), NULL)) {
handle_logout(c); handle_logout(c);
} else if (mg_http_match_uri(hm, "/api/debug")) { } else if (mg_match(hm->uri, mg_str("/api/debug"), NULL)) {
handle_debug(c, hm); handle_debug(c, hm);
} else if (mg_http_match_uri(hm, "/api/stats/get")) { } else if (mg_match(hm->uri, mg_str("/api/stats/get"), NULL)) {
handle_stats_get(c); handle_stats_get(c);
} else if (mg_http_match_uri(hm, "/api/events/get")) { } else if (mg_match(hm->uri, mg_str("/api/events/get"), NULL)) {
handle_events_get(c, hm); handle_events_get(c, hm);
} else if (mg_http_match_uri(hm, "/api/settings/get")) { } else if (mg_match(hm->uri, mg_str("/api/settings/get"), NULL)) {
handle_settings_get(c); handle_settings_get(c);
} else if (mg_http_match_uri(hm, "/api/settings/set")) { } else if (mg_match(hm->uri, mg_str("/api/settings/set"), NULL)) {
handle_settings_set(c, hm->body); handle_settings_set(c, hm->body);
} else if (mg_http_match_uri(hm, "/api/firmware/upload")) { } else if (mg_match(hm->uri, mg_str("/api/firmware/upload"), NULL)) {
handle_firmware_upload(c, hm); handle_firmware_upload(c, hm);
} else if (mg_http_match_uri(hm, "/api/firmware/commit")) { } else if (mg_match(hm->uri, mg_str("/api/firmware/commit"), NULL)) {
handle_firmware_commit(c); handle_firmware_commit(c);
} else if (mg_http_match_uri(hm, "/api/firmware/rollback")) { } else if (mg_match(hm->uri, mg_str("/api/firmware/rollback"), NULL)) {
handle_firmware_rollback(c); handle_firmware_rollback(c);
} else if (mg_http_match_uri(hm, "/api/firmware/status")) { } else if (mg_match(hm->uri, mg_str("/api/firmware/status"), NULL)) {
handle_firmware_status(c); handle_firmware_status(c);
} else if (mg_http_match_uri(hm, "/api/device/reset")) { } else if (mg_match(hm->uri, mg_str("/api/device/reset"), NULL)) {
handle_device_reset(c); handle_device_reset(c);
} else if (mg_http_match_uri(hm, "/api/device/eraselast")) { } else if (mg_match(hm->uri, mg_str("/api/device/eraselast"), NULL)) {
handle_device_eraselast(c); handle_device_eraselast(c);
} else { } else {
struct mg_http_serve_opts opts; struct mg_http_serve_opts opts;
@@ -313,7 +313,7 @@ static void fn(struct mg_connection *c, int ev, void *ev_data) {
mg_http_serve_dir(c, ev_data, &opts); mg_http_serve_dir(c, ev_data, &opts);
} }
MG_DEBUG(("%lu %.*s %.*s -> %.*s", c->id, (int) hm->method.len, MG_DEBUG(("%lu %.*s %.*s -> %.*s", c->id, (int) hm->method.len,
hm->method.ptr, (int) hm->uri.len, hm->uri.ptr, (int) 3, hm->method.buf, (int) hm->uri.len, hm->uri.buf, (int) 3,
&c->send.buf[9])); &c->send.buf[9]));
} }
} }
Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

-1
View File
@@ -1 +0,0 @@
See detailed tutorial at https://mongoose.ws/tutorials/embedded-filesystem/
-1
View File
@@ -1 +0,0 @@
../../mongoose.c
-1
View File
@@ -1 +0,0 @@
../../mongoose.h
@@ -3,8 +3,5 @@ idf_component_register(SRCS "main.c"
"net.c" "net.c"
"packed_fs.c" "packed_fs.c"
"mongoose.c") "mongoose.c")
component_compile_options(-DMG_ENABLE_LINES)
component_compile_options(-DMG_ENABLE_PACKED_FS)
component_compile_options(-DHTTP_URL="http://0.0.0.0:80") component_compile_options(-DHTTP_URL="http://0.0.0.0:80")
component_compile_options(-DHTTPS_URL="https://0.0.0.0:443") component_compile_options(-DHTTPS_URL="https://0.0.0.0:443")
component_compile_options(-DMG_TLS=MG_TLS_NONE) # change to 'MG_TLS_MBED' to enable TLS
+237 -9
View File
@@ -1,22 +1,13 @@
// Copyright (c) 2020 Cesanta Software Limited // Copyright (c) 2020 Cesanta Software Limited
// All rights reserved // All rights reserved
#include "esp_spiffs.h"
#include "mongoose.h" #include "mongoose.h"
#include "net.h" #include "net.h"
#define WIFI_SSID "YOUR_WIFI_NETWORK_NAME" // SET THIS! #define WIFI_SSID "YOUR_WIFI_NETWORK_NAME" // SET THIS!
#define WIFI_PASS "YOUR_WIFI_PASSWORD" // SET THIS! #define WIFI_PASS "YOUR_WIFI_PASSWORD" // SET THIS!
#define FS_ROOT "/spiffs"
void app_main(void) { void app_main(void) {
// Mount filesystem
esp_vfs_spiffs_conf_t conf = {
.base_path = FS_ROOT, .max_files = 20, .format_if_mount_failed = true};
int res = esp_vfs_spiffs_register(&conf);
MG_INFO(("FS %s, %d", conf.base_path, res));
mg_file_printf(&mg_fs_posix, FS_ROOT "/hello.txt", "%s", "hello from ESP");
// Setup wifi. This function is implemented in wifi.c // Setup wifi. This function is implemented in wifi.c
// It blocks until connected to the configured WiFi network // It blocks until connected to the configured WiFi network
void wifi_init(const char *ssid, const char *pass); void wifi_init(const char *ssid, const char *pass);
@@ -35,3 +26,240 @@ void app_main(void) {
web_init(&mgr); web_init(&mgr);
for (;;) mg_mgr_poll(&mgr, 1000); // Infinite event loop for (;;) mg_mgr_poll(&mgr, 1000); // Infinite event loop
} }
#if MG_DEVICE == MG_DEVICE_CUSTOM
void *mg_flash_start(void) {
return NULL;
}
size_t mg_flash_size(void) {
return 0;
}
size_t mg_flash_sector_size(void) {
return 0;
}
size_t mg_flash_write_align(void) {
return 0;
}
int mg_flash_bank(void) {
return 0;
}
bool mg_flash_erase(void *location) {
(void) location;
return false;
}
bool mg_flash_swap_bank(void) {
return true;
}
bool mg_flash_write(void *addr, const void *buf, size_t len) {
(void) addr, (void) buf, (void) len;
return false;
}
void mg_device_reset(void) {
esp_restart();
}
#endif
#if MG_OTA == MG_OTA_CUSTOM
#include "esp_app_format.h"
#include "esp_ota_ops.h"
static size_t s_size = 0; // Firmware size to flash. In-progress indicator
static bool rx_checked = false; // Whether firmware being received has been checked as valid
const esp_partition_t * update_partition = NULL; // The partition the update is being applied to
esp_ota_handle_t update_handle = 0; // Handle of the current update process
const esp_partition_t * get_partition_from_fw(int fw) {
if (MG_FIRMWARE_CURRENT == fw) {
return esp_ota_get_running_partition();
}
const esp_partition_t * p = esp_ota_get_last_invalid_partition();
if (NULL == p) {
p = esp_ota_get_next_update_partition(NULL);
}
return p;
}
// Returns true if the data buffer contains the header of a valid firmware
const size_t fw_size_required = sizeof(esp_image_header_t) + sizeof(esp_image_segment_header_t) + sizeof(esp_app_desc_t);
bool check_fw_header(const void* buf, size_t len) {
// Ensure we have received enough data to do the check
if (len < fw_size_required) {
MG_ERROR(("Insufficient data to check firmware header - %d bytes, require %d bytes", len, fw_size_required));
return false;
}
// Check the magic word of the received firmare
esp_app_desc_t* rx_app_info = (esp_app_desc_t*)(((char*)buf) + sizeof(esp_image_header_t) + sizeof(esp_image_segment_header_t));
if (ESP_APP_DESC_MAGIC_WORD != rx_app_info->magic_word) {
MG_ERROR(("Invalid app - invalid magic word"));
return false;
}
MG_INFO(("Received firmware: %s %s", rx_app_info->project_name, rx_app_info->version));
// Get the name/version of the running firmware
const esp_partition_t *current = esp_ota_get_running_partition();
esp_app_desc_t curr_app_info;
esp_err_t res = esp_ota_get_partition_description(current, &curr_app_info);
if (ESP_OK != res) {
MG_ERROR(("Unable to get name/version of running firmware"));
return false;
}
MG_INFO(("Running firmware: %s %s", curr_app_info.project_name, curr_app_info.version));
// Check the name of the new firmware is the same as the old firmware
if (memcmp(curr_app_info.project_name, rx_app_info->project_name, sizeof(curr_app_info.project_name)) != 0) {
MG_ERROR(("Firmware name is different. Wrong firmware uploaded! Current %s Uploaded %s", curr_app_info.project_name, rx_app_info->project_name));
return false;
}
// Check the version of the new firmware is different from the old firmware
if (memcmp(curr_app_info.version, rx_app_info->version, sizeof(curr_app_info.version)) == 0) {
MG_ERROR(("Firmware version is the same. Wrong firmware uploaded! Current %s, Uploaded %s", curr_app_info.version, rx_app_info->version));
//return false;
}
return true;
}
bool mg_ota_begin(size_t new_firmware_size) {
rx_checked = false;
if (s_size) {
MG_ERROR(("OTA already in progress. Call mg_ota_end()"));
return false;
}
int partition_size = mg_ota_size(MG_FIRMWARE_PREVIOUS);
if (new_firmware_size > partition_size) {
MG_ERROR(("Firmware %lu bytes, max %lu", new_firmware_size, partition_size));
return false;
}
update_partition = esp_ota_get_next_update_partition(NULL);
if (NULL == update_partition) {
MG_ERROR(("esp_ota_get_next_update_partition returned NULL"));
return false;
}
esp_err_t res = esp_ota_begin(update_partition, OTA_WITH_SEQUENTIAL_WRITES, &update_handle);
if (res != ESP_OK) {
esp_ota_abort(update_handle);
MG_ERROR(("esp_ota_begin failed (%s)", esp_err_to_name(res)));
return false;
}
s_size = new_firmware_size;
MG_INFO(("Starting OTA, firmware size %lu", s_size));
return true;
}
bool mg_ota_write(const void *buf, size_t len) {
if (s_size == 0) {
MG_ERROR(("OTA is not started, call mg_ota_begin()"));
return false;
}
if (!rx_checked) {
if (!check_fw_header(buf, len)) {
return false;
}
rx_checked = true;
}
esp_err_t res = esp_ota_write(update_handle, buf, len);
if (res != ESP_OK) {
esp_ota_abort(update_handle);
MG_ERROR(("esp_ota_write FAILED (%s)", esp_err_to_name(res)));
return false;
}
return true;
}
bool mg_ota_end(void) {
if (0 == s_size) {
MG_INFO(("Finishing OTA: fail"));
return false;
}
s_size = 0;
esp_err_t err = esp_ota_end(update_handle);
if (err != ESP_OK) {
MG_ERROR(("esp_ota_end failed (%s)!", esp_err_to_name(err)));
return false;
}
err = esp_ota_set_boot_partition(update_partition);
if (err != ESP_OK) {
MG_ERROR(("esp_ota_set_boot_partition failed (%s)!", esp_err_to_name(err)));
return false;
}
return true;
}
bool mg_ota_commit(void) {
esp_ota_mark_app_valid_cancel_rollback();
return true;
}
bool mg_ota_rollback(void) {
if(esp_ota_check_rollback_is_possible()) {
esp_ota_mark_app_invalid_rollback_and_reboot();
return true;
}
MG_ERROR(("Rollback NOT possible"));
return false;
}
int mg_ota_status(int fw) {
const esp_partition_t *p = get_partition_from_fw(fw);
if (NULL == p) {
return 0;
}
int status = MG_OTA_UNAVAILABLE;
esp_ota_img_states_t img_state = ESP_OTA_IMG_UNDEFINED;
esp_err_t res = esp_ota_get_state_partition(p, &img_state);
if (ESP_OK == res) {
if (ESP_OTA_IMG_VALID == img_state) {
status = MG_OTA_COMMITTED;
} else if (ESP_OTA_IMG_UNDEFINED == img_state) {
status = MG_OTA_UNCOMMITTED;
} else if (ESP_OTA_IMG_INVALID == img_state) {
status = MG_OTA_UNAVAILABLE;
} else if (ESP_OTA_IMG_ABORTED == img_state) {
status = MG_OTA_UNAVAILABLE;
} else if (ESP_OTA_IMG_NEW == img_state) {
status = MG_OTA_FIRST_BOOT;
} else if (ESP_OTA_IMG_PENDING_VERIFY == img_state) {
status = MG_OTA_UNCOMMITTED;
}
}
return status;
}
uint32_t mg_ota_crc32(int fw) {
(void) fw;
return 0;
}
uint32_t mg_ota_timestamp(int fw) {
const esp_partition_t *p = get_partition_from_fw(fw);
esp_app_desc_t app;
esp_err_t res = esp_ota_get_partition_description(p, &app);
if (ESP_OK != res)
{
return 0;
}
struct tm datetime = {};
if (NULL == strptime(app.date, "%b %d %Y", &datetime))
{
return 0;
}
if (NULL == strptime(app.time, "%H:%M:%S", &datetime))
{
return 0;
}
return mktime(&datetime);
}
size_t mg_ota_size(int fw) {
const esp_partition_t *p = get_partition_from_fw(fw);
if (NULL == p) {
return 0;
}
return p->size;
}
#endif
@@ -0,0 +1,6 @@
#define MG_ARCH MG_ARCH_ESP32
#define MG_ENABLE_PACKED_FS 1
#define MG_TLS MG_TLS_NONE // change to 'MG_TLS_MBED' to enable TLS
#define MG_OTA MG_OTA_CUSTOM
#define MG_DEVICE MG_DEVICE_CUSTOM
+1 -1
View File
@@ -32,7 +32,7 @@ static void event_handler(void *arg, esp_event_base_t event_base,
esp_wifi_connect(); esp_wifi_connect();
} else if (event_base == WIFI_EVENT && } else if (event_base == WIFI_EVENT &&
event_id == WIFI_EVENT_STA_DISCONNECTED) { event_id == WIFI_EVENT_STA_DISCONNECTED) {
if (s_retry_num < 3) { if (s_retry_num < 10) {
esp_wifi_connect(); esp_wifi_connect();
s_retry_num++; s_retry_num++;
MG_INFO(("retry to connect to the AP")); MG_INFO(("retry to connect to the AP"));
@@ -1,5 +1,6 @@
# Name, Type, SubType, Offset, Size, Flags # Name, Type, SubType, Offset, Size, Flags
nvs, data, nvs, 0x9000, 0x6000, nvs, data, nvs, , 0x6000
phy_init, data, phy, 0xf000, 0x1000, otadata, data, ota, , 0x2000,
storage, data, spiffs, 0x10000, 0x10000, phy_init, data, phy, , 0x1000,
factory, app, factory, 0x100000, 1M, ota_0, app, ota_0, , 948K,
ota_1, app, ota_1, , 948K,
1 # Name # Name, Type, SubType, Offset, Size, Flags Type SubType Offset Size Flags
2 nvs nvs, data, nvs, , 0x6000 data nvs 0x9000 0x6000
3 phy_init otadata, data, ota, , 0x2000, data phy 0xf000 0x1000
4 storage phy_init, data, phy, , 0x1000, data spiffs 0x10000 0x10000
5 factory ota_0, app, ota_0, , 948K, app factory 0x100000 1M
6 ota_1, app, ota_1, , 948K,
@@ -1,4 +1,5 @@
CONFIG_PARTITION_TABLE_CUSTOM=y CONFIG_PARTITION_TABLE_CUSTOM=y
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv" CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv"
CONFIG_PARTITION_TABLE_FILENAME="partitions.csv" CONFIG_PARTITION_TABLE_FILENAME="partitions.csv"
CONFIG_BOOTLOADER_APP_ROLLBACK_ENABLE=y
#CONFIG_ESP_MAIN_TASK_STACK_SIZE=8192 #CONFIG_ESP_MAIN_TASK_STACK_SIZE=8192
+1 -1
View File
@@ -15,7 +15,7 @@ build: micropython
$(DOCKER) $(CMD) $(DOCKER) $(CMD)
micropython: micropython:
$(DOCKER) git clone https://github.com/micropython/micropython.git $(DOCKER) git clone --depth 1 -b v1.22.2 https://github.com/micropython/micropython.git
clean: clean:
test -d micropython && $(DOCKER) rm -rf micropython || true test -d micropython && $(DOCKER) rm -rf micropython || true
@@ -0,0 +1 @@
#define MG_ARCH MG_ARCH_ESP32
@@ -1,2 +0,0 @@
// For some reason, IDF detection at build time does not work here
#define MG_ARCH MG_ARCH_ESP32
@@ -5,6 +5,4 @@ idf_component_register(SRCS "main.c"
"net.c" "net.c"
"packed_fs.c" "packed_fs.c"
"mongoose.c") "mongoose.c")
component_compile_options(-DMG_ENABLE_LINES=1)
component_compile_options(-DMG_ENABLE_PACKED_FS=1)
component_compile_options(-DUART_API_IMPLEMENTED=1) component_compile_options(-DUART_API_IMPLEMENTED=1)
+5 -7
View File
@@ -5,14 +5,12 @@
const char *s_listening_url = "http://0.0.0.0:80"; const char *s_listening_url = "http://0.0.0.0:80";
#if 0 struct mg_str config_read(void) {
char *config_read(void) { return mg_file_read(&mg_fs_posix, FS_ROOT "/config.json");
return mg_file_read(&mg_fs_posix, FS_ROOT "/config.json", NULL);
} }
#endif
void config_write(struct mg_str config) { void config_write(struct mg_str config) {
mg_file_write(&mg_fs_posix, FS_ROOT "/config.json", config.ptr, config.len); mg_file_write(&mg_fs_posix, FS_ROOT "/config.json", config.buf, config.len);
} }
void app_main(void) { void app_main(void) {
@@ -24,13 +22,13 @@ void app_main(void) {
// Try to connect to wifi by using saved WiFi credentials // Try to connect to wifi by using saved WiFi credentials
struct mg_str json = mg_file_read(&mg_fs_posix, WIFI_FILE); struct mg_str json = mg_file_read(&mg_fs_posix, WIFI_FILE);
if (json.ptr != NULL) { if (json.buf != NULL) {
char *ssid = mg_json_get_str(json, "$.ssid"); char *ssid = mg_json_get_str(json, "$.ssid");
char *pass = mg_json_get_str(json, "$.pass"); char *pass = mg_json_get_str(json, "$.pass");
while (!wifi_init(ssid, pass)) (void) 0; while (!wifi_init(ssid, pass)) (void) 0;
free(ssid); free(ssid);
free(pass); free(pass);
free((void *) json.ptr); free((void *) json.buf);
} else { } else {
// If WiFi is not configured, run CLI until configured // If WiFi is not configured, run CLI until configured
MG_INFO(("WiFi is not configured, running CLI. Press enter")); MG_INFO(("WiFi is not configured, running CLI. Press enter"));
@@ -0,0 +1,3 @@
#define MG_ARCH MG_ARCH_ESP32
#define MG_ENABLE_PACKED_FS 1
@@ -7,4 +7,3 @@
# please read the ESP-IDF documents if you need to do this. # please read the ESP-IDF documents if you need to do this.
# #
COMPONENT_INCLUDES += ../../../../../..
@@ -23,10 +23,10 @@ static void cb(struct mg_connection *c, int ev, void *ev_data) {
static void cb2(struct mg_connection *c, int ev, void *ev_data) { static void cb2(struct mg_connection *c, int ev, void *ev_data) {
if (ev == MG_EV_CONNECT) { if (ev == MG_EV_CONNECT) {
struct mg_str s = mg_url_host(CLIENT_URL); struct mg_str s = mg_url_host(CLIENT_URL);
mg_printf(c, "GET / HTTP/1.0\r\nHost: %.*s\r\n\r\n", (int) s.len, s.ptr); mg_printf(c, "GET / HTTP/1.0\r\nHost: %.*s\r\n\r\n", (int) s.len, s.buf);
} else if (ev == MG_EV_HTTP_MSG) { } else if (ev == MG_EV_HTTP_MSG) {
struct mg_http_message *hm = ev_data; // Print HTTP response struct mg_http_message *hm = ev_data; // Print HTTP response
MG_INFO(("Fetched:\n%.*s", (int) hm->message.len, hm->message.ptr)); MG_INFO(("Fetched:\n%.*s", (int) hm->message.len, hm->message.buf));
c->is_draining = 1; c->is_draining = 1;
} }
} }
@@ -0,0 +1 @@
../../../../../mongoose.h
@@ -0,0 +1,2 @@
#define MG_ARCH MG_ARCH_ESP8266
+2 -2
View File
@@ -38,7 +38,7 @@ static void fn(struct mg_connection *c, int ev, void *ev_data) {
"Host: %.*s\r\n" "Host: %.*s\r\n"
"Content-Type: octet-stream\r\n" "Content-Type: octet-stream\r\n"
"Content-Length: %d\r\n", "Content-Length: %d\r\n",
mg_url_uri(s_url), (int) host.len, host.ptr, fsize); mg_url_uri(s_url), (int) host.len, host.buf, fsize);
mg_http_bauth(c, s_user, s_pass); // Add Basic auth header mg_http_bauth(c, s_user, s_pass); // Add Basic auth header
mg_printf(c, "%s", "\r\n"); // End HTTP headers mg_printf(c, "%s", "\r\n"); // End HTTP headers
} else if (ev == MG_EV_WRITE && c->send.len < MG_IO_SIZE) { } else if (ev == MG_EV_WRITE && c->send.len < MG_IO_SIZE) {
@@ -53,7 +53,7 @@ static void fn(struct mg_connection *c, int ev, void *ev_data) {
MG_DEBUG(("MSG")); MG_DEBUG(("MSG"));
// Response is received. Print it // Response is received. Print it
struct mg_http_message *hm = (struct mg_http_message *) ev_data; struct mg_http_message *hm = (struct mg_http_message *) ev_data;
printf("%.*s", (int) hm->body.len, hm->body.ptr); printf("%.*s", (int) hm->body.len, hm->body.buf);
c->is_draining = 1; // Tell mongoose to close this connection c->is_draining = 1; // Tell mongoose to close this connection
mg_fs_close(fd); mg_fs_close(fd);
*(bool *) c->fn_data = true; // Tell event loop to stop *(bool *) c->fn_data = true; // Tell event loop to stop
+77 -69
View File
@@ -25,79 +25,89 @@ static bool authuser(struct mg_http_message *hm) {
return false; return false;
} }
// Streaming upload example. Demonstrates how to use MG_EV_READ events struct upload_state {
// to get large payload in smaller chunks. To test, use curl utility: size_t expected; // POST data length, bytes
static void cb(struct mg_connection *c, int ev, void *ev_data) { size_t received; // Already received bytes
if (ev == MG_EV_READ) { void *fp; // Opened uploaded file
// Parse the incoming data ourselves. If we can parse the request, };
// store two size_t variables in c->data: expected len and recv len.
size_t *data = (size_t *) c->data; static void handle_uploads(struct mg_connection *c, int ev, void *ev_data) {
struct mg_fd *fd = (struct mg_fd *) c->fn_data; // get file descriptor struct upload_state *us = (struct upload_state *) c->data;
if (data[0]) { // Already parsed, receiving body struct mg_fs *fs = &mg_fs_posix;
data[1] += c->recv.len;
MG_DEBUG(("Got chunk len %lu, %lu total", c->recv.len, data[1])); // Catch /upload requests early, without buffering whole body
fd->fs->wr(fd->fd, c->recv.buf, c->recv.len); // When we receive MG_EV_HTTP_HDRS event, that means we've received all
c->recv.len = 0; // And cleanup the receive buffer. Streaming! // HTTP headers but not necessarily full HTTP body
if (data[1] >= data[0]) { if (ev == MG_EV_HTTP_HDRS) {
mg_fs_close(fd); struct mg_http_message *hm = (struct mg_http_message *) ev_data;
mg_http_reply(c, 200, "", "ok\n"); if (mg_match(hm->uri, mg_str("/upload/#"), NULL)) {
} c->pfn = NULL; // Silence HTTP protocol handler, we'll take over
} else if (c->is_resp == 0) { if (!authuser(hm)) {
struct mg_http_message hm; mg_http_reply(c, 403, "", "Denied\n");
int n = mg_http_parse((char *) c->recv.buf, c->recv.len, &hm); c->is_draining = 1; // Tell mongoose to close this connection
if (n < 0) mg_error(c, "Bad response"); } else if (hm->body.len > (size_t) s_max_size) {
if (n > 0) { mg_http_reply(c, 400, "", "Too long\n");
if (mg_http_match_uri(&hm, "/upload/#")) { c->is_draining = 1; // Tell mongoose to close this connection
if (!authuser(&hm)) { } else if (hm->uri.len == 8) { // 8: /upload/
mg_http_reply(c, 403, "", "Denied\n"); mg_http_reply(c, 400, "", "Name required\n");
c->is_draining = 1; // Tell mongoose to close this connection c->is_draining = 1; // Tell mongoose to close this connection
} else if (hm.body.len > (size_t) s_max_size) { } else if (strlen(s_upld_dir) + (hm->uri.len - 8) + 2 >
mg_http_reply(c, 400, "", "Too long\n"); MG_PATH_MAX) { // 2: MG_DIRSEP + NUL
c->is_draining = 1; // Tell mongoose to close this connection mg_http_reply(c, 400, "", "Path is too long\n");
} else if (hm.uri.len == 8) { // 8: /upload/ c->is_draining = 1; // Tell mongoose to close this connection
mg_http_reply(c, 400, "", "Name required\n"); } else {
c->is_draining = 1; // Tell mongoose to close this connection char fpath[MG_PATH_MAX];
} else if (strlen(s_upld_dir) + (hm.uri.len - 8) + 2 > snprintf(fpath, MG_PATH_MAX, "%s%c", s_upld_dir, MG_DIRSEP);
MG_PATH_MAX) { // 2: MG_DIRSEP + NUL strncat(fpath, hm->uri.buf + 8, hm->uri.len - 8);
mg_http_reply(c, 400, "", "Path is too long\n"); if (!mg_path_is_sane(mg_str(fpath))) {
mg_http_reply(c, 400, "", "Invalid path\n");
c->is_draining = 1; // Tell mongoose to close this connection
} else {
struct mg_fd *fd;
MG_DEBUG(("Got request"));
fs->rm(fpath); // Delete file if it exists
if ((fd = fs->op(fpath, MG_FS_WRITE)) == NULL) {
mg_http_reply(c, 400, "", "open failed: %d\n", errno);
c->is_draining = 1; // Tell mongoose to close this connection c->is_draining = 1; // Tell mongoose to close this connection
} else { } else {
char fpath[MG_PATH_MAX]; us->fp = fd;
snprintf(fpath, MG_PATH_MAX, "%s%c", s_upld_dir, MG_DIRSEP); us->expected = hm->body.len; // Store number of bytes we expect
strncat(fpath, hm.uri.ptr + 8, hm.uri.len - 8); mg_iobuf_del(&c->recv, 0, hm->head.len); // Delete HTTP headers
if (!mg_path_is_sane(fpath)) {
mg_http_reply(c, 400, "", "Invalid path\n");
c->is_draining = 1; // Tell mongoose to close this connection
} else {
MG_DEBUG(("Got request, chunk len %lu", c->recv.len - n));
if ((fd = mg_fs_open(&mg_fs_posix, fpath, MG_FS_WRITE)) == NULL) {
mg_http_reply(c, 400, "", "open failed: %d\n", errno);
c->is_draining = 1; // Tell mongoose to close this connection
} else {
c->fn_data = fd;
c->recv.len -= n; // remove headers
data[0] = hm.body.len;
data[1] = c->recv.len;
if (c->recv.len)
fd->fs->wr(fd->fd, c->recv.buf + n, c->recv.len);
c->recv.len = 0; // consume data
if (data[1] >= data[0]) {
mg_fs_close(fd);
mg_http_reply(c, 200, "", "ok\n");
}
}
}
} }
c->is_resp = 1; // ignore the rest of the body
} else {
struct mg_http_serve_opts opts = {0};
opts.root_dir = s_root_dir;
mg_http_serve_dir(c, &hm, &opts);
} }
} }
} }
} }
(void) ev_data;
// Catch uploaded file data for both MG_EV_READ and MG_EV_HTTP_HDRS
if (us->expected > 0 && c->recv.len > 0) {
us->received += c->recv.len;
MG_DEBUG(("Got chunk: %lu bytes, %lu so far, %lu total", c->recv.len,
us->received, us->expected));
if (us->fp) fs->wr(us->fp, c->recv.buf, c->recv.len); // Write to file
c->recv.len = 0; // Delete received data
if (us->received >= us->expected) {
// Uploaded everything. Send response back
MG_INFO(("Uploaded %lu bytes", us->received));
mg_http_reply(c, 200, NULL, "%lu ok\n", us->received);
if (us->fp) fs->cl(us->fp); // Close file
memset(us, 0, sizeof(*us)); // Cleanup upload state
c->is_draining = 1; // Close connection when response gets sent
}
}
}
static void cb(struct mg_connection *c, int ev, void *ev_data) {
if (ev == MG_EV_READ || ev == MG_EV_HTTP_HDRS) {
handle_uploads(c, ev, ev_data);
} else if (ev == MG_EV_HTTP_MSG && c->pfn != NULL) {
// Non-upload requests, we serve normally
// NOTE: handle_uploads() may delete request and reset c->pfn
struct mg_http_message *hm = (struct mg_http_message *) ev_data;
struct mg_http_serve_opts opts = {0};
opts.root_dir = s_root_dir;
mg_http_serve_dir(c, hm, &opts);
}
} }
static void usage(const char *prog) { static void usage(const char *prog) {
@@ -159,9 +169,7 @@ int main(int argc, char *argv[]) {
signal(SIGTERM, signal_handler); signal(SIGTERM, signal_handler);
mg_log_set(s_debug_level); mg_log_set(s_debug_level);
mg_mgr_init(&mgr); mg_mgr_init(&mgr);
// use mg_listen instead of mg_http_listen to be able to override the parser if (mg_http_listen(&mgr, s_listening_address, cb, NULL) == NULL) {
// and shape buffering
if (mg_listen(&mgr, s_listening_address, cb, NULL) == NULL) {
MG_ERROR(("Cannot listen on %s.", s_listening_address)); MG_ERROR(("Cannot listen on %s.", s_listening_address));
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
-1
View File
@@ -1 +0,0 @@
See detailed tutorial at https://mongoose.ws/tutorials/file-uploads/
@@ -1 +0,0 @@
../../mongoose.c
@@ -1 +0,0 @@
../../mongoose.h
@@ -1 +0,0 @@
See detailed tutorial at https://mongoose.ws/tutorials/file-uploads/
@@ -1 +0,0 @@
../../mongoose.c
@@ -1 +0,0 @@
../../mongoose.h
@@ -1 +0,0 @@
See detailed tutorial at https://mongoose.ws/tutorials/file-uploads/
-55
View File
@@ -1,55 +0,0 @@
// Copyright (c) 2020-2024 Cesanta Software Limited
// All rights reserved
//
// Streaming upload example. Demonstrates how to use MG_EV_READ events
// to get large payload in smaller chunks. To test, use curl utility:
//
// curl http://localhost:8000/upload?name=a.txt --data-binary @large_file.txt
#include "mongoose.h"
// HTTP request handler function. It implements the following endpoints:
// /upload - Saves the next file chunk
// all other URI - serves web_root/ directory
static void fn(struct mg_connection *c, int ev, void *ev_data) {
if (ev == MG_EV_READ) {
// Parse the incoming data ourselves. If we can parse the request,
// store two size_t variables in the c->data: expected len and recv len.
size_t *data = (size_t *) c->data;
if (data[0]) { // Already parsed, simply print received data
data[1] += c->recv.len;
MG_INFO(("Got chunk len %lu, %lu total", c->recv.len, data[1]));
c->recv.len = 0; // And cleanup the receive buffer. Streaming!
if (data[1] >= data[0]) mg_http_reply(c, 200, "", "ok\n");
} else {
struct mg_http_message hm;
int n = mg_http_parse((char *) c->recv.buf, c->recv.len, &hm);
if (n < 0) mg_error(c, "Bad response");
if (n > 0) {
if (mg_http_match_uri(&hm, "/upload")) {
MG_INFO(("Got chunk len %lu", c->recv.len - n));
data[0] = hm.body.len;
data[1] = c->recv.len - n;
if (data[1] >= data[0]) mg_http_reply(c, 200, "", "ok\n");
} else {
struct mg_http_serve_opts opts = {.root_dir = "web_root"};
mg_http_serve_dir(c, &hm, &opts);
}
}
}
}
(void) ev_data;
}
int main(void) {
struct mg_mgr mgr;
mg_mgr_init(&mgr);
mg_log_set(MG_LL_DEBUG); // Set debug log level
mg_listen(&mgr, "http://localhost:8000", fn, NULL);
for (;;) mg_mgr_poll(&mgr, 50);
mg_mgr_free(&mgr);
return 0;
}
@@ -1 +0,0 @@
../../mongoose.c
@@ -1 +0,0 @@
../../mongoose.h
-1
View File
@@ -1 +0,0 @@
See detailed tutorial at https://mongoose.ws/tutorials/http-client/
-1
View File
@@ -1 +0,0 @@
../../../test/data/ca.pem
-1
View File
@@ -1 +0,0 @@
../../mongoose.c
-1
View File
@@ -1 +0,0 @@
../../mongoose.h
-1
View File
@@ -1 +0,0 @@
See detailed tutorial at https://mongoose.ws/tutorials/http-proxy-client/
-1
View File
@@ -1 +0,0 @@
../../mongoose.c
-1
View File
@@ -1 +0,0 @@
../../mongoose.h
-1
View File
@@ -1 +0,0 @@
See detailed tutorial at https://mongoose.ws/tutorials/http-server/
-1
View File
@@ -1 +0,0 @@
../../mongoose.c
-1
View File
@@ -1 +0,0 @@
../../mongoose.h
-1
View File
@@ -1 +0,0 @@
See detailed tutorial at https://mongoose.ws/tutorials/http-reverse-proxy/
-1
View File
@@ -1 +0,0 @@
../../mongoose.c
-1
View File
@@ -1 +0,0 @@
../../mongoose.h
-1
View File
@@ -1 +0,0 @@
See detailed tutorial at https://mongoose.ws/tutorials/http-server/
-1
View File
@@ -1 +0,0 @@
../../mongoose.c
-1
View File
@@ -1 +0,0 @@
../../mongoose.h
@@ -1 +0,0 @@
../../mongoose.c
@@ -1 +0,0 @@
../../mongoose.h
-1
View File
@@ -1 +0,0 @@
See detailed tutorial at https://mongoose.ws/tutorials/huge-response/
-1
View File
@@ -1 +0,0 @@
../../mongoose.c
-1
View File
@@ -1 +0,0 @@
../../mongoose.h
@@ -0,0 +1,41 @@
CFLAGS = -W -Wall -Werror -Wextra -Wundef -Wshadow -Wdouble-promotion
CFLAGS += -Wformat-truncation -fno-common # -Wconversion is not SDK-friendly
CFLAGS += -g3 -Os -ffunction-sections -fdata-sections
CFLAGS += -I. -Icmsis_core/CMSIS/Core/Include -Icmsis_xmc7/devices/COMPONENT_CAT1C/include/
CFLAGS += -Icmsis_xmc7/devices/COMPONENT_CAT1C/include/ip/
CFLAGS += -mcpu=cortex-m7 -mthumb -mfloat-abi=hard -mfpu=fpv5-d16 $(CFLAGS_EXTRA)
LDSCRIPT = link.ld
LDFLAGS ?= -T$(LDSCRIPT) -nostdlib -nostartfiles --specs nano.specs -lc -lgcc -Wl,--gc-sections -Wl,-Map=$@.map
SOURCES = main.c hal.c startup.c
CFLAGS += -D__ATOLLIC__ -D__STARTUP_CLEAR_BSS # Make startup code work as expected
# Mongoose options are defined in mongoose_custom.h
SOURCES += mongoose.c net.c packed_fs.c
# Example specific build options. See README.md
CFLAGS += -DHTTP_URL=\"http://0.0.0.0/\" -DHTTPS_URL=\"https://0.0.0.0/\"
ifeq ($(OS),Windows_NT)
RM = cmd /C del /Q /F /S
else
RM = rm -rf
endif
all build example: firmware.bin
firmware.bin: firmware.elf
arm-none-eabi-objcopy -O binary $< $@
firmware.elf: cmsis_core cmsis_xmc7 $(SOURCES) hal.h link.ld Makefile
arm-none-eabi-gcc $(SOURCES) $(CFLAGS) $(LDFLAGS) -o $@
arm-none-eabi-size $@
cmsis_core: # ARM CMSIS core headers
git clone -q --depth 1 -b 5.9.0 https://github.com/ARM-software/CMSIS_5 $@
cmsis_xmc7:
git clone https://github.com/Infineon/mtb-pdl-cat1.git $@
echo "" > cmsis_xmc7/devices/COMPONENT_CAT1C/include/ip/system_cat1c.h
clean:
$(RM) firmware.* *.su cmsis_core cmsis_xmc7 *.zip
+146
View File
@@ -0,0 +1,146 @@
// Copyright (c) 2024 Cesanta Software Limited
// All rights reserved
#include "hal.h"
static volatile uint64_t s_ticks; // Milliseconds since boot
void SysTick_Handler(void) { // SyStick IRQ handler, triggered every 1ms
s_ticks++;
}
void mg_random(void *buf, size_t len) { // Use on-board RNG
for (size_t n = 0; n < len; n += sizeof(uint32_t)) {
uint32_t r = rng_read();
memcpy((char *) buf + n, &r, n + sizeof(r) > len ? len - n : sizeof(r));
}
}
uint64_t mg_millis(void) { // Let Mongoose use our uptime function
return s_ticks; // Return number of milliseconds since boot
}
void hal_init(void) {
clock_init(); // Set system clock to SYS_FREQUENCY
SystemCoreClock = SYS_FREQUENCY; // Update SystemCoreClock global var
SysTick_Config(SystemCoreClock / 1000); // Sys tick every 1ms
rng_init(); // Initialise random number generator
uart_init(UART_DEBUG, 115200); // Initialise UART
gpio_output(LED1); // Initialise LED1
gpio_output(LED2); // Initialise LED2
gpio_output(LED3); // Initialise LED3
ethernet_init(); // Initialise Ethernet pins
}
#if defined(__ARMCC_VERSION)
// Keil specific - implement IO printf redirection
int fputc(int c, FILE *stream) {
if (stream == stdout || stream == stderr) uart_write_byte(UART_DEBUG, c);
return c;
}
#elif defined(__GNUC__)
// ARM GCC specific. ARM GCC is shipped with Newlib C library.
// Implement newlib syscalls:
// _sbrk() for malloc
// _write() for printf redirection
// the rest are just stubs
#include <sys/stat.h> // For _fstat()
uint32_t SystemCoreClock;
void SystemInit(void) { // Called automatically by startup code
}
int _fstat(int fd, struct stat *st) {
(void) fd, (void) st;
return -1;
}
extern unsigned char _end[]; // End of data section, start of heap. See link.ld
static unsigned char *s_current_heap_end = _end;
size_t hal_ram_used(void) {
return (size_t) (s_current_heap_end - _end);
}
size_t hal_ram_free(void) {
unsigned char endofstack;
return (size_t) (&endofstack - s_current_heap_end);
}
void *_sbrk(int incr) {
unsigned char *prev_heap;
unsigned char *heap_end = (unsigned char *) ((size_t) &heap_end - 256);
prev_heap = s_current_heap_end;
// Check how much space we got from the heap end to the stack end
if (s_current_heap_end + incr > heap_end) return (void *) -1;
s_current_heap_end += incr;
return prev_heap;
}
int _open(const char *path) {
(void) path;
return -1;
}
int _close(int fd) {
(void) fd;
return -1;
}
int _isatty(int fd) {
(void) fd;
return 1;
}
int _lseek(int fd, int ptr, int dir) {
(void) fd, (void) ptr, (void) dir;
return 0;
}
void _exit(int status) {
(void) status;
for (;;) asm volatile("BKPT #0");
}
void _kill(int pid, int sig) {
(void) pid, (void) sig;
}
int _getpid(void) {
return -1;
}
int _write(int fd, char *ptr, int len) {
(void) fd, (void) ptr, (void) len;
if (fd == 1) uart_write_buf(UART_DEBUG, ptr, (size_t) len);
return -1;
}
int _read(int fd, char *ptr, int len) {
(void) fd, (void) ptr, (void) len;
return -1;
}
int _link(const char *a, const char *b) {
(void) a, (void) b;
return -1;
}
int _unlink(const char *a) {
(void) a;
return -1;
}
int _stat(const char *path, struct stat *st) {
(void) path, (void) st;
return -1;
}
int mkdir(const char *path, mode_t mode) {
(void) path, (void) mode;
return -1;
}
void _init(void) {
}
#endif // __GNUC__
+244
View File
@@ -0,0 +1,244 @@
// Copyright (c) 2023 Cesanta Software Limited
// All rights reserved
#pragma once
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#define LED1 PIN(16, 1)
#define LED2 PIN(16, 2)
#define LED3 PIN(16, 3)
#include "xmc7200d_e272k8384.h"
#define BIT(x) (1UL << (x))
#define CLRSET(reg, clear, set) ((reg) = ((reg) & ~(clear)) | (set))
#define PIN(bank, num) ((bank << 8) | (num))
#define PINNO(pin) (pin & 255)
#define PINBANK(pin) (pin >> 8)
void hal_init(void);
size_t hal_ram_free(void);
size_t hal_ram_used(void);
static inline void spin(volatile uint32_t count) {
while (count--) (void) 0;
}
extern uint32_t SystemCoreClock;
enum {PLL_FEEDBACK = 50, PLL_REF = 1, PLL_OUT = 4};
#define CLK_IMO 8000000UL
#define SYS_FREQUENCY ((CLK_IMO * PLL_FEEDBACK) / (PLL_REF * PLL_OUT))
#ifndef UART_DEBUG
#define UART_DEBUG SCB3
#endif
enum { GPIO_MODE_INPUT, GPIO_MODE_OUTPUT, GPIO_MODE_AF, GPIO_MODE_ANALOG };
enum { GPIO_HIGHZ = 0, GPIO_PULLUP = 2, GPIO_PULLDOWN = 3, GPIO_OPENDRAIN_LOW = 4,
GPIO_OPENDRAIN_HIGH = 5, GPIO_STRONG = 6, GPIO_PULLUP_DOWN = 7};
enum { GPIO_SPEED_LOW = 3, GPIO_SPEED_MEDIUM = 2, GPIO_SPEED_HIGH = 0};
#undef GPIO
#define GPIO_TypeDef GPIO_PRT_Type
#define GPIO(N) ((GPIO_TypeDef *) (GPIO_BASE + 0x80 * (N)))
static GPIO_TypeDef *gpio_bank(uint16_t pin) { return GPIO(PINBANK(pin)); }
static inline void gpio_init(uint16_t pin, uint8_t mode, uint8_t type,
uint8_t speed, uint8_t pull, uint8_t af) {
(void) pin, (void) mode, (void) type, (void) speed, (void) pull, (void) af;
GPIO_TypeDef *gpio = gpio_bank(pin);
uint8_t pinno = PINNO(pin);
uint32_t msk, pos;
// configure input / output direction
if (mode == GPIO_MODE_INPUT) {
gpio->CFG |= 1 << (4 * pinno + 3); // enable input buffer (IN_ENx)
}
if (af || (mode == GPIO_MODE_AF && af)) {
// configure alternate function
HSIOM_PRT_Type* hsiom = ((HSIOM_PRT_Type*) HSIOM) + PINBANK(pin);
volatile uint32_t *port_sel = pinno < 4 ? &hsiom->PORT_SEL0 : &hsiom->PORT_SEL1;
pos = 8 * (pinno % 4), msk = 0x1f << pos;
*port_sel &= ~msk, *port_sel |= af << pos;
}
// configure driver mode
msk = 7, pos = 4 * pinno;
CLRSET(gpio->CFG, msk << pos, type << pos);
// configure speed
msk = 3, pos = 2 * pinno + 16;
CLRSET(gpio->CFG_OUT, msk << pos, speed << pos);
if (mode == GPIO_MODE_OUTPUT /*&& af == 0*/) {
gpio->OUT_SET = (1 << pinno);
}
}
static inline void gpio_input(uint16_t pin) {
gpio_init(pin, GPIO_MODE_INPUT, GPIO_HIGHZ, GPIO_SPEED_HIGH,
0, 0);
}
static inline void gpio_output(uint16_t pin) {
gpio_init(pin, GPIO_MODE_OUTPUT, GPIO_STRONG, GPIO_SPEED_MEDIUM,
0, 0);
}
static inline bool gpio_read(uint16_t pin) {
GPIO_TypeDef *gpio = gpio_bank(pin);
uint8_t pinno = PINNO(pin);
if (gpio->CFG & (1 << (4 * pinno + 3))) {
// pin mode is input, reading from GPIO_PRT_IN
return gpio->IN & (1 << pinno);
} else {
// pin mode is output, reading from GPIO_PRT_OUT
return gpio->OUT & (1 << pinno);
}
}
static inline void gpio_write(uint16_t pin, bool value) {
GPIO_TypeDef *gpio = gpio_bank(pin);
uint8_t pinno = PINNO(pin);
if (value) {
gpio->OUT_SET = 1 << pinno;
} else {
gpio->OUT_CLR = 1 << pinno;
}
}
static inline void gpio_toggle(uint16_t pin) {
gpio_write(pin, !gpio_read(pin));
}
static inline void uart_init(volatile CySCB_Type *uart, unsigned long baud) {
(void) uart, (void) baud;
uint16_t rx = 0, tx = 0;
if (uart == SCB3) {
rx = PIN(13, 0), tx = PIN(13, 1);
} else {
return; // unsupported uart
}
// set pins
gpio_init(rx, GPIO_MODE_INPUT, GPIO_HIGHZ, GPIO_SPEED_HIGH, 0, 17);
gpio_init(tx, GPIO_MODE_OUTPUT, GPIO_STRONG, GPIO_SPEED_HIGH, 0, 17);
// enable peripheral clock (18.6.2)
// compute divider first (we choose 24 bit divider 0)
unsigned long div = 0, frac = 0, ovs = 16;
div = SYS_FREQUENCY / (baud * ovs);
if (div == 0) div = 1;
frac = SYS_FREQUENCY % (baud * ovs);
frac = (frac * 100) / (baud * ovs);
PERI_PCLK->GR[1].DIV_CMD = (3 << PERI_PCLK_GR_DIV_CMD_TYPE_SEL_Pos) |
PERI_PCLK_GR_DIV_CMD_PA_DIV_SEL_Msk |
PERI_PCLK_GR_DIV_CMD_PA_TYPE_SEL_Msk;
PERI_PCLK->GR[1].DIV_CMD |= PERI_PCLK_GR_DIV_CMD_DISABLE_Msk; // disable divider
PERI_PCLK->GR[1].DIV_24_5_CTL[0] = (((uint8_t) (div - 1)) << PERI_PCLK_GR_DIV_24_5_CTL_INT24_DIV_Pos) |
(frac << PERI_PCLK_GR_DIV_24_5_CTL_FRAC5_DIV_Pos);
PERI_PCLK->GR[1].DIV_CMD = (3 << PERI_PCLK_GR_DIV_CMD_TYPE_SEL_Pos) |
PERI_PCLK_GR_DIV_CMD_PA_DIV_SEL_Msk |
PERI_PCLK_GR_DIV_CMD_PA_TYPE_SEL_Msk;;
PERI_PCLK->GR[1].DIV_CMD |= PERI_PCLK_GR_DIV_CMD_ENABLE_Msk; // enable divider
PERI_PCLK->GR[1].CLOCK_CTL[PCLK_SCB3_CLOCK & 0xff] = 3 << PERI_PCLK_GR_CLOCK_CTL_TYPE_SEL_Pos; // connect SCB3 to div_24_5_ctl[0]
// configure UART interface
uart->CTRL = ((ovs - 1) << SCB_CTRL_OVS_Pos) | (2 << SCB_CTRL_MODE_Pos);
uart->UART_CTRL = 0;
uart->UART_RX_CTRL = 1 << SCB_UART_RX_CTRL_STOP_BITS_Pos;
uart->RX_CTRL = 7 << SCB_RX_CTRL_DATA_WIDTH_Pos;
uart->UART_TX_CTRL = 1 << SCB_UART_TX_CTRL_STOP_BITS_Pos;
uart->TX_CTRL = 7 << SCB_TX_CTRL_DATA_WIDTH_Pos;
uart->TX_FIFO_CTRL = 1 << 16;
uart->TX_FIFO_CTRL = 0;
uart->CTRL |= 1 << SCB_CTRL_ENABLED_Pos;
}
static inline void uart_write_byte(volatile CySCB_Type *uart, uint8_t byte) {
(void) byte; (void) uart;
while((uart->INTR_TX & SCB_INTR_TX_EMPTY_Msk) == 0) spin(1);
uart->TX_FIFO_WR = byte;
uart->INTR_TX |= ~SCB_INTR_TX_EMPTY_Msk;
}
static inline void uart_write_buf(volatile CySCB_Type *uart, char *buf, size_t len) {
while (len-- > 0) uart_write_byte(uart, *(uint8_t *) buf++);
}
static inline void rng_init(void) {
}
static inline uint32_t rng_read(void) {
return 0;
}
static inline void ethernet_init(void) {
gpio_init(PIN(26, 0), GPIO_MODE_INPUT, GPIO_HIGHZ, GPIO_SPEED_HIGH, 0, 27); // ETH1_REF_CLK
gpio_init(PIN(26, 1), GPIO_MODE_OUTPUT, GPIO_STRONG, GPIO_SPEED_HIGH, 0, 27); // ETH1_TX_CTL
gpio_init(PIN(26, 2), GPIO_MODE_OUTPUT, GPIO_STRONG, GPIO_SPEED_HIGH, 0, 27); // ETH1_TX_CLK
gpio_init(PIN(26, 3), GPIO_MODE_OUTPUT, GPIO_STRONG, GPIO_SPEED_HIGH, 0, 27); // ETH1_TXD_0
gpio_init(PIN(26, 4), GPIO_MODE_OUTPUT, GPIO_STRONG, GPIO_SPEED_HIGH, 0, 27); // ETH1_TXD_1
gpio_init(PIN(26, 5), GPIO_MODE_OUTPUT, GPIO_STRONG, GPIO_SPEED_HIGH, 0, 27); // ETH1_TXD_2
gpio_init(PIN(26, 6), GPIO_MODE_OUTPUT, GPIO_STRONG, GPIO_SPEED_HIGH, 0, 27); // ETH1_TXD_3
gpio_init(PIN(26, 7), GPIO_MODE_INPUT, GPIO_HIGHZ, GPIO_SPEED_HIGH, 0, 27); // ETH1_RXD_0
gpio_init(PIN(27, 0), GPIO_MODE_INPUT, GPIO_HIGHZ, GPIO_SPEED_HIGH, 0, 27); // ETH1_RXD_1
gpio_init(PIN(27, 1), GPIO_MODE_INPUT, GPIO_HIGHZ, GPIO_SPEED_HIGH, 0, 27); // ETH1_RXD_2
gpio_init(PIN(27, 2), GPIO_MODE_INPUT, GPIO_HIGHZ, GPIO_SPEED_HIGH, 0, 27); // ETH1_RXD_3
gpio_init(PIN(27, 3), GPIO_MODE_INPUT, GPIO_HIGHZ, GPIO_SPEED_HIGH, 0, 27); // ETH1_RX_CTL
gpio_init(PIN(27, 4), GPIO_MODE_INPUT, GPIO_HIGHZ, GPIO_SPEED_HIGH, 0, 27); // ETH1_RX_CLK
gpio_init(PIN(27, 5), GPIO_MODE_INPUT, GPIO_STRONG, GPIO_SPEED_LOW, 0, 27); // ETH1_MDIO
gpio_init(PIN(27, 6), GPIO_MODE_OUTPUT, GPIO_STRONG, GPIO_SPEED_LOW, 0, 27); // ETH1_MDC
//gpio_init(PIN(27, 7), GPIO_MODE_OUTPUT, GPIO_HIGHZ, GPIO_SPEED_HIGH, 0, 0); // ETH1_RST
CPUSS->CM7_0_SYSTEM_INT_CTL[eth_1_interrupt_eth_0_IRQn] = 0x80000003; // assign CPU interrupt #3
NVIC->ISER[0] = 1 << 3;
spin(10000000); // artificial delay to wait for PHY init
}
static inline void clock_init(void) {
SCB->CPACR |= ((3UL << 10 * 2) | (3UL << 11 * 2)); // Enable FPU
asm("DSB");
asm("ISB");
// configure PLL
CLRSET(SRSS->CLK_PLL400M[0].CONFIG, CLK_PLL400M_CONFIG_BYPASS_SEL_Msk, BIT(29)); // First bypass PLL
spin(10);
SRSS->CLK_PLL400M[0].CONFIG &= ~CLK_PLL400M_CONFIG_ENABLE_Msk; // disable the PLL itself
// IMO source generates a frequency of 8MHz. The final frequency will be
// calculated as (CLK_IMO * feedback) / (reference * output_div)
CLRSET(SRSS->CLK_PLL400M[0].CONFIG, CLK_PLL400M_CONFIG_FEEDBACK_DIV_Msk, PLL_FEEDBACK << CLK_PLL400M_CONFIG_FEEDBACK_DIV_Pos);
CLRSET(SRSS->CLK_PLL400M[0].CONFIG, CLK_PLL400M_CONFIG_REFERENCE_DIV_Msk, PLL_REF << CLK_PLL400M_CONFIG_REFERENCE_DIV_Pos);
CLRSET(SRSS->CLK_PLL400M[0].CONFIG, CLK_PLL400M_CONFIG_OUTPUT_DIV_Msk, PLL_OUT << CLK_PLL400M_CONFIG_OUTPUT_DIV_Pos);
CLRSET(SRSS->CLK_PLL400M[0].CONFIG2, CLK_PLL400M_CONFIG2_FRAC_DIV_Msk, 0);
CLRSET(SRSS->CLK_PLL400M[0].CONFIG2, CLK_PLL400M_CONFIG2_FRAC_DITHER_EN_Msk, 0);
CLRSET(SRSS->CLK_PLL400M[0].CONFIG2, CLK_PLL400M_CONFIG2_FRAC_EN_Msk, 1 << CLK_PLL400M_CONFIG2_FRAC_EN_Pos);
CLRSET(SRSS->CLK_PLL400M[0].CONFIG, CLK_PLL400M_CONFIG_BYPASS_SEL_Msk, 0);
spin(10);
SRSS->CLK_PLL400M[0].CONFIG |= CLK_PLL400M_CONFIG_ENABLE_Msk; // enable the PLL
while (SRSS->CLK_PLL400M[0].CONFIG & 1) spin(1);
// configure PATH1 with source set to IMO
SRSS->CLK_PATH_SELECT[1] = 0;
// enable CLK_HFx
uint8_t clocks[] = {0, 1, 2, 3, 4, 5, 6};
for (size_t i = 0; i < sizeof(clocks) / sizeof(uint8_t); i++) {
CLRSET(SRSS->CLK_ROOT_SELECT[clocks[i]], SRSS_CLK_ROOT_SELECT_ROOT_MUX_Msk, 1); // choose PATH1
CLRSET(SRSS->CLK_ROOT_SELECT[clocks[i]], SRSS_CLK_ROOT_SELECT_DIRECT_MUX_Msk, 1 << SRSS_CLK_ROOT_SELECT_DIRECT_MUX_Pos);
if (clocks[i] != 0) // CLF_HF0 is already enabled
SRSS->CLK_ROOT_SELECT[clocks[i]] |= SRSS_CLK_ROOT_SELECT_ENABLE_Msk; // enable clock root
}
// set systick frequency
uint32_t tenms = SYS_FREQUENCY / 100 - 1; // number of cycles executed in 10ms
CPUSS->SYSTICK_CTL = tenms | (3 << CPUSS_SYSTICK_CTL_CLOCK_SOURCE_Pos); // select CLK_HF as source
}
@@ -0,0 +1,31 @@
OUTPUT_FORMAT("elf32-littlearm")
OUTPUT_ARCH(arm)
ENTRY(Reset_Handler)
MEMORY
{
flash(RX) : ORIGIN = 0x10080000, LENGTH = 0x80000
sram(!RX) : ORIGIN = 0x28000800, LENGTH = 510K
}
_estack = ORIGIN(sram) + LENGTH(sram);
SECTIONS
{
.vectors : { . = ALIGN(4); KEEP(*(.vectors)); . = ALIGN(4); } > flash
.text : { *(.text*) } > flash
.rodata : { *(.rodata*) } > flash
.data : {
_sdata = .;
*(.first_data)
*(.data SORT(.data.*))
_edata = .;
} > sram AT > flash
_sidata = LOADADDR(.data);
.bss : { _sbss = .; *(.bss SORT(.bss.*) COMMON) _ebss = .; } > sram
. = ALIGN(8);
_end = .;
}
+32
View File
@@ -0,0 +1,32 @@
// Copyright (c) 2024 Cesanta Software Limited
// All rights reserved
#include "hal.h"
#include "mongoose.h"
#include "net.h"
#define BLINK_PERIOD_MS 1000
static void timer_fn(void *arg) {
gpio_toggle(LED1); // Blink LED
(void) arg; // Unused
}
int main(void) {
struct mg_mgr mgr; // Mongoose event manager
hal_init(); // Cross-platform hardware init
mg_mgr_init(&mgr); // Initialise it
mg_log_set(MG_LL_DEBUG); // Set log level to debug
mg_timer_add(&mgr, BLINK_PERIOD_MS, MG_TIMER_REPEAT, timer_fn, &mgr);
MG_INFO(("Initialising application..."));
web_init(&mgr);
for (;;) {
mg_mgr_poll(&mgr, 0);
}
return 0;
}
+1
View File
@@ -0,0 +1 @@
../../../mongoose.c
+1
View File
@@ -0,0 +1 @@
../../../mongoose.h
@@ -0,0 +1,26 @@
#pragma once
// See https://mongoose.ws/documentation/#build-options
#define MG_ARCH MG_ARCH_NEWLIB
#define MG_ENABLE_TCPIP 1
#define MG_ENABLE_DRIVER_XMC7 1
#define MG_IO_SIZE 256
#define MG_ENABLE_CUSTOM_MILLIS 1
#define MG_ENABLE_CUSTOM_RANDOM 1
#define MG_ENABLE_PACKED_FS 1
// For static IP configuration, define MG_TCPIP_{IP,MASK,GW}
// By default, those are set to zero, meaning that DHCP is used
//
// #define MG_TCPIP_IP MG_IPV4(192, 168, 1, 10)
// #define MG_TCPIP_GW MG_IPV4(192, 168, 1, 1)
// #define MG_TCPIP_MASK MG_IPV4(255, 255, 255, 0)
// Set custom MAC address. By default, it is randomly generated
// Using a build-time constant:
// #define MG_SET_MAC_ADDRESS(mac) do { uint8_t buf_[6] = {2,3,4,5,6,7}; memmove(mac, buf_, sizeof(buf_)); } while (0)
//
// Using custom function:
// extern void my_function(unsigned char *mac);
// #define MG_SET_MAC_ADDRESS(mac) my_function(mac)
+1
View File
@@ -0,0 +1 @@
../../device-dashboard/net.c
+1
View File
@@ -0,0 +1 @@
../../device-dashboard/net.h
+1
View File
@@ -0,0 +1 @@
../../device-dashboard/packed_fs.c
@@ -0,0 +1,83 @@
#include "xmc7200d_e272k8384.h"
void Reset_Handler(void); // Defined below
void Dummy_Handler(void); // Defined below
void SysTick_Handler(void); // Defined in main.c
void SystemInit(void); // Defined in main.c, called by reset handler
void _estack(void); // Defined in link.ld
#define WEAK_ALIAS __attribute__((weak, alias("Default_Handler")))
WEAK_ALIAS void NMI_Handler(void);
WEAK_ALIAS void HardFault_Handler(void);
WEAK_ALIAS void SVCall_Handler(void);
WEAK_ALIAS void PendSV_Handler(void);
WEAK_ALIAS void SysTick_Handler(void);
WEAK_ALIAS void Default_Intr_Handler(void);
WEAK_ALIAS void CM0P_CpuIntr0_Handler(void);
WEAK_ALIAS void CM0P_CpuIntr1_Handler(void);
WEAK_ALIAS void CM0P_CpuIntr2_Handler(void);
WEAK_ALIAS void CM0P_CpuIntr4_Handler(void);
WEAK_ALIAS void CM0P_CpuIntr5_Handler(void);
WEAK_ALIAS void CM0P_CpuIntr6_Handler(void);
WEAK_ALIAS void CM0P_CpuIntr7_Handler(void);
WEAK_ALIAS void ETH_IRQHandler(void);
void CM0P_CpuIntr3_Handler(void) {
ETH_IRQHandler();
}
__attribute__((section(".vectors"))) void (*const tab[16 + 16])(void) = {
_estack,
Reset_Handler,
NMI_Handler,
HardFault_Handler,
0,
0,
0,
0,
0,
0,
0,
SVCall_Handler,
0,
0,
PendSV_Handler,
SysTick_Handler,
CM0P_CpuIntr0_Handler,
CM0P_CpuIntr1_Handler,
CM0P_CpuIntr2_Handler,
CM0P_CpuIntr3_Handler,
CM0P_CpuIntr4_Handler,
CM0P_CpuIntr5_Handler,
CM0P_CpuIntr6_Handler,
CM0P_CpuIntr7_Handler,
Default_Intr_Handler,
Default_Intr_Handler,
Default_Intr_Handler,
Default_Intr_Handler,
Default_Intr_Handler,
Default_Intr_Handler,
Default_Intr_Handler,
Default_Intr_Handler
};
__attribute__((naked, noreturn)) void Reset_Handler(void) {
// Clear BSS section, and copy data section from flash to RAM
extern long _sbss, _ebss, _sdata, _edata, _sidata;
for (long *src = &_sbss; src < &_ebss; src++) *src = 0;
for (long *src = &_sdata, *dst = &_sidata; src < &_edata;) *src++ = *dst++;
SCB->VTOR = (uint32_t) &tab;
SystemInit();
// Call main()
extern void main(void);
main();
for (;;) (void) 0; // Infinite loop
}
void Default_Handler(void) {
for (;;) (void) 0;
}
@@ -1 +0,0 @@
See detailed tutorial at https://mongoose.ws/tutorials/json-rpc-over-websocket/
@@ -1 +0,0 @@
../../mongoose.c
@@ -1 +0,0 @@
../../mongoose.h
-1
View File
@@ -1 +0,0 @@
See detailed tutorial at https://mongoose.ws/tutorials/webui-push/
-1
View File
@@ -1 +0,0 @@
../../mongoose.c
-1
View File
@@ -1 +0,0 @@
../../mongoose.h
@@ -48,20 +48,20 @@ static void fn(struct mg_connection *c, int ev, void *ev_data) {
sub_opts.topic = subt; sub_opts.topic = subt;
sub_opts.qos = s_qos; sub_opts.qos = s_qos;
mg_mqtt_sub(c, &sub_opts); mg_mqtt_sub(c, &sub_opts);
MG_INFO(("%lu SUBSCRIBED to %.*s", c->id, (int) subt.len, subt.ptr)); MG_INFO(("%lu SUBSCRIBED to %.*s", c->id, (int) subt.len, subt.buf));
struct mg_mqtt_opts pub_opts; struct mg_mqtt_opts pub_opts;
memset(&pub_opts, 0, sizeof(pub_opts)); memset(&pub_opts, 0, sizeof(pub_opts));
pub_opts.topic = pubt; pub_opts.topic = pubt;
pub_opts.message = data; pub_opts.message = data;
pub_opts.qos = s_qos, pub_opts.retain = false; pub_opts.qos = s_qos, pub_opts.retain = false;
mg_mqtt_pub(c, &pub_opts); mg_mqtt_pub(c, &pub_opts);
MG_INFO(("%lu PUBLISHED %.*s -> %.*s", c->id, (int) data.len, data.ptr, MG_INFO(("%lu PUBLISHED %.*s -> %.*s", c->id, (int) data.len, data.buf,
(int) pubt.len, pubt.ptr)); (int) pubt.len, pubt.buf));
} else if (ev == MG_EV_MQTT_MSG) { } else if (ev == MG_EV_MQTT_MSG) {
// When we get echo response, print it // When we get echo response, print it
struct mg_mqtt_message *mm = (struct mg_mqtt_message *) ev_data; struct mg_mqtt_message *mm = (struct mg_mqtt_message *) ev_data;
MG_INFO(("%lu RECEIVED %.*s <- %.*s", c->id, (int) mm->data.len, MG_INFO(("%lu RECEIVED %.*s <- %.*s", c->id, (int) mm->data.len,
mm->data.ptr, (int) mm->topic.len, mm->topic.ptr)); mm->data.buf, (int) mm->topic.len, mm->topic.buf));
} else if (ev == MG_EV_CLOSE) { } else if (ev == MG_EV_CLOSE) {
MG_INFO(("%lu CLOSED", c->id)); MG_INFO(("%lu CLOSED", c->id));
s_conn = NULL; // Mark that we're closed s_conn = NULL; // Mark that we're closed
+1 -1
View File
@@ -7,7 +7,7 @@ example: micropython
$(MAKE) -C micropython/ports/unix USER_C_MODULES=../../.. $(MAKE) -C micropython/ports/unix USER_C_MODULES=../../..
micropython: micropython:
git clone https://github.com/micropython/micropython.git git clone --depth 1 -b v1.22.2 https://github.com/micropython/micropython.git
clean: clean:
rm -rf micropython rm -rf micropython
-1
View File
@@ -1 +0,0 @@
../../mongoose.c
-1
View File
@@ -1 +0,0 @@
../../mongoose.h
-1
View File
@@ -1 +0,0 @@
../../mongoose.c
-1
View File
@@ -1 +0,0 @@
../../mongoose.h
-1
View File
@@ -1 +0,0 @@
../device-dashboard/net.c
-1
View File
@@ -1 +0,0 @@
../device-dashboard/net.h
-1
View File
@@ -1 +0,0 @@
../device-dashboard/packed_fs.c
-13
View File
@@ -10,17 +10,4 @@ following features:
needing a filesystem to serve it; so being resilient to FS problems needing a filesystem to serve it; so being resilient to FS problems
- All changes are propagated to all connected clients - All changes are propagated to all connected clients
## Screenshots
This is a login screen that prompts for user/password
![](screenshots/login.webp)
## Main dashboard
The main dashboard page shows the interactive console
![](screenshots/dashboard.webp)
See a detailed tutorial at https://mongoose.ws/tutorials/device-dashboard/ See a detailed tutorial at https://mongoose.ws/tutorials/device-dashboard/
Loaded 100 of 708 files, more files were not shown because too many files have changed in this diff. Show more