1 /*
2  * Copyright (C) 2015-2018 Alibaba Group Holding Limited
3  */
4 
5 #ifndef __AWSS_OS_H__
6 #define __AWSS_OS_H__
7 
8 #ifdef __cplusplus
9 extern "C" {
10 #endif
11 #include <ctype.h>
12 #include "linkkit/infra/infra_defs.h"
13 #include <stdio.h>
14 #include <string.h>
15 #include "linkkit/infra/infra_compat.h"
16 
17 #ifndef _IN_OPT_
18 #define _IN_OPT_
19 #endif
20 #ifndef _OUT_
21 #define _OUT_
22 #endif
23 #ifndef _OUT_OPT_
24 #define _OUT_OPT_
25 #endif
26 #ifndef _INOUT_
27 #define _INOUT_
28 #endif
29 #ifndef _INOUT_OPT_
30 #define _INOUT_OPT_
31 #endif
32 
33 /** @defgroup group_os os
34  *  @{
35  */
36 #define OS_MAC_LEN              HAL_MAC_LEN
37 #define OS_ETH_ALEN             ETH_ALEN
38 #define OS_IP_LEN               (NETWORK_ADDR_LEN)
39 #define OS_MAX_PASSWD_LEN       HAL_MAX_PASSWD_LEN
40 #define OS_MAX_SSID_LEN         HAL_MAX_SSID_LEN
41 #define OS_PRODUCT_KEY_LEN      IOTX_PRODUCT_KEY_LEN
42 #define OS_PRODUCT_SECRET_LEN   IOTX_PRODUCT_SECRET_LEN
43 #define OS_DEVICE_NAME_LEN      IOTX_DEVICE_NAME_LEN
44 #define OS_DEVICE_SECRET_LEN    IOTX_DEVICE_SECRET_LEN
45 #define PLATFORM_AES_DECRYPTION AES_DECRYPTION
46 #define PLATFORM_AES_ENCRYPTION AES_ENCRYPTION
47 #define PLATFORM_MAX_SSID_LEN   HAL_MAX_SSID_LEN
48 #define PLATFORM_MAX_PASSWD_LEN HAL_MAX_PASSWD_LEN
49 
50 char *os_wifi_get_mac_str(char mac_str[HAL_MAC_LEN]);
51 char *os_wifi_str2mac(char mac_str[HAL_MAC_LEN], char mac[ETH_ALEN]);
52 uint8_t *os_wifi_get_mac(uint8_t mac[ETH_ALEN]);
53 uint32_t os_get_time_ms(void);
54 
55 int os_is_big_endian(void);
56 uint16_t os_htobe16(uint16_t data);
57 uint16_t os_htole16(uint16_t data);
58 uint16_t os_be16toh(uint16_t data);
59 uint16_t os_le16toh(uint16_t data);
60 uint32_t os_le32toh(uint32_t data);
61 uint16_t os_get_unaligned_be16(uint8_t *ptr);
62 uint16_t os_get_unaligned_le16(uint8_t *ptr);
63 uint32_t os_get_unaligned_be32(uint8_t *ptr);
64 uint32_t os_get_unaligned_le32(uint8_t *ptr);
65 void *awss_zalloc(uint32_t size);
66 uint32_t time_elapsed_ms_since(uint32_t start_timestamp);
67 #ifdef __cplusplus
68 }
69 #endif
70 
71 #endif /* SRC_OSA_ABSTRAC_H_ */
72