You've already forked iw4x-client
Add dependencies locally
This commit is contained in:
1
deps/mongoose/examples/arduino/w5500/mongoose.c
vendored
Normal file
1
deps/mongoose/examples/arduino/w5500/mongoose.c
vendored
Normal file
@ -0,0 +1 @@
|
||||
../../../mongoose.c
|
1
deps/mongoose/examples/arduino/w5500/mongoose.h
vendored
Normal file
1
deps/mongoose/examples/arduino/w5500/mongoose.h
vendored
Normal file
@ -0,0 +1 @@
|
||||
../../../mongoose.h
|
14
deps/mongoose/examples/arduino/w5500/mongoose_custom.h
vendored
Normal file
14
deps/mongoose/examples/arduino/w5500/mongoose_custom.h
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
#include "Arduino.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
|
||||
#define MG_ARCH MG_ARCH_CUSTOM
|
||||
#define MG_ENABLE_SOCKET 0
|
||||
#define MG_ENABLE_TCPIP 1
|
||||
#define mkdir(a, b) (-1)
|
||||
//#define MG_ENABLE_LOG 0
|
49
deps/mongoose/examples/arduino/w5500/w5500.ino
vendored
Normal file
49
deps/mongoose/examples/arduino/w5500/w5500.ino
vendored
Normal file
@ -0,0 +1,49 @@
|
||||
#include <SPI.h>
|
||||
#include "mongoose.h"
|
||||
|
||||
#define SS_PIN 3 // Slave select pin
|
||||
struct mg_mgr mgr; // Mongoose event manager
|
||||
struct mg_tcpip_spi spi = {
|
||||
NULL, // SPI data
|
||||
[](void *) { digitalWrite(SS_PIN, LOW); }, // begin transation
|
||||
[](void *) { digitalWrite(SS_PIN, HIGH); }, // end transaction
|
||||
[](void *, uint8_t c) { return SPI.transfer(c); }, // execute transaction
|
||||
};
|
||||
struct mg_tcpip_if mif = {.mac = {2, 0, 1, 2, 3, 5}}; // network interface
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
pinMode(SS_PIN, OUTPUT);
|
||||
SPI.begin();
|
||||
|
||||
// Set logging function to a serial print
|
||||
mg_log_set_fn([](char ch, void *) { Serial.print(ch); }, NULL);
|
||||
mg_mgr_init(&mgr);
|
||||
|
||||
delay(3000);
|
||||
MG_INFO(("Starting TCP/IP stack..."));
|
||||
|
||||
mif.driver = &mg_tcpip_driver_w5500;
|
||||
mif.driver_data = &spi;
|
||||
mg_tcpip_init(&mgr, &mif);
|
||||
|
||||
// Start a 5 sec timer, print status message periodically
|
||||
mg_timer_add(
|
||||
&mgr, 5000, MG_TIMER_REPEAT,
|
||||
[](void *) {
|
||||
MG_INFO(("ethernet: %s", mg_tcpip_driver_w5500.up(&mif) ? "up" : "down"));
|
||||
},
|
||||
NULL);
|
||||
|
||||
// Setup HTTP listener. Respond "ok" on any HTTP request
|
||||
mg_http_listen(
|
||||
&mgr, "http://0.0.0.0",
|
||||
[](struct mg_connection *c, int ev, void *ev_data, void *fn_data) {
|
||||
if (ev == MG_EV_HTTP_MSG) mg_http_reply(c, 200, "", "ok\n");
|
||||
},
|
||||
&mgr);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
mg_mgr_poll(&mgr, 1);
|
||||
}
|
Reference in New Issue
Block a user