mirror of
https://github.com/cesanta/mongoose.git
synced 2026-10-27 12:26:24 +00:00
Changes
This commit is contained in:
1 parent
519d4b0286
commit
70fc71c6f7
7 files changed
+194
-88
No files matched your search
@@ -56,14 +56,14 @@ uint64_t mg_now(void) {
|
||||
int ui_event_next(int no, struct ui_event *e) {
|
||||
if (no < 0 || no >= MAX_EVENTS_NO) return 0;
|
||||
|
||||
srand(no);
|
||||
srand((unsigned) no);
|
||||
e->type = (uint8_t) rand() % 4;
|
||||
e->prio = (uint8_t) rand() % 3;
|
||||
e->timestamp =
|
||||
(unsigned long) (mg_now() - 86400 * 1000 /* one day back */ +
|
||||
(unsigned long) ((int64_t) mg_now() - 86400 * 1000 /* one day back */ +
|
||||
no * 300 * 1000 /* 5 mins between alerts */ +
|
||||
1000 * (rand() % 300) /* randomize event time */) /
|
||||
1000;
|
||||
1000UL;
|
||||
|
||||
mg_snprintf(e->text, MAX_EVENT_TEXT_SIZE, "event#%d", no);
|
||||
return no + 1;
|
||||
@@ -163,7 +163,7 @@ static void handle_stats_get(struct mg_connection *c) {
|
||||
static size_t print_events(void (*out)(char, void *), void *ptr, va_list *ap) {
|
||||
size_t len = 0;
|
||||
struct ui_event ev;
|
||||
int pageno = va_arg(*ap, unsigned);
|
||||
int pageno = va_arg(*ap, int);
|
||||
int no = (pageno - 1) * EVENTS_PER_PAGE;
|
||||
int end = no + EVENTS_PER_PAGE;
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ SOURCES = main.c syscalls.c startup.c
|
||||
#SOURCES += cmsis_sam/xc32/ATSAME54P20A/startup_atsame54p20a.c
|
||||
|
||||
SOURCES += mongoose.c net.c packed_fs.c
|
||||
CFLAGS += -DMG_ENABLE_TCPIP=1 -DMG_ARCH=MG_ARCH_NEWLIB -DMG_ENABLE_CUSTOM_MILLIS=1 -DMG_ENABLE_LINES=1
|
||||
CFLAGS += -DMG_ENABLE_TCPIP=1 -DMG_ARCH=MG_ARCH_NEWLIB -DMG_ENABLE_CUSTOM_MILLIS=1 #-DMG_ENABLE_LINES=1
|
||||
CFLAGS += -DMG_ENABLE_DRIVER_SAME54=1 -DMG_ENABLE_CUSTOM_RANDOM=1 -DMG_ENABLE_PACKED_FS=1 $(CFLAGS_EXTRA)
|
||||
|
||||
VCON_API_KEY=IBrJL5K4arSGMiAXbUKWdG6I2gM
|
||||
|
||||
@@ -149,13 +149,18 @@ static inline uint32_t rng_read(void) {
|
||||
return TRNG_REGS->TRNG_DATA;
|
||||
}
|
||||
|
||||
#define UUID ((uint8_t *) UID_BASE) // Unique 96-bit chip ID. TRM 39.1
|
||||
#define UID_BASE_W0 0x008061FC // Word 0 location of the 128-bit chip ID
|
||||
#define UID_BASE_W1_3 0x00806010 // Words 1-3 location of the 128-bit chip ID
|
||||
|
||||
// Helper macro for MAC generation
|
||||
#define GENERATE_LOCALLY_ADMINISTERED_MAC() \
|
||||
{ \
|
||||
2, UUID[0] ^ UUID[1], UUID[2] ^ UUID[3], UUID[4] ^ UUID[5], \
|
||||
UUID[6] ^ UUID[7] ^ UUID[8], UUID[9] ^ UUID[10] ^ UUID[11] \
|
||||
#define UUID(n) ((n >= 0 && n <= 3) ? \
|
||||
(((uint8_t *) UID_BASE_W0)[n]) : \
|
||||
(((uint8_t *) UID_BASE_W1_3)[n - 4]))
|
||||
|
||||
#define GENERATE_LOCALLY_ADMINISTERED_MAC() \
|
||||
{ \
|
||||
2, UUID(0) ^ UUID(1) ^ UUID(2), UUID(3) ^ UUID(4) ^ UUID(5), \
|
||||
UUID(6) ^ UUID(7) ^ UUID(8), UUID(9) ^ UUID(10) ^ UUID(11), \
|
||||
UUID(12) ^ UUID(13) ^ UUID(14) ^ UUID(15) \
|
||||
}
|
||||
|
||||
static inline bool timer_expired(volatile uint64_t *t, uint64_t prd,
|
||||
@@ -194,9 +199,9 @@ static inline void ethernet_init(void) {
|
||||
PORT_REGS->GROUP[bank].PORT_PINCFG[no] |= PORT_PINCFG_PMUXEN_Msk;
|
||||
volatile uint8_t *m = &PORT_REGS->GROUP[bank].PORT_PMUX[no / 2], v = m[0];
|
||||
if (no & 1) {
|
||||
m[0] = (uint8_t) (v & ~0xf0) | PORT_PMUX_PMUXO(af[i]);
|
||||
m[0] = (uint8_t) ((v & ~0xf0) | PORT_PMUX_PMUXO(af[i]));
|
||||
} else {
|
||||
m[0] = (uint8_t) (v & ~0x0f) | PORT_PMUX_PMUXE(af[i]);
|
||||
m[0] = (uint8_t) ((v & ~0x0f) | PORT_PMUX_PMUXE(af[i]));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,8 @@ static void timer_fn(void *arg) {
|
||||
|
||||
static void fn(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");
|
||||
}
|
||||
(void) ev_data, (void) fn_data;
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
gpio_input(BUTTON_PIN);
|
||||
@@ -55,7 +56,7 @@ int main(void) {
|
||||
|
||||
// Initialise Mongoose network stack
|
||||
struct mg_tcpip_driver_same54_data driver_data = {.mdc_cr = 5};
|
||||
struct mg_tcpip_if mif = {.mac = {2, 3, 4, 5, 6, 7},
|
||||
struct mg_tcpip_if mif = {.mac = GENERATE_LOCALLY_ADMINISTERED_MAC()/*{2, 3, 4, 5, 6, 7}*/,
|
||||
// Uncomment below for static configuration:
|
||||
// .ip = mg_htonl(MG_U32(192, 168, 0, 223)),
|
||||
// .mask = mg_htonl(MG_U32(255, 255, 255, 0)),
|
||||
@@ -72,7 +73,7 @@ int main(void) {
|
||||
|
||||
MG_INFO(("Initialising application..."));
|
||||
mg_http_listen(&mgr, "http://0.0.0.0", fn, NULL);
|
||||
//web_init(&mgr);
|
||||
// web_init(&mgr);
|
||||
|
||||
MG_INFO(("Starting event loop"));
|
||||
for (;;) {
|
||||
|
||||
Reference in new issue
Block a user