使用hdc TCP模式无线方式连接OpenHarmony设备

离北况归
发布于 2024-8-27 17:08
浏览
0收藏

本文将介绍如何使用hdc工具 tcp模式以无线的方式连接OpenHarmony设备。

1. usb连接方式切换为tcp模式。

将usb线将OpenHarmony设备和电脑端连接,并且将两个连接至同一个局域网。

# 执行 tmode port port-number,port-number设置为端口号。
hdc tmode port 6666

# 执行 hdc tconn OpenHarmony设备IP地址:port-number端口号,然后把两者的USB线拔下
hdc tconn 192.168.229.195:6666

hdc shell
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.

使用hdc TCP模式无线方式连接OpenHarmony设备-鸿蒙开发者社区

  • OpenHarmony设备IP地址可以通过wifiManager.getIpInfo().ipAddress获取,具体见该样例tcp_demo

2. tcp模式切换回usb模式

# 将设备和电脑两者之间USB线连接
hdc tmode usb

hdc shell 
  • 1.
  • 2.
  • 3.
  • 4.

使用hdc TCP模式无线方式连接OpenHarmony设备-鸿蒙开发者社区

3. 同时启用hdc tcp和usb模式

# 进入shell终端
hdc shell

# 设置属性 persist.hdc.mode 为all ,同时启用hdc tcp和usb模式
param set persist.hdc.mode all

# 设置属性 persist.hdc.port 端口号
param set persist.hdc.port 6666

# 设置属性 persist.hdc.mode 为tcp ,启用hdc tcp模式
param set persist.hdc.mode tcp

# 设置属性 persist.hdc.mode 为usb ,启用hdc usb模式
param set persist.hdc.mode usb
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.

标签
已于2024-8-27 17:08:51修改
收藏
回复
举报


回复
    相关推荐