File tree 2 files changed +17
-5
lines changed
2 files changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -79,9 +79,7 @@ pub async fn coap_run(handler: impl coap_handler::Handler + coap_handler::Report
79
79
80
80
info ! ( "Starting up CoAP server" ) ;
81
81
82
- // Can't that even bind to the Any address??
83
- // let local_any = "0.0.0.0:5683".parse().unwrap(); // shame
84
- let local_any = "10.42.0.61:5683" . parse ( ) . unwrap ( ) ; // shame
82
+ let local_any = "0.0.0.0:5683" . parse ( ) . unwrap ( ) ; // shame
85
83
let mut unconnected = udp_nal:: UnconnectedUdp :: bind_multiple ( socket, local_any)
86
84
. await
87
85
. unwrap ( ) ;
Original file line number Diff line number Diff line change @@ -66,7 +66,15 @@ impl<'a> ConnectedUdp<'a> {
66
66
local : SocketAddr ,
67
67
remote : SocketAddr ,
68
68
) -> Result < Self , Error > {
69
- socket. bind ( sockaddr_nal2smol ( local) ?) ?;
69
+ // Workaround for https://github.com/smoltcp-rs/smoltcp/issues/1037
70
+ let bind_to = sockaddr_nal2smol ( local) ?;
71
+ if bind_to. addr . is_unspecified ( ) {
72
+ defmt:: info!( "Binding to port {}" , bind_to. port) ;
73
+ socket. bind ( bind_to. port ) ?;
74
+ } else {
75
+ defmt:: info!( "Binding to sockaddr {}" , bind_to) ;
76
+ socket. bind ( bind_to) ?;
77
+ }
70
78
71
79
Ok ( ConnectedUdp {
72
80
remote : sockaddr_nal2smol ( remote) ?,
@@ -111,7 +119,13 @@ impl<'a> UnconnectedUdp<'a> {
111
119
mut socket : udp:: UdpSocket < ' a > ,
112
120
local : SocketAddr ,
113
121
) -> Result < Self , Error > {
114
- socket. bind ( sockaddr_nal2smol ( local) ?) ?;
122
+ // Workaround for https://github.com/smoltcp-rs/smoltcp/issues/1037
123
+ let bind_to = sockaddr_nal2smol ( local) ?;
124
+ if bind_to. addr . is_unspecified ( ) {
125
+ socket. bind ( bind_to. port ) ?;
126
+ } else {
127
+ socket. bind ( bind_to) ?;
128
+ }
115
129
116
130
Ok ( UnconnectedUdp { socket } )
117
131
}
You can’t perform that action at this time.
0 commit comments