diff --git a/examples/CC3200/Makefile b/examples/CC3200/Makefile
index 227bc70b..cbb9fe4e 100644
--- a/examples/CC3200/Makefile
+++ b/examples/CC3200/Makefile
@@ -7,6 +7,9 @@ PORT ?= auto
MAKEFLAGS += w
all clean:
+ rm -rf ccs/*/Debug
+ rm -rf ccs/*/Release
+ rm -rf ccs/*/.launches
docker run --rm -i -v $(SRC_DIR):/src $(SDK) \
/bin/bash -c "\
make -C /src/mongoose mongoose.c mongoose.h && \
diff --git a/examples/CC3200/Makefile.build b/examples/CC3200/Makefile.build
index 967025de..331492b1 100644
--- a/examples/CC3200/Makefile.build
+++ b/examples/CC3200/Makefile.build
@@ -93,7 +93,7 @@ VPATH += $(SDK_PATH)/driverlib $(SDK_PATH)/example/common $(SDK_PATH)/oslib \
$(SDK_PATH)/third_party/FreeRTOS/source/portable/GCC/ARM_CM4 \
$(SDK_PATH)/third_party/FreeRTOS/source/portable/MemMang \
-APP_SRCS = main.c bm222.c data.c mongoose.c mg_task.c tmp006.c wifi.c $(SDK_SRCS)
+APP_SRCS = main.c bm222.c data.c mongoose.c tmp006.c wifi.c $(SDK_SRCS)
APP_OBJS = $(addprefix $(OBJDIR)/,$(patsubst %.c,%.o,$(APP_SRCS)))
$(FW_ELF): $(APP_OBJS)
diff --git a/examples/CC3200/ccs/Mongoose/.project b/examples/CC3200/ccs/Mongoose/.project
index c5ea2ce9..091a2a58 100644
--- a/examples/CC3200/ccs/Mongoose/.project
+++ b/examples/CC3200/ccs/Mongoose/.project
@@ -25,16 +25,6 @@
org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
-
- mg_task.c
- 1
- PARENT-2-PROJECT_LOC/mg_task.c
-
-
- mg_task.h
- 1
- PARENT-2-PROJECT_LOC/mg_task.h
-
mongoose.c
1
diff --git a/examples/CC3200/main.c b/examples/CC3200/main.c
index 4ae23540..81770c81 100644
--- a/examples/CC3200/main.c
+++ b/examples/CC3200/main.c
@@ -31,7 +31,6 @@
#include "data.h"
#include "mongoose.h"
-#include "mg_task.h"
#include "wifi.h"
/* Set up an AP or connect to existing WiFi network. */
@@ -52,8 +51,6 @@
#define BM222_ADDR 0x18
#define TMP006_ADDR 0x41
-extern int cc3200_fs_init();
-
static struct mg_str upload_fname(struct mg_connection *nc,
struct mg_str fname) {
struct mg_str lfn;
@@ -124,7 +121,9 @@ static void mg_init(struct mg_mgr *mgr) {
data_init_sensors(TMP006_ADDR, BM222_ADDR);
- cc3200_fs_init();
+ sl_fs_init();
+
+ sl_Start(NULL, NULL, NULL);
#if defined(WIFI_STA_SSID)
if (!wifi_setup_sta(WIFI_STA_SSID, WIFI_STA_PASS)) {
diff --git a/examples/CC3200/mg_task.c b/examples/CC3200/mg_task.c
deleted file mode 100644
index 696d8db4..00000000
--- a/examples/CC3200/mg_task.c
+++ /dev/null
@@ -1,46 +0,0 @@
-#include "mg_task.h"
-
-enum mg_q_msg_type {
- MG_Q_MSG_CB,
-};
-struct mg_q_msg {
- enum mg_q_msg_type type;
- void (*cb)(struct mg_mgr *mgr, void *arg);
- void *arg;
-};
-static OsiMsgQ_t s_mg_q;
-static void mg_task(void *arg);
-
-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", stack_size,
- (void *) mg_init, priority, NULL) != OSI_OK) {
- return false;
- }
- return true;
-}
-
-static void mg_task(void *arg) {
- struct mg_mgr mgr;
- mg_init_cb mg_init = (mg_init_cb) arg;
- sl_Start(NULL, NULL, NULL);
- mg_mgr_init(&mgr, NULL);
- mg_init(&mgr);
- while (1) {
- struct mg_q_msg msg;
- mg_mgr_poll(&mgr, 1);
- if (osi_MsgQRead(&s_mg_q, &msg, 1) != OSI_OK) continue;
- switch (msg.type) {
- case MG_Q_MSG_CB: {
- msg.cb(&mgr, msg.arg);
- }
- }
- }
-}
-
-void mg_run_in_task(void (*cb)(struct mg_mgr *mgr, void *arg), void *cb_arg) {
- struct mg_q_msg msg = {MG_Q_MSG_CB, cb, cb_arg};
- osi_MsgQWrite(&s_mg_q, &msg, OSI_NO_WAIT);
-}
diff --git a/examples/CC3200/mg_task.h b/examples/CC3200/mg_task.h
deleted file mode 100644
index dfbd5311..00000000
--- a/examples/CC3200/mg_task.h
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright (c) 2014-2016 Cesanta Software Limited
- * All rights reserved
- */
-
-#ifndef CS_MONGOOSE_EXAMPLES_CC3200_MG_TASK_H_
-#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 stack_size, mg_init_cb mg_init);
-
-void mg_run_in_task(void (*cb)(struct mg_mgr *mgr, void *arg), void *cb_arg);
-
-#endif /* CS_MONGOOSE_EXAMPLES_CC3200_MG_TASK_H_ */
diff --git a/mongoose.c b/mongoose.c
index 115cbaef..cfcab884 100644
--- a/mongoose.c
+++ b/mongoose.c
@@ -10153,10 +10153,13 @@ int _isatty(int fd) {
#if CS_PLATFORM == CS_P_MSP432
+#include
+#include
+
int gettimeofday(struct timeval *tp, void *tzp) {
- /* FIXME */
- tp->tv_sec = 42;
- tp->tv_usec = 123;
+ uint32_t ticks = Clock_getTicks();
+ tp->tv_sec = ticks / 1000;
+ tp->tv_usec = (ticks % 1000) * 1000;
return 0;
}
@@ -10173,8 +10176,8 @@ long int random(void) {
* All rights reserved
*/
-#ifndef CS_SMARTJS_PLATFORMS_SIMPLELINK_SL_FS_SLFS_H_
-#define CS_SMARTJS_PLATFORMS_SIMPLELINK_SL_FS_SLFS_H_
+#ifndef CS_COMMON_PLATFORMS_SIMPLELINK_SL_FS_SLFS_H_
+#define CS_COMMON_PLATFORMS_SIMPLELINK_SL_FS_SLFS_H_
#if defined(MG_FS_SLFS)
@@ -10199,7 +10202,7 @@ int fs_slfs_rename(const char *from, const char *to);
#endif /* defined(MG_FS_SLFS) */
-#endif /* CS_SMARTJS_PLATFORMS_SIMPLELINK_SL_FS_SLFS_H_ */
+#endif /* CS_COMMON_PLATFORMS_SIMPLELINK_SL_FS_SLFS_H_ */
#ifdef MG_MODULE_LINES
#line 1 "./src/../../common/platforms/simplelink/sl_fs_slfs.c"
#endif
@@ -10273,7 +10276,7 @@ int fs_slfs_open(const char *pathname, int flags, mode_t mode) {
struct sl_fd_info *fi = &s_sl_fds[fd];
_u32 am = 0;
- fi->size = -1;
+ fi->size = (size_t) -1;
if (pathname[0] == '/') pathname++;
int rw = (flags & 3);
if (rw == O_RDONLY) {
@@ -10322,7 +10325,7 @@ ssize_t fs_slfs_read(int fd, void *buf, size_t count) {
if (fi->fh <= 0) return set_errno(EBADF);
/* Simulate EOF. sl_FsRead @ file_size return SL_FS_ERR_OFFSET_OUT_OF_RANGE.
*/
- if (fi->size >= 0 && fi->pos == fi->size) return 0;
+ if (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));
@@ -10636,7 +10639,7 @@ ssize_t _read(int fd, void *buf, size_t count) {
ssize_t _write(int fd, const void *buf, size_t count) {
int r = -1;
- size_t i;
+ size_t i = 0;
switch (fd_type(fd)) {
case FD_INVALID:
r = set_errno(EBADF);
@@ -10652,6 +10655,8 @@ ssize_t _write(int fd, const void *buf, size_t count) {
if (c == '\n') MAP_UARTCharPut(CONSOLE_UART, '\r');
MAP_UARTCharPut(CONSOLE_UART, c);
}
+#else
+ (void) i;
#endif
r = count;
break;
@@ -10745,7 +10750,7 @@ int mkdir(const char *path, mode_t mode) {
}
#endif
-int cc3200_fs_init() {
+int sl_fs_init() {
int ret = 1;
#ifdef __TI_COMPILER_VERSION__
#ifdef MG_FS_SLFS
@@ -10811,4 +10816,58 @@ int inet_pton(int af, const char *src, void *dst) {
return 1;
}
-#endif /* MG_SOCKET_SIMPLELINK */
+#endif /* CS_COMMON_PLATFORMS_SIMPLELINK_SL_SOCKET_C_ */
+#ifdef MG_MODULE_LINES
+#line 1 "./src/../../common/platforms/simplelink/sl_mg_task.c"
+#endif
+#if defined(MG_SOCKET_SIMPLELINK)
+
+/* Amalgamated: #include "mg_task.h" */
+
+#include
+
+enum mg_q_msg_type {
+ MG_Q_MSG_CB,
+};
+struct mg_q_msg {
+ enum mg_q_msg_type type;
+ void (*cb)(struct mg_mgr *mgr, void *arg);
+ void *arg;
+};
+static OsiMsgQ_t s_mg_q;
+static void mg_task(void *arg);
+
+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", stack_size,
+ (void *) mg_init, priority, NULL) != OSI_OK) {
+ return false;
+ }
+ return true;
+}
+
+static void mg_task(void *arg) {
+ struct mg_mgr mgr;
+ mg_init_cb mg_init = (mg_init_cb) arg;
+ mg_mgr_init(&mgr, NULL);
+ mg_init(&mgr);
+ while (1) {
+ struct mg_q_msg msg;
+ mg_mgr_poll(&mgr, 1);
+ if (osi_MsgQRead(&s_mg_q, &msg, 1) != OSI_OK) continue;
+ switch (msg.type) {
+ case MG_Q_MSG_CB: {
+ msg.cb(&mgr, msg.arg);
+ }
+ }
+ }
+}
+
+void mg_run_in_task(void (*cb)(struct mg_mgr *mgr, void *arg), void *cb_arg) {
+ struct mg_q_msg msg = {MG_Q_MSG_CB, cb, cb_arg};
+ osi_MsgQWrite(&s_mg_q, &msg, OSI_NO_WAIT);
+}
+
+#endif /* defined(MG_SOCKET_SIMPLELINK) */
diff --git a/mongoose.h b/mongoose.h
index 810c61e8..dfe53266 100644
--- a/mongoose.h
+++ b/mongoose.h
@@ -621,12 +621,14 @@ int _stat(const char *pathname, struct stat *st);
* All rights reserved
*/
-#ifndef CS_SMARTJS_PLATFORMS_SIMPLELINK_CS_SIMPLELINK_H_
-#define CS_SMARTJS_PLATFORMS_SIMPLELINK_CS_SIMPLELINK_H_
+#ifndef CS_COMMON_PLATFORMS_SIMPLELINK_CS_SIMPLELINK_H_
+#define CS_COMMON_PLATFORMS_SIMPLELINK_CS_SIMPLELINK_H_
/* If simplelink.h is already included, all bets are off. */
#if defined(MG_SOCKET_SIMPLELINK) && !defined(__SIMPLELINK_H__)
+#include
+
#ifndef __TI_COMPILER_VERSION__
#undef __CONCAT
#undef FD_CLR
@@ -711,9 +713,18 @@ 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 mg_mgr;
+
+typedef void (*mg_init_cb)(struct mg_mgr *mgr);
+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);
+
+int sl_fs_init();
+
#endif /* defined(MG_SOCKET_SIMPLELINK) && !defined(__SIMPLELINK_H__) */
-#endif /* CS_SMARTJS_PLATFORMS_SIMPLELINK_CS_SIMPLELINK_H_ */
+#endif /* CS_COMMON_PLATFORMS_SIMPLELINK_CS_SIMPLELINK_H_ */
/*
* Copyright (c) 2014-2016 Cesanta Software Limited
* All rights reserved