How to switch to another network card when the current network card can not connect to the broker with paho mqtt library
okyihu opened this issue · 4 comments
Discussed in #1468
Originally posted by okyihu April 13, 2024
there are 4 network ports on my circuit board (running the embedded linux system), how to switch to another network card when the current network cann't connect to the broker with paho mqtt API ? thanks for helping.
The 1.4 branch has an update to allow this. You can take a look at the paho_c_sub and paho_c_pub samples to see how this works.
The 1.4 branch has an update to allow this. You can take a look at the paho_c_sub and paho_c_pub samples to see how this works.
If you invoke paho_c_pub (on the 1.4 branch) like this:
paho_c_pub x -A sds -v
it will display a list of interfaces and addresses:
Interface name "lo0" family 0 addresses:
IPv4 127.0.0.1
IPv6 ::1
IPv6 fe80::1
Interface name "en0" family 0 addresses:
IPv6 fe80::81:8c3c:5d27:34f7
IPv6 2002:3394:b915:0:4e8:d264:2b4f:fb10
IPv6 2002:3394:b915:0:297b:2435:7003:4898
IPv4 192.168.178.20
Interface name "awdl0" family 0 addresses:
IPv6 fe80::84a:6ff:fe18:e6d3
Interface name "llw0" family 0 addresses:
IPv6 fe80::84a:6ff:fe18:e6d3
Interface name "utun0" family 0 addresses:
IPv6 fe80::94cd:2fe6:5b7c:db09
Interface name "utun1" family 0 addresses:
IPv6 fe80::f0e8:9e61:7169:fa82
Interface name "utun2" family 0 addresses:
IPv6 fe80::ce81:b1c:bd2c:69e
You can use the interface name or an address to select the interface to use.
The 1.4 branch has an update to allow this. You can take a look at the paho_c_sub and paho_c_pub samples to see how this works.
If you invoke paho_c_pub (on the 1.4 branch) like this:
paho_c_pub x -A sds -v
it will display a list of interfaces and addresses:
Interface name "lo0" family 0 addresses: IPv4 127.0.0.1 IPv6 ::1 IPv6 fe80::1 Interface name "en0" family 0 addresses: IPv6 fe80::81:8c3c:5d27:34f7 IPv6 2002:3394:b915:0:4e8:d264:2b4f:fb10 IPv6 2002:3394:b915:0:297b:2435:7003:4898 IPv4 192.168.178.20 Interface name "awdl0" family 0 addresses: IPv6 fe80::84a:6ff:fe18:e6d3 Interface name "llw0" family 0 addresses: IPv6 fe80::84a:6ff:fe18:e6d3 Interface name "utun0" family 0 addresses: IPv6 fe80::94cd:2fe6:5b7c:db09 Interface name "utun1" family 0 addresses: IPv6 fe80::f0e8:9e61:7169:fa82 Interface name "utun2" family 0 addresses: IPv6 fe80::ce81:b1c:bd2c:69e
You can use the interface name or an address to select the interface to use.
thank you very much. I'll try it later and give you feedback
Which interface is called to set the ip of the specified network card ?
Sorry, I didn't find the branch code through 1.4