From 1530abb812ba1d79bf8f684f42eb32983da407e9 Mon Sep 17 00:00:00 2001 From: zt222 Date: Tue, 21 Feb 2023 10:51:53 +0800 Subject: [PATCH] feat(Simcom-A7670C): Add platone to Simcom-A7670C #1377 BoATE-872 --- .../A7670CRootDirCode/sc_application.c | 64 +++++ .../sc_demo/inc/boat_platone_demo.h | 8 + .../sc_demo/inc/my_contract.cpp.abi.h | 11 + .../sc_demo/src/boat_platone_demo.c | 250 ++++++++++++++++++ .../sc_demo/src/my_contract.cpp.abi.c | 99 +++++++ .../Simcom-A7670C/BoatPlatoneDemo/README.md | 154 +++++++++++ .../BoatPlatoneDemo/README_en.md | 155 +++++++++++ 7 files changed, 741 insertions(+) create mode 100644 vendor/platform/Simcom-A7670C/BoatPlatoneDemo/A7670CRootDirCode/sc_application.c create mode 100644 vendor/platform/Simcom-A7670C/BoatPlatoneDemo/A7670CRootDirCode/sc_demo/inc/boat_platone_demo.h create mode 100644 vendor/platform/Simcom-A7670C/BoatPlatoneDemo/A7670CRootDirCode/sc_demo/inc/my_contract.cpp.abi.h create mode 100644 vendor/platform/Simcom-A7670C/BoatPlatoneDemo/A7670CRootDirCode/sc_demo/src/boat_platone_demo.c create mode 100644 vendor/platform/Simcom-A7670C/BoatPlatoneDemo/A7670CRootDirCode/sc_demo/src/my_contract.cpp.abi.c create mode 100644 vendor/platform/Simcom-A7670C/BoatPlatoneDemo/README.md create mode 100644 vendor/platform/Simcom-A7670C/BoatPlatoneDemo/README_en.md diff --git a/vendor/platform/Simcom-A7670C/BoatPlatoneDemo/A7670CRootDirCode/sc_application.c b/vendor/platform/Simcom-A7670C/BoatPlatoneDemo/A7670CRootDirCode/sc_application.c new file mode 100644 index 000000000..185e32187 --- /dev/null +++ b/vendor/platform/Simcom-A7670C/BoatPlatoneDemo/A7670CRootDirCode/sc_application.c @@ -0,0 +1,64 @@ +/** + ****************************************************************************** + * @file sc_application.c + * @author SIMCom OpenSDK Team + * @brief Source code for SIMCom OpenSDK application, void userSpace_Main(void * arg) is the app entry for OpenSDK application,customer should start application from this call. + ****************************************************************************** + * @attention + * + * Copyright (c) 2022 SIMCom Wireless. + * All rights reserved. + * + ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include +#include +#include +#include +#include +#include +#include "sc_ApiMap.h" +#include "simcom_debug.h" +#include "simcom_os.h" +#include "simcom_uart.h" + +extern void sAPP_SimcomUIDemo(void); +extern void sAPP_HelloWorldDemo(void); +extern void sAPP_UrcTask(void); +extern void sAPP_UartTask(void); +extern void sAPP_UsbVcomTask(void); +extern void sAPP_PlatoneDemo(void); + +/** + * @brief OpenSDK app entry. + * @param Pointer arg + * @note This is the app entry,like main(),all functions must start from here!!!!!! + * @retval void + */ +void userSpace_Main(void *arg) +{ + /* simcom api init. Do not modify! */ + ApiMapInit(arg); + // sAPI_enableDUMP(); + /* UI demo task for customer with CLI method for all demo running, + customer need to define SIMCOM_UI_DEMO_TO_USB_AT_PORT or + SIMCOM_UI_DEMO_TO_UART1_PORT to select hardware interface. + */ + sleep(5);//Wait for USB initialization to complete and print catstudio log. + + // sAPP_SimcomUIDemo(); + + sAPP_UartTask(); + sAPP_UrcTask(); + sAPP_UsbVcomTask(); + // sAPP_HelloWorldDemo(); + sAPP_PlatoneDemo(); + printf("user app is running..."); + +} +#define _appRegTable_attr_ __attribute__((unused, section(".userSpaceRegTable"))) + +#define appMainStackSize (1024*10) +userSpaceEntry_t userSpaceEntry _appRegTable_attr_ = {NULL, NULL, appMainStackSize, 30, "userSpaceMain", userSpace_Main, NULL }; \ No newline at end of file diff --git a/vendor/platform/Simcom-A7670C/BoatPlatoneDemo/A7670CRootDirCode/sc_demo/inc/boat_platone_demo.h b/vendor/platform/Simcom-A7670C/BoatPlatoneDemo/A7670CRootDirCode/sc_demo/inc/boat_platone_demo.h new file mode 100644 index 000000000..bdf8a01bc --- /dev/null +++ b/vendor/platform/Simcom-A7670C/BoatPlatoneDemo/A7670CRootDirCode/sc_demo/inc/boat_platone_demo.h @@ -0,0 +1,8 @@ +#ifndef __MBTK_BOAT_PLATONE_DEMO_H__ +#define __MBTK_BOAT_PLATONE_DEMO_H__ + +#include "boattypes.h" + +BOAT_RESULT PlatoneDemo(void); + +#endif diff --git a/vendor/platform/Simcom-A7670C/BoatPlatoneDemo/A7670CRootDirCode/sc_demo/inc/my_contract.cpp.abi.h b/vendor/platform/Simcom-A7670C/BoatPlatoneDemo/A7670CRootDirCode/sc_demo/inc/my_contract.cpp.abi.h new file mode 100644 index 000000000..a74f355cb --- /dev/null +++ b/vendor/platform/Simcom-A7670C/BoatPlatoneDemo/A7670CRootDirCode/sc_demo/inc/my_contract.cpp.abi.h @@ -0,0 +1,11 @@ +/****************************************************************************** +This file is generated from contract ABI. DO NOT modify it by hand. +******************************************************************************/ + + +// Generated C function interface from smart contract ABI + +#include "boatiotsdk.h" + +BCHAR * my_contract_cpp_abi_setName(BoatPlatoneTx *tx_ptr, BCHAR* msg); +BCHAR * my_contract_cpp_abi_getName(BoatPlatoneTx *tx_ptr); diff --git a/vendor/platform/Simcom-A7670C/BoatPlatoneDemo/A7670CRootDirCode/sc_demo/src/boat_platone_demo.c b/vendor/platform/Simcom-A7670C/BoatPlatoneDemo/A7670CRootDirCode/sc_demo/src/boat_platone_demo.c new file mode 100644 index 000000000..3f62c93ec --- /dev/null +++ b/vendor/platform/Simcom-A7670C/BoatPlatoneDemo/A7670CRootDirCode/sc_demo/src/boat_platone_demo.c @@ -0,0 +1,250 @@ +/* Copyright (C) 2018 RDA Technologies Limited and/or its affiliates("RDA"). + * All rights reserved. + * + * This software is supplied "AS IS" without any warranties. + * RDA assumes no responsibility or liability for the use of the software, + * conveys no license or title under any patent, copyright, or mask work + * right to the product. RDA reserves the right to make changes in the + * software without notification. RDA also make no representation or + * warranty that such application will be suitable for the specified use + * without further testing or modification. + */ + +#include "stdio.h" +#include "stdlib.h" +#include "string.h" +#include "api_platone.h" +#include "boatiotsdk.h" +#include "my_contract.cpp.abi.h" +#include "simcom_os.h" +#include "simcom_ntp_client.h" +#include "simcom_debug.h" + +sTaskRef PlatoneProcesser; +static UINT8 PlatoneProcesserStack[30 * 1024]; +sMsgQRef ntpUIResp_msgq; + +const char *native_demoKey = "0xfcf6d76706e66250dbacc9827bc427321edb9542d58a74a67624b253960465ca"; + +/** + * test node url + */ +const BCHAR *demoUrl = "http://116.236.47.90:7545"; + +/** + * transfer recipient address + */ +const BCHAR *demoRecipientAddress = "0xaac9fb1d70ee0d4b5a857a28b9c3b16114518e45"; + +BoatPlatoneWallet *g_platone_wallet_ptr; +BUINT8 keypairIndex = 0; +BUINT8 networkIndex = 0; + +__BOATSTATIC BOAT_RESULT platone_createKeypair(BCHAR *keypairName) +{ + BOAT_RESULT result = BOAT_SUCCESS; + BoatKeypairPriKeyCtx_config keypair_config = {0}; + BUINT8 binFormatKey[32] = {0}; + + (void)binFormatKey; //avoid warning + + //sAPI_Debug(">>>>>>>>>> wallet format: external injection[native]."); + keypair_config.prikey_genMode = BOAT_KEYPAIR_PRIKEY_GENMODE_EXTERNAL_INJECTION; + keypair_config.prikey_format = BOAT_KEYPAIR_PRIKEY_FORMAT_NATIVE; + keypair_config.prikey_type = BOAT_KEYPAIR_PRIKEY_TYPE_SECP256K1; + UtilityHexToBin(binFormatKey, 32, native_demoKey, TRIMBIN_TRIM_NO, BOAT_FALSE); + keypair_config.prikey_content.field_ptr = binFormatKey; + keypair_config.prikey_content.field_len = 32; + + /* create platone wallet */ + result = BoatKeypairCreate( &keypair_config, keypairName,BOAT_STORE_TYPE_RAM); + + if (result < 0) + { + //sAPI_Debug("create one-time keypair failed."); + return BOAT_ERROR_WALLET_CREATE_FAIL; + } + keypairIndex = result; + + return BOAT_SUCCESS; +} + +__BOATSTATIC BOAT_RESULT createOnetimeNetwork(void) +{ + BOAT_RESULT result = BOAT_SUCCESS; + BoatPlatoneNetworkConfig network_config = {0}; + + network_config.chain_id = 1; + network_config.eip155_compatibility = BOAT_FALSE; + strncpy(network_config.node_url_str, demoUrl, BOAT_PLATONE_NODE_URL_MAX_LEN - 1); + + /* create platone network */ + result = BoatPlatoneNetworkCreate( &network_config, BOAT_STORE_TYPE_RAM); + + if (result < 0) + { + //sAPI_Debug("create one-time wallet failed."); + return BOAT_ERROR_WALLET_CREATE_FAIL; + } + networkIndex = result; + + return BOAT_SUCCESS; +} + +BOAT_RESULT platone_call_mycontract(BoatPlatoneWallet *wallet_ptr) +{ + BCHAR *result_str; + BoatPlatoneTx tx_ctx; + BOAT_RESULT result; + + /* Set Contract Address */ + result = BoatPlatoneTxInit(wallet_ptr, &tx_ctx, BOAT_TRUE, NULL, + "0x333333", + (BCHAR *)demoRecipientAddress, + BOAT_PLATONE_TX_TYPE_CONTRACT_NULL_TERMED_STR); + + if (result != BOAT_SUCCESS) + { + //sAPI_Debug("BoatPlatoneTxInit fails."); + return BOAT_ERROR_WALLET_INIT_FAIL; + } + + result_str = my_contract_cpp_abi_setName(&tx_ctx, "HelloWorld"); + if (result_str == NULL) + { + //sAPI_Debug("my_contract_cpp_abi_setName failed: %s.", result_str); + return BOAT_ERROR; + } + //sAPI_Debug("setName returns: %s", result_str); + + result_str = my_contract_cpp_abi_getName(&tx_ctx); + if (result_str == NULL) + { + //sAPI_Debug("my_contract_cpp_abi_getName failed: %s.", result_str); + return BOAT_ERROR; + } + //sAPI_Debug("getName returns: %s", result_str); + + return BOAT_SUCCESS; +} + +BOAT_RESULT PlatoneDemo(void) +{ + BOAT_RESULT result = BOAT_SUCCESS; + boat_try_declare; + /* step-1: Boat SDK initialization */ + BoatIotSdkInit(); + + /* step-2: create platone wallet */ + //sAPI_Debug(">>>>>>>>>> wallet type: create one-time wallet."); + result = platone_createKeypair("keypair00"); + if (result != BOAT_SUCCESS) + { + //sAPI_Debug("platoneWalletPrepare_create failed : %d.", result); + //return -1; + boat_throw(result, platone_demo_catch); + } + result = createOnetimeNetwork(); + if (result != BOAT_SUCCESS) + { + //sAPI_Debug("platoneWalletPrepare_create failed : %d.", result); + //return -1; + boat_throw(result, platone_demo_catch); + } + if (result != BOAT_SUCCESS) + { + //sAPI_Debug("platoneWalletPrepare_create failed : %d.", result); + //return -1; + boat_throw(result, platone_demo_catch); + } + g_platone_wallet_ptr = BoatPlatoneWalletInit(keypairIndex,networkIndex); + if(g_platone_wallet_ptr == NULL){ + // sAPI_Debug("BoatPlatoneWalletInit fail"); + boat_throw(BOAT_ERROR, platone_demo_catch); + } + /* step-3: execute 'platone_call_mycontract' */ + result = platone_call_mycontract(g_platone_wallet_ptr); + if (result != BOAT_SUCCESS) + { + //sAPI_Debug("platone mycontract access Failed: %d.", result); + } + else + { + //sAPI_Debug("platone mycontract access Passed."); + } + boat_catch(platone_demo_catch) + { + } + /* step-4: Boat SDK Deinitialization */ + BoatIotSdkDeInit(); + + return result; +} + +BOAT_RESULT NtpService(void) +{ + SCsysTime_t currUtcTime; + char buff[220]={0}; + BOAT_RESULT result = BOAT_SUCCESS; + + // SIM_MSG_T ntp_result = {SC_SRV_NONE, -1, 0, NULL}; + if(NULL == ntpUIResp_msgq) + { + SC_STATUS status; + status = sAPI_MsgQCreate(&ntpUIResp_msgq, "ntpUIResp_msgq", sizeof(SIM_MSG_T), 4, SC_FIFO); + if(SC_SUCCESS != status) + { + sAPI_Debug("[CNTP]msgQ create fail\n"); + sAPI_Debug("\r\nNTP Update Fail!\r\n"); + } + } + + memset(&currUtcTime,0,sizeof(currUtcTime)); + + sAPI_GetSysLocalTime(&currUtcTime); + sAPI_Debug("[CNTP] sAPI_GetSysLocalTime %d - %d - %d - %d : %d : %d %d\n",currUtcTime.tm_year,currUtcTime.tm_mon,currUtcTime.tm_mday, + currUtcTime.tm_hour,currUtcTime.tm_min,currUtcTime.tm_sec,currUtcTime.tm_wday); + result = sAPI_NtpUpdate(SC_NTP_OP_SET, "ntp3.aliyun.com", 32, NULL); //Unavailable addr may cause long time suspend + sAPI_Debug("SC_NTP_OP_SET result[%d]\n",result); + + result = sAPI_NtpUpdate(SC_NTP_OP_GET, buff, 0, NULL); + sAPI_Debug("SC_NTP_OP_GET result[%d] buff[%s]\n", result, buff); + + result = sAPI_NtpUpdate(SC_NTP_OP_EXC, NULL, 0, ntpUIResp_msgq); + sAPI_Debug("SC_NTP_OP_EXC result[%d]\n",result ); + + memset(&currUtcTime,0,sizeof(currUtcTime)); + sAPI_GetSysLocalTime(&currUtcTime); + sAPI_Debug("[CNTP] sAPI_GetSysLocalTime %d - %d - %d - %d : %d : %d %d\n",currUtcTime.tm_year,currUtcTime.tm_mon,currUtcTime.tm_mday, + currUtcTime.tm_hour,currUtcTime.tm_min,currUtcTime.tm_sec,currUtcTime.tm_wday); + + return result; +} + +void sTask_PlatoneProcesser(void* argv) +{ + BOAT_RESULT result = BOAT_SUCCESS; + sAPI_DelayUs(3000000); + result = NtpService(); + if(result != BOAT_SUCCESS) + { + sAPI_Debug("NTP get time failed : %d.", result); + } + result = PlatoneDemo(); + if(result != BOAT_SUCCESS) + { + sAPI_Debug("Platone Demo failed : %d.", result); + } + +} + +void sAPP_PlatoneDemo(void) +{ + SC_STATUS status = SC_SUCCESS; + + status = sAPI_TaskCreate(&PlatoneProcesser, PlatoneProcesserStack, 30 * 1024, 150, "PlatoneProcesser",sTask_PlatoneProcesser,(void *)0); + if(SC_SUCCESS != status) + { + sAPI_Debug("Task create fail,status = [%d]",status); + } +} \ No newline at end of file diff --git a/vendor/platform/Simcom-A7670C/BoatPlatoneDemo/A7670CRootDirCode/sc_demo/src/my_contract.cpp.abi.c b/vendor/platform/Simcom-A7670C/BoatPlatoneDemo/A7670CRootDirCode/sc_demo/src/my_contract.cpp.abi.c new file mode 100644 index 000000000..f0bfcc5c7 --- /dev/null +++ b/vendor/platform/Simcom-A7670C/BoatPlatoneDemo/A7670CRootDirCode/sc_demo/src/my_contract.cpp.abi.c @@ -0,0 +1,99 @@ +/****************************************************************************** +This file is generated from contract ABI. DO NOT modify it by hand. +******************************************************************************/ + + +// Generated C function interface from smart contract ABI + +#include "boatiotsdk.h" +#include "api_platone.h" + +BCHAR * my_contract_cpp_abi_setName(BoatPlatoneTx *tx_ptr, BCHAR* msg) +{ + static BCHAR tx_hash_str[67] = ""; + BoatFieldVariable data_field; + RlpEncodedStreamObject * rlp_stream_ptr; + RlpObject rlp_object_list; + RlpObject rlp_object_txtype; + BUINT64 txtype; + RlpObject rlp_object_string_func_name; + RlpObject rlp_object_string_msg; + boat_try_declare; + + boat_try(BoatPlatoneTxSetNonce(tx_ptr, BOAT_PLATONE_NONCE_AUTO)); + + boat_try(RlpInitListObject(&rlp_object_list)); + + txtype = tx_ptr->rawtx_fields.txtype; + boat_try(RlpInitStringObject(&rlp_object_txtype, UtilityChangeEndian(&txtype, sizeof(txtype)), sizeof(txtype))); + boat_try(0 > RlpEncoderAppendObjectToList(&rlp_object_list, &rlp_object_txtype)); + + boat_try(RlpInitStringObject(&rlp_object_string_func_name, (BUINT8*)"setName", strlen("setName"))); + boat_try(0 > RlpEncoderAppendObjectToList(&rlp_object_list, &rlp_object_string_func_name)); + + boat_try(RlpInitStringObject(&rlp_object_string_msg, (BUINT8*)msg, strlen(msg))); + boat_try(0 > RlpEncoderAppendObjectToList(&rlp_object_list, &rlp_object_string_msg)); + + boat_try(RlpEncode(&rlp_object_list, NULL)); + + rlp_stream_ptr = RlpGetEncodedStream(&rlp_object_list); + + data_field.field_ptr = rlp_stream_ptr->stream_ptr; + data_field.field_len = rlp_stream_ptr->stream_len; + boat_try(BoatPlatoneTxSetData(tx_ptr, &data_field)); + + boat_try(BoatPlatoneTxSend(tx_ptr)); + + UtilityHexToBin((BUINT8 *)tx_hash_str, tx_ptr->tx_hash.field_len, (BCHAR *)tx_ptr->tx_hash.field,TRIMBIN_TRIM_NO, BOAT_FALSE); + + + boat_catch(cleanup) + { + //BoatLog(BOAT_LOG_VERBOSE, "Exception: %d", boat_exception); + RlpRecursiveDeleteObject(&rlp_object_list); + return(NULL); + } + + RlpRecursiveDeleteObject(&rlp_object_list); + return(tx_hash_str); + +} + +BCHAR * my_contract_cpp_abi_getName(BoatPlatoneTx *tx_ptr) +{ + BCHAR *call_result_str = NULL; + RlpEncodedStreamObject * rlp_stream_ptr; + RlpObject rlp_object_list; + RlpObject rlp_object_txtype; + BUINT64 txtype; + RlpObject rlp_object_string_func_name; + boat_try_declare; + + boat_try(RlpInitListObject(&rlp_object_list)); + + txtype = tx_ptr->rawtx_fields.txtype; + boat_try(RlpInitStringObject(&rlp_object_txtype, UtilityChangeEndian(&txtype, sizeof(txtype)), sizeof(txtype))); + boat_try(0 > RlpEncoderAppendObjectToList(&rlp_object_list, &rlp_object_txtype)); + + boat_try(RlpInitStringObject(&rlp_object_string_func_name, (BUINT8*)"getName", strlen("getName"))); + boat_try(0 > RlpEncoderAppendObjectToList(&rlp_object_list, &rlp_object_string_func_name)); + + boat_try(RlpEncode(&rlp_object_list, NULL)); + + rlp_stream_ptr = RlpGetEncodedStream(&rlp_object_list); + + call_result_str = BoatPlatoneCallContractFunc(tx_ptr, rlp_stream_ptr->stream_ptr, rlp_stream_ptr->stream_len); + + + boat_catch(cleanup) + { + // BoatLog(BOAT_LOG_VERBOSE, "Exception: %d", boat_exception); + RlpRecursiveDeleteObject(&rlp_object_list); + return(NULL); + } + + RlpRecursiveDeleteObject(&rlp_object_list); + return(call_result_str); + +} + diff --git a/vendor/platform/Simcom-A7670C/BoatPlatoneDemo/README.md b/vendor/platform/Simcom-A7670C/BoatPlatoneDemo/README.md new file mode 100644 index 000000000..51ab40fb3 --- /dev/null +++ b/vendor/platform/Simcom-A7670C/BoatPlatoneDemo/README.md @@ -0,0 +1,154 @@ +# BoAT-X-Framework for 芯讯通A7670C整合说明 + + +## 一、前言 + +本文档说明如何在A7670C开发环境中整合BoAT-X-Framework,编译BoAT-X-Framework静态库,以及生成demo程序。 + + +## 二、拷贝文件 + +约定``是A7670C平台SDK的根目录: + +1、拷贝 BoAT代码,将 BoAT-X-Framework 整个文件夹拷贝至``下。 + +2、拷贝并覆盖 `BoAT-X-Framework/vendor/platform/Simcom-A7670C/BoatPlatoneDemo/A7670CRootDirCode/sc_demo`到``下。 + +3、拷贝并覆盖 `BoAT-X-Framework/vendor/platform/Simcom-A7670C/BoatPlatoneDemo/A7670CRootDirCode/sc_application.c`到``下。 + +拷贝后的目录和文件结构如下: +``` + +|-- BoAT-X-Framework +|-- config +|-- examples +|-- kernel +|-- sc_lib +|-- script +|-- tools +|-- app_build_doc.md +|-- CMakeLists.txt +|-- makeDepend.mak +|-- Makefile +|-- sc_application.c +`-- sc_demo + |-- inc + | |-- demo_lcd.h + | |-- boat_platone_demo.h + | |-- my_contract.cpp.abi.h + |-- src + | |-- token + | |-- utils + | |-- cus_uart.c + | |-- cus_urc.c + | |-- cus_usb_vcom.c + | |-- demo_app_download.c + | |-- demo_app_updater.c + | |-- demo_audio.c + | |-- demo_auto_mqtt.c + | |-- demo_ble.c + | |-- demo_call.c + | |-- demo_cam.c + | |-- demo_file_system.c + | |-- demo_flash.c + | |-- demo_fota.c + | |-- demo_ftps.c + | |-- demo_ftps_test.c + | |-- demo_gpio.c + | |-- demo_gps.c + | |-- demo_helloworld.c + | |-- demo_htp.c + | |-- demo_https.c + | |-- demo_i2c.c + | |-- demo_lcd.c + | |-- demo_mqtt.c + | |-- demo_network.c + | |-- demo_ntp.c + | |-- boat_platone_demo.c + | |-- demo_pm.c + | |-- demo_poc.c + | |-- demo_pwm.c + | |-- demo_simcard.c + | |-- demo_sms.c + | |-- demo_spi.c + | |-- demo_ssl.c + | |-- demo_ssl_test.c + | |-- demo_tcpip.c + | |-- demo_uart.c + | |-- demo_wifi.c + | |-- mqtt_OneNET.c + | |-- mqtt_tencent.c + | |-- my_contract.cpp.abi.c + | |-- simcom_demo.c + |-- CMakeLists.txt +``` + + +## 三、文件修改 + +### 1、添加BoAT-X-Framework生成的静态库.a文件到A7670C平台 + + 打开`/CMakeLists.txt`文件。 + + 首先找到 + ``` + set_property(TARGET third_libs APPEND PROPERTY IMPORTED_OBJECTS + "${CMAKE_SOURCE_DIR}/sc_lib/${SCMODULE}/lib/libsc_lib.a" + ) + endif() + endif() + ``` + 然后在下方添加以下内容: + ``` + set_property(TARGET third_libs APPEND PROPERTY IMPORTED_OBJECTS + "${CMAKE_SOURCE_DIR}/BoAT-X-Framework/lib/libboatwallet.a" + ) + set_property(TARGET third_libs APPEND PROPERTY IMPORTED_OBJECTS + "${CMAKE_SOURCE_DIR}/BoAT-X-Framework/lib/libboatvendor.a" + ) + ``` + +### 2、添加BoAT-X-Framework有关头文件路径到A7670C平台 + + 打开`/sc_demo/CMakeLists.txt`文件。 + + 首先找到 `${CMAKE_SOURCE_DIR}/sc_demo/inc`,然后在下方添加以下内容: + ``` + ${CMAKE_SOURCE_DIR}/BoAT-X-Framework/include + ${CMAKE_SOURCE_DIR}/BoAT-X-Framework/include/protocolapi + ${CMAKE_SOURCE_DIR}/BoAT-X-Framework/vendor/platform/include + ${CMAKE_SOURCE_DIR}/BoAT-X-Framework/sdk/network/platone + ``` + + +## 四、编译BoAT-X-Framework静态库 + +### 1、在Cygwin环境下编译BoAT-X-Framework静态库.a文件 + + #### a、修改BoAT-X-Framework/Makefile中的target + ``` + PLATFORM_TARGET ?= Simcom-A7670C + ``` + + #### b、打开Cygwin终端进入BoAT-X-Framework目录编译BoAT静态库 + ``` + cd /BoAT-X-Framework + ../tools/win32/GNUmake.exe clean + ../tools/win32/GNUmake.exe all + ``` + + 编译成功后,在BoAT-X-Framework/lib下会生成静态库`libboatvendor.a`、`libboatwallet.a`。 + + +### 2、编译A7670C演示demo程序,生成.zip下载文件 + + 通过BoAT-X-Framework访问区块链的演示代码,在`/sc_demo/src/boat_platone_demo.c`。 + + 打开windows终端进入`` + ``` + cd + make clean + make A7670C_LANS + ``` + + 编译成功会在`/out`下生成`A7670C_LANS.zip`下载文件。 \ No newline at end of file diff --git a/vendor/platform/Simcom-A7670C/BoatPlatoneDemo/README_en.md b/vendor/platform/Simcom-A7670C/BoatPlatoneDemo/README_en.md new file mode 100644 index 000000000..fc3f52f7e --- /dev/null +++ b/vendor/platform/Simcom-A7670C/BoatPlatoneDemo/README_en.md @@ -0,0 +1,155 @@ +# BoAT-X Framework for Simcom A7670C Integration Guideline + + +## About This Guideline + +This guide describes how to integrate BoAT-X Framework source code into A7670C SDK, compile BoAT-X Framework static library and build the demo program under Windows environment. + + +## Copy files + +Assuming `` to be the root directory of A7670C SDK: + +1. Copy the entire BoAT-X-Framework directory into `/app`. + +2. Copy `BoAT-X-Framework/vendor/platform/Simcom-A7670C/BoatPlatoneDemo/A7670CRootDirCode/sc_demo` into ``. + +3. Copy `BoAT-X-Framework/vendor/platform/Simcom-A7670C/BoatPlatoneDemo/A7670CRootDirCode/sc_application.c` into ``. + + +After these files copied, the directory structure should look like: +``` + +|-- BoAT-X-Framework +|-- config +|-- examples +|-- kernel +|-- sc_lib +|-- script +|-- tools +|-- app_build_doc.md +|-- CMakeLists.txt +|-- makeDepend.mak +|-- Makefile +|-- sc_application.c +`-- sc_demo + |-- inc + | |-- demo_lcd.h + | |-- boat_platone_demo.h + | |-- my_contract.cpp.abi.h + |-- src + | |-- token + | |-- utils + | |-- cus_uart.c + | |-- cus_urc.c + | |-- cus_usb_vcom.c + | |-- demo_app_download.c + | |-- demo_app_updater.c + | |-- demo_audio.c + | |-- demo_auto_mqtt.c + | |-- demo_ble.c + | |-- demo_call.c + | |-- demo_cam.c + | |-- demo_file_system.c + | |-- demo_flash.c + | |-- demo_fota.c + | |-- demo_ftps.c + | |-- demo_ftps_test.c + | |-- demo_gpio.c + | |-- demo_gps.c + | |-- demo_helloworld.c + | |-- demo_htp.c + | |-- demo_https.c + | |-- demo_i2c.c + | |-- demo_lcd.c + | |-- demo_mqtt.c + | |-- demo_network.c + | |-- demo_ntp.c + | |-- boat_platone_demo.c + | |-- demo_pm.c + | |-- demo_poc.c + | |-- demo_pwm.c + | |-- demo_simcard.c + | |-- demo_sms.c + | |-- demo_spi.c + | |-- demo_ssl.c + | |-- demo_ssl_test.c + | |-- demo_tcpip.c + | |-- demo_uart.c + | |-- demo_wifi.c + | |-- mqtt_OneNET.c + | |-- mqtt_tencent.c + | |-- my_contract.cpp.abi.c + | |-- simcom_demo.c + |-- CMakeLists.txt +``` + + +## File Modification + +### 1. Add BoAT-X-Framework static libraries .a files onto A7670C platform + + Open `/CMakeLists.txt`. + + Find + ``` + set_property(TARGET third_libs APPEND PROPERTY IMPORTED_OBJECTS + "${CMAKE_SOURCE_DIR}/sc_lib/${SCMODULE}/lib/libsc_lib.a" + ) + endif() + endif() + ``` + add the following content in the last new line: + ``` + set_property(TARGET third_libs APPEND PROPERTY IMPORTED_OBJECTS + "${CMAKE_SOURCE_DIR}/BoAT-X-Framework/lib/libboatwallet.a" + ) + set_property(TARGET third_libs APPEND PROPERTY IMPORTED_OBJECTS + "${CMAKE_SOURCE_DIR}/BoAT-X-Framework/lib/libboatvendor.a" + ) + ``` + +### 2. Add the BoAT-X-Framework header files + + Open `/sc_demo/CMakeLists.txt`. + + Find `${CMAKE_SOURCE_DIR}/sc_demo/inc`, add the following content in the last new line: + ``` + ${CMAKE_SOURCE_DIR}/BoAT-X-Framework/include + ${CMAKE_SOURCE_DIR}/BoAT-X-Framework/include/protocolapi + ${CMAKE_SOURCE_DIR}/BoAT-X-Framework/vendor/platform/include + ${CMAKE_SOURCE_DIR}/BoAT-X-Framework/sdk/network/platone + ``` + + +## Compile BoAT-X-Framework Static library + +### 1. Compile BoAT-X Framework static library (under Cygwin) + + #### a. Configure the target platform in directory BoAT-X-Framework/Makefile + ``` + PLATFORM_TARGET ?= Simcom-A7670C + ``` + + #### b. Open a Cygwin shell, enter /BoAT-X-Framework directory and compile BoAT static library + ``` + cd /BoAT-X-Framework + ../tools/win32/GNUmake.exe clean + ../tools/win32/GNUmake.exe all + ``` + + After compiling, static library `libboatvendor.a` and `libboatwallet.a` will be created in `/BoAT-X-Framework/lib` directory. + + +### 2. Build demo program, generate .zip file for download + + Demo code for accessing blockchain through BoAT-X Framework is in `/sc_demo/src/boat_platone_demo.c`。 + + Open a Windows cmd window and build the download file: + ``` + cd + make clean + make A7670C_LANS + ``` + + The download file `A7670C_LANS.zip` will be generated under `/out` once compiled successfully. \ No newline at end of file