diff --git a/.gitmodules b/.gitmodules index 17f8003..d0d6642 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,6 @@ [submodule "lwip/lwip"] path = lwip/lwip - url = https://github.com/ourairquality/lwip.git + url = https://github.com/ccbruce0812/lwip.git [submodule "extras/mbedtls/mbedtls"] path = extras/mbedtls/mbedtls url = https://github.com/ARMmbed/mbedtls.git @@ -28,3 +28,15 @@ [submodule "extras/crc_generic/crc_lib"] path = extras/crc_generic/crc_lib url = https://github.com/Zaltora/crc_generic_lib.git +[submodule "extras/kt0803l"] + path = extras/kt0803l + url = https://github.com/ccbruce0812/kt0803l.git +[submodule "extras/rda5807m"] + path = extras/rda5807m + url = https://github.com/ccbruce0812/rda5807m.git +[submodule "examples/rda5807m_test"] + path = examples/rda5807m_test + url = https://github.com/ccbruce0812/rda5807m_test.git +[submodule "extras/mcpwm"] + path = extras/mcpwm + url = https://github.com/ccbruce0812/mcpwm.git diff --git a/examples/rda5807m_test b/examples/rda5807m_test new file mode 160000 index 0000000..439b9fa --- /dev/null +++ b/examples/rda5807m_test @@ -0,0 +1 @@ +Subproject commit 439b9fa3dfd8ea29cfef60184889ea461f56a7d7 diff --git a/extras/dhcpserver/dhcpserver.c b/extras/dhcpserver/dhcpserver.c old mode 100644 new mode 100755 index 934beb2..e0debff --- a/extras/dhcpserver/dhcpserver.c +++ b/extras/dhcpserver/dhcpserver.c @@ -106,6 +106,29 @@ void dhcpserver_start(const ip4_addr_t *first_client_addr, uint8_t max_leases) xTaskCreate(dhcpserver_task, "DHCP Server", 448, NULL, 2, &dhcpserver_task_handle); } +uint32_t dhcpserver_get_leases(dhcpserver_lease_t *leases, uint32_t capacity) { + uint32_t i=0, count=0; + + taskENTER_CRITICAL(); + + for(i=0;imax_leases;i++) { + if(count>=capacity) { + count=capacity; + break; + } + + if(state->leases[i].active) { + memcpy(&leases[count].hwaddr, &state->leases[i].hwaddr, sizeof(uint8_t)*6); + ip4_addr_copy(leases[count].ipaddr, state->first_client_addr); + leases[count].ipaddr.addr+=count; + count++; + } + } + + taskEXIT_CRITICAL(); + return count; +} + void dhcpserver_stop(void) { if (dhcpserver_task_handle) { @@ -150,6 +173,8 @@ static void dhcpserver_task(void *pxParameter) printf("DHCP Server Error: Failed to receive DHCP packet. err=%d\r\n", err); continue; } + + taskENTER_CRITICAL(); /* expire any leases that have passed */ uint32_t now = xTaskGetTickCount(); @@ -169,6 +194,7 @@ static void dhcpserver_task(void *pxParameter) if (netbuf_len(netbuf) < offsetof(struct dhcp_msg, options)) { /* too short to be a valid DHCP client message */ netbuf_delete(netbuf); + taskEXIT_CRITICAL(); continue; } if (netbuf_len(netbuf) >= sizeof(struct dhcp_msg)) { @@ -182,6 +208,7 @@ static void dhcpserver_task(void *pxParameter) DHCP_OPTION_MESSAGE_TYPE_LEN, NULL); if (!message_type) { printf("DHCP Server Error: No message type field found"); + taskEXIT_CRITICAL(); continue; } @@ -207,6 +234,8 @@ static void dhcpserver_task(void *pxParameter) printf("DHCP Server Error: Unsupported message type %d\r\n", *message_type); break; } + + taskEXIT_CRITICAL(); } } diff --git a/extras/dhcpserver/include/dhcpserver.h b/extras/dhcpserver/include/dhcpserver.h old mode 100644 new mode 100755 index 62fa0ac..814b461 --- a/extras/dhcpserver/include/dhcpserver.h +++ b/extras/dhcpserver/include/dhcpserver.h @@ -18,6 +18,11 @@ extern "C" { #endif +typedef struct { + uint8_t hwaddr[6]; + ip4_addr_t ipaddr; +} dhcpserver_lease_t; + /* Start DHCP server. Static IP of server should already be set and network interface enabled. @@ -28,7 +33,7 @@ extern "C" { */ void dhcpserver_start(const ip4_addr_t *first_client_addr, uint8_t max_leases); -void dhcpserver_get_lease(const ip4_addr_t *first_client_addr, uint8_t max_leases); +uint32_t dhcpserver_get_leases(dhcpserver_lease_t *leases, uint32_t capacity); /* Stop DHCP server. */ diff --git a/extras/kt0803l b/extras/kt0803l new file mode 160000 index 0000000..32f7a13 --- /dev/null +++ b/extras/kt0803l @@ -0,0 +1 @@ +Subproject commit 32f7a131390d2f73f5260fa383383f1fae0e96db diff --git a/extras/mcpwm b/extras/mcpwm new file mode 160000 index 0000000..0f76d81 --- /dev/null +++ b/extras/mcpwm @@ -0,0 +1 @@ +Subproject commit 0f76d8141318899388c990c45c347ae5f37b9c07 diff --git a/extras/rda5807m b/extras/rda5807m new file mode 160000 index 0000000..fc137d4 --- /dev/null +++ b/extras/rda5807m @@ -0,0 +1 @@ +Subproject commit fc137d42d5189a8d830f027fcd3c65c3048aa9ab diff --git a/lwip/include/arch/cc.h b/lwip/include/arch/cc.h index e7cf291..74fc332 100644 --- a/lwip/include/arch/cc.h +++ b/lwip/include/arch/cc.h @@ -101,6 +101,8 @@ typedef int sys_prot_t; #define LWIP_PLATFORM_HTONS(_n) ((u16_t)((((_n) & 0xff) << 8) | (((_n) >> 8) & 0xff))) #define LWIP_PLATFORM_HTONL(_n) ((u32_t)( (((_n) & 0xff) << 24) | (((_n) & 0xff00) << 8) | (((_n) >> 8) & 0xff00) | (((_n) >> 24) & 0xff) )) +#ifndef LWIP_RAND #define LWIP_RAND() hwrand() +#endif #endif /* __ARCH_CC_H__ */ diff --git a/lwip/include/lwipopts.h b/lwip/include/lwipopts.h old mode 100644 new mode 100755 index 4d69eda..c86dace --- a/lwip/include/lwipopts.h +++ b/lwip/include/lwipopts.h @@ -221,6 +221,9 @@ ---------- RAW options ---------- --------------------------------- */ +#ifndef LWIP_RAW +#define LWIP_RAW 1 +#endif /* ---------------------------------- diff --git a/lwip/lwip b/lwip/lwip index 74676d4..e5bf00e 160000 --- a/lwip/lwip +++ b/lwip/lwip @@ -1 +1 @@ -Subproject commit 74676d46f0bc5ed82515f8e247008b7c45ec6cf6 +Subproject commit e5bf00eab33ad371994368dbe53f7b2d456ec884