Skip to content

Commit

Permalink
docker运行方式,可以指定提供服务的端口号
Browse files Browse the repository at this point in the history
  • Loading branch information
IoTServ committed Feb 23, 2021
1 parent 972c763 commit afe9a75
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 9 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@
* 如果你想云易连的手机和插件不是同一个网络也能控制,请安装[云易连网关](https://github.com/OpenIoTHub/gateway-go/releases) 如果只需要局域网控制请忽略
docker 运行:
```batch
docker run openiothub/phicomm-r1-controler:latest r1-ip -i {这里是你的斐讯R1的ip}
docker run -d -p 2847:2847 openiothub/phicomm-r1-controler:latest r1-ip -i {这里是你的斐讯R1的ip} - p 2847
```
例如:
```batch
docker run openiothub/phicomm-r1-controler:latest r1-ip -i 192.168.123.146
docker run -d -p 2847:2847 openiothub/phicomm-r1-controler:latest r1-ip -i 192.168.123.146 - p 2847
```
##### 上面2847是容器对外提供服务的端口,如果你不懂但是想换就都换成同一个端口号,基本上小于10000的整数都没啥问题,前提是不会跟其他软件端口号冲突
![avatar](./images/ui.jpg)
```sh
phicomm-r1-controler -c /path/to/config/file/phicomm-r1-controler.yaml
Expand Down
1 change: 1 addition & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
var WG sync.WaitGroup

var SingleIpPort = ""
var SingleServicePort = 0
var ConfigFileName = "phicomm-r1-controler.yaml"
var ConfigFilePath = fmt.Sprintf("./%s", ConfigFileName)
var ConfigModelVar = &ConfigModel{
Expand Down
2 changes: 1 addition & 1 deletion config/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func (ao *AndroidAdbDeviceWithOpenIoTHub) Reg() {
WG.Add(1)
defer WG.Done()
var err error
ao.listener, err = net.Listen("tcp", ":")
ao.listener, err = net.Listen("tcp", fmt.Sprintf(":%d", SingleServicePort))
if err != nil {
log.Println(err)
return
Expand Down
8 changes: 8 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@ func main() {
EnvVars: []string{"R1IP"},
Destination: &config.SingleIpPort,
},
&cli.IntFlag{
Name: "port",
Aliases: []string{"p"},
Value: 0,
Usage: "指定提供服务的端口",
EnvVars: []string{"R1PORT"},
Destination: &config.SingleServicePort,
},
},
Action: func(c *cli.Context) error {
config.LoadSnapcraftConfigPath()
Expand Down
6 changes: 0 additions & 6 deletions services/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,6 @@ func Run(c *cli.Context) (err error) {
log.Println("List adb devices:")
log.Printf("%+v", info)
dev := adbClient.Device(adb.DeviceWithSerial(info.Serial))
//rst, err := dev.RunCommand("ls")
//if err != nil {
// log.Println(err)
// continue
//}
//log.Println(rst)
id := fmt.Sprintf("%s-%s", info.Model, info.Serial)
log.Println("id:", id)
AndroidAdbDeviceWithOpenIoTHubMap[id] = &config.AndroidAdbDeviceWithOpenIoTHub{
Expand Down

0 comments on commit afe9a75

Please sign in to comment.