1 /* 2 * Copyright (C) 2015-2020 Alibaba Group Holding Limited 3 */ 4 5 #ifndef AMP_DEFINES_H 6 #define AMP_DEFINES_H 7 8 #include "amp_config.h" 9 #include "amp_memory.h" 10 #include "mbedtls/md5.h" 11 #include "mbedtls/sha1.h" 12 #include "mbedtls/aes.h" 13 #include "mbedtls/des.h" 14 #include "mbedtls/base64.h" 15 #include "ulog/ulog.h" 16 #include "aos_fs.h" 17 18 #define AMP_APP_MAIN_JS AMP_FS_ROOT_DIR"/app.js" 19 #define AMP_APP_MAIN_JSB AMP_FS_ROOT_DIR"/app.jsb" 20 #define AMP_APP_MAIN_JSON AMP_FS_ROOT_DIR"/app.json" 21 #define AMP_APP_PACKAGE_JSON AMP_FS_ROOT_DIR"/package.json" 22 #define AMP_APP_INDEX_JS AMP_FS_ROOT_DIR"/index.js" 23 24 typedef enum { 25 HAL_SEEK_SET, 26 HAL_SEEK_CUR, 27 HAL_SEEK_END 28 } hal_fs_seek_type_t; 29 30 /* sdk version */ 31 #define AMP_VERSION_LENGTH 128 32 #define AMP_VERSION_NUMBER "3.0.1" 33 #define AMP_GIT_COMMIT "g9c40fab" 34 #define AMP_MODULE_HARDWARE aos_get_module_hardware_version() 35 #define AMP_MODULE_SOFTWARE aos_get_module_software_version() 36 37 /* interval device infomation */ 38 #define AMP_DEVICE_TOKEN "_amp_device_token" 39 #define AMP_DEVICE_TOKEN_VERIFY_FLAG "_amp_device_token_verify_flag" 40 #define AMP_DEVICE_TOKEN_LENGTH 64 41 42 #define AMP_INTERNAL_PRODUCTKEY "_amp_internal_productkey" 43 #define AMP_INTERNAL_PRODUCTSECRET "_amp_internal_productsecret" 44 #define AMP_INTERNAL_DEVICENAME "_amp_internal_devicename" 45 #define AMP_INTERNAL_DEVICESECRET "_amp_internal_devicesecret" 46 47 /* customer device infomation */ 48 #define AMP_CUSTOMER_PRODUCTKEY "_amp_customer_productkey" 49 #define AMP_CUSTOMER_PRODUCTSECRET "_amp_customer_productsecret" 50 #define AMP_CUSTOMER_DEVICENAME "_amp_customer_devicename" 51 #define AMP_CUSTOMER_DEVICESECRET "_amp_customer_devicesecret" 52 53 #define osWaitForever 0xFFFFFFFF /* wait forever timeout value */ 54 #define PLATFORM_WAIT_INFINITE (~0) 55 56 #define IOTX_PRODUCT_KEY_LEN (20) 57 #define IOTX_DEVICE_NAME_LEN (32) 58 #define IOTX_DEVICE_SECRET_LEN (64) 59 #define IOTX_PRODUCT_SECRET_LEN (64) 60 61 /* task stack size */ 62 #define JSENGINE_TASK_STACK_SIZE 1024 * 15 63 64 /* task priority */ 65 #define JSE_TSK_PRIORITY AOS_DEFAULT_APP_PRI + 5 66 #define CLI_TSK_PRIORITY AOS_DEFAULT_APP_PRI + 7 67 #define MQTT_TSK_PRIORITY AOS_DEFAULT_APP_PRI + 6 68 #define MQTTHTTP_TSK_PRIORITY AOS_DEFAULT_APP_PRI + 4 69 #define SSDP_TSK_PRIORITY AOS_DEFAULT_APP_PRI + 3 70 #define WEBSOCKET_TSK_PRIORITY AOS_DEFAULT_APP_PRI + 4 71 #define WIFI_TSK_PRIORITY AOS_DEFAULT_APP_PRI + 4 72 #define UPDATE_TSK_PRIORITY AOS_DEFAULT_APP_PRI + 6 73 #define ADDON_TSK_PRIORRITY AOS_DEFAULT_APP_PRI + 3 74 75 /* log system operation wrapper */ 76 #define amp_debug(mod, fmt, ...) LOGD(mod, fmt, ##__VA_ARGS__) 77 #define amp_info(mod, fmt, ...) LOGI(mod, fmt, ##__VA_ARGS__) 78 #define amp_warn(mod, fmt, ...) LOGW(mod, fmt, ##__VA_ARGS__) 79 #define amp_error(mod, fmt, ...) LOGE(mod, fmt, ##__VA_ARGS__) 80 #define amp_fatal(mod, fmt, ...) LOGF(mod, fmt, ##__VA_ARGS__) 81 82 /* JS console stdout */ 83 #if defined(AMP_REPL_ENABLE) && defined(AMP_REPL_STDIO_EXTERNAL) 84 #define amp_console(fmt, ...) do { \ 85 repl_printf(fmt, ##__VA_ARGS__); \ 86 repl_printf("\r\n"); \ 87 }while(0) 88 #else 89 #define amp_console(fmt, ...) do { \ 90 aos_printf(fmt, ##__VA_ARGS__); \ 91 aos_printf("\r\n"); \ 92 }while(0) 93 #endif 94 /* md5 */ 95 #define amp_md5_context mbedtls_md5_context 96 #define amp_md5 mbedtls_md5 97 #define amp_md5_init mbedtls_md5_init 98 #define amp_md5_starts mbedtls_md5_starts 99 #define amp_md5_update mbedtls_md5_update 100 #define amp_md5_finish mbedtls_md5_finish 101 #define amp_md5_free mbedtls_md5_free 102 103 /* sha1 */ 104 #define amp_sha1_context mbedtls_sha1_context 105 #define amp_sha1_init mbedtls_sha1_init 106 #define amp_sha1_starts mbedtls_sha1_starts 107 #define amp_sha1_update mbedtls_sha1_update 108 #define amp_sha1_finish mbedtls_sha1_finish 109 #define amp_sha1_free mbedtls_sha1_free 110 111 /* aes */ 112 #define AMP_AES_ENCRYPT MBEDTLS_AES_ENCRYPT 113 #define AMP_AES_DECRYPT MBEDTLS_AES_DECRYPT 114 #define amp_aes_context mbedtls_aes_context 115 #define amp_aes_init mbedtls_aes_init 116 #define amp_aes_setkey_enc mbedtls_aes_setkey_enc 117 #define amp_aes_setkey_dec mbedtls_aes_setkey_dec 118 #define amp_aes_crypt_cbc mbedtls_aes_crypt_cbc 119 #define amp_aes_free mbedtls_aes_free 120 121 /* des */ 122 #define amp_des_context mbedtls_des_context 123 #define amp_des_init mbedtls_des_init 124 #define amp_des_setkey_enc mbedtls_des_setkey_enc 125 #define amp_des_crypt_ecb mbedtls_des_crypt_ecb 126 #define amp_des_free mbedtls_des_free 127 128 /* base64 */ 129 #define amp_base64_encode mbedtls_base64_encode 130 #define amp_base64_decode mbedtls_base64_decode 131 132 #endif /* AMP_DEFINES_H */ 133