@@ -32,19 +32,19 @@ void setup() {
3232void loop () {
3333 // Get current device role
3434 ot_device_role_t currentRole = threadLeaderNode.otGetDeviceRole ();
35-
35+
3636 // Only print network information when not detached
3737 if (currentRole != OT_ROLE_DETACHED && currentRole != OT_ROLE_DISABLED) {
3838 Serial.println (" ==============================================" );
3939 Serial.println (" OpenThread Network Information:" );
40-
40+
4141 // Basic network information
4242 Serial.printf (" Role: %s\r\n " , threadLeaderNode.otGetStringDeviceRole ());
4343 Serial.printf (" RLOC16: 0x%04x\r\n " , threadLeaderNode.getRloc16 ());
4444 Serial.printf (" Network Name: %s\r\n " , threadLeaderNode.getNetworkName ().c_str ());
4545 Serial.printf (" Channel: %d\r\n " , threadLeaderNode.getChannel ());
4646 Serial.printf (" PAN ID: 0x%04x\r\n " , threadLeaderNode.getPanId ());
47-
47+
4848 // Extended PAN ID
4949 const uint8_t *extPanId = threadLeaderNode.getExtendedPanId ();
5050 if (extPanId) {
@@ -54,7 +54,7 @@ void loop() {
5454 }
5555 Serial.println ();
5656 }
57-
57+
5858 // Network Key
5959 const uint8_t *networkKey = threadLeaderNode.getNetworkKey ();
6060 if (networkKey) {
@@ -64,19 +64,19 @@ void loop() {
6464 }
6565 Serial.println ();
6666 }
67-
67+
6868 // Mesh Local EID
6969 IPAddress meshLocalEid = threadLeaderNode.getMeshLocalEid ();
7070 Serial.printf (" Mesh Local EID: %s\r\n " , meshLocalEid.toString ().c_str ());
71-
71+
7272 // Leader RLOC
7373 IPAddress leaderRloc = threadLeaderNode.getLeaderRloc ();
7474 Serial.printf (" Leader RLOC: %s\r\n " , leaderRloc.toString ().c_str ());
75-
75+
7676 // Node RLOC
7777 IPAddress nodeRloc = threadLeaderNode.getRloc ();
7878 Serial.printf (" Node RLOC: %s\r\n " , nodeRloc.toString ().c_str ());
79-
79+
8080 // Demonstrate address listing with two different methods:
8181 // Method 1: Unicast addresses using counting API (individual access)
8282 Serial.println (" \r\n --- Unicast Addresses (Using Count + Index API) ---" );
@@ -85,29 +85,29 @@ void loop() {
8585 IPAddress addr = threadLeaderNode.getUnicastAddress (i);
8686 Serial.printf (" [%zu]: %s\r\n " , i, addr.toString ().c_str ());
8787 }
88-
88+
8989 // Method 2: Multicast addresses using std::vector (bulk access)
9090 Serial.println (" \r\n --- Multicast Addresses (Using std::vector API) ---" );
9191 std::vector<IPAddress> allMulticast = threadLeaderNode.getAllMulticastAddresses ();
9292 for (size_t i = 0 ; i < allMulticast.size (); i++) {
9393 Serial.printf (" [%zu]: %s\r\n " , i, allMulticast[i].toString ().c_str ());
9494 }
95-
95+
9696 // Check for role change and clear cache if needed (only when active)
9797 if (currentRole != lastKnownRole) {
98- Serial.printf (" Role changed from %s to %s - clearing address cache\r\n " ,
99- (lastKnownRole < 5 ) ? otRoleString[lastKnownRole] : " Unknown" ,
100- threadLeaderNode.otGetStringDeviceRole ());
98+ Serial.printf (
99+ " Role changed from %s to %s - clearing address cache\r\n " , (lastKnownRole < 5 ) ? otRoleString[lastKnownRole] : " Unknown" ,
100+ threadLeaderNode.otGetStringDeviceRole ()
101+ );
101102 threadLeaderNode.clearAllAddressCache ();
102103 lastKnownRole = currentRole;
103104 }
104105 } else {
105- Serial.printf (" Thread Node Status: %s - Waiting for thread network start...\r\n " ,
106- threadLeaderNode.otGetStringDeviceRole ());
107-
106+ Serial.printf (" Thread Node Status: %s - Waiting for thread network start...\r\n " , threadLeaderNode.otGetStringDeviceRole ());
107+
108108 // Update role tracking even when detached/disabled, but don't clear cache
109109 lastKnownRole = currentRole;
110110 }
111-
111+
112112 delay (5000 );
113113}
0 commit comments