Skip to content

Commit c9cd830

Browse files
author
Devdutt Shenoi
authored
feat: default main on port 5050 if tcpapps unconfigured (#264)
* feat: automatically assign main port * feat: default app on port 5555 * fix: default to port `5050` * doc: move to using port 5050
1 parent f2f6f46 commit c9cd830

File tree

20 files changed

+485
-470
lines changed

20 files changed

+485
-470
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ With the help of tunshell, uplink allows you to remotely connect to a device she
195195
You can test sending JSON data to Bytebeam over uplink with the following command while uplink is active
196196

197197
```sh
198-
nc localhost 5555
198+
nc localhost 5050
199199
{ "stream": "can", "sequence": 1, "timestamp": 12345, "data": 100 }
200200
{ "stream": "can", "sequence": 1, "timestamp": 12345, "data": 100 }
201201
{ "stream": "can", "sequence": 1, "timestamp": 12345, "data": 100 }

configs/config.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ network_timeout = 30
3636
# - actions: A list of actions that uplink can forward to the app,
3737
# with configurable timeouts
3838
[tcpapps.1]
39-
port = 5555
39+
port = 5050
4040
actions = [{ name = "install_update" }, { name = "load_file" }]
4141

4242
[tcpapps.2]
43-
port = 5556
43+
port = 6060
4444
actions = []
4545

4646
# Metrics configurations are available for serializer and streams. By default

configs/simulator.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ action_redirections = { "update_firmware" = "install_update", "send_file" = "loa
55
persistence_path = "/tmp/uplink"
66

77
[tcpapps.1]
8-
port = 5555
8+
port = 5050

configs/stress.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ processes = [{ name = "echo" }]
44
action_redirections = { "update_firmware" = "install_update", "send_file" = "load_file" }
55

66
[tcpapps.1]
7-
port = 5555
7+
port = 5050
88
actions = [{ name = "install_update" }, { name = "load_file" }]
99

1010
[persistence]

docs/apps.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
uplink is a service that runs in the background and connects user applications to the bytebeam platform.
33

44
## Configuring uplink
5-
Applications can connect to the uplink service over TCP to send and receive JSON data, and for this uplink has to expose a TCP port per application. The following example configuration describes to uplink that two applications require it to expose the ports 5555 and 6666, where one of them also expects to receive `install_firmware` actions:
5+
Applications can connect to the uplink service over TCP to send and receive JSON data, and for this uplink has to expose a TCP port per application. The following example configuration describes to uplink that two applications require it to expose the ports 5050 and 6060, where one of them also expects to receive `install_firmware` actions:
66
```
77
[tcpapps.main_app]
8-
port = 5555
8+
port = 5050
99
1010
[tcpapps.ota_installer]
11-
port = 5555
11+
port = 6060
1212
actions = [{ name = "install_firmware" }]
1313
```
1414
NOTE: Only one client can connect to a TCP port at a time. If a second client attempts to connect to a port which is already occupied, the first client will be disconnected from uplink.
@@ -77,7 +77,7 @@ An example success response to an action with the id `"123"`, would look like:
7777
> **NOTE:** There is a timeout mechanism which on being triggered will send a ***Failed*** response to platform and stop forwarding any *Progress* responses from the connected applications. In order to not trigger this timeout, an application must send a ***Failed*** or ***Completed*** response before the action timeout. Once an action has timedout, a failure response is sent and all it's future responses are dropped. Action timeouts can be configured per action when setting up uplink, as follows:
7878
> ```
7979
> [tcpapps.main_app]
80-
> port = 5555
80+
> port = 5050
8181
> actions = [{ name = "abc", timeout = 300 }] # Allow the connected app to send responses for action abc upto 5 minutes from receive, send a failure response and drop all responses afterwards if not yet completed.
8282
> ```
8383
@@ -86,7 +86,7 @@ We have provided examples written in python and golang to demonstrate how you ca
8686
1. Ensure uplink is running on the device, connected to relevant broker and using the following config:
8787
```toml
8888
[tcpapps.main_app]
89-
port = 5555
89+
port = 5050
9090
actions = [{ name = "update_firmware" }, { name = "reboot" }, { name = "update_config" }]
9191
```
9292
2. Run the python/golang examples

examples/demo.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ type Action struct {
2626

2727
func main() {
2828
// Connect to uplink via bridge port
29-
c, err := net.Dial("tcp", "localhost:5555")
29+
c, err := net.Dial("tcp", "localhost:5050")
3030
if err != nil {
3131
fmt.Println(err)
3232
return

examples/demo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import threading
88

99
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
10-
s.connect(("localhost", 5555))
10+
s.connect(("localhost", 5050))
1111

1212
# Converts JSON data received over TCP into a python dictionary
1313
def recv_action(s):

examples/demo.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::thread;
44
use std::time::{Duration, SystemTime, UNIX_EPOCH};
55

66
fn main() -> Result<()> {
7-
let mut stream = TcpStream::connect("localhost:5555").expect("couldn't connect to server");
7+
let mut stream = TcpStream::connect("localhost:5050").expect("couldn't connect to server");
88
let stream_clone = stream.try_clone().expect("clone failed...");
99
println!("Connected to the server!");
1010

examples/rpi/updates/app_update/app_update.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
# COPROC[1] is the stdin for netcat
1212
# COPROC[0] is the stdout of netcat
13-
# By echoing to the stdin of nc, we write to the port 5555
13+
# By echoing to the stdin of nc, we write to the port 5050
1414

1515
PORT=$2
1616
APP=$3

examples/rpi/updates/app_update_rollback/app_update_rollback.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
# COPROC[1] is the stdin for netcat
1313
# COPROC[0] is the stdout of netcat
14-
# By echoing to the stdin of nc, we write to the port 5555
14+
# By echoing to the stdin of nc, we write to the port 5050
1515

1616
PORT=$2
1717
APP=$3

0 commit comments

Comments
 (0)