@@ -51,9 +51,10 @@ fn main() -> Result<(), Error> {
51
51
thread. join ( ) . unwrap ( )
52
52
}
53
53
54
+ // NOTE: For no_std, name this entry point according to your MCU platform
54
55
#[ cfg( not( feature = "std" ) ) ]
55
56
#[ no_mangle]
56
- fn main ( ) {
57
+ fn app_main ( ) {
57
58
run ( ) . unwrap ( ) ;
58
59
}
59
60
@@ -93,11 +94,27 @@ fn run() -> Result<(), Error> {
93
94
94
95
let dev_att = dev_att:: HardCodedDevAtt :: new ( ) ;
95
96
96
- let matter = Matter :: new_default (
97
+ #[ cfg( feature = "std" ) ]
98
+ let epoch = matter:: utils:: epoch:: sys_epoch;
99
+
100
+ #[ cfg( feature = "std" ) ]
101
+ let rand = matter:: utils:: rand:: sys_rand;
102
+
103
+ // NOTE: For no_std, provide your own function here
104
+ #[ cfg( not( feature = "std" ) ) ]
105
+ let epoch = matter:: utils:: epoch:: dummy_epoch;
106
+
107
+ // NOTE: For no_std, provide your own function here
108
+ #[ cfg( not( feature = "std" ) ) ]
109
+ let rand = matter:: utils:: rand:: dummy_rand;
110
+
111
+ let matter = Matter :: new (
97
112
// vid/pid should match those in the DAC
98
113
& dev_det,
99
114
& dev_att,
100
115
& mdns,
116
+ epoch,
117
+ rand,
101
118
matter:: MATTER_PORT ,
102
119
) ;
103
120
@@ -203,6 +220,10 @@ fn run() -> Result<(), Error> {
203
220
204
221
let mut fut = pin ! ( async move { select( & mut io_fut, & mut mdns_fut) . await . unwrap( ) } ) ;
205
222
223
+ info ! ( "Final future: {:p}" , & mut fut) ;
224
+
225
+ // NOTE: For no_std, replace with your own no_std way of polling the future
226
+ #[ cfg( feature = "std" ) ]
206
227
smol:: block_on ( & mut fut) ?;
207
228
208
229
Ok :: < _ , matter:: error:: Error > ( ( ) )
@@ -222,15 +243,27 @@ fn handler<'a>(matter: &'a Matter<'a>) -> impl Handler + 'a {
222
243
)
223
244
}
224
245
225
- #[ cfg( not( target_os = "espidf" ) ) ]
246
+ // NOTE: For no_std, implement here your own way of initializing the logger
247
+ #[ cfg( all( not( feature = "std" ) , not( target_os = "espidf" ) ) ) ]
248
+ #[ inline( never) ]
249
+ fn initialize_logger ( ) { }
250
+
251
+ // NOTE: For no_std, implement here your own way of initializing the network
252
+ #[ cfg( all( not( feature = "std" ) , not( target_os = "espidf" ) ) ) ]
253
+ #[ inline( never) ]
254
+ fn initialize_network ( ) -> Result < ( Ipv4Addr , Ipv6Addr , u32 ) , Error > {
255
+ Ok ( ( Ipv4Addr :: UNSPECIFIED , Ipv6Addr :: UNSPECIFIED , 0 ) )
256
+ }
257
+
258
+ #[ cfg( all( feature = "std" , not( target_os = "espidf" ) ) ) ]
226
259
#[ inline( never) ]
227
260
fn initialize_logger ( ) {
228
261
env_logger:: init_from_env (
229
262
env_logger:: Env :: default ( ) . filter_or ( env_logger:: DEFAULT_FILTER_ENV , "info" ) ,
230
263
) ;
231
264
}
232
265
233
- #[ cfg( not( target_os = "espidf" ) ) ]
266
+ #[ cfg( all ( feature = "std" , not( target_os = "espidf" ) ) ) ]
234
267
#[ inline( never) ]
235
268
fn initialize_network ( ) -> Result < ( Ipv4Addr , Ipv6Addr , u32 ) , Error > {
236
269
use log:: error;
0 commit comments