瀏覽代碼

Merge pull request #1 from jpush/master

sync
senduo 6 年之前
父節點
當前提交
f9161ca2a2

+ 3 - 1
README.md

@@ -25,7 +25,9 @@ MIT License 协议许可。
 
 ## 2 获取软件包
 
+使用 `jiot-c-sdl` 软件包使用 menuconfig 命令打开 Env 配置界面,在 `RT-Thread online packages → IoT - internet of things → IoT Cloud` 中选择 jiot-c-sdk 软件包,操作界面如下图所示:
 
+![选中 jiot-c-sdk 软件包](https://github.com/jpush/JIoT-rtthread-package/blob/master/docs/figures/select_jiot_c_sdk.png?raw=true)
 
-## 3 软件包使用
+选择合适的配置项后,使用 `pkgs --update` 命令下载软件包并添加到工程中即可。
 

+ 39 - 0
SConscript_rtthread

@@ -0,0 +1,39 @@
+Import('RTT_ROOT')
+from building import *
+
+# get current directory
+cwd = GetCurrentDir()
+
+# The set of source files associated with this SConscript file.
+src = []
+path = []
+
+src += Glob('jiot-c-sdk/src/jclient/*.c')
+src += Glob('jiot-c-sdk/src/sisclient/*.c')
+src += Glob('jiot-c-sdk/src/mqtt/MQTTClient-C/src/*.c')
+src += Glob('jiot-c-sdk/src/mqtt/MQTTPacket/src/*.c')
+src += Glob('jiot-c-sdk/common/*.c')
+src += Glob('jiot-c-sdk/public/net/tcp/*.c')
+src += Glob('jiot-c-sdk/platform/os/rt-thread/*.c')
+
+path += [cwd + '/jiot-c-sdk/common']
+path += [cwd + '/jiot-c-sdk/include/jclient']
+path += [cwd + '/jiot-c-sdk/include/mqtt']
+path += [cwd + '/jiot-c-sdk/include/sisclient']
+path += [cwd + '/jiot-c-sdk/platform/os/rt-thread']
+path += [cwd + '/jiot-c-sdk/src/mqtt/MQTTPacket/src']
+path += [cwd + '/jiot-c-sdk/public/net/tcp']
+
+if GetDepend(['PKG_USING_JIOT_EXAMPLES']):
+	src += Glob('samples/*.c')
+	
+if GetDepend(['JIOT_SSL']):
+
+	src += Glob('jiot-c-sdk/public/net/ssl/*.c')
+	src += Glob('jiot-c-sdk/platform/ssl/mbedtls/*.c')
+	path += [cwd + '/jiot-c-sdk/platform/ssl/mbedtls']
+	path += [cwd + '/jiot-c-sdk/public/net/ssl']
+	
+group = DefineGroup('jiot-c-sdk', src, depend = [''], CPPPATH = path)
+
+Return('group')

二進制
docs/figures/select_jiot_c_sdk.png


+ 26 - 4
jiot-c-sdk/platform/os/rt-thread/jiot_timer.c

@@ -70,16 +70,38 @@ void jiot_timer_countdown(S_JIOT_TIME_TYPE* timer,UINT32 millisecond)
 
 UINT64 jiot_timer_now_ms()
 {
-    struct timeval now;
+    /*struct timeval now;
     gettimeofday(&now, NULL);
-    return now.tv_sec*1000 + now.tv_usec/1000 ;
+    return now.tv_sec*1000 + now.tv_usec/1000 ;*/
+#if (RT_TICK_PER_SECOND == 1000)
+    return (UINT64)rt_tick_get();
+#else
+
+    uint64_t tick;
+    tick = rt_tick_get();
+
+    tick = tick * 1000;
+
+    return (tick + RT_TICK_PER_SECOND - 1)/RT_TICK_PER_SECOND;
+#endif
 }
 
 UINT32 jiot_timer_now()
 {
-    struct timeval now;
+    /*struct timeval now;
     gettimeofday(&now, NULL);
-    return now.tv_sec;
+    return now.tv_sec;*/
+#if (RT_TICK_PER_SECOND == 1000)
+    return (UINT32)(rt_tick_get() / 1000);
+#else
+
+    uint64_t tick;
+    tick = rt_tick_get();
+
+    tick = tick * 1000;
+
+    return (tick + RT_TICK_PER_SECOND - 1)/RT_TICK_PER_SECOND / 1000;
+#endif
 }
 
 void jiot_timer_s2str(UINT32 second,char* buf )

+ 0 - 1
jiot-c-sdk/platform/os/rt-thread/jiot_timer.h

@@ -7,7 +7,6 @@
 #ifndef JIOT_TIMER_H
 #define JIOT_TIMER_H
 
-#include <time.h>
 #include <sys/time.h>
 #include "jiot_err.h"
 #include "jiot_std.h"