.. _auto_get_state_led_rule: get_state_led_rule (Auto Mode) ------------------------------------------ This section explains how to use :ref:`get_state_led_rule ` during **Auto** operations. This function returns the LED rule: 0 = default, 1 = custom by state, 2 = custom by command. It also returns 0 when the call is refused. Available in Auto mode only, on controller v3.4 or later. In other modes, or on an older controller, the function returns 0. The mode check uses the value returned by :ref:`get_robot_mode `. **Typical usage** - Check which LED rule is currently active before or after custom color control. - Use to synchronize external UI indicators with the robot’s LED behavior. - Log the LED rule for diagnostics. **Example** The example obtains control authority and sets Auto mode before the LED calls, because the LED functions are refused in other modes. .. code-block:: cpp #include #include #include #include std::atomic g_bHasControlAuthority(false); void OnMonitoringAccessControlCB(const MONITORING_ACCESS_CONTROL eAccess) { if (eAccess == MONITORING_ACCESS_CONTROL_GRANT) g_bHasControlAuthority = true; } drfl.set_on_monitoring_access_control(OnMonitoringAccessControlCB); if (!drfl.open_connection("192.168.137.100")) return 1; drfl.manage_access_control(MANAGE_ACCESS_CONTROL_FORCE_REQUEST); while (!g_bHasControlAuthority) std::this_thread::sleep_for(std::chrono::milliseconds(100)); // The LED functions are refused unless Auto mode is set if (!drfl.set_robot_mode(ROBOT_MODE_AUTONOMOUS)) return 1; unsigned char rule = drfl.get_state_led_rule(); printf("[LED] Current LED rule: %d\n", rule); if (rule == 0) printf("LED rule: Default\n"); else if (rule == 1) printf("LED rule: Custom by state\n"); else if (rule == 2) printf("LED rule: Custom by command\n"); This function provides insight into **the LED rule currently applied by the controller**, helping users maintain consistent visual feedback policies. **Tips** - Useful for verifying whether the LED follows the **default** rule or a **custom** rule. - Combine with :ref:`state_led_reset ` to restore the default LED rule if needed. - After :ref:`set_state_led_color ` or :ref:`set_state_led_off `, the rule is 2 (custom by command).