From ccd0167e400bcbb8a40e8b482a7f7a3c4e1adac8 Mon Sep 17 00:00:00 2001 From: Deomid Ryabkov Date: Wed, 6 Apr 2016 09:22:45 +0200 Subject: [PATCH] Switch to CC3200 SDK 1.2.0 PUBLISHED_FROM=857459178e3af50fa6626379d1f71a725cd3b68b --- examples/CC3200/Makefile.build | 6 +- examples/CC3200/main.c | 6 ++ examples/CC3200/mg_task.c | 6 +- examples/CC3200/mg_task.h | 4 +- examples/CC3200/sdk.version | 2 +- examples/CC3200/wifi.c | 3 +- mongoose.c | 21 +++-- mongoose.h | 168 ++++++++------------------------- 8 files changed, 66 insertions(+), 150 deletions(-) diff --git a/examples/CC3200/Makefile.build b/examples/CC3200/Makefile.build index c1d5ccef..967025de 100644 --- a/examples/CC3200/Makefile.build +++ b/examples/CC3200/Makefile.build @@ -78,11 +78,12 @@ $(FW_ZIP): $(FW_ELF) $(FW_BIN) $(SLFS_FILES) FREERTOS_SRCS = timers.c list.c queue.c tasks.c port.c heap_3.c osi_freertos.c DRIVER_SRCS = cpu.c gpio.c gpio_if.c i2c.c i2c_if.c interrupt.c pin.c prcm.c spi.c uart.c udma.c utils.c -SL_SRCS = socket.c wlan.c driver.c device.c netapp.c netcfg.c cc_pal.c fs.c +SL_SRCS = socket.c wlan.c driver.c device.c netapp.c netcfg.c network_common.c cc_pal.c fs.c SDK_SRCS = startup_gcc.c $(FREERTOS_SRCS) $(DRIVER_SRCS) $(SL_SRCS) IPATH += $(SDK_PATH) $(SDK_PATH)/inc $(SDK_PATH)/driverlib \ $(SDK_PATH)/example/common $(SDK_PATH)/oslib \ $(SDK_PATH)/simplelink $(SDK_PATH)/simplelink/include \ + $(SDK_PATH)/simplelink_extlib/provisioninglib \ $(SDK_PATH)/third_party/FreeRTOS/source \ $(SDK_PATH)/third_party/FreeRTOS/source/include \ $(SDK_PATH)/third_party/FreeRTOS/source/portable/GCC/ARM_CM4 @@ -103,4 +104,5 @@ ENTRY_$(PROG) = ResetISR # Disable certain warnings on SDK sources, we have no control over them anyway. SDK_OBJS = $(addprefix $(OBJDIR)/,$(patsubst %.c,%.o,$(SDK_SRCS))) -$(SDK_OBJS): CFLAGS += -Wno-missing-braces -Wno-strict-aliasing -Wno-parentheses -Wno-unused-variable +$(SDK_OBJS): CFLAGS += -include mongoose.h -Wno-missing-braces -Wno-strict-aliasing -Wno-parentheses -Wno-unused-variable +$(BUILD_DIR)/cc_pal.o: CFLAGS += -Wno-error diff --git a/examples/CC3200/main.c b/examples/CC3200/main.c index 2c82fc60..4ae23540 100644 --- a/examples/CC3200/main.c +++ b/examples/CC3200/main.c @@ -25,6 +25,7 @@ #include "gpio_if.h" #include "i2c_if.h" +#include "mongoose.h" #include "simplelink.h" #include "device.h" @@ -226,3 +227,8 @@ void SimpleLinkHttpServerCallback(SlHttpServerEvent_t *e, void SimpleLinkSockEventHandler(SlSockEvent_t *e) { } + +void SimpleLinkGeneralEventHandler(SlDeviceEvent_t *e) { + LOG(LL_INFO, ("status %d sender %d", e->EventData.deviceEvent.status, + e->EventData.deviceEvent.sender)); +} diff --git a/examples/CC3200/mg_task.c b/examples/CC3200/mg_task.c index 57196138..696d8db4 100644 --- a/examples/CC3200/mg_task.c +++ b/examples/CC3200/mg_task.c @@ -1,7 +1,5 @@ #include "mg_task.h" -#include - enum mg_q_msg_type { MG_Q_MSG_CB, }; @@ -13,11 +11,11 @@ struct mg_q_msg { static OsiMsgQ_t s_mg_q; static void mg_task(void *arg); -bool mg_start_task(int priority, int stask_size, mg_init_cb mg_init) { +bool mg_start_task(int priority, int stack_size, mg_init_cb mg_init) { if (osi_MsgQCreate(&s_mg_q, "MG", sizeof(struct mg_q_msg), 16) != OSI_OK) { return false; } - if (osi_TaskCreate(mg_task, (const signed char *) "MG", stask_size, + if (osi_TaskCreate(mg_task, (const signed char *) "MG", stack_size, (void *) mg_init, priority, NULL) != OSI_OK) { return false; } diff --git a/examples/CC3200/mg_task.h b/examples/CC3200/mg_task.h index df36c0f8..dfbd5311 100644 --- a/examples/CC3200/mg_task.h +++ b/examples/CC3200/mg_task.h @@ -7,11 +7,13 @@ #define CS_MONGOOSE_EXAMPLES_CC3200_MG_TASK_H_ #include +#include +#include #include "mongoose.h" typedef void (*mg_init_cb)(struct mg_mgr *mgr); -bool mg_start_task(int priority, int stask_size, mg_init_cb mg_init); +bool mg_start_task(int priority, int stack_size, mg_init_cb mg_init); void mg_run_in_task(void (*cb)(struct mg_mgr *mgr, void *arg), void *cb_arg); diff --git a/examples/CC3200/sdk.version b/examples/CC3200/sdk.version index 77212f1f..f8fbdf5d 100644 --- a/examples/CC3200/sdk.version +++ b/examples/CC3200/sdk.version @@ -1 +1 @@ -docker.cesanta.com:5000/cc3200-build:1.1.0-r7 +docker.cesanta.com:5000/cc3200-build:1.2.0-r1 diff --git a/examples/CC3200/wifi.c b/examples/CC3200/wifi.c index b34278f0..ad82c5b8 100644 --- a/examples/CC3200/wifi.c +++ b/examples/CC3200/wifi.c @@ -1,12 +1,11 @@ #include "wifi.h" +#include "mongoose.h" #include "simplelink.h" #include "wlan.h" #include "gpio_if.h" -#include "mongoose.h" - void SimpleLinkWlanEventHandler(SlWlanEvent_t *e) { switch (e->Event) { case SL_WLAN_CONNECT_EVENT: diff --git a/mongoose.c b/mongoose.c index d88d6fa0..d1bce24b 100644 --- a/mongoose.c +++ b/mongoose.c @@ -10071,7 +10071,7 @@ int mg_set_protocol_coap(struct mg_connection *nc) { /* Amalgamated: #include "common/cs_dbg.h" */ -extern int set_errno(int e); /* From cc3200_fs.c */ +extern int set_errno(int e); /* From cc3200_fs.c */ /* * With SLFS, you have to pre-declare max file size. Yes. Really. @@ -10144,7 +10144,7 @@ int fs_slfs_open(const char *pathname, int flags, mode_t mode) { } _i32 r = sl_FsOpen((_u8 *) pathname, am, NULL, &fi->fh); DBG(("sl_FsOpen(%s, 0x%x) = %d, %d", pathname, (int) am, (int) r, - (int) fi->fh)); + (int) fi->fh)); if (r == SL_FS_OK) { fi->pos = 0; r = fd; @@ -10171,8 +10171,8 @@ ssize_t fs_slfs_read(int fd, void *buf, size_t count) { */ if (fi->size >= 0 && fi->pos == fi->size) return 0; _i32 r = sl_FsRead(fi->fh, fi->pos, buf, count); - DBG(("sl_FsRead(%d, %d, %d) = %d", (int) fi->fh, (int) fi->pos, - (int) count, (int) r)); + DBG(("sl_FsRead(%d, %d, %d) = %d", (int) fi->fh, (int) fi->pos, (int) count, + (int) r)); if (r >= 0) { fi->pos += r; return r; @@ -10184,8 +10184,8 @@ ssize_t fs_slfs_write(int fd, const void *buf, size_t count) { struct sl_fd_info *fi = &s_sl_fds[fd]; if (fi->fh <= 0) return set_errno(EBADF); _i32 r = sl_FsWrite(fi->fh, fi->pos, (_u8 *) buf, count); - DBG(("sl_FsWrite(%d, %d, %d) = %d", (int) fi->fh, (int) fi->pos, - (int) count, (int) r)); + DBG(("sl_FsWrite(%d, %d, %d) = %d", (int) fi->fh, (int) fi->pos, (int) count, + (int) r)); if (r >= 0) { fi->pos += r; return r; @@ -10587,15 +10587,16 @@ int mkdir(const char *path, mode_t mode) { } #endif - int cc3200_fs_init() { + int ret = 1; #ifdef __TI_COMPILER_VERSION__ #ifdef CC3200_FS_SLFS - return add_device("SL", _MSA, fs_slfs_open, fs_slfs_close, fs_slfs_read, fs_slfs_write, fs_slfs_lseek, fs_slfs_unlink, fs_slfs_rename) == 0; + ret = (add_device("SL", _MSA, fs_slfs_open, fs_slfs_close, fs_slfs_read, + fs_slfs_write, fs_slfs_lseek, fs_slfs_unlink, + fs_slfs_rename) == 0); #endif -#else - return 1; #endif + return ret; } #endif /* CS_PLATFORM == CS_P_CC3200 */ diff --git a/mongoose.h b/mongoose.h index 1b0f3dca..c6c09cf4 100644 --- a/mongoose.h +++ b/mongoose.h @@ -431,140 +431,43 @@ unsigned long os_random(void); #define MG_DISABLE_DIRECTORY_LISTING 1 #endif +#ifndef __TI_COMPILER_VERSION__ +#undef __CONCAT +#undef EACCES +#undef EADDRINUSE +#undef EADDRNOTAVAIL +#undef EAFNOSUPPORT +#undef EAGAIN +#undef EBADF +#undef ECONNREFUSED +#undef EDESTADDRREQ +#undef EFAULT +#undef EINVAL +#undef EISCONN +#undef ENETUNREACH +#undef ENOBUFS +#undef ENOMEM +#undef ENOPROTOOPT +#undef ENOTCONN +#undef EOPNOTSUPP +#undef EPROTONOSUPPORT +#undef EPROTOTYPE +#undef ETIMEDOUT +#undef EWOULDBLOCK +#undef FD_CLR +#undef FD_ISSET +#undef FD_SET +#undef FD_SETSIZE +#undef FD_ZERO +#undef fd_set +#endif + #include #define SOMAXCONN 8 -/* Undefine a bunch of conflicting symbols so we can use SDK defs verbatim. */ - -#undef FD_CLR -#undef FD_SET -#undef FD_ZERO -#undef FD_ISSET -#undef FD_SETSIZE -#undef fd_set - -#undef EACCES -#undef EBADF -#undef EAGAIN -#undef EWOULDBLOCK -#undef ENOMEM -#undef EFAULT -#undef EINVAL -#undef EDESTADDRREQ -#undef EPROTOTYPE -#undef ENOPROTOOPT -#undef EPROTONOSUPPORT -#undef EOPNOTSUPP -#undef EAFNOSUPPORT -#undef EAFNOSUPPORT -#undef EADDRINUSE -#undef EADDRNOTAVAIL -#undef ENETUNREACH -#undef ENOBUFS -#undef EISCONN -#undef ENOTCONN -#undef ETIMEDOUT -#undef ECONNREFUSED - -/* The following comes from $SDK/simplelink/include/socket.h */ -/* clang-format off */ -#define FD_SETSIZE SL_FD_SETSIZE - -#define SOCK_STREAM SL_SOCK_STREAM -#define SOCK_DGRAM SL_SOCK_DGRAM -#define SOCK_RAW SL_SOCK_RAW -#define IPPROTO_TCP SL_IPPROTO_TCP -#define IPPROTO_UDP SL_IPPROTO_UDP -#define IPPROTO_RAW SL_IPPROTO_RAW - -#define AF_INET SL_AF_INET -#define AF_INET6 SL_AF_INET6 -#define AF_INET6_EUI_48 SL_AF_INET6_EUI_48 -#define AF_RF SL_AF_RF -#define AF_PACKET SL_AF_PACKET - -#define PF_INET SL_PF_INET -#define PF_INET6 SL_PF_INET6 - -#define INADDR_ANY SL_INADDR_ANY -#define ERROR SL_SOC_ERROR -#define INEXE SL_INEXE -#define EBADF SL_EBADF -#define ENSOCK SL_ENSOCK -#define EAGAIN SL_EAGAIN -#define EWOULDBLOCK SL_EWOULDBLOCK -#define ENOMEM SL_ENOMEM -#define EACCES SL_EACCES -#define EFAULT SL_EFAULT -#define EINVAL SL_EINVAL -#define EDESTADDRREQ SL_EDESTADDRREQ -#define EPROTOTYPE SL_EPROTOTYPE -#define ENOPROTOOPT SL_ENOPROTOOPT -#define EPROTONOSUPPORT SL_EPROTONOSUPPORT -#define ESOCKTNOSUPPORT SL_ESOCKTNOSUPPORT -#define EOPNOTSUPP SL_EOPNOTSUPP -#define EAFNOSUPPORT SL_EAFNOSUPPORT -#define EADDRINUSE SL_EADDRINUSE -#define EADDRNOTAVAIL SL_EADDRNOTAVAIL -#define ENETUNREACH SL_ENETUNREACH -#define ENOBUFS SL_ENOBUFS -#define EOBUFF SL_EOBUFF -#define EISCONN SL_EISCONN -#define ENOTCONN SL_ENOTCONN -#define ETIMEDOUT SL_ETIMEDOUT -#define ECONNREFUSED SL_ECONNREFUSED - -#define SOL_SOCKET SL_SOL_SOCKET -#define IPPROTO_IP SL_IPPROTO_IP -#define SO_KEEPALIVE SL_SO_KEEPALIVE - -#define SO_RCVTIMEO SL_SO_RCVTIMEO -#define SO_NONBLOCKING SL_SO_NONBLOCKING - -#define IP_MULTICAST_IF SL_IP_MULTICAST_IF -#define IP_MULTICAST_TTL SL_IP_MULTICAST_TTL -#define IP_ADD_MEMBERSHIP SL_IP_ADD_MEMBERSHIP -#define IP_DROP_MEMBERSHIP SL_IP_DROP_MEMBERSHIP - -#define socklen_t SlSocklen_t -#ifdef __TI_COMPILER_VERSION__ -#define timeval SlTimeval_t -#endif -#define sockaddr SlSockAddr_t -#define in6_addr SlIn6Addr_t -#define sockaddr_in6 SlSockAddrIn6_t -#define in_addr SlInAddr_t -#define sockaddr_in SlSockAddrIn_t - -#define MSG_DONTWAIT SL_MSG_DONTWAIT - -#define FD_SET SL_FD_SET -#define FD_CLR SL_FD_CLR -#define FD_ISSET SL_FD_ISSET -#define FD_ZERO SL_FD_ZERO -#define fd_set SlFdSet_t - -#define socket sl_Socket -#define accept sl_Accept -#define bind sl_Bind -#define listen sl_Listen -#define connect sl_Connect -#define select sl_Select -#define setsockopt sl_SetSockOpt -#define getsockopt sl_GetSockOpt -#define recv sl_Recv -#define recvfrom sl_RecvFrom -#define write sl_Write -#define send sl_Send -#define sendto sl_SendTo /* rojer: gethostbyname() and sl_NetAppDnsGetHostByName are NOT compatible. */ -/* #define gethostbyname sl_NetAppDnsGetHostByName */ -#define htonl sl_Htonl -#define ntohl sl_Ntohl -#define htons sl_Htons -#define ntohs sl_Ntohs -/* clang-format on */ +#undef gethostbyname typedef int sock_t; #define INVALID_SOCKET (-1) @@ -576,6 +479,7 @@ typedef struct stat cs_stat_t; #define INT64_X_FMT PRIx64 #define __cdecl +#undef close /* Defined by SL's socket.h */ #define closesocket(x) sl_Close(x) #define fileno(x) -1 @@ -586,8 +490,12 @@ const char *inet_ntop(int af, const void *src, char *dst, socklen_t size); char *inet_ntoa(struct in_addr in); int inet_pton(int af, const char *src, void *dst); -struct timeval; +#ifdef __TI_COMPILER_VERSION__ +#define timeval SlTimeval_t int gettimeofday(struct timeval *t, void *tz); +#else +#undef timeval +#endif long int random(void);