diff --git a/bouffalo.mk b/bouffalo.mk index f57921c48..c3c071464 100644 --- a/bouffalo.mk +++ b/bouffalo.mk @@ -1,7 +1,7 @@ # Component Makefile # ## These include paths would be exported to project level -COMPONENT_ADD_INCLUDEDIRS += src/ src/httpserver/ src/cmnds/ +COMPONENT_ADD_INCLUDEDIRS += src/ src/httpserver/ src/cmnds/ src/logging/ src/hal/bl602/ src/mqtt/ ## not be exported to project level COMPONENT_PRIV_INCLUDEDIRS := @@ -14,7 +14,7 @@ COMPONENT_SRCS := COMPONENT_OBJS := $(patsubst %.c,%.o, $(COMPONENT_SRCS)) COMPONENT_OBJS := $(patsubst %.S,%.o, $(COMPONENT_OBJS)) -COMPONENT_SRCDIRS := src/ src/httpserver/ src/cmnds/ +COMPONENT_SRCDIRS := src/ src/httpserver/ src/cmnds/ src/logging/ src/hal/bl602/ src/mqtt/ diff --git a/src/hal/hal_generic_bk7231.c b/src/hal/bk7231/hal_generic_bk7231.c similarity index 100% rename from src/hal/hal_generic_bk7231.c rename to src/hal/bk7231/hal_generic_bk7231.c diff --git a/src/hal/hal_main_bk7231.c b/src/hal/bk7231/hal_main_bk7231.c similarity index 100% rename from src/hal/hal_main_bk7231.c rename to src/hal/bk7231/hal_main_bk7231.c diff --git a/src/hal/hal_wifi_bk7231.c b/src/hal/bk7231/hal_wifi_bk7231.c similarity index 99% rename from src/hal/hal_wifi_bk7231.c rename to src/hal/bk7231/hal_wifi_bk7231.c index 7dc087c44..1e2c90316 100644 --- a/src/hal/hal_wifi_bk7231.c +++ b/src/hal/bk7231/hal_wifi_bk7231.c @@ -1,12 +1,12 @@ -#include "hal_wifi.h" +#include "../hal_wifi.h" #define LOG_FEATURE LOG_FEATURE_MAIN #include "wlan_ui_pub.h" #include "ethernet_intf.h" -#include "../new_common.h" +#include "../../new_common.h" #include "net.h" -#include "../logging/logging.h" +#include "../../logging/logging.h" #include "../../beken378/app/config/param_config.h" #include "lwip/netdb.h" diff --git a/src/hal/bl602/hal_generic_bl602.c b/src/hal/bl602/hal_generic_bl602.c new file mode 100644 index 000000000..ec94592dd --- /dev/null +++ b/src/hal/bl602/hal_generic_bl602.c @@ -0,0 +1,9 @@ +#ifdef PLATFORM_BL602 + + +void HAL_RebootModule() { + + +} + +#endif // PLATFORM_XR809 \ No newline at end of file diff --git a/src/hal/bl602/hal_main_bl602.c b/src/hal/bl602/hal_main_bl602.c new file mode 100644 index 000000000..c6674f728 --- /dev/null +++ b/src/hal/bl602/hal_main_bl602.c @@ -0,0 +1,6 @@ +#ifdef PLATFORM_BL602 + +#include "../../new_common.h" +#include "../../logging/logging.h" + +#endif // PLATFORM_BL602 \ No newline at end of file diff --git a/src/hal/bl602/hal_wifi_bl602.c b/src/hal/bl602/hal_wifi_bl602.c new file mode 100644 index 000000000..2718bc353 --- /dev/null +++ b/src/hal/bl602/hal_wifi_bl602.c @@ -0,0 +1,33 @@ +#ifdef PLATFORM_BL602 + +#include "../hal_wifi.h" + +char g_ipStr[64]; + +void HAL_ConnectToWiFi(const char *ssid, const char *psk) +{ + +} +int HAL_SetupWiFiOpenAccessPoint(const char *ssid) { + + + return 0; +} +void HAL_WiFi_SetupStatusCallback(void (*cb)(int code)) { + +} + + +void HAL_PrintNetworkInfo() { + +} +const char *HAL_GetMyIPString() { + + return g_ipStr; +} +const char *HAL_GetMACStr(char *macstr) { + + return macstr; +} + +#endif // PLATFORM_BL602 \ No newline at end of file diff --git a/src/hal/hal_generic_xr809.c b/src/hal/xr809/hal_generic_xr809.c similarity index 100% rename from src/hal/hal_generic_xr809.c rename to src/hal/xr809/hal_generic_xr809.c diff --git a/src/hal/hal_main_xr809.c b/src/hal/xr809/hal_main_xr809.c similarity index 88% rename from src/hal/hal_main_xr809.c rename to src/hal/xr809/hal_main_xr809.c index 018bd54eb..3ec1ad685 100644 --- a/src/hal/hal_main_xr809.c +++ b/src/hal/xr809/hal_main_xr809.c @@ -1,7 +1,7 @@ #ifdef PLATFORM_XR809 -#include "../new_common.h" -#include "../logging/logging.h" +#include "../../new_common.h" +#include "../../logging/logging.h" // main timer tick every 1s OS_Thread_t g_main_timer_1s; diff --git a/src/hal/hal_wifi_xr809.c b/src/hal/xr809/hal_wifi_xr809.c similarity index 94% rename from src/hal/hal_wifi_xr809.c rename to src/hal/xr809/hal_wifi_xr809.c index e543b05cf..b6722e2d7 100644 --- a/src/hal/hal_wifi_xr809.c +++ b/src/hal/xr809/hal_wifi_xr809.c @@ -1,6 +1,6 @@ #ifdef PLATFORM_XR809 -#include "hal_wifi.h" +#include "../hal_wifi.h" #include #include diff --git a/src/httpserver/http_fns.c b/src/httpserver/http_fns.c index 878a19351..33058e4d1 100644 --- a/src/httpserver/http_fns.c +++ b/src/httpserver/http_fns.c @@ -191,7 +191,9 @@ int http_fn_index(http_request_t *request) { poststr(request,""); } } +#ifndef OBK_DISABLE_ALL_DRIVERS DRV_AppendInformationToHTTPIndexPage(request); +#endif // strcat(outbuf,""); @@ -729,6 +731,7 @@ int http_fn_uart_tool(http_request_t *request) { if(http_getArg(request->url,"data",tmpA,sizeof(tmpA))) { +#ifndef OBK_DISABLE_ALL_DRIVERS hprintf128(request,"

Sent %s!

",tmpA); if(0){ TuyaMCU_Send((byte *)tmpA, strlen(tmpA)); @@ -746,6 +749,7 @@ int http_fn_uart_tool(http_request_t *request) { } TuyaMCU_Send(results, resultLen); } +#endif } else { strcpy(tmpA,"Hello UART world"); } @@ -1094,6 +1098,8 @@ int http_fn_ota_exec(http_request_t *request) { hprintf128(request,"

OTA requested for %s!

",tmpA); #if WINDOWS +#elif PLATFORM_BL602 + #elif PLATFORM_XR809 //cmd_ota_http_exec(tmpA); xr809_do_ota_next_frame(tmpA); diff --git a/src/httpserver/rest_interface.c b/src/httpserver/rest_interface.c index 24b7921a4..e5a6366ae 100644 --- a/src/httpserver/rest_interface.c +++ b/src/httpserver/rest_interface.c @@ -796,6 +796,8 @@ static int http_rest_error(http_request_t *request, int code, char *msg){ static int http_rest_post_flash(http_request_t *request, int startaddr){ #if PLATFORM_XR809 +#elif PLATFORM_BL602 + #else int total = 0; int towrite; @@ -1005,6 +1007,8 @@ static int http_rest_get_testconfig(http_request_t *request){ static int http_rest_get_flash_vars_test(http_request_t *request){ #if PLATFORM_XR809 return http_rest_error(request, 400, "flash vars unsupported"); +#elif PLATFORM_BL602 + return http_rest_error(request, 400, "flash vars unsupported"); #else #ifndef DISABLE_FLASH_VARS_VARS char *params = request->url + 17; diff --git a/src/logging/logging.c b/src/logging/logging.c index cf6e768e0..35d1820d0 100644 --- a/src/logging/logging.c +++ b/src/logging/logging.c @@ -1,21 +1,9 @@ // Trying to narrow down Boozeman crash. // Is the code with this define enabled crashing/freezing BK after few minutes for anybody? -// #define DEBUG_USE_SIMPLE_LOGGER + #include "../new_common.h" #include "../httpserver/new_http.h" -#if WINDOWS -#include - -#elif PLATFORM_XR809 -#include -#include "lwip/sockets.h" -#include "lwip/ip_addr.h" -#include "lwip/inet.h" - -#else -#endif - #include "../logging/logging.h" // Commands register, execution API and cmd tokenizer #include "../cmnds/cmd_public.h" @@ -82,6 +70,8 @@ char *logfeaturenames[] = { }; +int direct_serial_log = DEFAULT_DIRECT_SERIAL_LOG; + #ifdef WINDOWS @@ -178,7 +168,6 @@ static struct tag_logMemory { SemaphoreHandle_t mutex; } logMemory; -int direct_serial_log = DEFAULT_DIRECT_SERIAL_LOG; static int initialised = 0; @@ -238,6 +227,9 @@ void addLogAdv(int level, int feature, char *fmt, ...){ #if PLATFORM_XR809 printf(tmp); #endif +#if PLATFORM_BL602 + printf(tmp); +#endif if (direct_serial_log){ bk_printf(tmp); diff --git a/src/mqtt/new_mqtt.c b/src/mqtt/new_mqtt.c index 438e911f5..1bfb0784c 100644 --- a/src/mqtt/new_mqtt.c +++ b/src/mqtt/new_mqtt.c @@ -96,6 +96,11 @@ int MQTT_RegisterCallback( const char *basetopic, const char *subscriptiontopic, if (!basetopic || !subscriptiontopic || !callback){ return -1; } +#ifdef PLATFORM_BL602 + // crash below +return -1; +#endif + addLogAdv(LOG_INFO,LOG_FEATURE_MQTT,"MQTT_RegisterCallback called for bT %s subT %s", basetopic, subscriptiontopic); // find existing to replace for (index = 0; index < numCallbacks; index++){ diff --git a/src/new_common.h b/src/new_common.h index cea33699d..1bd527486 100644 --- a/src/new_common.h +++ b/src/new_common.h @@ -8,6 +8,7 @@ #include #include +#include "obk_config.h" #if WINDOWS @@ -27,6 +28,8 @@ typedef unsigned short uint16_t; #include #include +#include +#include typedef int bool; #define true 1 @@ -38,6 +41,8 @@ typedef int bool; #define os_free free #define os_memset memset +#define bk_printf printf + #define rtos_delay_milliseconds vTaskDelay #define kNoErr 0 //! No error occurred. diff --git a/src/new_pins.c b/src/new_pins.c index e08d3b082..f3bff43d2 100644 --- a/src/new_pins.c +++ b/src/new_pins.c @@ -733,7 +733,9 @@ void Channel_OnChanged(int ch) { iVal = g_channelValues[ch]; bOn = iVal > 0; +#ifndef OBK_DISABLE_ALL_DRIVERS I2C_OnChannelChanged(ch,iVal); +#endif for(i = 0; i < GPIO_MAX; i++) { if(g_pins.channels[i] == ch) { diff --git a/src/obk_config.h b/src/obk_config.h index 51cf7fccf..21e799698 100644 --- a/src/obk_config.h +++ b/src/obk_config.h @@ -10,6 +10,8 @@ #elif WINDOWS #elif PLATFORM_BL602 +#define DEBUG_USE_SIMPLE_LOGGER +#define OBK_DISABLE_ALL_DRIVERS 1 #else diff --git a/src/user_main.c b/src/user_main.c index 1705a24d0..af72aa940 100644 --- a/src/user_main.c +++ b/src/user_main.c @@ -61,7 +61,7 @@ int g_bHasWiFiConnected = 0; #define LOG_FEATURE LOG_FEATURE_MAIN -#if PLATFORM_XR809 || PLATFORM_BL602 +#if PLATFORM_XR809 void boot_complete(){ } @@ -79,6 +79,51 @@ size_t xPortGetFreeHeapSize() { return 0; } #endif +#if PLATFORM_BL602 +void boot_complete(){ + +} +int config_commit(){ + + return 0; +} +int boot_failures(){ + return 0; +} +void increment_boot_count(){ + +} + + + + +OSStatus rtos_create_thread( beken_thread_t* thread, + uint8_t priority, const char* name, + beken_thread_function_t function, + uint32_t stack_size, beken_thread_arg_t arg ) { + OSStatus err = kNoErr; + + + err = xTaskCreate(function, name, stack_size, arg, 15, &thread); +/* + BaseType_t xTaskCreate( + TaskFunction_t pvTaskCode, + const char * const pcName, + configSTACK_DEPTH_TYPE usStackDepth, + void *pvParameters, + UBaseType_t uxPriority, + TaskHandle_t *pvCreatedTask + ); +*/ + + return err; +} + +OSStatus rtos_delete_thread( beken_thread_t* thread ) { + vTaskDelete(thread); + return kNoErr; +} +#endif void RESET_ScheduleModuleReset(int delSeconds) { g_reset = delSeconds; } @@ -137,7 +182,9 @@ void Main_OnEverySecond() // run_adc_test(); MQTT_RunEverySecondUpdate(); RepeatingEvents_OnEverySecond(); +#ifndef OBK_DISABLE_ALL_DRIVERS DRV_OnEverySecond(); +#endif g_secondsElapsed ++; ADDLOGF_INFO("Timer is %i free mem %d\n", g_secondsElapsed, xPortGetFreeHeapSize()); @@ -264,7 +311,9 @@ void Main_Init() // this actually sets the pins, moved out so we could avoid if necessary PIN_SetupPins(); +#ifndef OBK_DISABLE_ALL_DRIVERS DRV_Generic_Init(); +#endif RepeatingEvents_Init(); PIN_Init();