diff --git a/components/cms/.gitignore b/components/cms/.gitignore deleted file mode 100644 index cc9ecf6e790adc0267740a3d642fd86adc4dc597..0000000000000000000000000000000000000000 --- a/components/cms/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -cms -source \ No newline at end of file diff --git a/components/cms/Kconfig b/components/cms/Kconfig deleted file mode 100644 index 57ad372d40d12986c1899924017a83a10d338d56..0000000000000000000000000000000000000000 --- a/components/cms/Kconfig +++ /dev/null @@ -1,10 +0,0 @@ -menu "CMS" -config USING_CMS - bool "Using CMS" - default n - - if USING_CMS - source "$OS_ROOT/components/cms/*/Kconfig" - endif -endmenu - diff --git a/components/cms/port/Kconfig b/components/cms/port/Kconfig deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/components/cms/port/cms_adapter.h b/components/cms/port/cms_adapter.h deleted file mode 100644 index 38920813f3fcbcd7f7d504781f82a482c190dcc9..0000000000000000000000000000000000000000 --- a/components/cms/port/cms_adapter.h +++ /dev/null @@ -1,50 +0,0 @@ -/** - *********************************************************************************************************************** - * Copyright (c) 2021, China Mobile Communications Group Co.,Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - * - * @file cms_clock.h - * - * @brief Interface related to OS. - * - * @revision - * Date Author Notes - * 2021-04-09 OneOS Team First version. - ***********************************************************************************************************************/ -#ifndef __CMS_ADAPTER_H__ -#define __CMS_ADAPTER_H__ -#include - -#if defined(__cplusplus) -extern "C" { -#endif - -#if defined(CMS_STD) -#define ASSERT(condition) \ - do \ - { \ - if (!(condition)) \ - { \ - printf("Assert failed. Condition(%s). [%s][%d]\r\n", #condition, __FUNCTION__, __LINE__); \ - cms_safety_assert_process(); \ - } \ - } while (0) - -void cms_safety_assert_process(void); -#else -#define ASSERT(condition) -#endif - -#if defined(__cplusplus) -} -#endif - -#endif /* __CMS_ADAPTER_H__ */ diff --git a/components/cms/port/cms_clock.h b/components/cms/port/cms_clock.h deleted file mode 100644 index b6528991b98b64ecf3580b6cbb20170876186385..0000000000000000000000000000000000000000 --- a/components/cms/port/cms_clock.h +++ /dev/null @@ -1,43 +0,0 @@ -/** - *********************************************************************************************************************** - * Copyright (c) 2021, China Mobile Communications Group Co.,Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - * - * @file cms_clock.h - * - * @brief Interface related to OS. - * - * @revision - * Date Author Notes - * 2021-04-09 OneOS Team First version. - ***********************************************************************************************************************/ -#ifndef __CMS_CLOCK_H__ -#define __CMS_CLOCK_H__ -#include -#include - -#if defined(__cplusplus) -extern "C" { -#endif - -size_t get_time_ms(void); - -size_t get_sys_tick(void); - -size_t get_tick_from_ms(size_t ms); - -size_t get_ms_from_tick(size_t tick); - -#if defined(__cplusplus) -} -#endif - -#endif /* __CMS_CLOCK_H__ */ diff --git a/components/cms/port/cms_memory.h b/components/cms/port/cms_memory.h deleted file mode 100644 index 1e3cda93332e78f661e51f2e87164fdb5d37225a..0000000000000000000000000000000000000000 --- a/components/cms/port/cms_memory.h +++ /dev/null @@ -1,47 +0,0 @@ -/** - *********************************************************************************************************************** - * Copyright (c) 2021, China Mobile Communications Group Co.,Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - * - * @file cms_memory.h - * - * @brief Interface related to OS. - * - * @revision - * Date Author Notes - * 2021-04-09 OneOS Team First version. - ***********************************************************************************************************************/ -#ifndef __CMS_MEMORY_H__ -#define __CMS_MEMORY_H__ -#include -#include - -#if defined(__cplusplus) -extern "C" { -#endif - -void *cms_malloc(size_t size); - -void *cms_calloc(size_t count, size_t size); - -void *cms_realloc(void *ptr, size_t new_size); - -void cms_free(void *ptr); - -void cms_memcpy(void *dst, const void *src, size_t size); - -void cms_memset(void *dst, int ch, size_t size); - -#if defined(__cplusplus) -} -#endif - -#endif /* __CMS_MEMORY_H__ */ diff --git a/components/cms/port/cms_mutex.h b/components/cms/port/cms_mutex.h deleted file mode 100644 index a29399415df2afd1ea59ebaef7d0a449d4c0e0aa..0000000000000000000000000000000000000000 --- a/components/cms/port/cms_mutex.h +++ /dev/null @@ -1,41 +0,0 @@ -/** - *********************************************************************************************************************** - * Copyright (c) 2021, China Mobile Communications Group Co.,Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - * - * @file cms_mutex.h - * - * @brief Interface related to OS. - * - * @revision - * Date Author Notes - * 2021-04-09 OneOS Team First version. - ***********************************************************************************************************************/ -#ifndef __CMS_MUTEX_H__ -#define __CMS_MUTEX_H__ - -#if defined(__cplusplus) -extern "C" { -#endif - -void *mutex_create(void); - -void mutex_destroy(void *mutex); - -void mutex_lock(void *mutex); - -void mutex_unlock(void *mutex); - -#if defined(__cplusplus) -} -#endif - -#endif /* __CMS_MUTEX_H__ */ diff --git a/components/cms/port/cms_net.h b/components/cms/port/cms_net.h deleted file mode 100644 index d07e7f81cab8d702c87245292810eeda9495b88c..0000000000000000000000000000000000000000 --- a/components/cms/port/cms_net.h +++ /dev/null @@ -1,63 +0,0 @@ -/** - *********************************************************************************************************************** - * Copyright (c) 2021, China Mobile Communications Group Co.,Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - * - * @file cms_net.h - * - * @brief Interface related to OS. - * - * @revision - * Date Author Notes - * 2021-04-09 OneOS Team First version. - ***********************************************************************************************************************/ -#ifndef __CMS_NET_H__ -#define __CMS_NET_H__ -#include -#include - -#if defined(__cplusplus) -extern "C" { -#endif - -#if !defined(BIG_ENDIAN) -#define CMS_NTOHS(x) ((uint16_t)((((x) & (uint16_t)0x00ffU) << 8) | (((x) & (uint16_t)0xff00U) >> 8))) -#define CMS_NTOHL(x) \ - ((((x) & (uint32_t)0x000000ffUL) << 24) | (((x) & (uint32_t)0x0000ff00UL) << 8) | \ - (((x) & (uint32_t)0x00ff0000UL) >> 8) | (((x) & (uint32_t)0xff000000UL) >> 24)) -#define CMS_HTONS(x) CMS_NTOHS(x) -#define CMS_HTONL(x) CMS_NTOHL(x) -#else -#define CMS_NTOHS(x) ((uint16_t)x) -#define CMS_NTOHL(x) ((uint32_t)x) -#define CMS_HTONS(x) CMS_NTOHS(x) -#define CMS_HTONL(x) CMS_NTOHL(x) -#endif - -enum CMS_TRANS_PROT_TYPE -{ - CMS_TCP, - CMS_UDP -}; - -void *cms_connect(const char *url, const char *port, enum CMS_TRANS_PROT_TYPE type); - -int cms_send_with_timeout(void *net_handle, const void *data, size_t size, int timeout_ms); - -int cms_recv_with_timeout(void *net_handle, void *mem, size_t len, int timeout_ms); - -int cms_closesocket(void *net_handle); - -#if defined(__cplusplus) -} -#endif - -#endif /* __CMS_NET_H__ */ diff --git a/components/cms/port/cms_ring_buff.h b/components/cms/port/cms_ring_buff.h deleted file mode 100644 index 7ac731d21b089b2cc2e4005dd7499336845dc8a1..0000000000000000000000000000000000000000 --- a/components/cms/port/cms_ring_buff.h +++ /dev/null @@ -1,48 +0,0 @@ -/** - *********************************************************************************************************************** - * Copyright (c) 2021, China Mobile Communications Group Co.,Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - * - * @file cms_ring_buff.h - * - * @brief Interface related to OS. - * - * @revision - * Date Author Notes - * 2021-04-09 OneOS Team First version. - ***********************************************************************************************************************/ -#ifndef __CMS_RING_BUFF_H__ -#define __CMS_RING_BUFF_H__ -#include -#include -#include - -#if defined(__cplusplus) -extern "C" { -#endif - -void *cms_con_ring_fifo_init(uint32_t max_length); - -void cms_con_ring_fifo_deinit(void *ring_fifo); - -int cms_con_ring_fifo_write(void *ring_fifo, uint8_t *buffer, uint32_t write_length); - -int cms_con_ring_fifo_read(void *ring_fifo, uint8_t *buffer, uint32_t read_length); - -uint32_t cms_con_ring_fifo_get_space_length(void *ring_fifo); - -uint32_t cms_con_ring_fifo_get_data_length(void *ring_fifo); - -#if defined(__cplusplus) -} -#endif - -#endif /* __CMS_RING_BUFF_H__ */ diff --git a/components/cms/port/cms_sem.h b/components/cms/port/cms_sem.h deleted file mode 100644 index 1fd889f103d4ba4000b9522d3a940ffca3a25885..0000000000000000000000000000000000000000 --- a/components/cms/port/cms_sem.h +++ /dev/null @@ -1,43 +0,0 @@ -/** - *********************************************************************************************************************** - * Copyright (c) 2021, China Mobile Communications Group Co.,Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - * - * @file cms_sem.h - * - * @brief Interface related to OS. - * - * @revision - * Date Author Notes - * 2021-04-09 OneOS Team First version. - ***********************************************************************************************************************/ -#ifndef __CMS_SEM_H__ -#define __CMS_SEM_H__ -#include -#include - -#if defined(__cplusplus) -extern "C" { -#endif - -void *cms_sem_create(const char *name, uint16_t initial_value, uint16_t max_value); - -void cms_sem_destroy(void *sem); - -int cms_sem_wait(void *sem, uint32_t timeout_ms); - -void cms_sem_post(void *sem); - -#if defined(__cplusplus) -} -#endif - -#endif /* __CMS_SEM_H__ */ diff --git a/components/cms/port/cms_thread.h b/components/cms/port/cms_thread.h deleted file mode 100644 index 9f29d22ff9e5f1040d40c4ca11fc608c36fb0a0f..0000000000000000000000000000000000000000 --- a/components/cms/port/cms_thread.h +++ /dev/null @@ -1,46 +0,0 @@ -/** - *********************************************************************************************************************** - * Copyright (c) 2021, China Mobile Communications Group Co.,Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - * - * @file cms_thread.h - * - * @brief Interface related to OS. - * - * @revision - * Date Author Notes - * 2021-04-09 OneOS Team First version. - ***********************************************************************************************************************/ -#ifndef __CMS_THREAD_H__ -#define __CMS_THREAD_H__ -#include -#include - -#if defined(__cplusplus) -extern "C" { -#endif - -void *task_create(void (*entry)(void *arg), void *arg, uint32_t stack_size, uint8_t priority); - -void task_destroy(void *mutex); - -void msleep(uint32_t ms); - -int task_startup(void *task); - -void * -task_create_with_name(const char *name, void (*entry)(void *arg), void *arg, uint32_t stack_size, uint8_t priority); - -#if defined(__cplusplus) -} -#endif - -#endif /* __CMS_THREAD_H__ */ diff --git a/components/cms/port/oneos/atest/cms_id_atest.c b/components/cms/port/oneos/atest/cms_id_atest.c deleted file mode 100644 index 6399942563314da8fcd5d3519046c49c5a8b5009..0000000000000000000000000000000000000000 --- a/components/cms/port/oneos/atest/cms_id_atest.c +++ /dev/null @@ -1,190 +0,0 @@ -/** -*********************************************************************************************************************** -* Copyright (c) 2021, China Mobile Communications Group Co.,Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with -* the License. You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on -* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the -* specific language governing permissions and limitations under the License. -* -* @file cms_id_atest.c -* -* @brief This is mqtt test file based atest. -* -* @revision -* Date Author Notes -* 2020-10-13 OneOS Team First Version -*********************************************************************************************************************** -*/ -#include -#include -#include -#include -#include "oneos_config.h" - -#ifdef CMS_USING_ID -#include "cms_id.h" -static void hexdump(const char *tag, size_t width, const unsigned char *buf, size_t size) -{ - printf("%s\r\n", tag); - int i = 0; - for (; i < size;) - { - printf("%02x ", buf[i]); - ++i; - if (i % width == 0) - printf("\r\n"); - } - if (i % width) - printf("\r\n"); -} - -static void strdump(const char *tag, size_t width, const unsigned char *buf, size_t size) -{ - printf("%s\r\n", tag); - int i = 0; - for (; i < size;) - { - printf("%c", buf[i]); - ++i; - if (i % width == 0) - printf("\r\n"); - } - if (i % width) - printf("\r\n"); -} - -static void atest_cms_id_get_id(void) -{ - size_t len = 0; - CMS_TYPE_T TYPE = PID; - char *name = NULL; - uint8_t id[128]; - for (; TYPE <= CWT_PLATFORM; TYPE++) - { - cms_id_get_id_len(TYPE, &len); - cms_id_get_id(TYPE, id, len); - - switch (TYPE) - { - case PID: - name = "PID"; - break; - case OID: - name = "OID"; - break; - case DID: - name = "DID"; - break; - case CTI_DEVICE: - name = "CTI_DEVICE"; - break; - case CTI_PLATFORM: - name = "CTI_PLATFORM"; - break; - case CWT_DEVICE: - name = "CWT_DEVICE"; - break; - case CWT_PLATFORM: - name = "CWT_PLATFORM"; - break; - default: - break; - } - if (TYPE > DID) - hexdump(name, 16, id, len); - else - strdump(name, 64, id, len); - memset(id, 0, sizeof(id)); - } -} - -static void atest_cms_id_regist_check(void) -{ - int rc = CMS_ERROR_GENERIC_ERROR; - rc = cms_id_regist_check(); - if (rc != CMS_ERROR_SUCCESS) - { - printf("Device is don't regist.\r\n"); - } - else - { - printf("Device has registed.\r\n"); - } -} - -static void atest_cms_id_regist(void) -{ - cms_id_regist(); -} - -static void atest_cms_id_auth_check(void) -{ - int rc = CMS_ERROR_GENERIC_ERROR; - rc = cms_id_auth_check(); - if (rc != CMS_ERROR_SUCCESS) - { - printf("Device is don't auth.\r\n"); - } - else - { - printf("Device was authed.\r\n"); - } -} - -static void atest_cms_id_auth(void) -{ - cms_id_authorize(); -} - -static void cms_id_all(void) -{ - ATEST_UNIT_RUN(atest_cms_id_regist_check); - ATEST_UNIT_RUN(atest_cms_id_auth_check); - - ATEST_UNIT_RUN(atest_cms_id_regist); - ATEST_UNIT_RUN(atest_cms_id_regist_check); - - ATEST_UNIT_RUN(atest_cms_id_auth); - ATEST_UNIT_RUN(atest_cms_id_auth_check); - - ATEST_UNIT_RUN(atest_cms_id_get_id); -} - -ATEST_TC_EXPORT(cms.id.all, cms_id_all, NULL, NULL, TC_PRIORITY_LOW); -ATEST_TC_EXPORT(cms.id.getid, atest_cms_id_get_id, NULL, NULL, TC_PRIORITY_LOW); -ATEST_TC_EXPORT(cms.id.check.auth, atest_cms_id_auth_check, NULL, NULL, TC_PRIORITY_LOW); -ATEST_TC_EXPORT(cms.id.auth, atest_cms_id_auth, NULL, NULL, TC_PRIORITY_LOW); -ATEST_TC_EXPORT(cms.id.regist, atest_cms_id_regist, NULL, NULL, TC_PRIORITY_LOW); -ATEST_TC_EXPORT(cms.id.check.regist, atest_cms_id_regist_check, NULL, NULL, TC_PRIORITY_LOW); -#endif - -/* just use for debug code. */ -//#define CMS_ID_DEBUG -#ifdef CMS_ID_DEBUG -#include "cms_id_internal.h" -static void cms_id_debug(void) -{ - uint8_t cti[16] = {0}; - memset(cti, 3, 16); - uint8_t oid[] = "1.2.156.113753.011P9sMHSB1P000000000032"; - - cms_id_init(); - cms_id_set_value(CTI_PLATFORM, cti, 16); - cms_id_gene_cwt(); - - cms_id_set_value(OID, oid, sizeof(oid)); - atest_cms_id_get_id(); - - cms_id_kdf_master(cti, 16); - memset(cti, 0, 16); - cms_id_get_value(KEY_MASTER, cti, 16); - - hexdump("key_diff", 64, cti, 16); -} -ATEST_TC_EXPORT(cms.id.debug, cms_id_debug, NULL, NULL, TC_PRIORITY_LOW); -#endif diff --git a/components/cms/port/oneos/atest/coap_atest.c b/components/cms/port/oneos/atest/coap_atest.c deleted file mode 100644 index 994c85cf84967c291274c782d100aff8472c22c3..0000000000000000000000000000000000000000 --- a/components/cms/port/oneos/atest/coap_atest.c +++ /dev/null @@ -1,819 +0,0 @@ -/** - *********************************************************************************************************************** - * Copyright (c) 2021, China Mobile Communications Group Co.,Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - * - * @file coap_atest.c - * - * @brief This is mqtt test file based atest. - * - * @revision - * Date Author Notes - * 2020-10-13 OneOS Team First Version - *********************************************************************************************************************** - */ -#include "oneos_config.h" -#if defined(CMS_CONNECT_COAP) -#include "cms_con_coap.h" -#include "cms_error.h" -#include "cms_def.h" -#include "cms_sem.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifndef OS_USING_DLOG -#error "pls enable dlog" -#endif -#include -#define LOG_TAG "cms_coap" -#if (SHELL_TASK_STACK_SIZE < 4096) -#error "shell task stack size must exceed 4095" -#endif - -#define COAP_TIME_OUT 5000 -#define COAP_BUFF_LENGTH 1024 -#define BLOCK_RES_NAME "block" -static int scode = 302; -static void *coap_context = NULL; -static cms_coap_optlist_t *coap_optlist = NULL; -static cms_coap_pdu_t *coap_pdu = NULL; -static os_task_id coap_task = NULL; -static const char *uri_path = "res"; -static const char *block_uri_path = BLOCK_RES_NAME; -static const char block_file[] = - "1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 " - "42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 " - "80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 " - "113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 " - "141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 " - "169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 " - "197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 " - "225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 " - "253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 " - "281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 "; -static const int block_file_size = sizeof(block_file) - 1; -static const int block_size = 128; - -static cms_coap_method_code -cms_coap_response(void *coap_context, const cms_coap_pdu_t *sent, const cms_coap_pdu_t *received, uint32_t mid) -{ - printf("%d send pdu:\r\n", scode); - cms_coap_show_pdu(sent); - printf("mid = %d, recv pdu:\r\n", mid); - cms_coap_show_pdu(received); - return coap_empty_code; -} - -static int cms_coap_event(void *coap_context, const int error_code) -{ - LOG_E(LOG_TAG, "error code is %d", error_code); - return 0; -} - -static void atest_cms_coap_new_context_success(void) -{ - cms_coap_param param = {COAP_BUFF_LENGTH * 4, COAP_BUFF_LENGTH}; - cms_coap_free_context(coap_context); - coap_context = NULL; - coap_context = cms_coap_new_context(scode, ¶m); - tp_assert_true(coap_context != NULL); -} - -static void atest_cms_coap_new_context_fail(void) -{ - cms_coap_param error_param = {0, 0}; - cms_coap_free_context(coap_context); - coap_context = NULL; - coap_context = cms_coap_new_context(scode, &error_param); - tp_assert_true(coap_context == NULL); -} - -static void atest_cms_coap_new_context(void) -{ - atest_cms_coap_new_context_fail(); - atest_cms_coap_new_context_success(); -} - -static void atest_cms_coap_free_context_success(void) -{ - cms_coap_free_context(coap_context); - coap_context = NULL; -} - -static void atest_cms_coap_free_context_fail(void) -{ - cms_coap_free_context(NULL); //非法输入 -} - -static void atest_cms_coap_free_context(void) -{ - atest_cms_coap_free_context_fail(); - atest_cms_coap_free_context_success(); -} - -static void atest_cms_coap_create_session(void) -{ - int rc = cms_coap_create_session(NULL); - tp_assert_true(rc != CMS_ERROR_SUCCESS); - if (coap_context == NULL) - atest_cms_coap_new_context_success(); - rc = cms_coap_create_session(coap_context); - tp_assert_true(rc == CMS_ERROR_SUCCESS); -} - -static void atest_cms_coap_release_session(void) -{ - int rc = cms_coap_release_session(NULL); - tp_assert_true(rc != CMS_ERROR_SUCCESS); - if (coap_context == NULL) - atest_cms_coap_create_session(); - rc = cms_coap_release_session(coap_context); - tp_assert_true(rc == CMS_ERROR_SUCCESS); -} - -static void atest_cms_coap_register_response_handler(void) -{ - int rc; - rc = cms_coap_register_response_handler(NULL, cms_coap_response); - tp_assert_true(rc != CMS_ERROR_SUCCESS); - if (coap_context == NULL) - atest_cms_coap_new_context_success(); - rc = cms_coap_register_response_handler(coap_context, NULL); - tp_assert_true(rc != CMS_ERROR_SUCCESS); - rc = cms_coap_register_response_handler(coap_context, cms_coap_response); - tp_assert_true(rc == CMS_ERROR_SUCCESS); -} - -static void atest_cms_coap_register_event_handler(void) -{ - int rc; - rc = cms_coap_register_event_handler(NULL, cms_coap_event); - tp_assert_true(rc != CMS_ERROR_SUCCESS); - if (coap_context == NULL) - atest_cms_coap_new_context_success(); - rc = cms_coap_register_event_handler(coap_context, NULL); - tp_assert_true(rc != CMS_ERROR_SUCCESS); - rc = cms_coap_register_event_handler(coap_context, cms_coap_event); - tp_assert_true(rc == CMS_ERROR_SUCCESS); -} - -static void atest_cms_coap_new_single_optlist(cms_coap_option opt, int min_len, int max_len, const char *data) -{ - cms_coap_optlist_t *optlist; - - optlist = cms_coap_new_optlist(opt, min_len, (uint8_t *)data); - tp_assert_true(optlist != NULL); - cms_coap_delete_optlist(&optlist); - tp_assert_true(optlist == NULL); - - if (min_len != max_len) - { - optlist = cms_coap_new_optlist(opt, max_len, (uint8_t *)data); - tp_assert_true(optlist != NULL); - cms_coap_delete_optlist(&optlist); - tp_assert_true(optlist == NULL); - } - - if (min_len) - { - optlist = cms_coap_new_optlist(opt, min_len - 1, (uint8_t *)data); - tp_assert_true(optlist == NULL); - } - optlist = cms_coap_new_optlist(opt, max_len + 1, (uint8_t *)data); - tp_assert_true(optlist == NULL); -} - -static void atest_cms_coap_insert_single_optlist(cms_coap_option opt, int min_len, int max_len, const char *data) -{ - int rc; - cms_coap_optlist_t *head = cms_coap_new_optlist(coap_option_if_match, 0, NULL); - tp_assert_true(head != NULL); - - rc = cms_coap_insert_optlist(head, opt, min_len, (uint8_t *)data); - tp_assert_true(rc == CMS_ERROR_SUCCESS); - - if (min_len != max_len) - { - rc = cms_coap_insert_optlist(head, opt, max_len, (uint8_t *)data); - tp_assert_true(rc == CMS_ERROR_SUCCESS); - } - - if (min_len) - { - rc = cms_coap_insert_optlist(head, opt, min_len - 1, (uint8_t *)data); - tp_assert_true(rc != CMS_ERROR_SUCCESS); - } - - if (max_len) - { - rc = cms_coap_insert_optlist(head, opt, max_len + 1, (uint8_t *)data); - tp_assert_true(rc != CMS_ERROR_SUCCESS); - } - cms_coap_delete_optlist(&head); -} - -static void atest_cms_coap_new_optlist(void) -{ - atest_cms_coap_new_single_optlist(coap_option_if_match, 0, 8, block_file); - atest_cms_coap_new_single_optlist(coap_option_uri_host, 1, 255, block_file); - atest_cms_coap_new_single_optlist(coap_option_etag, 1, 8, block_file); - atest_cms_coap_new_single_optlist(coap_option_if_none_match, 0, 0, block_file); - atest_cms_coap_new_single_optlist(coap_option_observe, 0, 3, block_file); - atest_cms_coap_new_single_optlist(coap_option_uri_port, 0, 2, block_file); - atest_cms_coap_new_single_optlist(coap_option_location_path, 0, 255, block_file); - atest_cms_coap_new_single_optlist(coap_option_uri_path, 0, 255, block_file); - atest_cms_coap_new_single_optlist(coap_option_content_type, 0, 2, block_file); - atest_cms_coap_new_single_optlist(coap_option_uri_query, 1, 255, block_file); - atest_cms_coap_new_single_optlist(coap_option_accept, 0, 2, block_file); - atest_cms_coap_new_single_optlist(coap_option_location_query, 0, 255, block_file); - atest_cms_coap_new_single_optlist(coap_option_block2, 0, 3, block_file); - atest_cms_coap_new_single_optlist(coap_option_block1, 0, 3, block_file); - atest_cms_coap_new_single_optlist(coap_option_size2, 0, 4, block_file); - atest_cms_coap_new_single_optlist(coap_option_proxy_uri, 1, 1034, block_file); - atest_cms_coap_new_single_optlist(coap_option_proxy_scheme, 1, 255, block_file); - atest_cms_coap_new_single_optlist(coap_option_size1, 0, 4, block_file); -} - -static void atest_cms_coap_insert_optlist(void) -{ - atest_cms_coap_insert_single_optlist(coap_option_if_match, 0, 8, block_file); - atest_cms_coap_insert_single_optlist(coap_option_uri_host, 1, 255, block_file); - atest_cms_coap_insert_single_optlist(coap_option_etag, 1, 8, block_file); - atest_cms_coap_insert_single_optlist(coap_option_if_none_match, 0, 0, block_file); - atest_cms_coap_insert_single_optlist(coap_option_observe, 0, 3, block_file); - atest_cms_coap_insert_single_optlist(coap_option_uri_port, 0, 2, block_file); - atest_cms_coap_insert_single_optlist(coap_option_location_path, 0, 255, block_file); - atest_cms_coap_insert_single_optlist(coap_option_uri_path, 0, 255, block_file); - atest_cms_coap_insert_single_optlist(coap_option_content_type, 0, 2, block_file); - atest_cms_coap_insert_single_optlist(coap_option_uri_query, 1, 255, block_file); - atest_cms_coap_insert_single_optlist(coap_option_accept, 0, 2, block_file); - atest_cms_coap_insert_single_optlist(coap_option_location_query, 0, 255, block_file); - atest_cms_coap_insert_single_optlist(coap_option_block2, 0, 3, block_file); - atest_cms_coap_insert_single_optlist(coap_option_block1, 0, 3, block_file); - atest_cms_coap_insert_single_optlist(coap_option_size2, 0, 4, block_file); - atest_cms_coap_insert_single_optlist(coap_option_proxy_uri, 1, 1034, block_file); - atest_cms_coap_insert_single_optlist(coap_option_proxy_scheme, 1, 255, block_file); - atest_cms_coap_insert_single_optlist(coap_option_size1, 0, 4, block_file); -} - -#define CMS_COAP_NEW(x, l) \ - do \ - { \ - coap_optlist = cms_coap_new_optlist(x, strlen(#x) > l ? l : strlen(#x), (uint8_t *)#x); \ - tp_assert_true(coap_optlist != NULL); \ - } while (0) - -#define CMS_COAP_INSERT(x, l) \ - do \ - { \ - rc = cms_coap_insert_optlist(coap_optlist, x, strlen(#x) > l ? l : strlen(#x), (uint8_t *)#x); \ - tp_assert_true(rc == CMS_ERROR_SUCCESS); \ - } while (0) - -static void atest_cms_coap_insert_optlist_for_pdu(void) -{ - int rc; - - cms_coap_delete_optlist(&coap_optlist); - tp_assert_true(coap_optlist == NULL); - - CMS_COAP_NEW(coap_option_if_match, 8); - CMS_COAP_INSERT(coap_option_uri_host, 255); - CMS_COAP_INSERT(coap_option_etag, 8); - CMS_COAP_INSERT(coap_option_if_none_match, 0); - CMS_COAP_INSERT(coap_option_observe, 3); - CMS_COAP_INSERT(coap_option_uri_port, 2); - CMS_COAP_INSERT(coap_option_location_path, 255); - CMS_COAP_INSERT(coap_option_uri_path, 255); - CMS_COAP_INSERT(coap_option_content_type, 2); - CMS_COAP_INSERT(coap_option_uri_query, 255); - CMS_COAP_INSERT(coap_option_accept, 2); - CMS_COAP_INSERT(coap_option_location_query, 255); - CMS_COAP_INSERT(coap_option_block2, 3); - CMS_COAP_INSERT(coap_option_block1, 3); - CMS_COAP_INSERT(coap_option_size2, 4); - CMS_COAP_INSERT(coap_option_proxy_uri, 1034); - CMS_COAP_INSERT(coap_option_proxy_scheme, 255); - CMS_COAP_INSERT(coap_option_size1, 4); -} - -static void atest_cms_coap_delete_optlist(void) -{ - cms_coap_delete_optlist(&coap_optlist); - tp_assert_true(coap_optlist == NULL); -} - -static void atest_cms_coap_new_pdu(void) -{ - uint8_t data[] = "this is cms coap!"; - cms_coap_delete_pdu(&coap_pdu); - if (coap_context == NULL) - atest_cms_coap_new_context_success(); - if (coap_optlist == NULL) - { - atest_cms_coap_insert_optlist_for_pdu(); - } - coap_pdu = cms_coap_new_pdu(coap_context, - coap_message_confirmable, - coap_request_code_post, - &coap_optlist, - data, - strlen((char *)data)); - tp_assert_true(coap_pdu != NULL); - atest_cms_coap_delete_optlist(); -} - -static void atest_cms_coap_delete_pdu(void) -{ - cms_coap_delete_pdu(&coap_pdu); - tp_assert_true(coap_pdu == NULL); -} - -static void atest_cms_coap_send(void) -{ - if (coap_context == NULL || cms_coap_get_state(coap_context) != cms_con_state_connect) - atest_cms_coap_create_session(); - if (coap_pdu == NULL) - atest_cms_coap_new_pdu(); - int rc = cms_coap_send(coap_context, &coap_pdu); - tp_assert_true(rc == CMS_ERROR_SUCCESS && coap_pdu == NULL); -} - -static int atest_cms_coap_io_process_single_time(void) -{ - if (coap_context == NULL || cms_coap_get_state(coap_context) != cms_con_state_connect) - atest_cms_coap_create_session(); - if (coap_context && cms_coap_get_state(coap_context) == cms_con_state_connect) - { - return cms_coap_io_process(coap_context); - } - return CMS_ERROR_GENERIC_ERROR; -} - -static void atest_cms_coap_io_process(void) -{ - tp_assert_true(atest_cms_coap_io_process_single_time() == CMS_ERROR_SUCCESS); -} - -static void cms_coap_task_handle(void *param) -{ - printf("start coap task.\r\n"); - atest_cms_coap_io_process(); - while (coap_context != NULL || cms_coap_get_state(coap_context) == cms_con_state_connect) - { - os_task_msleep(10); - int rc = cms_coap_io_process(coap_context); - if (CMS_ERROR_SUCCESS != rc) - { - printf("coap io process error %d.\r\n", rc); - } - } - printf("stop coap task.\r\n"); - coap_task = NULL; -} - -static void atest_cms_coap_io_process_start(void) -{ - if (coap_task != NULL) - { - return; - } - coap_task = os_task_create(NULL, NULL, 8192, "cms coap", cms_coap_task_handle, NULL, OS_TASK_PRIORITY_MAX / 2); - OS_ASSERT(coap_task); - os_task_startup(coap_task); -} - -static void atest_cms_coap_io_process_stop(void) -{ - if (coap_task == NULL) - { - return; - } - os_task_destroy(coap_task); - printf("stop coap task.\r\n"); - coap_task = NULL; - return; -} - -static void atest_cms_coap_get_state(void) -{ - if (cms_coap_get_state(coap_context) == cms_con_state_connect) - printf("%d is connected\r\n", scode); - else - printf("%d is not connected\r\n", scode); -} - -//场景测试 -static void atest_cms_coap_operation_func(cms_coap_message_type type, cms_coap_method_code code, const char *body) -{ - cms_coap_optlist_t *optlist = cms_coap_new_optlist(coap_option_uri_path, strlen(uri_path), (uint8_t *)uri_path); - tp_assert_true(optlist != NULL); - size_t body_len = 0; - int rc; - if (body != NULL) - body_len = strlen(body); - cms_coap_pdu_t *pdu = cms_coap_new_pdu(coap_context, type, code, &optlist, (uint8_t *)body, body_len); - tp_assert_true(pdu != NULL); - rc = cms_coap_send(coap_context, &pdu); - tp_assert_true(rc == CMS_ERROR_SUCCESS); - os_task_msleep(COAP_TIME_OUT); - atest_cms_coap_io_process(); - cms_coap_delete_optlist(&optlist); - cms_coap_delete_pdu(&pdu); -} - -static void atest_cms_coap_operation_post(void) -{ - if (coap_context == NULL || cms_coap_get_state(coap_context) != cms_con_state_connect) - atest_cms_coap_create_session(); - atest_cms_coap_register_response_handler(); - atest_cms_coap_operation_func(coap_message_confirmable, coap_request_code_post, "put confirmable message"); - atest_cms_coap_operation_func(coap_message_non_confirmable, coap_request_code_post, "put non confirmable message"); -} - -static void atest_cms_coap_operation_put(void) -{ - if (coap_context == NULL || cms_coap_get_state(coap_context) != cms_con_state_connect) - atest_cms_coap_create_session(); - atest_cms_coap_register_response_handler(); - atest_cms_coap_operation_func(coap_message_confirmable, coap_request_code_put, "put confirmable message"); - atest_cms_coap_operation_func(coap_message_non_confirmable, coap_request_code_put, "put non confirmable message"); -} - -static void atest_cms_coap_operation_get(void) -{ - if (coap_context == NULL || cms_coap_get_state(coap_context) != cms_con_state_connect) - atest_cms_coap_create_session(); - atest_cms_coap_register_response_handler(); - atest_cms_coap_operation_func(coap_message_confirmable, coap_request_code_get, NULL); - atest_cms_coap_operation_func(coap_message_non_confirmable, coap_request_code_get, NULL); -} - -static void atest_cms_coap_operation_del(void) -{ - if (coap_context == NULL || cms_coap_get_state(coap_context) != cms_con_state_connect) - atest_cms_coap_create_session(); - atest_cms_coap_register_response_handler(); - - atest_cms_coap_operation_func(coap_message_confirmable, coap_request_code_delete, NULL); - atest_cms_coap_operation_func(coap_message_non_confirmable, coap_request_code_delete, NULL); -} - -//块传输 -static uint16_t atest_cms_coap_coap_log_2(uint16_t value) -{ - uint16_t result = 0; - do - { - value = value >> 1; - result++; - } while (value); - - return result ? result - 1 : result; -} - -static uint32_t atest_cms_coap_structure_block(int block_num, char more_flag, int block_size) -{ - OS_ASSERT(block_num < 0x1000000); - uint32_t block = block_num << 4; - if (more_flag) - { - block |= 0x8; - } - block |= (atest_cms_coap_coap_log_2(block_size / 16) & 0x7); - return block; -} - -struct cms_coap_block -{ - const char *uri_path; //资源名字 - uint8_t *block_buff; // block接收缓存 - size_t totol_length; //缓存最大长度 - uint32_t sent_block_num; //已发送block序号 - uint16_t block_size; //块大小 - uint8_t more_flag; //是否还有更多的块 - void *sem; //信号量 -}; -static struct cms_coap_block coap_block = {NULL, NULL, 0, 0, 0, 0, NULL}; - -static void destroy_coap_block(struct cms_coap_block *coap_block) -{ - if (coap_block->block_buff) - free(coap_block->block_buff); - if (coap_block->sem) - cms_sem_destroy(coap_block->sem); - memset(coap_block, 0, sizeof(struct cms_coap_block)); -} - -static cms_coap_method_code atest_cms_coap_block_post_handle(void *coap_context, - const cms_coap_pdu_t *sent, - const cms_coap_pdu_t *received, - uint32_t mid) -{ - printf("%d send pdu:\r\n", scode); - cms_coap_show_pdu(sent); - printf("recv pdu:\r\n"); - cms_coap_show_pdu(received); - OS_ASSERT(coap_block.sem); - cms_sem_post(coap_block.sem); - return coap_empty_code; -} - -static void atest_cms_coap_block_post(void) -{ - int rc; - if (coap_context == NULL || cms_coap_get_state(coap_context) != cms_con_state_connect) - atest_cms_coap_create_session(); - destroy_coap_block(&coap_block); - coap_block.uri_path = block_uri_path; - coap_block.block_size = block_size; - coap_block.sem = cms_sem_create(BLOCK_RES_NAME, 0, 1); - if (coap_block.sem == NULL) - { - LOG_E(LOG_TAG, "out of memory"); - return; - } - rc = cms_coap_register_response_handler(coap_context, atest_cms_coap_block_post_handle); - tp_assert_true(rc == CMS_ERROR_SUCCESS); - int block_num = 0; - atest_cms_coap_io_process_start(); //开始io调度 - while ((block_num * block_size) < block_file_size) - { - uint8_t buff[4]; - cms_coap_optlist_t *optlist = - cms_coap_new_optlist(coap_option_uri_path, strlen(block_uri_path), (uint8_t *)block_uri_path); - tp_assert_true(optlist != NULL); // uri - int more_flag = 0; - int single_len = block_file_size - (block_num * block_size); - if (single_len > block_size) - { - single_len = block_size; - more_flag = 1; - } - uint32_t block1 = atest_cms_coap_structure_block(block_num, more_flag, block_size); - buff[0] = (block1 >> 16) & 0xFF; - buff[1] = (block1 >> 8) & 0xFF; - buff[2] = block1 & 0xFF; - rc = cms_coap_insert_optlist(optlist, coap_option_block1, 3, buff); - tp_assert_true(rc == CMS_ERROR_SUCCESS); - buff[0] = (block_file_size >> 24) & 0xFF; - buff[1] = (block_file_size >> 16) & 0xFF; - buff[2] = (block_file_size >> 8) & 0xFF; - buff[3] = block_file_size & 0xFF; - rc = cms_coap_insert_optlist(optlist, coap_option_size1, 4, buff); - tp_assert_true(rc == CMS_ERROR_SUCCESS); - cms_coap_pdu_t *pdu = cms_coap_new_pdu(coap_context, - coap_message_confirmable, - coap_request_code_post, - &optlist, - (uint8_t *)&block_file[block_num * block_size], - single_len); - tp_assert_true(pdu != NULL); - rc = cms_coap_send(coap_context, &pdu); - tp_assert_true(rc == CMS_ERROR_SUCCESS); - cms_coap_delete_optlist(&optlist); - cms_coap_delete_pdu(&pdu); - // os_task_msleep(100); - if (cms_sem_wait(coap_block.sem, COAP_TIME_OUT * 10)) - { - LOG_E(LOG_TAG, "block %d post error", block_num); - break; - } - block_num++; - } - atest_cms_coap_io_process_stop(); - os_task_msleep(500); - destroy_coap_block(&coap_block); -} - -static cms_coap_method_code atest_cms_coap_block_get_handle(void *coap_context, - const cms_coap_pdu_t *sent, - const cms_coap_pdu_t *received, - uint32_t mid) -{ - OS_ASSERT(received != NULL); - cms_coap_optlist_t *optlist = NULL; - int block_num = 0; - char recv_block_more = 0; - int recv_block_size = 0; - int total_size = 0; - int rc = cms_coap_deserialization_option_list(received->option_data, received->option_len, &optlist); - if (rc != CMS_ERROR_SUCCESS || optlist == NULL) - { - LOG_E(LOG_TAG, "block get error!"); - cms_coap_show_pdu(received); - return coap_empty_code; - } - cms_coap_optlist_t *node = optlist; - while (node) - { - if (node->number == coap_option_uri_path) - { - if (memcmp(node->data, coap_block.uri_path, node->length)) - { - LOG_W(LOG_TAG, "resources is not %s", coap_block.uri_path); - break; - } - } - if (node->number == coap_option_block2) - { - int block_len = node->length; - int block2 = 0; - int index = 0; - while (block_len--) - { - block2 = (block2 << 8); - block2 += node->data[index++]; - } - block_num = (block2 >> 4); - if (block2 & 0x08) - recv_block_more = 1; - recv_block_size = 1 << ((block2 & 0x07) + 4); - } - if (node->number == coap_option_size2) - { - int node_len = node->length; - int size2 = 0; - int index = 0; - while (node_len--) - { - size2 = (size2 << 8); - size2 += node->data[index++]; - } - total_size = size2; - } - node = node->next; - } - cms_coap_delete_optlist(&optlist); - if (!recv_block_size || !total_size) - { - goto error; //报文异常,退出处理 - } - if (!received->body_len || received->body_data == NULL) - { - goto error; - } - if (coap_block.totol_length != total_size) - { - if (block_num) - { - LOG_E(LOG_TAG, "The total size has been modified, please try again"); - goto error; - } - coap_block.block_buff = realloc(coap_block.block_buff, total_size); - if (coap_block.block_buff == NULL) - { - LOG_E(LOG_TAG, "out of memory"); - return coap_empty_code; - } - memset(coap_block.block_buff, 0, total_size); - coap_block.totol_length = total_size; - } - if (block_num * block_size + received->body_len > coap_block.totol_length || block_num != coap_block.sent_block_num) - { - LOG_E(LOG_TAG, "block number(%d) error", block_num); - goto error; - } - LOG_I(LOG_TAG, "recv block %d", block_num); - memcpy(&coap_block.block_buff[block_num * block_size], received->body_data, received->body_len); - coap_block.more_flag = recv_block_more; - OS_ASSERT(coap_block.sem); - cms_sem_post(coap_block.sem); - return coap_empty_code; -error: - LOG_E(LOG_TAG, "Not expected message", mid); - cms_coap_show_pdu(received); - return coap_empty_code; -} -static int atest_cms_coap_single_block_get(struct cms_coap_block coap_block) -{ - uint8_t buff[4]; - uint32_t block2; - cms_coap_pdu_t *pdu = NULL; - cms_coap_optlist_t *optlist = NULL; - int rc; - optlist = cms_coap_new_optlist(coap_option_uri_path, strlen(coap_block.uri_path), (uint8_t *)coap_block.uri_path); - if (optlist == NULL) - return -1; - block2 = atest_cms_coap_structure_block(coap_block.sent_block_num, 0, coap_block.block_size); - buff[0] = (block2 >> 16) & 0xFF; - buff[1] = (block2 >> 8) & 0xFF; - buff[2] = block2 & 0xFF; - rc = cms_coap_insert_optlist(optlist, coap_option_block2, 3, buff); - if (rc != CMS_ERROR_SUCCESS) - { - goto exit; - } - pdu = cms_coap_new_pdu(coap_context, coap_message_confirmable, coap_request_code_get, &optlist, NULL, 0); - if (pdu == NULL) - { - rc = -1; - goto exit; - } - rc = cms_coap_send(coap_context, &pdu); -exit: - cms_coap_delete_optlist(&optlist); - cms_coap_delete_pdu(&pdu); - return rc; -} - -static void atest_cms_coap_block_get(void) -{ - int rc; - if (coap_context == NULL || cms_coap_get_state(coap_context) != cms_con_state_connect) - atest_cms_coap_create_session(); - destroy_coap_block(&coap_block); - coap_block.uri_path = block_uri_path; - coap_block.block_size = block_size; - coap_block.sem = cms_sem_create(BLOCK_RES_NAME, 0, 1); - if (coap_block.sem == NULL) - { - LOG_E(LOG_TAG, "out of memory"); - return; - } - rc = cms_coap_register_response_handler(coap_context, atest_cms_coap_block_get_handle); - tp_assert_true(rc == CMS_ERROR_SUCCESS); - atest_cms_coap_io_process_start(); //开始io调度 - do - { - rc = atest_cms_coap_single_block_get(coap_block); - if (rc != CMS_ERROR_SUCCESS) - { - tp_assert_true(0); - LOG_E(LOG_TAG, "block sent error"); - break; - } - rc = cms_sem_wait(coap_block.sem, COAP_TIME_OUT * 10); - if (rc) - { - tp_assert_true(0); - LOG_E(LOG_TAG, "time out(%d s)", COAP_TIME_OUT / 100); - break; - } - ++coap_block.sent_block_num; - if (coap_block.sent_block_num * coap_block.block_size >= coap_block.totol_length) - { - tp_assert_true(1); - LOG_I(LOG_TAG, "block transfer completed"); - break; - } - } while (coap_block.more_flag); - if (rc == CMS_ERROR_SUCCESS) - { - LOG_I(LOG_TAG, "bolck recv finish"); - LOG_HEX(LOG_TAG, 16, coap_block.block_buff, coap_block.totol_length); - } - atest_cms_coap_io_process_stop(); - os_task_msleep(500); - destroy_coap_block(&coap_block); -} - -static void atest_cms_coap_free_all(void) -{ - atest_cms_coap_free_context_success(); - cms_coap_delete_optlist(&coap_optlist); - tp_assert_true(coap_optlist == NULL); - cms_coap_delete_pdu(&coap_pdu); - tp_assert_true(coap_pdu == NULL); - atest_cms_coap_io_process_stop(); -} - -ATEST_TC_EXPORT(cms.coap.context.new, atest_cms_coap_new_context, NULL, NULL, TC_PRIORITY_LOW); -ATEST_TC_EXPORT(cms.coap.context.free, atest_cms_coap_free_context, NULL, NULL, TC_PRIORITY_LOW); -ATEST_TC_EXPORT(cms.coap.creat.session, atest_cms_coap_create_session, NULL, NULL, TC_PRIORITY_LOW); -ATEST_TC_EXPORT(cms.coap.release.session, atest_cms_coap_release_session, NULL, NULL, TC_PRIORITY_LOW); -ATEST_TC_EXPORT(cms.coap.reg.resp, atest_cms_coap_register_response_handler, NULL, NULL, TC_PRIORITY_LOW); -ATEST_TC_EXPORT(cms.coap.reg.event, atest_cms_coap_register_event_handler, NULL, NULL, TC_PRIORITY_LOW); -ATEST_TC_EXPORT(cms.coap.option.new, atest_cms_coap_new_optlist, NULL, NULL, TC_PRIORITY_LOW); -ATEST_TC_EXPORT(cms.coap.option.insert, atest_cms_coap_insert_optlist, NULL, NULL, TC_PRIORITY_LOW); -ATEST_TC_EXPORT(cms.coap.option.delete, atest_cms_coap_delete_optlist, NULL, NULL, TC_PRIORITY_LOW); -ATEST_TC_EXPORT(cms.coap.pdu.new, atest_cms_coap_new_pdu, NULL, NULL, TC_PRIORITY_LOW); -ATEST_TC_EXPORT(cms.coap.pdu.send, atest_cms_coap_send, NULL, NULL, TC_PRIORITY_LOW); -ATEST_TC_EXPORT(cms.coap.pdu.delete, atest_cms_coap_delete_pdu, NULL, NULL, TC_PRIORITY_LOW); -ATEST_TC_EXPORT(cms.coap.io.single, atest_cms_coap_io_process, NULL, NULL, TC_PRIORITY_LOW); -ATEST_TC_EXPORT(cms.coap.io.start, atest_cms_coap_io_process_start, NULL, NULL, TC_PRIORITY_LOW); -ATEST_TC_EXPORT(cms.coap.io.stop, atest_cms_coap_io_process_stop, NULL, NULL, TC_PRIORITY_LOW); -ATEST_TC_EXPORT(cms.coap.state, atest_cms_coap_get_state, NULL, NULL, TC_PRIORITY_LOW); -ATEST_TC_EXPORT(cms.coap.operation.post.res, atest_cms_coap_operation_post, NULL, NULL, TC_PRIORITY_LOW); -ATEST_TC_EXPORT(cms.coap.operation.put.res, atest_cms_coap_operation_put, NULL, NULL, TC_PRIORITY_LOW); -ATEST_TC_EXPORT(cms.coap.operation.get.res, atest_cms_coap_operation_get, NULL, NULL, TC_PRIORITY_LOW); -ATEST_TC_EXPORT(cms.coap.operation.del.res, atest_cms_coap_operation_del, NULL, NULL, TC_PRIORITY_LOW); -ATEST_TC_EXPORT(cms.coap.operation.block.post, atest_cms_coap_block_post, NULL, NULL, TC_PRIORITY_LOW); -ATEST_TC_EXPORT(cms.coap.operation.block.get, atest_cms_coap_block_get, NULL, NULL, TC_PRIORITY_LOW); -ATEST_TC_EXPORT(cms.coap.free, atest_cms_coap_free_all, NULL, NULL, TC_PRIORITY_LOW); - -#endif diff --git a/components/cms/port/oneos/atest/mqtt_atest.c b/components/cms/port/oneos/atest/mqtt_atest.c deleted file mode 100644 index c48456d1bdd594bf253847cc1ffc7fd809154ff8..0000000000000000000000000000000000000000 --- a/components/cms/port/oneos/atest/mqtt_atest.c +++ /dev/null @@ -1,159 +0,0 @@ -/** - *********************************************************************************************************************** - * Copyright (c) 2021, China Mobile Communications Group Co.,Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - * - * @file mqtt_atest.c - * - * @brief This is mqtt test file based atest. - * - * @revision - * Date Author Notes - * 2020-10-13 OneOS Team First Version - *********************************************************************************************************************** - */ -#include "oneos_config.h" -#if defined(CMS_CONNECT_MQTT) -#include "cms_con_mqtt.h" -#include -#include -#include -#include -#include -#include -#include - -static void *mqtt_handle = NULL; -static int scode = 300; -char topic_str[] = "svr/300/req"; - -#define MQTT_ATEST_BUFF_DEEP 1000 -static void atest_cms_mqtt_init(void) -{ - if (mqtt_handle != NULL) - return; - cms_mqtt_param param = {5000, MQTT_ATEST_BUFF_DEEP, MQTT_ATEST_BUFF_DEEP * 2}; - mqtt_handle = cms_mqtt_init(scode, ¶m); - tp_assert_true(mqtt_handle != NULL); -} - -static void atest_cms_mqtt_deinit(void) -{ - cms_mqtt_deinit(mqtt_handle); - mqtt_handle = NULL; -} - -static void atest_cms_mqtt_connect(void) -{ - if (cms_mqtt_get_state(mqtt_handle) == cms_con_state_connect) - return; - - cms_mqtt_connect_param param; - memset(¶m, 0, sizeof(cms_mqtt_connect_param)); - param.client_id = "12345678"; - param.username = "oneos"; - param.password = "123456"; - param.keep_alive_s = 300; - int ret = cms_mqtt_connect(mqtt_handle, ¶m); - tp_assert_true(ret == 0); - tp_assert_true(cms_mqtt_get_state(mqtt_handle) == cms_con_state_connect); -} - -static void atest_cms_mqtt_disconnect(void) -{ - tp_assert_true(cms_mqtt_get_state(mqtt_handle) == cms_con_state_connect); - cms_mqtt_disconnect(mqtt_handle); - tp_assert_true(cms_mqtt_get_state(mqtt_handle) == cms_con_state_disconnect); -} - -static void message_handler(void *handle, const char *topic_name, void *payload, size_t payload_len) -{ - printf("%s\r\n", __func__); - printf("topic:%s\r\n", topic_name); - uint8_t *buf = (uint8_t *)payload; - for (int i = 0; i < payload_len; i++) - { - printf("%02X ", buf[i]); - } - printf("\r\n"); -} - -static void atest_cms_mqtt_subscribe(void) -{ - int rc = cms_mqtt_subscribe(mqtt_handle, topic_str, mqtt_qos1, message_handler); - tp_assert_true(rc == CMS_ERROR_SUCCESS); -} - -static void atest_cms_mqtt_unsubscribe(void) -{ - int rc = cms_mqtt_unsubscribe(mqtt_handle, topic_str); - tp_assert_true(rc == CMS_ERROR_SUCCESS); -} - -static char long_buf[MQTT_ATEST_BUFF_DEEP] = {0}; -static void atest_cms_mqtt_publish(void) -{ - cms_mqtt_message mqtt_message; - - memset(long_buf, '0', MQTT_ATEST_BUFF_DEEP - 100); - - mqtt_message.qos = mqtt_qos0; - mqtt_message.payload = (void *)long_buf; - mqtt_message.payloadlen = MQTT_ATEST_BUFF_DEEP - 100; - int rc = cms_mqtt_publish(mqtt_handle, topic_str, &mqtt_message); - tp_assert_true(rc == CMS_ERROR_SUCCESS); - - memset(long_buf, '1', MQTT_ATEST_BUFF_DEEP - 100); - mqtt_message.qos = mqtt_qos1; - mqtt_message.payload = (void *)long_buf; - mqtt_message.payloadlen = MQTT_ATEST_BUFF_DEEP - 100; - rc = cms_mqtt_publish(mqtt_handle, topic_str, &mqtt_message); - tp_assert_true(rc == CMS_ERROR_SUCCESS); -} - -static void atest_cms_mqtt_pingreq(void) -{ - int rc = cms_mqtt_ping_request(mqtt_handle); - tp_assert_true(rc == CMS_ERROR_SUCCESS); -} - -static void atest_cms_mqtt_get_state(void) -{ - int rc = cms_mqtt_get_state(mqtt_handle); - if (rc == cms_con_state_connect) - printf("mqtt is connected!\r\n"); - else - printf("mqtt is not connected!\r\n"); -} - -static void cms_mqtt_all(void) -{ - ATEST_UNIT_RUN(atest_cms_mqtt_init); - ATEST_UNIT_RUN(atest_cms_mqtt_connect); - ATEST_UNIT_RUN(atest_cms_mqtt_subscribe); - ATEST_UNIT_RUN(atest_cms_mqtt_publish); - ATEST_UNIT_RUN(atest_cms_mqtt_pingreq); - ATEST_UNIT_RUN(atest_cms_mqtt_unsubscribe); - ATEST_UNIT_RUN(atest_cms_mqtt_disconnect); - ATEST_UNIT_RUN(atest_cms_mqtt_deinit); -} - -ATEST_TC_EXPORT(cms.mqtt.total, cms_mqtt_all, NULL, NULL, TC_PRIORITY_LOW); -ATEST_TC_EXPORT(cms.mqtt.init, atest_cms_mqtt_init, NULL, NULL, TC_PRIORITY_LOW); -ATEST_TC_EXPORT(cms.mqtt.deinit, atest_cms_mqtt_deinit, NULL, NULL, TC_PRIORITY_LOW); -ATEST_TC_EXPORT(cms.mqtt.connect, atest_cms_mqtt_connect, NULL, NULL, TC_PRIORITY_LOW); -ATEST_TC_EXPORT(cms.mqtt.disconnect, atest_cms_mqtt_disconnect, NULL, NULL, TC_PRIORITY_LOW); -ATEST_TC_EXPORT(cms.mqtt.subscribe, atest_cms_mqtt_subscribe, NULL, NULL, TC_PRIORITY_LOW); -ATEST_TC_EXPORT(cms.mqtt.unsubscribe, atest_cms_mqtt_unsubscribe, NULL, NULL, TC_PRIORITY_LOW); -ATEST_TC_EXPORT(cms.mqtt.publish, atest_cms_mqtt_publish, NULL, NULL, TC_PRIORITY_LOW); -ATEST_TC_EXPORT(cms.mqtt.ping, atest_cms_mqtt_pingreq, NULL, NULL, TC_PRIORITY_LOW); -ATEST_TC_EXPORT(cms.mqtt.state, atest_cms_mqtt_get_state, NULL, NULL, TC_PRIORITY_LOW); -#endif diff --git a/components/cms/port/oneos/atest/tcp_atest.c b/components/cms/port/oneos/atest/tcp_atest.c deleted file mode 100644 index f11e25e5ff02aff8dd8a2818b5a8d9983dd77ac7..0000000000000000000000000000000000000000 --- a/components/cms/port/oneos/atest/tcp_atest.c +++ /dev/null @@ -1,157 +0,0 @@ -/** - *********************************************************************************************************************** - * Copyright (c) 2021, China Mobile Communications Group Co.,Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - * - * @file tcp_atest.c - * - * @brief This is tcp test file based atest. - * - * @revision - * Date Author Notes - * 2020-10-13 OneOS Team First Version - *********************************************************************************************************************** - */ -#include "oneos_config.h" -#if defined(CMS_CONNECT_MQTT) || defined(CMS_CONNECT_TCP) -#include "cms_con_tcp.h" -#include -#include -#include -#include -#include -#include -#include -#include - -static int scode = 301; -static void *tcp_handle = NULL; -static os_task_id recv_task = 0; -#define TCP_RX_MAX_LENGTH 5 - -static float get_time_s(void) -{ - return ((float)os_tick_get_value() / OS_TICK_PER_SECOND); -} - -static uint8_t recv_buff[TCP_RX_MAX_LENGTH]; -static int cms_tcp_recv_once(uint32_t timeout) -{ - int rc = cms_tcp_recv(tcp_handle, recv_buff, sizeof(recv_buff), timeout); - if (rc <= 0) - return rc; - printf("%s(time:%02f,len:%d)", __func__, get_time_s(), rc); - for (int i = 0; i < rc; i++) - { - if (i % 0x10 == 0) - printf("\r\n"); - printf("%02X ", recv_buff[i]); - } - printf("\r\n"); - return rc; -} -static void atest_cms_tcp_recv(void) -{ - int rc = cms_tcp_recv_once(10 * 1000); - tp_assert_true(rc > 0); -} - -static void atest_cms_tcp_recv_process(void *param) -{ - while (cms_tcp_get_state(tcp_handle) == cms_con_state_connect) - { - os_task_msleep(100); - cms_tcp_recv_once(1); - } - printf("exit tcp recv task!\r\n"); - recv_task = 0; -} - -static void atest_cms_tcp_recv_task(void) -{ - if (recv_task) - { - os_task_destroy(recv_task); - recv_task = 0; - return; - } - recv_task = os_task_create(NULL, NULL, 1024, "tcp_recv_test", atest_cms_tcp_recv_process, NULL, 22); - os_task_startup(recv_task); -} - -static void atest_cms_tcp_init(void) -{ - if (tcp_handle != NULL) - return; - tcp_handle = cms_tcp_init(scode, TCP_RX_MAX_LENGTH); - tp_assert_true(tcp_handle != NULL); -} - -static void atest_cms_tcp_deinit(void) -{ - if (tcp_handle == NULL) - return; - cms_tcp_deinit(tcp_handle); - tcp_handle = NULL; -} - -static void atest_cms_tcp_connect(void) -{ - int rc; - if (cms_tcp_get_state(tcp_handle) == cms_con_state_connect) - return; - rc = cms_tcp_connect(tcp_handle); - tp_assert_true(rc == CMS_ERROR_SUCCESS); - rc = cms_tcp_get_state(tcp_handle); - tp_assert_true(rc == cms_con_state_connect); -} - -static void atest_cms_tcp_disconnect(void) -{ - cms_tcp_disconnect(tcp_handle); - tp_assert_true(cms_tcp_get_state(tcp_handle) == cms_con_state_disconnect); -} - -static uint8_t buf[5] = {0x31, 0x32, 0x33, 0x34, 0x35}; -static void atest_cms_tcp_send(void) -{ - int rc = cms_tcp_send(tcp_handle, buf, sizeof(buf)); - tp_assert_true(rc == sizeof(buf)); -} - -static void atest_cms_mqtt_get_state(void) -{ - int rc = cms_tcp_get_state(tcp_handle); - if (rc == cms_con_state_connect) - printf("tcp is connected!\r\n"); - else - printf("tcp is not connected!\r\n"); -} - -static void cms_tcp_all(void) -{ - ATEST_UNIT_RUN(atest_cms_tcp_init); - ATEST_UNIT_RUN(atest_cms_tcp_connect); - ATEST_UNIT_RUN(atest_cms_tcp_send); - ATEST_UNIT_RUN(atest_cms_tcp_disconnect); - ATEST_UNIT_RUN(atest_cms_tcp_deinit); -} - -ATEST_TC_EXPORT(cms.tcp.total, cms_tcp_all, NULL, NULL, TC_PRIORITY_LOW); -ATEST_TC_EXPORT(cms.tcp.init, atest_cms_tcp_init, NULL, NULL, TC_PRIORITY_LOW); -ATEST_TC_EXPORT(cms.tcp.deinit, atest_cms_tcp_deinit, NULL, NULL, TC_PRIORITY_LOW); -ATEST_TC_EXPORT(cms.tcp.connect, atest_cms_tcp_connect, NULL, NULL, TC_PRIORITY_LOW); -ATEST_TC_EXPORT(cms.tcp.disconnect, atest_cms_tcp_disconnect, NULL, NULL, TC_PRIORITY_LOW); -ATEST_TC_EXPORT(cms.tcp.recv.once, atest_cms_tcp_recv, NULL, NULL, TC_PRIORITY_LOW); -ATEST_TC_EXPORT(cms.tcp.recv.task, atest_cms_tcp_recv_task, NULL, NULL, TC_PRIORITY_LOW); -ATEST_TC_EXPORT(cms.tcp.state, atest_cms_mqtt_get_state, NULL, NULL, TC_PRIORITY_LOW); -ATEST_TC_EXPORT(cms.tcp.send, atest_cms_tcp_send, NULL, NULL, TC_PRIORITY_LOW); -#endif diff --git a/components/cms/port/oneos/atest/udp_atest.c b/components/cms/port/oneos/atest/udp_atest.c deleted file mode 100644 index ba106ca3e3f2dfb08036f1ceb332ac17de3d07d9..0000000000000000000000000000000000000000 --- a/components/cms/port/oneos/atest/udp_atest.c +++ /dev/null @@ -1,131 +0,0 @@ -/** - *********************************************************************************************************************** - * Copyright (c) 2021, China Mobile Communications Group Co.,Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - * - * @file udp_atest.c - * - * @brief This is udp test file based atest. - * - * @revision - * Date Author Notes - * 2020-10-13 OneOS Team First Version - *********************************************************************************************************************** - */ -#include "oneos_config.h" -#if defined(CMS_CONNECT_COAP) || defined(CMS_CONNECT_UDP) -#include "cms_con_udp.h" -#include -#include -#include -#include -#include -#include -#include -#include - -static int scode = 303; -static void *udp_handle = NULL; -static os_task_id recv_task = 0; -#define UDP_RX_MAX_LENGTH 5 - -static float get_time_s(void) -{ - return ((float)os_tick_get_value() / OS_TICK_PER_SECOND); -} - -static uint8_t recv_buff[UDP_RX_MAX_LENGTH]; -static int cms_udp_recv_once(uint32_t timeout) -{ - int rc = cms_udp_recv(udp_handle, recv_buff, sizeof(recv_buff), timeout); - if (rc <= 0) - return rc; - printf("%s(time:%02f,len:%d)", __func__, get_time_s(), rc); - for (int i = 0; i < rc; i++) - { - if (i % 0x10 == 0) - printf("\r\n"); - printf("%02X ", recv_buff[i]); - } - printf("\r\n"); - return rc; -} - -static void atest_cms_udp_recv(void) -{ - int rc = cms_udp_recv_once(10 * 1000); - tp_assert_true(rc > 0); -} - -static void atest_cms_udp_recv_process(void *param) -{ - while (cms_udp_get_state(udp_handle) == cms_con_state_connect) - { - os_task_msleep(100); - cms_udp_recv_once(1); - } - printf("exit udp recv task!\r\n"); - recv_task = 0; -} - -static void atest_cms_udp_recv_task(void) -{ - if (recv_task) - { - os_task_destroy(recv_task); - recv_task = 0; - return; - } - recv_task = os_task_create(NULL, NULL, 1024, "udp_recv_test", atest_cms_udp_recv_process, NULL, 22); - os_task_startup(recv_task); -} - -static void atest_cms_udp_init(void) -{ - if (udp_handle != NULL) - return; - udp_handle = cms_udp_init(scode, UDP_RX_MAX_LENGTH); - tp_assert_true(udp_handle != NULL); -} - -static void atest_cms_udp_deinit(void) -{ - if (udp_handle == NULL) - return; - cms_udp_deinit(udp_handle); - udp_handle = NULL; -} - -static uint8_t buf[5] = {1, 2, 3, 4, 5}; -static void atest_cms_udp_send(void) -{ - // for (int i = 0; i < sizeof(buf); i++) - // { - // buf[i] = i % 10 + '0'; - // } - int rc = cms_udp_send(udp_handle, buf, sizeof(buf)); - tp_assert_true(rc == sizeof(buf)); -} - -static void cms_udp_all(void) -{ - ATEST_UNIT_RUN(atest_cms_udp_init); - ATEST_UNIT_RUN(atest_cms_udp_send); - ATEST_UNIT_RUN(atest_cms_udp_deinit); -} - -ATEST_TC_EXPORT(cms.udp.all, cms_udp_all, NULL, NULL, TC_PRIORITY_LOW); -ATEST_TC_EXPORT(cms.udp.init, atest_cms_udp_init, NULL, NULL, TC_PRIORITY_LOW); -ATEST_TC_EXPORT(cms.udp.deinit, atest_cms_udp_deinit, NULL, NULL, TC_PRIORITY_LOW); -ATEST_TC_EXPORT(cms.udp.send, atest_cms_udp_send, NULL, NULL, TC_PRIORITY_LOW); -ATEST_TC_EXPORT(cms.udp.recv.once, atest_cms_udp_recv, NULL, NULL, TC_PRIORITY_LOW); -ATEST_TC_EXPORT(cms.udp.recv.task, atest_cms_udp_recv_task, NULL, NULL, TC_PRIORITY_LOW); -#endif diff --git a/components/cms/port/oneos/cms_adapter.c b/components/cms/port/oneos/cms_adapter.c deleted file mode 100644 index 8d0c979caf6295e94269d1c4a779a163afdf6200..0000000000000000000000000000000000000000 --- a/components/cms/port/oneos/cms_adapter.c +++ /dev/null @@ -1,31 +0,0 @@ -/** - *********************************************************************************************************************** - * Copyright (c) 2021, China Mobile Communications Group Co.,Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - * - * @file cms_adapter.c - * - * @brief Interface related to OS. - * - * @revision - * Date Author Notes - * 2020-10-13 OneOS Team First Version - *********************************************************************************************************************** - */ -#include "cms_adapter.h" -#include - -void cms_safety_assert_process(void) -{ - os_irq_disable(); - while (1) - ; -} diff --git a/components/cms/port/oneos/cms_clock.c b/components/cms/port/oneos/cms_clock.c deleted file mode 100644 index 0ef11c8825ea603931bb53eadf083203e32a3d22..0000000000000000000000000000000000000000 --- a/components/cms/port/oneos/cms_clock.c +++ /dev/null @@ -1,48 +0,0 @@ -/** - *********************************************************************************************************************** - * Copyright (c) 2021, China Mobile Communications Group Co.,Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - * - * @file cms_adapter.c - * - * @brief Interface related to OS. - * - * @revision - * Date Author Notes - * 2020-10-13 OneOS Team First Version - *********************************************************************************************************************** - */ -#include "cms_clock.h" -#include - -size_t get_time_ms(void) -{ - size_t sys_ms; - if (OS_TICK_PER_SECOND < 1000) - sys_ms = os_tick_get_value() * (1000 / OS_TICK_PER_SECOND); - else - sys_ms = os_tick_get_value() / OS_TICK_PER_SECOND * 1000; - return sys_ms; -} -size_t get_sys_tick(void) -{ - return os_tick_get_value(); -} - -size_t get_tick_from_ms(size_t ms) -{ - return ms * OS_TICK_PER_SECOND / 1000; -} - -size_t get_ms_from_tick(size_t tick) -{ - return tick * 1000 / OS_TICK_PER_SECOND; -} diff --git a/components/cms/port/oneos/cms_memory.c b/components/cms/port/oneos/cms_memory.c deleted file mode 100644 index 66ab67406186434553aa8bfbd95661031e2eafef..0000000000000000000000000000000000000000 --- a/components/cms/port/oneos/cms_memory.c +++ /dev/null @@ -1,55 +0,0 @@ -/** - *********************************************************************************************************************** - * Copyright (c) 2021, China Mobile Communications Group Co.,Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - * - * @file cms_adapter.c - * - * @brief Interface related to OS. - * - * @revision - * Date Author Notes - * 2020-10-13 OneOS Team First Version - *********************************************************************************************************************** - */ -#include "cms_memory.h" -#include -#include - -void *cms_malloc(size_t size) -{ - return os_malloc(size); -} - -void *cms_calloc(size_t count, size_t size) -{ - return os_calloc(count, size); -} - -void *cms_realloc(void *ptr, size_t new_size) -{ - return os_realloc(ptr, new_size); -} - -void cms_free(void *ptr) -{ - os_free(ptr); -} - -void cms_memcpy(void *dst, const void *src, size_t size) -{ - memcpy(dst, src, size); -} - -void cms_memset(void *dst, int ch, size_t size) -{ - memset(dst, ch, size); -} diff --git a/components/cms/port/oneos/cms_mutex.c b/components/cms/port/oneos/cms_mutex.c deleted file mode 100644 index 394ce8ef1ee96165baea7d64965bb8b4b4daaaa0..0000000000000000000000000000000000000000 --- a/components/cms/port/oneos/cms_mutex.c +++ /dev/null @@ -1,67 +0,0 @@ -/** - *********************************************************************************************************************** - * Copyright (c) 2021, China Mobile Communications Group Co.,Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - * - * @file cms_adapter.c - * - * @brief Interface related to OS. - * - * @revision - * Date Author Notes - * 2020-10-13 OneOS Team First Version - *********************************************************************************************************************** - */ -#include "cms_mutex.h" -#include "cms_memory.h" -#include - -#ifndef FALSE -#define FALSE (0) -#endif - -#ifndef TRUE -#define TRUE (1) -#endif - -void *mutex_create(void) -{ - os_mutex_id *mutex = cms_malloc(sizeof(os_mutex_id)); - if (mutex == NULL) - return NULL; - *mutex = os_mutex_create(NULL, "cms", TRUE); - if (*mutex) - return mutex; // success - cms_free(mutex); - return NULL; // fail -} - -void mutex_destroy(void *mutex) -{ - if (mutex == NULL) - return; - (void)os_mutex_destroy(*(os_mutex_id *)mutex); - cms_free(mutex); -} - -void mutex_lock(void *mutex) -{ - if (mutex == NULL) - return; - os_mutex_recursive_lock(*(os_mutex_id *)mutex, OS_WAIT_FOREVER); -} - -void mutex_unlock(void *mutex) -{ - if (mutex == NULL) - return; - os_mutex_recursive_unlock(*(os_mutex_id *)mutex); -} diff --git a/components/cms/port/oneos/cms_net.c b/components/cms/port/oneos/cms_net.c deleted file mode 100644 index 32ca2b22ed1fbaa2abba1b255c351dd91a7ac238..0000000000000000000000000000000000000000 --- a/components/cms/port/oneos/cms_net.c +++ /dev/null @@ -1,201 +0,0 @@ -/** - *********************************************************************************************************************** - * Copyright (c) 2021, China Mobile Communications Group Co.,Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - * - * @file cms_adapter.c - * - * @brief Interface related to OS. - * - * @revision - * Date Author Notes - * 2020-10-13 OneOS Team First Version - *********************************************************************************************************************** - */ -#include "cms_net.h" -#include "cms_memory.h" -#include -#include -#include -#include - -typedef struct __CMS_NET_HANDEL__ -{ - int type; - struct sockaddr to_addr; - int fd; -} CMS_NET_HANDEL; - -void *cms_connect(const char *url, const char *port, enum CMS_TRANS_PROT_TYPE type) -{ - int fd = -1; - struct addrinfo *addr_list; - struct addrinfo *addr; - struct addrinfo addr_info; - struct sockaddr to_addr; - - cms_memset(&addr_info, 0, sizeof(addr_info)); - if (CMS_TCP == type) - { - addr_info.ai_protocol = IPPROTO_TCP; - addr_info.ai_socktype = SOCK_STREAM; - } - else if (CMS_UDP == type) - { - addr_info.ai_protocol = IPPROTO_UDP; - addr_info.ai_socktype = SOCK_DGRAM; - } - else - return NULL; - - if (getaddrinfo(url, port, &addr_info, &addr_list)) - { - return NULL; - } - - for (addr = addr_list; addr != NULL; addr = addr->ai_next) - { - fd = socket(addr->ai_family, addr->ai_socktype, addr->ai_protocol); - if (fd < 0) - { - continue; - } - - if (type == CMS_UDP) - { - to_addr = *(addr->ai_addr); - break; - } - - if (type == CMS_TCP && connect(fd, addr->ai_addr, addr->ai_addrlen) == 0) - { - break; - } - closesocket(fd); - fd = -1; - } - freeaddrinfo(addr_list); - if (fd < 0) - return NULL; - CMS_NET_HANDEL *handle = cms_malloc(sizeof(CMS_NET_HANDEL)); - if (handle == NULL) - return NULL; - handle->type = type; - handle->to_addr = to_addr; - handle->fd = fd; - return (void *)handle; -} - -static int cms_tcp_send(int fd, const void *data, size_t size, int timeout_ms) -{ - if (timeout_ms) - { - struct timeval interval = {timeout_ms / 1000, (timeout_ms % 1000) * 1000}; - setsockopt(fd, SOL_SOCKET, SO_SNDTIMEO, (char *)&interval, sizeof(struct timeval)); - } - return send(fd, data, size, 0); -} - -static int cms_udp_send(int fd, const void *data, size_t size, int timeout_ms, const struct sockaddr *to, size_t tolen) -{ - if (timeout_ms) - { - struct timeval interval = {timeout_ms / 1000, (timeout_ms % 1000) * 1000}; - setsockopt(fd, SOL_SOCKET, SO_SNDTIMEO, (char *)&interval, sizeof(struct timeval)); - } - return sendto(fd, data, size, 0, to, tolen); -} - -static int cms_tcp_recv(int fd, void *data, size_t size, int timeout_ms) -{ - int rc; - struct timeval interval; - fd_set read_fds; - - FD_ZERO(&read_fds); - FD_SET(fd, &read_fds); - - interval.tv_sec = timeout_ms / 1000; - interval.tv_usec = (timeout_ms % 1000) * 1000 + 1; - - rc = select(fd + 1, &read_fds, NULL, NULL, &interval); - if (rc <= 0) - return rc; - - rc = recv(fd, data, size, 0); - if (rc == 0) - { - closesocket(fd); - return -1; - } - return rc; -} - -static int cms_udp_recv(int fd, void *data, size_t size, int timeout_ms, struct sockaddr *from, uint32_t *fromlen) -{ - int rc; - struct timeval interval; - fd_set read_fds; - - FD_ZERO(&read_fds); - FD_SET(fd, &read_fds); - - interval.tv_sec = timeout_ms / 1000; - interval.tv_usec = (timeout_ms % 1000) * 1000 + 1; - - rc = select(fd + 1, &read_fds, NULL, NULL, &interval); - if (rc <= 0) - { - return rc; - } - return recvfrom(fd, data, size, 0, from, fromlen); -} - -int cms_send_with_timeout(void *net_handle, const void *data, size_t size, int timeout_ms) -{ - CMS_NET_HANDEL *handle = (CMS_NET_HANDEL *)net_handle; - if (handle == NULL) - return -1; - if (handle->type == CMS_TCP) - { - return cms_tcp_send(handle->fd, data, size, timeout_ms); - } - else - { - return cms_udp_send(handle->fd, data, size, timeout_ms, &(handle->to_addr), sizeof(handle->to_addr)); - } -} - -int cms_recv_with_timeout(void *net_handle, void *mem, size_t len, int timeout_ms) -{ - CMS_NET_HANDEL *handle = (CMS_NET_HANDEL *)net_handle; - if (handle == NULL) - return -1; - if (handle->type == CMS_TCP) - { - return cms_tcp_recv(handle->fd, mem, len, timeout_ms); - } - else - { - uint32_t fromlen = sizeof(handle->to_addr); - return cms_udp_recv(handle->fd, mem, len, timeout_ms, &(handle->to_addr), &fromlen); - } -} - -int cms_closesocket(void *net_handle) -{ - CMS_NET_HANDEL *handle = (CMS_NET_HANDEL *)net_handle; - if (handle == NULL) - return -1; - int rc = closesocket(handle->fd); - cms_free(handle); - return rc; -} diff --git a/components/cms/port/oneos/cms_ring_buff.c b/components/cms/port/oneos/cms_ring_buff.c deleted file mode 100644 index 646a02f7cdac35b602a854cb61b4702b844ec702..0000000000000000000000000000000000000000 --- a/components/cms/port/oneos/cms_ring_buff.c +++ /dev/null @@ -1,54 +0,0 @@ -/** - *********************************************************************************************************************** - * Copyright (c) 2021, China Mobile Communications Group Co.,Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - * - * @file cms_adapter.c - * - * @brief Interface related to OS. - * - * @revision - * Date Author Notes - * 2020-10-13 OneOS Team First Version - *********************************************************************************************************************** - */ -#include "cms_ring_buff.h" -#include - -void *cms_con_ring_fifo_init(uint32_t max_length) -{ - return (void *)rb_ring_buff_create(OS_ALIGN_UP(max_length, OS_ALIGN_SIZE)); -} - -void cms_con_ring_fifo_deinit(void *ring_fifo) -{ - rb_ring_buff_destroy((rb_ring_buff_t *)ring_fifo); -} - -int cms_con_ring_fifo_write(void *ring_fifo, uint8_t *buffer, uint32_t write_length) -{ - return rb_ring_buff_put((rb_ring_buff_t *)ring_fifo, buffer, write_length); -} - -int cms_con_ring_fifo_read(void *ring_fifo, uint8_t *buffer, uint32_t read_length) -{ - return rb_ring_buff_get((rb_ring_buff_t *)ring_fifo, buffer, read_length); -} - -uint32_t cms_con_ring_fifo_get_space_length(void *ring_fifo) -{ - return rb_ring_buff_space_len((rb_ring_buff_t *)ring_fifo); -} - -uint32_t cms_con_ring_fifo_get_data_length(void *ring_fifo) -{ - return rb_ring_buff_data_len((rb_ring_buff_t *)ring_fifo); -} diff --git a/components/cms/port/oneos/cms_sem.c b/components/cms/port/oneos/cms_sem.c deleted file mode 100644 index 4a4a62be613064264e979ed0ce8c61b945a2497e..0000000000000000000000000000000000000000 --- a/components/cms/port/oneos/cms_sem.c +++ /dev/null @@ -1,55 +0,0 @@ -/** - *********************************************************************************************************************** - * Copyright (c) 2021, China Mobile Communications Group Co.,Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - * - * @file cms_adapter.c - * - * @brief Interface related to OS. - * - * @revision - * Date Author Notes - * 2020-10-13 OneOS Team First Version - *********************************************************************************************************************** - */ -#include "cms_sem.h" -#include "cms_memory.h" -#include -#include - -void *cms_sem_create(const char *name, uint16_t initial_value, uint16_t max_value) -{ - os_semaphore_id *sem = cms_malloc(sizeof(os_semaphore_id)); - if (sem == NULL) - return NULL; - *sem = os_semaphore_create(NULL, name, initial_value, max_value); - if (*sem) - return sem; // success - cms_free(sem); - return NULL; // fail -} - -void cms_sem_destroy(void *sem) -{ - os_semaphore_destroy(*(os_semaphore_id *)sem); - cms_free(sem); -} - -int cms_sem_wait(void *sem, uint32_t timeout_ms) -{ - os_tick_t timeout_tick = os_tick_from_ms(timeout_ms); - return os_semaphore_wait(*(os_semaphore_id *)sem, timeout_tick); -} - -void cms_sem_post(void *sem) -{ - os_semaphore_post(*(os_semaphore_id *)sem); -} diff --git a/components/cms/port/oneos/cms_thread.c b/components/cms/port/oneos/cms_thread.c deleted file mode 100644 index ab66b98556785eaa899c5150c3649a1703a7a8c9..0000000000000000000000000000000000000000 --- a/components/cms/port/oneos/cms_thread.c +++ /dev/null @@ -1,53 +0,0 @@ -/** - *********************************************************************************************************************** - * Copyright (c) 2021, China Mobile Communications Group Co.,Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - * - * @file cms_adapter.c - * - * @brief Interface related to OS. - * - * @revision - * Date Author Notes - * 2020-10-13 OneOS Team First Version - *********************************************************************************************************************** - */ -#include "cms_thread.h" -#include "cms_memory.h" -#include - -void *task_create(void (*entry)(void *arg), void *arg, uint32_t stack_size, uint8_t priority) -{ - return task_create_with_name(NULL, entry, arg, stack_size, priority); -} -void * -task_create_with_name(const char *name, void (*entry)(void *arg), void *arg, uint32_t stack_size, uint8_t priority) -{ - os_task_id task = os_task_create(NULL, NULL, stack_size, name, entry, arg, priority); - if (task) - return (void *)task; // success - return NULL; -} - -int task_startup(void *task) -{ - return os_task_startup((os_task_id)task); -} - -void task_destroy(void *task) -{ - (void)os_task_destroy((os_task_id)task); -} - -void msleep(uint32_t ms) -{ - (void)os_task_msleep(ms); -} diff --git a/components/cms/port/oneos/weave.yaml b/components/cms/port/oneos/weave.yaml deleted file mode 100644 index cf259c1a939f041d82e832dee542e18e66b731e2..0000000000000000000000000000000000000000 --- a/components/cms/port/oneos/weave.yaml +++ /dev/null @@ -1,19 +0,0 @@ -# 组名 -group_name: cms/port - -# 编译选项(支持条件表达式) -build_option: - cpppath: - - ../ - -# 源码(支持条件表达式) -source_file: - - cms_clock.c - - cms_memory.c - - cms_mutex.c - - cms_net.c - - cms_ring_buff.c - - cms_sem.c - - cms_thread.c - - cms_adapter.c - \ No newline at end of file diff --git a/components/cms/port/weave.yaml b/components/cms/port/weave.yaml deleted file mode 100644 index 9f0049893dbb8a9162412fb1eddcb10b287c411c..0000000000000000000000000000000000000000 --- a/components/cms/port/weave.yaml +++ /dev/null @@ -1,3 +0,0 @@ -# 子目录(支持条件表达式) -add_subdirectory: - - oneos \ No newline at end of file diff --git a/components/cms/weave.yaml b/components/cms/weave.yaml deleted file mode 100644 index ae25b3ef062745d11ee893d47ae981b24bd434cd..0000000000000000000000000000000000000000 --- a/components/cms/weave.yaml +++ /dev/null @@ -1,4 +0,0 @@ -# 子目录(支持条件表达式) -add_subdirectory: - - port?{is_define('USING_CMS_CONNECT') or is_define('CMS_USING_ID')} - - source?{is_define('USING_CMS_CONNECT') or is_define('CMS_USING_ID')} \ No newline at end of file diff --git a/components/fs/Kconfig b/components/fs/Kconfig index 64eb3698f1171aa7fdb6db4e5984fd35a7dcbdd4..2fccfd4e1c8b35d2e4ace9d64d1f70425f3dcd02 100644 --- a/components/fs/Kconfig +++ b/components/fs/Kconfig @@ -151,6 +151,16 @@ if OS_USING_VFS config LFS_THREADSAFE bool "Enable thread safe of the little filesystem." default y + + config LFS_TIMESTAMP + bool "Enable the timestamp of file" + default n + + if LFS_TIMESTAMP + config LFS_ATTR + int + default 1 + endif endmenu endif diff --git a/components/fs/source/fs_cmd.c b/components/fs/source/fs_cmd.c index 252c0832030b8a480cdd8fdafdbc9d729f4f6be4..1a500a0e2997ba447f9215c6eb97015d09296982 100644 --- a/components/fs/source/fs_cmd.c +++ b/components/fs/source/fs_cmd.c @@ -779,6 +779,11 @@ static void _move(const char *src, const char *dst) int result_dst; int result_rename; + if (0 == strcmp(src, dst)) + { + os_kprintf("mv: %s and %s are the same\r\n", src, dst); + return; + } dst_exist = OS_FALSE; result_rename = 0; memset(&stat_src, 0, sizeof(struct stat)); diff --git a/components/fs/source/littlefs/lfs.h b/components/fs/source/littlefs/lfs.h index 41f33684738e4073b32ec3cd3155fc715276924c..f0b72da19e8e6b8c552a2cf668ab01b362d6bd90 100644 --- a/components/fs/source/littlefs/lfs.h +++ b/components/fs/source/littlefs/lfs.h @@ -140,6 +140,11 @@ enum lfs_type LFS_FROM_MOVE = 0x101, #ifdef LFS_ATTR LFS_FROM_USERATTRS = 0x102, +#ifdef LFS_TIMESTAMP + LFS_TYPE_MTIME = 0x010, /* modification time */ + LFS_TYPE_CTIME = 0x011, /* creation time */ + LFS_TYPE_ATIME = 0x012, /* access time */ +#endif #endif }; diff --git a/components/fs/source/littlefs/vfs_lfs.c b/components/fs/source/littlefs/vfs_lfs.c index 13c1bf16426ba42b8c414ebe459fc1516091f054..5c6d9861f89af69267db410c93fc1c45c0245203 100644 --- a/components/fs/source/littlefs/vfs_lfs.c +++ b/components/fs/source/littlefs/vfs_lfs.c @@ -11,6 +11,10 @@ #include "lfs.h" #include "lfs_io.h" +#ifdef LFS_TIMESTAMP +#include +#endif + #define LFS_FS_TAG "littlefs" #define LFS_ENTER_OPEN_LIST_CRITICAL(part_info) os_mutex_lock((os_mutex_id)(&(part_info->open_lock)), OS_WAIT_FOREVER) @@ -607,6 +611,20 @@ static int vfs_lfs_open(struct vfs_file *file) } else { +#ifdef LFS_TIMESTAMP + /*check is newly file created*/ + struct lfs_info info; + int old_file_flag = 0; + ret = lfs_stat(&part_info->lfs, name, &info); + if (ret < 0) + { + old_file_flag = 0; + } + else + { + old_file_flag = 1; + } +#endif ret = vfs_lfs_add_entry(part_info, file->path); if (0 == ret) @@ -625,6 +643,15 @@ static int vfs_lfs_open(struct vfs_file *file) * Save this pointer, it will be used when calling read(), write(), * flush(), lessk(), and will be free when calling close(). */ +#ifdef LFS_TIMESTAMP + if (!old_file_flag) + { + time_t ctime = time(NULL); + lfs_setattr(&part_info->lfs, file->path, LFS_TYPE_CTIME, &ctime, sizeof(ctime)); + lfs_setattr(&part_info->lfs, file->path, LFS_TYPE_MTIME, &ctime, sizeof(ctime)); + lfs_setattr(&part_info->lfs, file->path, LFS_TYPE_ATIME, &ctime, sizeof(ctime)); + } +#endif file->desc = data; } } @@ -710,6 +737,10 @@ static int vfs_lfs_read(struct vfs_file *file, void *buf, size_t size) else { ret = (int)read_cnt; +#ifdef LFS_TIMESTAMP + time_t atime = time(NULL); + lfs_setattr(&part_info->lfs, file->path, LFS_TYPE_ATIME, &atime, sizeof(atime)); +#endif } } } @@ -755,6 +786,10 @@ static int vfs_lfs_write(struct vfs_file *file, const void *buf, size_t size) else { ret = (int)write_cnt; +#ifdef LFS_TIMESTAMP + time_t mtime = time(NULL); + lfs_setattr(&part_info->lfs, file->path, LFS_TYPE_MTIME, &mtime, sizeof(mtime)); +#endif } } } @@ -1258,6 +1293,29 @@ static int vfs_lfs_stat(struct vfs_mountpoint *mnt_point, const char *path, stru } ret = 0; +#ifdef LFS_TIMESTAMP + /*directory set all default time: 2000-01-01 00:00:00*/ + time_t ctime, mtime, atime; + lfs_ssize_t res = -1; + res = lfs_getattr(&part_info->lfs, path, LFS_TYPE_CTIME, &ctime, sizeof(ctime)); + if (res < 0) + { + ctime = 946684800; + } + res = lfs_getattr(&part_info->lfs, path, LFS_TYPE_MTIME, &mtime, sizeof(mtime)); + if (res < 0) + { + mtime = 946684800; + } + res = lfs_getattr(&part_info->lfs, path, LFS_TYPE_ATIME, &atime, sizeof(atime)); + if (res < 0) + { + atime = 946684800; + } + st->st_ctime = ctime; + st->st_mtime = mtime; + st->st_atime = atime; +#endif } } diff --git a/components/net/ip/lwip-2.1.2/Kconfig b/components/net/ip/lwip-2.1.2/Kconfig index ad22f42be21c139fe53f49437f5e30afcd92eed4..1f67e458fd8a4a01923b0a7cb2d2e1a094a6298c 100644 --- a/components/net/ip/lwip-2.1.2/Kconfig +++ b/components/net/ip/lwip-2.1.2/Kconfig @@ -20,6 +20,7 @@ config NET_USING_LWIP menuconfig NET_USING_LWIP_IPV6 bool "IPV6 protocol" + select BSD_USING_IPV6 default n if NET_USING_LWIP_IPV6 diff --git a/components/net/socket/Kconfig b/components/net/socket/Kconfig index 54abdefc3c50562756bb676d7ae51b72b4a620ac..e6793c62a67b8725449918a4136aeccb9ba4bab7 100644 --- a/components/net/socket/Kconfig +++ b/components/net/socket/Kconfig @@ -19,6 +19,10 @@ config NET_USING_BSD depends on NET_USING_LWIP endchoice + config BSD_USING_IPV6 + bool + default n + endif endif diff --git a/drivers/boot/cotex-m/vector_table.c b/drivers/boot/cotex-m/vector_table.c index 6ae783143e6110a8bf20b5ac560928d872183847..f6a16b5786aeb66ee3e0032ca5a4f84d0b658d6d 100644 --- a/drivers/boot/cotex-m/vector_table.c +++ b/drivers/boot/cotex-m/vector_table.c @@ -25,6 +25,10 @@ #include #include +#ifdef OS_USING_IRQ_MONITOR +#include +#endif + int OS_USED OS_SECTION("reserved_ram") rsv_ram_start = 0; #define RESERVED_RAM_VECTOR_ADDR (&rsv_ram_start + 1) @@ -111,6 +115,10 @@ static void cortex_m_vector_entry(void) vector_entry *vtable; os_irq_hook hook; +#ifdef OS_USING_IRQ_MONITOR + cpu_usage_irq_monitor_start(); +#endif + int irq = os_irq_num(); if (irq == 0) @@ -128,6 +136,10 @@ static void cortex_m_vector_entry(void) vtable[irq](); os_interrupt_stack_check(); + +#ifdef OS_USING_IRQ_MONITOR + cpu_usage_irq_monitor_stop(); +#endif } #ifdef BSP_INCLUDE_VECTOR_TABLE diff --git a/kernel/Kconfig b/kernel/Kconfig index a77c1fa7271c93c6ddcb06edd61b3a8b713fd89e..4057fe0f98dabdeb95b74a465ccd5f66b789fb9d 100644 --- a/kernel/Kconfig +++ b/kernel/Kconfig @@ -232,15 +232,25 @@ menu "Check" select OS_USING_OVERFLOW_CHECK default n endmenu # check + menu "CPU monitor" - config OS_USING_CPU_MONITOR - bool "Monitor CPU usage" - select OS_USING_TASK_HOOK - select OS_TASK_SWITCH_NOTIFY + config OS_USING_CPU_MONITOR + bool "Monitor CPU usage" + select OS_USING_TASK_HOOK + select OS_TASK_SWITCH_NOTIFY + default n + help + Monitor CPU usage over a period of time. + if OS_USING_CPU_MONITOR + config OS_USING_IRQ_MONITOR + bool "Monitor CPU usage including interrupts" default n - help - Monitor CPU usage over a period of time. - + if OS_USING_IRQ_MONITOR + config OS_IRQ_MONITOR_NUM + int "Maximum number of interrupts supported for monitoring" + default 10 + endif + endif endmenu # CPU monitor source "$OS_ROOT/kernel/source/debug/mem_monitor/Kconfig" diff --git a/kernel/include/debug/cpu_monitor/cpu_monitor.h b/kernel/include/debug/cpu_monitor/cpu_monitor.h index 93df7f010ddb23d97563ed1a64e426f6bfa9a386..e44e2cddf35590a6b214da44390b7422d10154ef 100644 --- a/kernel/include/debug/cpu_monitor/cpu_monitor.h +++ b/kernel/include/debug/cpu_monitor/cpu_monitor.h @@ -18,6 +18,7 @@ * @revision * Date Author Notes * 2021-11-29 OneOS Team First Version. + * 2024-11-20 weiyongjun add irq monitor when task monitoring *********************************************************************************************************************** */ @@ -41,6 +42,11 @@ struct cpu_use_info typedef struct cpu_use_info cpu_use_info_t; +#ifdef OS_USING_IRQ_MONITOR +extern void cpu_usage_irq_monitor_start(void); +extern void cpu_usage_irq_monitor_stop(void); +#endif + #ifdef __cplusplus } #endif diff --git a/kernel/source/debug/cpu_monitor/cpu_monitor.c b/kernel/source/debug/cpu_monitor/cpu_monitor.c index 3b825e4af9ed1f28ba06dd9c742e3e57725d1de0..7d2c5467ffb81878e03a7e54af60ab8005fb1564 100644 --- a/kernel/source/debug/cpu_monitor/cpu_monitor.c +++ b/kernel/source/debug/cpu_monitor/cpu_monitor.c @@ -18,6 +18,7 @@ * @revision * Date Author Notes * 2021-11-29 OneOS team First Version + * 2024-11-20 weiyongjun add irq monitor when task monitoring *********************************************************************************************************************** */ #include @@ -32,6 +33,200 @@ #ifdef OS_USING_CPU_MONITOR +#ifdef OS_USING_IRQ_MONITOR +#include + +/* Maximum number of interrupts supported for monitoring */ +#define IRQ_MONITOR_NUM OS_IRQ_MONITOR_NUM + +/* Signs for monitoring CPU interrupt information */ +#define IRQ_MONITOR_START 0XAAA +#define IRQ_MONITOR_STOP 0X555 + +/* A structure used to record interrupt runtime */ +typedef struct cpu_irq_info +{ + int status; + int irq; + uint64_t start_time; /* Record the time of switching to the irq.*/ + uint64_t total_time; /* Accumulation of running time. */ +} cpu_irq_info_t; + +struct +{ + int status; /* Interrupt monitoring status */ + int cur_index; /* current IRQ index of irq_info */ + int nest_count; /* Save interrupt nesting depth */ + int already_monitor_num; /* Save the number of monitored interrupts */ +} irq_monitor_state = {0}; + +static char cpu_nest_info[IRQ_MONITOR_NUM] = {0}; /* Used to find the nested order of interrupts */ +static cpu_irq_info_t irq_info[IRQ_MONITOR_NUM] = {0}; /* Used to save the running status of interrupts */ + +/** + *********************************************************************************************************************** + * @brief Start monitoring of the current interrupt. + * + * @param[in] irq The current interrupt num. + * @param[in] time The current interrupt needs to be updated start time. + * + * @return None. + *********************************************************************************************************************** + */ + +static void current_irq_timestamp_start(int irq) +{ + int irq_exist = OS_FALSE; + int irq_save = 0; + + /* The current IRQ has been running within the monitoring time */ + for (int index = 0; index < IRQ_MONITOR_NUM; index++) + { + if ((irq_info[index].irq == irq) && (irq_info[index].status == 1)) + { + irq_info[index].start_time = os_clocksource_gettime(); + irq_monitor_state.cur_index = index; + irq_exist = OS_TRUE; + break; + } + } + + /* The current IRQ is not running within the monitoring time */ + if (irq_exist == OS_FALSE) + { + if ((irq_monitor_state.already_monitor_num == IRQ_MONITOR_NUM) && + (irq_monitor_state.already_monitor_num != (IRQ_MONITOR_NUM + 1))) + { + os_kprintf("The current monitoring interrupt count of %d has reached the maximum monitoring count.\r\n", + "To monitor more interrupts, please reconfigure OS_IRQ_MONITOR_NUM\r\n", + IRQ_MONITOR_NUM); + irq_monitor_state.already_monitor_num++; + return; + } + + for (int index = 0; index < IRQ_MONITOR_NUM; index++) + { + irq_save = os_irq_lock(); + if (irq_info[index].status == 0) + { + irq_info[index].status = 1; + os_irq_unlock(irq_save); + irq_info[index].irq = irq; + irq_info[index].start_time = os_clocksource_gettime(); + irq_info[index].total_time = 0; + irq_monitor_state.cur_index = index; + + irq_monitor_state.already_monitor_num++; + break; + } + os_irq_unlock(irq_save); + } + } + + return; +} + +/** + *********************************************************************************************************************** + * @brief Interrupt entry, start monitoring. + * + * @param[in] None. + * + * @return None. + *********************************************************************************************************************** + */ + +void cpu_usage_irq_monitor_start(void) +{ + os_task_t *current_task; + + if (irq_monitor_state.status == IRQ_MONITOR_START) + { + uint64_t time = os_clocksource_gettime(); + int irq = os_irq_num(); + + irq_monitor_state.nest_count++; + cpu_nest_info[irq_monitor_state.nest_count - 1] = irq; + + /* if irq_monitor_state.nest_count > 1, interrupt nesting occurred */ + if (irq_monitor_state.nest_count > 1) + { + /* first: stop prev irq monitor, update prev irq running time */ + int prev_irq = cpu_nest_info[irq_monitor_state.nest_count - 2]; + for (int index = 0; index < IRQ_MONITOR_NUM; index++) + { + if ((irq_info[index].irq == prev_irq) && (irq_info[index].status == 1)) + { + irq_info[index].total_time += time - irq_info[index].start_time; + break; + } + } + } + else + { + /* first: stop current task monitor */ + current_task = (os_task_t *)os_get_current_task(); + current_task->usage_info.total_time += time - current_task->usage_info.start_time; + } + + /* second: start current irq monitor */ + current_irq_timestamp_start(irq); + } + + return; +} + +/** + *********************************************************************************************************************** + * @brief Interrupt exit, exit monitoring. + * + * @param[in] None. + * + * @return None. + *********************************************************************************************************************** + */ + +void cpu_usage_irq_monitor_stop(void) +{ + os_task_t *current_task; + + if (irq_monitor_state.status == IRQ_MONITOR_START) + { + int irq = os_irq_num(); + + uint64_t time = os_clocksource_gettime(); + + /* first: stop current irq monitor, update current irq running time */ + irq_info[irq_monitor_state.cur_index].total_time += time - irq_info[irq_monitor_state.cur_index].start_time; + + if (irq_monitor_state.nest_count > 1) + { + /* second: start prev irq monitor, update prev irq start time */ + int prev_irq = cpu_nest_info[irq_monitor_state.nest_count - 2]; + for (int index = 0; index < IRQ_MONITOR_NUM; index++) + { + if ((irq_info[index].irq == prev_irq) && (irq_info[index].status == 1)) + { + irq_info[index].start_time = os_clocksource_gettime(); + irq_monitor_state.cur_index = index; + break; + } + } + } + else + { + /* second: start current task monitor */ + current_task = (os_task_t *)os_get_current_task(); + current_task->usage_info.start_time = os_clocksource_gettime(); + } + + irq_monitor_state.nest_count--; + } + + return; +} +#endif + /** *********************************************************************************************************************** * @brief This function accumulates the running time of the current task during task switching. @@ -115,6 +310,10 @@ static os_err_t cpu_usage_monitor_start(void) os_schedule_lock(); +#ifdef OS_USING_IRQ_MONITOR + irq_monitor_state.status = IRQ_MONITOR_START; +#endif + ret = get_current_task_timestamp_start(); if (0 == ret) @@ -125,6 +324,10 @@ static os_err_t cpu_usage_monitor_start(void) } else { +#ifdef OS_USING_IRQ_MONITOR + irq_monitor_state.status = IRQ_MONITOR_STOP; +#endif + os_kprintf(" %s failed to add switch hook function.\r\n", __FUNCTION__, __LINE__); ret = OS_FAILURE; } @@ -164,6 +367,10 @@ static os_err_t cpu_usage_monitor_stop(void) return OS_FAILURE; } +#ifdef OS_USING_IRQ_MONITOR + irq_monitor_state.status = IRQ_MONITOR_STOP; +#endif + os_schedule_unlock(); /* Count the total time spent. */ @@ -178,6 +385,16 @@ static os_err_t cpu_usage_monitor_stop(void) } os_spin_unlock(task_resource_list_lock); +#ifdef OS_USING_IRQ_MONITOR + for (int index = 0; index < IRQ_MONITOR_NUM; index++) + { + if (irq_info[index].status == 1) + { + total += irq_info[index].total_time; + } + } +#endif + // os_kprintf("total %lld\r\n",total); os_kprintf("TID %-*s Ratio\r\n", OS_NAME_MAX, "Task"); @@ -220,6 +437,41 @@ static os_err_t cpu_usage_monitor_stop(void) } os_spin_unlock(task_resource_list_lock); +#ifdef OS_USING_IRQ_MONITOR + os_kprintf("IRQ %-*s Ratio\r\n", OS_NAME_MAX, " "); + + for (int index = 0; index < IRQ_MONITOR_NUM; index++) + { + if (irq_info[index].status == 1) + { + os_kprintf("0x%-8x %-*s", irq_info[index].irq, OS_NAME_MAX, " "); + rate = irq_info[index].total_time * 10000 / total; + integer_part = rate / 100; + fractional_part = rate % 100; + + if ((0 == integer_part) && (0 == fractional_part)) + { + os_kprintf(" 0.01%c\r\n", '%'); + } + else + { + if (fractional_part >= 10) + { + os_kprintf(" %2d.%d%c\r\n", integer_part, fractional_part, '%'); + } + else + { + os_kprintf(" %2d.0%d%c\r\n", integer_part, fractional_part, '%'); + } + } + } + } + + memset(irq_info, 0, sizeof(irq_info)); + memset(cpu_nest_info, 0, sizeof(cpu_nest_info)); + memset(&irq_monitor_state, 0, sizeof(irq_monitor_state)); +#endif + return OS_SUCCESS; } diff --git a/templates/stm32f103zet6-atk-elite-nano/.config b/templates/stm32f103zet6-atk-elite-nano/.config index 5edd225dfb8184f51cf2f06f08a33308c0b15cba..858edd5239b4a4bf96ce6e4b9d9ffc02e7cc579b 100644 --- a/templates/stm32f103zet6-atk-elite-nano/.config +++ b/templates/stm32f103zet6-atk-elite-nano/.config @@ -7,11 +7,14 @@ CONFIG_ARCH_ARM_CORTEX_M3=y # # Kernel # -# CONFIG_OS_USING_SMP is not set CONFIG_OS_NAME_MAX_7=y # CONFIG_OS_NAME_MAX_15 is not set # CONFIG_OS_NAME_MAX_31 is not set CONFIG_OS_NAME_MAX=7 + +# +# Task +# CONFIG_OS_TASK_PRIORITY_8=y # CONFIG_OS_TASK_PRIORITY_16 is not set # CONFIG_OS_TASK_PRIORITY_32 is not set @@ -21,53 +24,129 @@ CONFIG_OS_TASK_PRIORITY_8=y CONFIG_OS_TASK_PRIORITY_MAX=8 CONFIG_OS_TICK_PER_SECOND=100 CONFIG_OS_SCHEDULE_TIME_SLICE=10 +CONFIG_OS_SYS_TASK_STACK_SIZE=256 +CONFIG_OS_IDLE_TASK_STACK_SIZE=64 +CONFIG_OS_RECYCLE_TASK_STACK_SIZE=64 +# end of Task + +# +# Timer +# +# CONFIG_OS_USING_KERNEL_TIMER is not set +# end of Timer + +# +# Log +# +# end of Log + +# +# Debug +# + +# +# Check +# # CONFIG_OS_USING_OVERFLOW_CHECK is not set # CONFIG_OS_USING_INTERRUPT_STACK_OVERFLOW_CHECK is not set # CONFIG_OS_USING_TASK_HOOK is not set # CONFIG_OS_USING_SAFETY_MECHANISM is not set -CONFIG_OS_SYS_TASK_STACK_SIZE=2048 -CONFIG_OS_IDLE_TASK_STACK_SIZE=256 -CONFIG_OS_RECYCLE_TASK_STACK_SIZE=256 -# CONFIG_OS_USING_KERNEL_TIMER is not set +# end of Check + +# +# CPU monitor +# +# CONFIG_OS_USING_CPU_MONITOR is not set +# end of CPU monitor # -# Inter-task communication and synchronization +# Memory Monitor +# +# CONFIG_OS_USING_MEM_MONITOR is not set +# end of Memory Monitor + +# +# Stack trace +# +# CONFIG_STACK_TRACE_EN is not set +# end of Stack trace +# end of Debug + +# +# IPC +# + +# +# IPC Trace & Hook +# +# CONFIG_OS_USING_IPC_TRACE is not set +# CONFIG_OS_USING_IPC_HOOK is not set +# end of IPC Trace & Hook + +# +# Event +# +# CONFIG_OS_USING_EVENT is not set +# end of Event + +# +# Mailbox +# +# CONFIG_OS_USING_MAILBOX is not set +# end of Mailbox + +# +# Message queue +# +# CONFIG_OS_USING_MESSAGEQUEUE is not set +# end of Message queue + +# +# Mutex # # CONFIG_OS_USING_MUTEX is not set -# CONFIG_OS_USING_SPINLOCK_CHECK is not set +# end of Mutex + +# +# Workqueue +# +# end of Workqueue + +# +# Semaphore +# CONFIG_OS_USING_SEMAPHORE=y # CONFIG_OS_SEM_WAIT_HOOK is not set # CONFIG_OS_SEM_POST_HOOK is not set -# CONFIG_OS_USING_EVENT is not set -# CONFIG_OS_USING_MESSAGEQUEUE is not set -# CONFIG_OS_USING_MAILBOX is not set -# end of Inter-task communication and synchronization +# end of Semaphore # -# Memory management +# Spinlock # -CONFIG_OS_USING_HEAP=y -CONFIG_OS_USING_ALG_FIRSTFIT=y -# CONFIG_OS_USING_ALG_BUDDY is not set -# CONFIG_OS_USING_MEM_TRACE is not set -# CONFIG_OS_USING_MEM_POOL is not set -# end of Memory management +# CONFIG_OS_USING_SPINLOCK_CHECK is not set +# end of Spinlock +# end of IPC -# CONFIG_OS_USING_IPC_TRACE is not set -# CONFIG_OS_USING_IPC_HOOK is not set +# +# Memory +# # -# Diagnose +# Memory-Heap # -# CONFIG_STACK_TRACE_EN is not set -# CONFIG_OS_USING_CPU_MONITOR is not set +# CONFIG_OS_USING_HEAP is not set +# CONFIG_OS_USING_ALG_FIRSTFIT is not set +CONFIG_OS_USING_ALG_BUDDY=y +CONFIG_OS_ALG_BUDDY_MAX_BLOCK_SIZE=512 +# CONFIG_OS_USING_MEM_TRACE is not set +# end of Memory-Heap # -# Memory Monitor +# Memory-Pool # -# CONFIG_OS_USING_MEM_MONITOR is not set -# end of Memory Monitor -# end of Diagnose +# CONFIG_OS_USING_MEM_POOL is not set +# end of Memory-Pool +# end of Memory # end of Kernel # @@ -257,7 +336,7 @@ CONFIG_DEFAULT_SYSTEM_CLOCK_CONFIG=y # # CONFIG_OS_USING_NET_DEVICE is not set # CONFIG_OS_USING_WLAN is not set -# CONFIG_BSP_USING_AP6181 is not set +# CONFIG_BSP_USING_BK7231N is not set # end of NET # @@ -382,208 +461,34 @@ CONFIG_OS_USING_SYSTICK_FOR_KERNEL_TICK=y # CONFIG_OS_USING_DBOT is not set # end of DBoT -# -# WWD -# -# CONFIG_OS_USING_WWD is not set -# end of WWD - -# -# AMS -# -# CONFIG_PKG_USING_AMS is not set -# end of AMS - # # Atest # # CONFIG_OS_USING_ATEST is not set # end of Atest -# -# BLE -# -# CONFIG_OS_USING_BLE is not set -# end of BLE - -# -# cJSON -# -# CONFIG_PKG_USING_CJSON is not set -# end of cJSON - -# -# CLI -# -# CONFIG_OS_USING_CLI is not set -# end of CLI - -# -# Cloud -# - -# -# Aliyun -# -# CONFIG_PKG_USING_ALI_IOTKIT is not set -# end of Aliyun - -# -# Amap -# -# CONFIG_AMAP_WEB_SERVICE is not set -# end of Amap - -# -# AWS -# -# CONFIG_PKG_USING_AWS_IOT is not set -# end of AWS - -# -# Baidu -# -# CONFIG_BAIDUIOT is not set -# end of Baidu - -# -# CTWing -# - -# -# MQTT -# -# CONFIG_OS_USING_CTWING_MQTT is not set -# end of MQTT -# end of CTWing - -# -# Huawei -# -# CONFIG_USING_HUAWEI_CLOUD_CONNECT is not set -# end of Huawei - -# -# OneNET -# - -# -# MQTT kit -# -# CONFIG_OS_USING_ONENET_MQTTS is not set -# end of MQTT kit - -# -# NB-IoT kit -# -# CONFIG_OS_USING_ONENET_NBIOT is not set -# end of NB-IoT kit - -# -# EDP -# -# CONFIG_OS_USING_ONENET_EDP is not set -# end of EDP -# end of OneNET -# end of Cloud - # # CMS # # CONFIG_USING_CMS is not set # end of CMS -# -# Diagnose -# -# CONFIG_OS_USING_WIRESHARK_DUMP is not set - -# -# eCoreDump -# -# CONFIG_USING_ECORE_DUMP is not set -# end of eCoreDump -# end of Diagnose - # # Dlog # # CONFIG_OS_USING_DLOG is not set # end of Dlog -# -# Easyflash -# -# CONFIG_PKG_USING_EASYFLASH is not set -# end of Easyflash - -# -# FFmpeg -# -# CONFIG_OS_USING_FFMPEG is not set -# end of FFmpeg - # # FileSystem # # CONFIG_OS_USING_VFS is not set # end of FileSystem -# -# GUI -# -CONFIG_OS_GUI_DISP_DEV_NAME="lcd" -CONFIG_OS_GUI_INPUT_DEV_NAME="touch" -# CONFIG_OS_USING_GUI_LVGL is not set -# CONFIG_OS_USING_GUI_ARM2D is not set -# CONFIG_OS_USING_GUI_CMSIS is not set -# end of GUI - -# -# Industrial -# - -# -# CANOpen -# -# CONFIG_OS_USING_CANFESTIVAL is not set -# end of CANOpen - -# -# CoDeSys -# -# CONFIG_OS_USING_CODESYS is not set -# end of CoDeSys - -# -# ModBus -# -# CONFIG_OS_USING_UCMODBUS is not set -# end of ModBus -# end of Industrial - -# -# IoTjs -# -# CONFIG_USING_IOTJS is not set -# end of IoTjs - -# -# JerryScript -# -# CONFIG_USING_JERRYSCRIPT is not set -# end of JerryScript - # # Network # -# -# Acw -# -# CONFIG_NET_USING_ACW is not set -# end of Acw - # # HGN # @@ -659,24 +564,6 @@ CONFIG_OS_GUI_INPUT_DEV_NAME="touch" # end of Socket # end of Network -# -# Iotivity -# -# CONFIG_PKG_USING_IOTIVITY is not set -# end of Iotivity - -# -# OneJS -# -# CONFIG_OS_USING_ONEJS is not set -# end of OneJS - -# -# Optparse -# -# CONFIG_TP_USING_OPTPARSE is not set -# end of Optparse - # # OTA # @@ -689,27 +576,10 @@ CONFIG_OS_GUI_INPUT_DEV_NAME="touch" # CONFIG_OS_USING_ONEPOS is not set # end of Position -# -# PowerManager -# -# CONFIG_OS_USING_POWER_MANAGER is not set -# end of PowerManager - -# -# Python -# -# CONFIG_OS_USING_PYTHON is not set -# end of Python - -# -# Ramdisk -# -# CONFIG_OS_USING_RAMDISK is not set -# end of Ramdisk - # # Security # +# CONFIG_SECURITY_USING_LIBSSH is not set # CONFIG_SECURITY_USING_MBEDTLS is not set # @@ -724,13 +594,23 @@ CONFIG_OS_GUI_INPUT_DEV_NAME="touch" # # CONFIG_OS_USING_SHELL is not set # end of Shell +# end of Components # -# SQL +# Demos # -# CONFIG_PKG_USING_SQLITE is not set -# end of SQL -# end of Components + +# +# Component demos +# + +# +# Camera web server +# +# CONFIG_OS_USING_CAMERA_WEB_SERVER is not set +# end of Camera web server +# end of Component demos +# end of Demos # # Debug diff --git a/templates/stm32f103zet6-atk-elite-nano/oneos_config.h b/templates/stm32f103zet6-atk-elite-nano/oneos_config.h index 12a8a3e85ef0658dd683768019968c4215619b59..7353eb11322d2a8cdce102c0bacbe6a0603a7299 100644 --- a/templates/stm32f103zet6-atk-elite-nano/oneos_config.h +++ b/templates/stm32f103zet6-atk-elite-nano/oneos_config.h @@ -11,33 +11,93 @@ #define OS_NAME_MAX_7 #define OS_NAME_MAX 7 + +/* Task */ + #define OS_TASK_PRIORITY_8 #define OS_TASK_PRIORITY_MAX 8 #define OS_TICK_PER_SECOND 100 #define OS_SCHEDULE_TIME_SLICE 10 -#define OS_SYS_TASK_STACK_SIZE 2048 -#define OS_IDLE_TASK_STACK_SIZE 256 -#define OS_RECYCLE_TASK_STACK_SIZE 256 +#define OS_SYS_TASK_STACK_SIZE 256 +#define OS_IDLE_TASK_STACK_SIZE 64 +#define OS_RECYCLE_TASK_STACK_SIZE 64 +/* end of Task */ -/* Inter-task communication and synchronization */ +/* Timer */ -#define OS_USING_SEMAPHORE -/* end of Inter-task communication and synchronization */ +/* end of Timer */ + +/* Log */ + +/* end of Log */ -/* Memory management */ +/* Debug */ + +/* Check */ -#define OS_USING_HEAP -#define OS_USING_HEAP -#define OS_USING_ALG_FIRSTFIT -/* end of Memory management */ +/* end of Check */ -/* Diagnose */ +/* CPU monitor */ +/* end of CPU monitor */ /* Memory Monitor */ /* end of Memory Monitor */ -/* end of Diagnose */ + +/* Stack trace */ + +/* end of Stack trace */ +/* end of Debug */ + +/* IPC */ + +/* IPC Trace & Hook */ + +/* end of IPC Trace & Hook */ + +/* Event */ + +/* end of Event */ + +/* Mailbox */ + +/* end of Mailbox */ + +/* Message queue */ + +/* end of Message queue */ + +/* Mutex */ + +/* end of Mutex */ + +/* Workqueue */ + +/* end of Workqueue */ + +/* Semaphore */ + +#define OS_USING_SEMAPHORE +/* end of Semaphore */ + +/* Spinlock */ + +/* end of Spinlock */ +/* end of IPC */ + +/* Memory */ + +/* Memory-Heap */ + +#define OS_USING_ALG_BUDDY +#define OS_ALG_BUDDY_MAX_BLOCK_SIZE 512 +/* end of Memory-Heap */ + +/* Memory-Pool */ + +/* end of Memory-Pool */ +/* end of Memory */ /* end of Kernel */ /* C standard library adapter */ @@ -240,138 +300,24 @@ /* end of DBoT */ -/* WWD */ - -/* end of WWD */ - -/* AMS */ - -/* end of AMS */ - /* Atest */ /* end of Atest */ -/* BLE */ - -/* end of BLE */ - -/* cJSON */ - -/* end of cJSON */ - -/* CLI */ - -/* end of CLI */ - -/* Cloud */ - -/* Aliyun */ - -/* end of Aliyun */ - -/* Amap */ - -/* end of Amap */ - -/* AWS */ - -/* end of AWS */ - -/* Baidu */ - -/* end of Baidu */ - -/* CTWing */ - -/* MQTT */ - -/* end of MQTT */ -/* end of CTWing */ - -/* Huawei */ - -/* end of Huawei */ - -/* OneNET */ - -/* MQTT kit */ - -/* end of MQTT kit */ - -/* NB-IoT kit */ - -/* end of NB-IoT kit */ - -/* EDP */ - -/* end of EDP */ -/* end of OneNET */ -/* end of Cloud */ - /* CMS */ /* end of CMS */ -/* Diagnose */ - - -/* eCoreDump */ - -/* end of eCoreDump */ -/* end of Diagnose */ - /* Dlog */ /* end of Dlog */ -/* Easyflash */ - -/* end of Easyflash */ - -/* FFmpeg */ - -/* end of FFmpeg */ - /* FileSystem */ /* end of FileSystem */ -/* GUI */ - -#define OS_GUI_DISP_DEV_NAME "lcd" -#define OS_GUI_INPUT_DEV_NAME "touch" -/* end of GUI */ - -/* Industrial */ - -/* CANOpen */ - -/* end of CANOpen */ - -/* CoDeSys */ - -/* end of CoDeSys */ - -/* ModBus */ - -/* end of ModBus */ -/* end of Industrial */ - -/* IoTjs */ - -/* end of IoTjs */ - -/* JerryScript */ - -/* end of JerryScript */ - /* Network */ -/* Acw */ - -/* end of Acw */ - /* HGN */ /* end of HGN */ @@ -421,18 +367,6 @@ /* end of Socket */ /* end of Network */ -/* Iotivity */ - -/* end of Iotivity */ - -/* OneJS */ - -/* end of OneJS */ - -/* Optparse */ - -/* end of Optparse */ - /* OTA */ /* end of OTA */ @@ -441,18 +375,6 @@ /* end of Position */ -/* PowerManager */ - -/* end of PowerManager */ - -/* Python */ - -/* end of Python */ - -/* Ramdisk */ - -/* end of Ramdisk */ - /* Security */ @@ -464,11 +386,17 @@ /* Shell */ /* end of Shell */ +/* end of Components */ -/* SQL */ +/* Demos */ -/* end of SQL */ -/* end of Components */ +/* Component demos */ + +/* Camera web server */ + +/* end of Camera web server */ +/* end of Component demos */ +/* end of Demos */ /* Debug */