HarmonyOS智慧設(shè)備開發(fā)-onehopdeviceAbil_第1頁
HarmonyOS智慧設(shè)備開發(fā)-onehopdeviceAbil_第2頁
HarmonyOS智慧設(shè)備開發(fā)-onehopdeviceAbil_第3頁
HarmonyOS智慧設(shè)備開發(fā)-onehopdeviceAbil_第4頁
HarmonyOS智慧設(shè)備開發(fā)-onehopdeviceAbil_第5頁
已閱讀5頁,還剩2頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡介

1、HarmonyOS智慧設(shè)備開發(fā)-onehop device Ability學(xué)習(xí)體驗(yàn)技術(shù)相關(guān)項(xiàng)目名稱: onehop_device項(xiàng)目語言: JAVA體驗(yàn)?zāi)0澹?onehop device Ability工具:deveco studio二、效果如下 注:由于沒有實(shí)際設(shè)備連接所以模板無法顯示控制頁面。三、開發(fā)步驟建立項(xiàng)目新建一個(gè)java的應(yīng)用項(xiàng)目然后構(gòu)建完成項(xiàng)目后在jltf_template下new-module 選擇phone下的onehop device Ability模板 登錄你的賬號(hào)然后啟動(dòng)模擬器即可實(shí)現(xiàn)效果項(xiàng)目介紹該模板用于碰一碰FA低代碼開發(fā),只需要修改少量的參數(shù)就可以實(shí)現(xiàn)碰一碰的配網(wǎng)

2、、控制以及頁面布局開發(fā)。缺點(diǎn):設(shè)備端無法主動(dòng)傳輸數(shù)據(jù)到FA。項(xiàng)目結(jié)構(gòu)如下:控制設(shè)備部分:配網(wǎng)部分:部分代碼(部分接口)var FANetConfig = / 是否支持WifiAware isSupportWifiAware: function () return callAbility(CONSTANT.IS_SUPPORT_WIFI_AWARE, ); , discoveryByNAN: function (scanInfo, callbackFunc) if (!(typeof scanInfo.duration = number & scanInfo.duration % 1 = 0)

3、console.error(NetConfig# call discoveryByNAN failed, parameter duration type should be integer.); return; if (!(typeof scanInfo.lockTime = number & scanInfo.lockTime % 1 = 0) console.error(NetConfig# call discoveryByNAN failed, parameter lockTime type should be integer.); return; if (typeof callback

4、Func != function) console.error(NetConfig# call discoveryByNAN failed, parameter callbackFunc type should be function.); return; return callAbility(CONSTANT.DISCOVERY_BY_NAN_CODE, scanNanInfo: scanInfo , callbackFunc); , discoveryBySoftAp: function (callbackFunc) if (typeof callbackFunc != function)

5、 console.error(NetConfig# call discoveryBySoftAp failed, parameter callbackFunc type should be function.); return; return callAbility(CONSTANT.DISCOVERY_BY_SOFT_AP_CODE, , callbackFunc); , connectDevice: function (connectInfo, callbackFunc) let isConnectInfoNull = connectInfo = null | connectInfo =

6、undefined; if (isConnectInfoNull) console.error(NetConfig# call connectDevice failed, parameter connectInfo should not be undefined.); return; if (typeof connectInfo.targetDeviceId != string) console.error(NetConfig# call connectDevice failed, parameter connectInfo.targetDeviceId type should be stri

7、ng.); return; if (!(typeof connectInfo.type = number & connectInfo.type % 1 = 0) console.error(NetConfig# call connectDevice failed, parameter connectInfo.type type should be integer.); return; if (typeof connectInfo.pin != string) console.error(NetConfig# call connectDevice failed, parameter connec

8、tInfo.pin type should be string.); return; if (typeof connectInfo.password != string) console.error(NetConfig# call connectDevice failed, parameter connectInfo.password type should be string.); return; if (typeof connectInfo.sessionId != string) console.error(NetConfig# call connectDevice failed, pa

9、rameter connectInfo.sessionId type should be string.); return; if (typeof callbackFunc != function) console.error(NetConfig# call connectDevice failed, parameter callbackFunc type should be function.); return; return callAbility(CONSTANT.CONNECT_DEVICE_CODE, connectInfo: connectInfo , callbackFunc);

10、 ,/ 獲取wifi列表 getWifiList: function (callbackFunc) if (typeof callbackFunc != function) console.error(NetConfig# call getWifiList failed, parameter callbackFunc type should be function.); return; return callAbility(CONSTANT.GET_WIFI_LIST_CODE, , callbackFunc); , sendMessage: function (commonInfo, mes

11、sage, callbackFunc) if (commonInfo = null | commonInfo = undefined) console.error(NetConfig# call sendMessage failed, parameter commonInfo type should be string.); return; if (typeof commonInfo.sessionId != string) console.error(NetConfig# call sendMessage failed, parameter sessionId type should be

12、string.); return; if (typeof message != string) console.error(NetConfig# call sendMessage failed, parameter message type should be string.); return; if (typeof callbackFunc != function) console.error(NetConfig# call sendMessage failed, parameter callbackFunc type should be function.); return; return callAbility(CONSTANT.SEND_MESS

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論