From e941e190cc709654b711827e4192a97028deac59 Mon Sep 17 00:00:00 2001 From: "Yang, Xiao" Date: Wed, 21 Nov 2018 11:37:31 +0800 Subject: [PATCH] [mingw32] fix build error when generate Windows version SDK Signed-off-by: Yang, Xiao --- README.md | 6 ++-- src/board/config.win7.mingw32 | 10 ++++-- src/ref-impl/hal/os/win7/HAL_OS_win7.c | 2 +- src/services/linkkit/dm/dm_msg_process.c | 42 ++++++++++++++-------- src/services/linkkit/dm/iotx_dm_internal.h | 6 ++++ src/tools/mock_build_options.mk | 2 ++ src/tools/parse_make_settings.mk | 2 +- 7 files changed, 48 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 9ccd447c4..48a94c107 100644 --- a/README.md +++ b/README.md @@ -6,13 +6,13 @@ # 快速开始 -用户可以通过[在Ubuntu快速的体验Link Kit SDK](https://code.aliyun.com/edward.yangx/public-docs/wikis/user-guide/linkkit/Quick_Start)感受如何将设备连接到阿里云物联网平台, 并如何将设备的数据发送到平台/以及如何从物联网平台接收数据 +用户可以通过[在Ubuntu快速的体验Link Kit SDK](https://help.aliyun.com/document_detail/96624.html)感受如何将设备连接到阿里云物联网平台, 并如何将设备的数据发送到平台/以及如何从物联网平台接收数据 # 移植说明 Link Kit SDK是一个与OS/硬件平台无关的用C编写的代码, 定义了HAL层来对接与硬件相关的功能, 因此在使用Link Kit SDK时用户需要去实现相关的HAL函数 -目前Link Kit SDK已实现了在Linux/Windows/AliOS上HAL的实现, 同时对于一些常见的OS或者模组也进行了适配, 可以[访问此处](https://code.aliyun.com/edward.yangx/public-docs/wikis/user-guide/Linkkit_User_Manual)查看如何在相应平台上进行SDK的编译与集成 +目前Link Kit SDK已实现了在Linux/Windows/AliOS上HAL的实现, 同时对于一些常见的OS或者模组也进行了适配, 可以[访问此处](https://help.aliyun.com/document_detail/97557.html)查看如何在相应平台上进行SDK的编译与集成 # 编程文档 -SDK提供了一系列的编程文档来描述如何使用SDK提供的软件功能, 请[访问此处](https://code.aliyun.com/edward.yangx/public-docs/wikis/user-guide/Linkkit_User_Manual)进行了解 +SDK提供了一系列的编程文档来描述如何使用SDK提供的软件功能, 请[访问此处](https://help.aliyun.com/document_detail/96627.html)进行了解 diff --git a/src/board/config.win7.mingw32 b/src/board/config.win7.mingw32 index b0b2932db..34122570e 100644 --- a/src/board/config.win7.mingw32 +++ b/src/board/config.win7.mingw32 @@ -4,8 +4,12 @@ CONFIG_ENV_CFLAGS += \ -DCC_IS_MINGW32 \ -D_PLATFORM_IS_WINDOWS_ \ +CONFIG_ENV_LDFLAGS += -lws2_32 + CROSS_PREFIX := i686-w64-mingw32- -CONFIG_src/protocol/coap/cloud := -CONFIG_src/services/uOTA := -CONFIG_tests := +CONFIG_src/protocol/coap/cloud := +CONFIG_src/services/uOTA := +CONFIG_tests := +CONFIG_src/services/awss := +CONFIG_src/services/dev_bind := diff --git a/src/ref-impl/hal/os/win7/HAL_OS_win7.c b/src/ref-impl/hal/os/win7/HAL_OS_win7.c index f7dc8bc24..a316942f7 100644 --- a/src/ref-impl/hal/os/win7/HAL_OS_win7.c +++ b/src/ref-impl/hal/os/win7/HAL_OS_win7.c @@ -653,7 +653,7 @@ int HAL_Fseek(void *stream, long offset, int framewhere) return fseek((FILE *)stream, offset, framewhere); } -int HAL_Fclose(FILE *stream) +int HAL_Fclose(void *stream) { return fclose((FILE *)stream); } diff --git a/src/services/linkkit/dm/dm_msg_process.c b/src/services/linkkit/dm/dm_msg_process.c index d446d0ae3..4916262aa 100644 --- a/src/services/linkkit/dm/dm_msg_process.c +++ b/src/services/linkkit/dm/dm_msg_process.c @@ -91,7 +91,8 @@ int dm_msg_proc_thing_model_down_raw(_IN_ dm_msg_source_t *source) char device_name[DEVICE_NAME_MAXLEN] = {0}; /* Parse Product Key And Device Name */ - res = dm_msg_uri_parse_pkdn((char *)source->uri, strlen(source->uri), 2, 4, product_key, device_name); + res = dm_msg_uri_parse_pkdn((char *)source->uri, strlen(source->uri), 2 + DM_URI_OFFSET, 4 + DM_URI_OFFSET, product_key, + device_name); if (res != SUCCESS_RETURN) { return FAIL_RETURN; } @@ -107,7 +108,8 @@ int dm_msg_proc_thing_model_up_raw_reply(_IN_ dm_msg_source_t *source) dm_log_info(DM_URI_THING_MODEL_UP_RAW_REPLY); - res = dm_msg_uri_parse_pkdn((char *)source->uri, strlen(source->uri), 2, 4, product_key, device_name); + res = dm_msg_uri_parse_pkdn((char *)source->uri, strlen(source->uri), 2 + DM_URI_OFFSET, 4 + DM_URI_OFFSET, product_key, + device_name); if (res != SUCCESS_RETURN) { return FAIL_RETURN; } @@ -132,7 +134,8 @@ int dm_msg_proc_thing_service_property_set(_IN_ dm_msg_source_t *source, _IN_ dm dm_log_info(DM_URI_THING_SERVICE_PROPERTY_SET); /* Request */ - res = dm_msg_uri_parse_pkdn((char *)source->uri, strlen(source->uri), 2, 4, product_key, device_name); + res = dm_msg_uri_parse_pkdn((char *)source->uri, strlen(source->uri), 2 + DM_URI_OFFSET, 4 + DM_URI_OFFSET, product_key, + device_name); if (res < SUCCESS_RETURN) { return res; } @@ -171,7 +174,8 @@ int dm_msg_proc_thing_service_property_get(_IN_ dm_msg_source_t *source, _IN_ dm dm_log_info(DM_URI_THING_SERVICE_PROPERTY_GET); /* Request */ - res = dm_msg_uri_parse_pkdn((char *)source->uri, strlen(source->uri), 2, 4, product_key, device_name); + res = dm_msg_uri_parse_pkdn((char *)source->uri, strlen(source->uri), 2 + DM_URI_OFFSET, 4 + DM_URI_OFFSET, product_key, + device_name); if (res < SUCCESS_RETURN) { return res; } @@ -230,7 +234,8 @@ int dm_msg_proc_thing_service_property_post(_IN_ dm_msg_source_t *source, _IN_ d dm_log_info(DM_URI_THING_EVENT_PROPERTY_POST); /* Request */ - res = dm_msg_uri_parse_pkdn((char *)source->uri, strlen(source->uri), 2, 4, product_key, device_name); + res = dm_msg_uri_parse_pkdn((char *)source->uri, strlen(source->uri), 2 + DM_URI_OFFSET, 4 + DM_URI_OFFSET, product_key, + device_name); if (res != SUCCESS_RETURN) { return FAIL_RETURN; } @@ -263,7 +268,8 @@ int dm_msg_proc_thing_service_request(_IN_ dm_msg_source_t *source) dm_log_info("Service Identifier: %.*s", strlen(source->uri) - serviceid_pos - 1, source->uri + serviceid_pos + 1); /* Parse Product Key And Device Name */ - res = dm_msg_uri_parse_pkdn((char *)source->uri, strlen(source->uri), 2, 4, product_key, device_name); + res = dm_msg_uri_parse_pkdn((char *)source->uri, strlen(source->uri), 2 + DM_URI_OFFSET, 4 + DM_URI_OFFSET, product_key, + device_name); if (res != SUCCESS_RETURN) { return FAIL_RETURN; } @@ -284,12 +290,14 @@ int dm_msg_proc_thing_event_post_reply(_IN_ dm_msg_source_t *source) int res = 0, eventid_start_pos = 0, eventid_end_pos = 0; dm_msg_response_payload_t response; - res = dm_utils_memtok((char *)source->uri, strlen(source->uri), DM_URI_SERVICE_DELIMITER, 6, &eventid_start_pos); + res = dm_utils_memtok((char *)source->uri, strlen(source->uri), DM_URI_SERVICE_DELIMITER, 6 + DM_URI_OFFSET, + &eventid_start_pos); if (res != SUCCESS_RETURN) { return FAIL_RETURN; } - res = dm_utils_memtok((char *)source->uri, strlen(source->uri), DM_URI_SERVICE_DELIMITER, 7, &eventid_end_pos); + res = dm_utils_memtok((char *)source->uri, strlen(source->uri), DM_URI_SERVICE_DELIMITER, 7 + DM_URI_OFFSET, + &eventid_end_pos); if (res != SUCCESS_RETURN) { return FAIL_RETURN; } @@ -410,7 +418,8 @@ int dm_msg_proc_rrpc_request(_IN_ dm_msg_source_t *source) dm_log_info("Rrpc Id: %.*s", strlen(source->uri) - rrpcid_pos - 1, source->uri + rrpcid_pos + 1); /* Parse Product Key And Device Name */ - res = dm_msg_uri_parse_pkdn((char *)source->uri, strlen(source->uri), 2, 4, product_key, device_name); + res = dm_msg_uri_parse_pkdn((char *)source->uri, strlen(source->uri), 2 + DM_URI_OFFSET, 4 + DM_URI_OFFSET, product_key, + device_name); if (res != SUCCESS_RETURN) { return FAIL_RETURN; } @@ -462,7 +471,8 @@ int dm_msg_proc_thing_topo_add_notify(_IN_ dm_msg_source_t *source, _IN_ dm_msg_ dm_log_info(DM_URI_THING_TOPO_ADD_NOTIFY); /* Request */ - res = dm_msg_uri_parse_pkdn((char *)source->uri, strlen(source->uri), 2, 4, product_key, device_name); + res = dm_msg_uri_parse_pkdn((char *)source->uri, strlen(source->uri), 2 + DM_URI_OFFSET, 4 + DM_URI_OFFSET, product_key, + device_name); if (res < SUCCESS_RETURN) { return res; } @@ -498,7 +508,8 @@ int dm_msg_proc_thing_disable(_IN_ dm_msg_source_t *source, _IN_ dm_msg_dest_t * dm_log_info(DM_URI_THING_DISABLE); /* Request */ - res = dm_msg_uri_parse_pkdn((char *)source->uri, strlen(source->uri), 2, 4, product_key, device_name); + res = dm_msg_uri_parse_pkdn((char *)source->uri, strlen(source->uri), 2 + DM_URI_OFFSET, 4 + DM_URI_OFFSET, product_key, + device_name); if (res < SUCCESS_RETURN) { return res; } @@ -531,7 +542,8 @@ int dm_msg_proc_thing_enable(_IN_ dm_msg_source_t *source, _IN_ dm_msg_dest_t *d dm_log_info(DM_URI_THING_DISABLE); /* Request */ - res = dm_msg_uri_parse_pkdn((char *)source->uri, strlen(source->uri), 2, 4, product_key, device_name); + res = dm_msg_uri_parse_pkdn((char *)source->uri, strlen(source->uri), 2 + DM_URI_OFFSET, 4 + DM_URI_OFFSET, product_key, + device_name); if (res < SUCCESS_RETURN) { return res; } @@ -564,7 +576,8 @@ int dm_msg_proc_thing_delete(_IN_ dm_msg_source_t *source, _IN_ dm_msg_dest_t *d dm_log_info(DM_URI_THING_DELETE); /* Request */ - res = dm_msg_uri_parse_pkdn((char *)source->uri, strlen(source->uri), 2, 4, product_key, device_name); + res = dm_msg_uri_parse_pkdn((char *)source->uri, strlen(source->uri), 2 + DM_URI_OFFSET, 4 + DM_URI_OFFSET, product_key, + device_name); if (res < SUCCESS_RETURN) { return res; } @@ -597,7 +610,8 @@ int dm_msg_proc_thing_gateway_permit(_IN_ dm_msg_source_t *source, _IN_ dm_msg_d dm_log_info(DM_URI_THING_DELETE); /* Request */ - res = dm_msg_uri_parse_pkdn((char *)source->uri, strlen(source->uri), 2, 4, product_key, device_name); + res = dm_msg_uri_parse_pkdn((char *)source->uri, strlen(source->uri), 2 + DM_URI_OFFSET, 4 + DM_URI_OFFSET, product_key, + device_name); if (res < SUCCESS_RETURN) { return res; } diff --git a/src/services/linkkit/dm/iotx_dm_internal.h b/src/services/linkkit/dm/iotx_dm_internal.h index a4f032f06..2902d3176 100644 --- a/src/services/linkkit/dm/iotx_dm_internal.h +++ b/src/services/linkkit/dm/iotx_dm_internal.h @@ -64,6 +64,12 @@ #endif #define DM_free(ptr) {LITE_free(ptr);ptr = NULL;} +#if defined(COAP_COMM_ENABLED) && !defined(MQTT_COMM_ENABLED) + #define DM_URI_OFFSET 1 +#else + #define DM_URI_OFFSET 0 +#endif + #if 1 #define dm_log_emerg(...) log_emerg("DM", __VA_ARGS__) #define dm_log_crit(...) log_crit("DM", __VA_ARGS__) diff --git a/src/tools/mock_build_options.mk b/src/tools/mock_build_options.mk index 805426df6..2f7b705f3 100644 --- a/src/tools/mock_build_options.mk +++ b/src/tools/mock_build_options.mk @@ -1,6 +1,8 @@ ifneq (,$(filter -D_PLATFORM_IS_WINDOWS_,$(CFLAGS))) CFLAGS := $(filter-out -DOTA_ENABLED,$(CFLAGS)) + CFLAGS := $(filter-out -DWIFI_PROVISION_ENABLED,$(CFLAGS)) + CFLAGS := $(filter-out -DDEV_BIND_ENABLED,$(CFLAGS)) endif ifeq (Darwin,$(shell uname)) diff --git a/src/tools/parse_make_settings.mk b/src/tools/parse_make_settings.mk index b7e10be22..2aca3bb2a 100644 --- a/src/tools/parse_make_settings.mk +++ b/src/tools/parse_make_settings.mk @@ -17,7 +17,7 @@ $(foreach v, \ ) ifeq (y,$(strip $(FEATURE_COAP_COMM_ENABLED))) - CFLAGS += -DDM_MESSAGE_CACHE_DISABLED + # CFLAGS += -DDM_MESSAGE_CACHE_DISABLED endif ifeq (y,$(strip $(FEATURE_DEVICE_MODEL_RAWDATA_SOLO)))