1 /* node-type-tracker.h 2 * 3 * Copyright (c) 2023 Apple Inc. All rights reserved. 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * https://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 * 17 * This file contains general support definitions for the thread network state tracker. 18 */ 19 20 #ifndef __THREAD_TRACKER_H__ 21 #define __THREAD_TRACKER_H__ 1 22 23 typedef struct thread_tracker thread_tracker_t; 24 25 typedef enum thread_thread { 26 thread_network_state_uninitialized, 27 thread_network_state_fault, 28 thread_network_state_upgrading, 29 thread_network_state_deep_sleep, 30 thread_network_state_offline, 31 thread_network_state_commissioned, 32 thread_network_state_associating, 33 thread_network_state_credentials_needed, 34 thread_network_state_associated, 35 thread_network_state_isolated, 36 thread_network_state_asleep, 37 thread_network_state_waking, 38 thread_network_state_unknown 39 } thread_network_state_t; 40 41 RELEASE_RETAIN_DECLS(thread_tracker); 42 #define thread_tracker_retain(watcher) thread_tracker_retain_(watcher, __FILE__, __LINE__) 43 #define thread_tracker_release(watcher) thread_tracker_release_(watcher, __FILE__, __LINE__) 44 const char *NONNULL thread_tracker_network_state_to_string(thread_network_state_t state); 45 void thread_tracker_cancel(thread_tracker_t *NONNULL publisher); 46 thread_tracker_t *NULLABLE thread_tracker_create(srp_server_t *NONNULL route_state); 47 void thread_tracker_set_reconnect_callback(thread_tracker_t *NONNULL tracker, 48 void (*NULLABLE reconnect_callback)(void *NULLABLE context)); 49 void thread_tracker_start(thread_tracker_t *NONNULL tracker); 50 bool thread_tracker_callback_add(thread_tracker_t *NONNULL tracker, void (*NONNULL callback)(void *NULLABLE context), 51 void (*NULLABLE context_release)(void *NULLABLE context), void *NULLABLE context); 52 void thread_tracker_callback_cancel(thread_tracker_t *NONNULL tracker, void *NONNULL context); 53 thread_network_state_t thread_tracker_state_get(thread_tracker_t *NULLABLE tracker, bool previous); 54 bool thread_tracker_associated_get(thread_tracker_t *NULLABLE tracker, bool previous); 55 #endif // __THREAD_TRACKER_H__ 56 57 // Local Variables: 58 // mode: C 59 // tab-width: 4 60 // c-file-style: "bsd" 61 // c-basic-offset: 4 62 // fill-column: 120 63 // indent-tabs-mode: nil 64 // End: 65