Bläddra i källkod

011 demo so 上传

zhangshenjie 1 dag sedan
förälder
incheckning
5e470783f2

+ 5 - 0
BusinessCommon/build.gradle

@@ -18,4 +18,9 @@ dependencies {
     api project(path: ':libBase')
     api project(path:':BusinessAirFryer')
     kapt  "androidx.room:room-compiler:2.4.2"
+
+//    api 'net.java.dev.jna:jna:5.15.0'
+//    api 'net.java.dev.jna:jna-platform:5.15.0'
+
+
 }

+ 23 - 8
BusinessCommon/src/main/java/com/develop/common/utils/CommonUtils.kt

@@ -158,11 +158,23 @@ object CommonUtils {
             }
 
             Log.e("TAG TUYA","url :"+url +"   json:"+json)
-            var httpResponse = TuyaUtils.ioTSDKManager.httpRequest(url, apiVersion, json)
+
+
+
+//            var httpResponse = TuyaUtils.ioTSDKManager.httpRequest(url, apiVersion, json)
+//            var str = ""
+//            if (httpResponse.errorCode == 0) {
+//                str = httpResponse.result
+//            }else{
+//                tuyaHttp.fail()
+//            }
+
+
             var str = ""
-            if (httpResponse.errorCode == 0) {
-                str = httpResponse.result
-            }else{
+            var pointer = TuyaSoUtils.tuyaApi.http_common_post_simple(url, apiVersion, json,"")
+                str = pointer.getString(0)
+
+            if (str == "") {
                 tuyaHttp.fail()
             }
             withContext(Dispatchers.Main){
@@ -213,11 +225,14 @@ object CommonUtils {
                 tuyaHttpList.fail()
                 return@launch
             }
-            var httpResponse = TuyaUtils.ioTSDKManager.httpRequest(url, apiVersion, json)
             var str = ""
-            if (httpResponse.errorCode == 0) {
-                str = httpResponse.result
-            }else{
+            var pointer = TuyaSoUtils.tuyaApi.http_common_post_simple(url, apiVersion, json,"")
+            str = pointer.getString(0)
+
+
+//            var httpResponse = TuyaUtils.ioTSDKManager.httpRequest(url, apiVersion, json)
+//            var str = ""
+            if (str == "") {
                 tuyaHttpList.fail()
             }
             withContext(Dispatchers.Main) {

+ 40 - 0
BusinessCommon/src/main/java/com/develop/common/utils/TuyaApi.java

@@ -0,0 +1,40 @@
+package com.develop.common.utils;
+import com.sun.jna.*;
+import com.sun.jna.ptr.*;
+
+public interface TuyaApi extends Library {
+
+    TuyaApi INSTANCE = Native.load("tuya_api", TuyaApi.class);
+
+
+    // 方法定义
+    int iot_httpc_common_post_simple(
+            String apiName,         // IN CONST CHAR_T *api_name
+            String apiVer,          // IN CONST CHAR_T *api_ver
+            String postData,        // IN CHAR_T *post_data
+            String pHeadOther,      // IN CONST CHAR_T *p_head_other
+            PointerByReference ppResult // OUT ty_cJSON **pp_result
+    );
+
+    // 声明原生方法
+    Pointer http_common_post_simple(
+            String apiName,    // IN CONST CHAR_T *api_name
+            String apiVer,     // IN CONST CHAR_T *api_ver
+            String postData,   // IN CHAR_T *post_data
+            String pHeadOther  // IN CONST CHAR_T *p_head_other
+    );
+
+    // 声明释放内存的方法
+    void free_memory(Pointer ptr);
+
+    // 定义回调接口
+    interface LogCallback extends Callback {
+        void invoke(String tag, String message);
+    }
+
+    // 注册日志回调函数
+    void register_log_callback(LogCallback callback);
+
+    int init(int argc,String[] argv,String pid, String uuid,String authkey, String version);
+
+}

+ 48 - 0
BusinessCommon/src/main/java/com/develop/common/utils/TuyaSoUtils.java

@@ -0,0 +1,48 @@
+package com.develop.common.utils;
+
+import android.content.Context;
+
+import com.tuya.smartai.iot_sdk.Log;
+
+public class TuyaSoUtils {
+
+    public static TuyaApi tuyaApi = TuyaApi.INSTANCE;
+
+    public static boolean init = false;
+
+    public static Context context;
+
+    public static  String mPid = "xkt4eqycakmkofec";
+    public static  String mUid = "uuid0f5a65239b9119b6";
+    public static  String mAk = "tK1YHcSdA3pyAYnlJnoprsbDbodRRomG";
+
+
+    public static void initSDK(Context ctx, String version) {
+//        tuyaApi = TuyaApi.INSTANCE;
+        context = ctx;
+        version = version;
+        //Log.init(ctx, "/sdcard/tuya_log/iot_demo/", 3);
+        baseInitSDK(ctx,version);
+    }
+
+    public static void baseInitSDK(Context ctx,String version) {
+        tuyaApi.register_log_callback(new TuyaApi.LogCallback() {
+            @Override
+            public void invoke(String tag, String message) {
+                Log.d(tag, message);
+                if (message.contains("TUYA-Cloud")) {
+                    Log.d("tuya_iot", "ddd");
+                    init = true;
+
+                }
+
+            }
+        });
+
+        tuyaApi.init(0, new String[]{},mPid,mUid,mAk,"1.0");
+
+    }
+
+
+
+}

+ 8 - 1
app/build.gradle

@@ -668,7 +668,11 @@ android {
 //        release.setRoot('build-types/release')
 //    }
 
-
+    sourceSets {
+        main {
+            jniLibs.srcDirs = ['src/main/jniLibs']
+        }
+    }
 
 
     signingConfigs {
@@ -1001,5 +1005,8 @@ dependencies {
 
     implementation project(path: ':BusinessStep') //烹饪步骤模块
 
+
+
     kapt 'com.alibaba:arouter-compiler:1.5.2'
+
 }

+ 20 - 16
app/src/main/java/com/develop/foodcooking/MainActivity.kt

@@ -1,45 +1,34 @@
 package com.develop.foodcooking
 
-import android.content.Context
 import android.os.Bundle
-import android.os.Debug
-import android.util.DisplayMetrics
-import android.util.Log
 import android.view.LayoutInflater
-import android.view.WindowManager
-import androidx.lifecycle.scopeNetLife
-import com.develop.base.ext.getGoneTuYa
+import com.develop.base.ext.appGlobalScope
 import com.develop.base.ext.globalApp
 import com.develop.base.ext.isBrand062
 import com.develop.base.ext.navigateTo
 import com.develop.base.ext.setScreenHeight
 import com.develop.base.ext.setScreenWidth
-import com.develop.base.ext.toJson
 import com.develop.base.util.MMkvUtils
 import com.develop.base.util.ScreenUtils
-import com.develop.base.util.SerialportUtils
-import com.develop.base.util.SettingKeyBoardUtils
-import com.develop.common.data_repo.db.DataFactory
 import com.develop.common.data_repo.net.Api
 import com.develop.common.data_repo.net.model.request.DeviceInfoBody
 import com.develop.common.data_repo.net.model.response.DevInfoResult
 import com.develop.common.food_sdk.FloatWindowManager
 import com.develop.common.router.Screens
-import com.develop.common.tag.CURRENT_LANGUAGE
 import com.develop.common.tag.FIRST_IN
 import com.develop.common.tag.ISTUYA
 import com.develop.common.ui.CommonBindingActivity
 import com.develop.common.utils.AppVersionUtil
 import com.develop.common.utils.ConfigUtils
+import com.develop.common.utils.TuyaSoUtils
 import com.develop.common.utils.TuyaUtils
 import com.develop.foodcooking.databinding.ActivityMainBinding
 import com.drake.net.Post
 import com.drake.net.utils.scopeNetLife
 import com.google.gson.Gson
 import com.kuyuntech.cofarcooking.device.sdk.util.core.CofarSDK
-import java.io.File
-import java.security.cert.X509Certificate
-import javax.net.ssl.TrustManager
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.launch
 
 
 class MainActivity : CommonBindingActivity<ActivityMainBinding>() {
@@ -100,10 +89,25 @@ class MainActivity : CommonBindingActivity<ActivityMainBinding>() {
 //            getAppTuya(true)
 //        }
 
-        getAppTuya(true)
+//        getAppTuya(true)
 //
 //        getDevInfo()
 
+        getSotuya()
+
+    }
+
+    fun getSotuya(){
+        appGlobalScope.launch(Dispatchers.IO) {
+
+            var pid = "xkt4eqycakmkofec"
+            var uuid = "uuid0f5a65239b9119b6"
+            var authkey = "tK1YHcSdA3pyAYnlJnoprsbDbodRRomG"
+
+            // 调用测试日志方法
+           TuyaSoUtils.initSDK(this@MainActivity,"1.0.0")
+
+        }
     }
 
     //获取是否有涂鸦功能

BIN
app/src/main/jniLibs/armeabi-v7a/libfake_pthread_cancel.so


BIN
app/src/main/jniLibs/armeabi-v7a/libjnidispatch.so


BIN
app/src/main/jniLibs/armeabi-v7a/libtuya_api.so


BIN
app/src/main/jniLibs/armeabi-v7a/libtuyaapp_components.so


BIN
app/src/main/jniLibs/armeabi-v7a/libtuyaapp_drivers.so


BIN
app/src/main/jniLibs/armeabi-v7a/libtuyaos.so


BIN
app/src/main/jniLibs/armeabi-v7a/libtuyaos_adapter.so


BIN
app/src/main/jniLibs/armeabi-v7a/libtuyaos_demo_linux_func.so


+ 1 - 0
libThirdPart/build.gradle

@@ -47,6 +47,7 @@ dependencies {
     api 'androidx.room:room-common:2.4.3'
     api 'androidx.room:room-runtime:2.4.3'
     implementation files('libs/commons-lang3-3.12.0.jar')
+    api files('libs\\jna-5.15.0.jar')
     kapt  "androidx.room:room-compiler:2.4.3"
 
     // ------------------------------优化策略-------------------------------------

BIN
libThirdPart/libs/jna-5.15.0.jar


+ 1 - 1
settings.gradle

@@ -1,4 +1,4 @@
-pluginManagement {
+    pluginManagement {
     repositories {
         maven { url 'https://jitpack.io' }
         maven { url 'https://maven.aliyun.com/nexus/content/groups/public/' }