static bool check_connect_methode(struct led *led) { int methode = event_get_value(connect_methode); return (led->options.connect_methods & CONNECT_METHODE(methode)) != 0; } static struct blink_code overlay_connect_error(struct led *led) { enum connect_pairing_values event; if (!check_connect_methode(led)) return BLINK_CODE_SKIP; event = event_get_value(connect_pairing); if (event == connect_pairing_error || event == connect_pairing_timeout) { return BLINK_CODE(.type = blink_4HZ); } return BLINK_CODE_SKIP; } static struct blink_code overlay_connect(struct led *led) { enum connect_pairing_values event; if (!check_connect_methode(led)) return BLINK_CODE_SKIP; event = event_get_value(connect_pairing); switch (event) { case connect_pairing_success: return BLINK_CODE(.type = blink_off_on); case connect_pairing_start: return BLINK_CODE(.type = blink_2HZ); case connect_pairing_error: case connect_pairing_timeout: return BLINK_CODE(.type = blink_4HZ); default: return BLINK_CODE_SKIP; } } static struct blink_code default_2hz(struct led *led) { return BLINK_CODE(.type = blink_2HZ); } static struct blink_code default_off(struct led *led) { return BLINK_CODE(.type = blink_off); } static struct blink_code default_on(struct led *led) { return BLINK_CODE(.type = blink_on); } static struct blink_code default_4hz(struct led *led) { return BLINK_CODE(.type = blink_4HZ); } static bool any_lan(void) { if (event_get_value(lan1) == lan1_active) return true; if (event_get_value(lan2) == lan2_active) return true; if (event_get_value(lan3) == lan3_active) return true; if (event_get_value(lan4) == lan4_active) return true; if (event_get_value(lan5) == lan5_active) return true; return false; } static struct blink_code overlay_lan_bridge_no_cable(struct led *led) { if (event_get_value(access_type) != access_type_lan_bridge) return BLINK_CODE_SKIP; if (!any_lan()) return BLINK_CODE(.type = blink_0_5HZ); return BLINK_CODE_SKIP; } static struct blink_code overlay_wlan_bridge_no_uplink(struct led *led) { enum wlan_sta_values wlan = event_get_value(wlan_sta); if (event_get_value(access_type) != access_type_wlan_bridge) return BLINK_CODE_SKIP; if (event_get_value(wlan_sta_base) != wlan_sta_base_configured) return BLINK_CODE_SKIP; if (wlan == wlan_sta_register_failed || wlan == wlan_sta_starting || wlan == wlan_sta_stopping) return BLINK_CODE(.type = blink_0_5HZ); return BLINK_CODE_SKIP; } static int get_wlan_rssi_level(void) { int level = event_get_value(wlan_rssi_level); if (level < 0) return -1; else if (level < 1 * 100 / 6) return 0; else if (level < 2 * 100 / 6) /*--- x < 33 ---*/ return 1; else if (level < 3 * 100 / 6) /*--- x < 50 ---*/ return 2; else if (level < 4 * 100 / 6) /*--- x < 66 ---*/ return 3; else if (level < 5 * 100 / 6) /*--- x < 83 ---*/ return 4; return 5; } static struct blink_code overlay_wlan_uplink_le_2(struct led *led) { int level = get_wlan_rssi_level(); if (event_get_value(access_type) != access_type_wlan_bridge) return BLINK_CODE_SKIP; if (event_get_value(wlan_sta_base) != wlan_sta_base_configured) return BLINK_CODE_SKIP; if (event_get_value(wlan) != wlan_on) return BLINK_CODE_SKIP; if (level < 0) return BLINK_CODE_SKIP; if (level < 2) return BLINK_CODE(.type = blink_on); return BLINK_CODE_SKIP; } static struct blink_code overlay_plc_low_phyrate(struct led *led) { if (event_get_value(access_type) != access_type_plc_bridge) return BLINK_CODE_SKIP; if (event_get_value(plc) == plc_low_phyrate) return BLINK_CODE(.type = blink_on); return BLINK_CODE_SKIP; } static struct blink_code overlay_plc_bridge(struct led *led) { if (event_get_value(access_type) != access_type_plc_bridge) return BLINK_CODE_SKIP; if (event_get_value(plc) == plc_not_connect) return BLINK_CODE(.type = blink_0_5HZ); if (event_get_value(plc) == plc_on) return BLINK_CODE(.type = blink_on); if (event_get_value(plc) == plc_standby_start) return BLINK_CODE(.type = blink_off); return BLINK_CODE_SKIP; } static struct blink_code overlay_lan_bridge(struct led *led) { if (event_get_value(access_type) != access_type_lan_bridge) return BLINK_CODE_SKIP; if (any_lan()) return BLINK_CODE(.type = blink_on); return BLINK_CODE_SKIP; } static struct blink_code overlay_disable_no_wlan(struct led *led) { if (event_get_value(wlan) == wlan_off || event_get_value(wlan) == wlan_error) return BLINK_CODE(.type = blink_off); return BLINK_CODE_SKIP; } static struct blink_code overlay_lan(struct led *led) { if (any_lan()) return BLINK_CODE(.type = blink_on); return BLINK_CODE_SKIP; } /*-------------------------------------------------------------------*\ * NEXUS-pairing fails on the first start after set factorydefaults, * so we have to wait until the nexus-service is on start - JZ87268 \*-------------------------------------------------------------------*/ static struct blink_code overlay_nexus_not_ready(struct led *led) { if (event_get_value(nexus) != nexus_unknown) return BLINK_CODE_SKIP; return BLINK_CODE(.type = blink_2HZ); } static struct blink_code overlay_nexus_not_ready_off(struct led *led) { if (event_get_value(nexus) != nexus_unknown) return BLINK_CODE_SKIP; return BLINK_CODE(.type = blink_off); } static struct blink_code overlay_bootup(struct led *led) { if (event_get_value(wlan) != wlan_unknown) return BLINK_CODE_SKIP; return BLINK_CODE(.type = blink_2HZ); } static struct blink_code overlay_bootup_slow(struct led *led) { if (event_get_value(wlan) != wlan_unknown) return BLINK_CODE_SKIP; return BLINK_CODE(.type = blink_0_5HZ); } static struct blink_code overlay_wlan_repeater(struct led *led) { enum wlan_sta_values wlan_station = event_get_value(wlan_sta); if (event_get_value(wlan_sta_base) != wlan_sta_base_configured && event_get_value(wlan) == wlan_on) return BLINK_CODE(.type = blink_0_5HZ); if (wlan_station == wlan_sta_register_failed || wlan_station == wlan_sta_starting || wlan_station == wlan_sta_stopping) return BLINK_CODE(.type = blink_off); if (wlan_station == wlan_sta_unregister) return BLINK_CODE(.type = blink_2HZ); return BLINK_CODE_SKIP; } static struct blink_code overlay_wlan_uplink_ge_2(struct led *led) { int level = get_wlan_rssi_level(); if (event_get_value(access_type) != access_type_wlan_bridge) return BLINK_CODE_SKIP; if (event_get_value(wlan_sta_base) != wlan_sta_base_configured) return BLINK_CODE_SKIP; if (event_get_value(wlan) != wlan_on) return BLINK_CODE_SKIP; if (level < 0) return BLINK_CODE_SKIP; if (level >= 2) return BLINK_CODE(.type = blink_on); return BLINK_CODE_SKIP; } /* * This is only used for new style "one-led" repeater, for other repeaters * hardware_error=16 will result in slow blinking */ static struct blink_code overlay_factory_defaults(struct led *led) { if (event_get_value(hardware_error) == 16) return BLINK_CODE(.type = blink_2HZ); if (event_get_value(device) == device_factory_defaults) return BLINK_CODE(.type = blink_off); return BLINK_CODE_SKIP; } static struct blink_code overlay_update(struct led *led) { if (event_get_value(update) == update_running) return BLINK_CODE(.type = blink_2HZ); return BLINK_CODE_SKIP; } static struct blink_code overlay_update_off(struct led *led) { if (event_get_value(update) == update_running) return BLINK_CODE(.type = blink_off); return BLINK_CODE_SKIP; } static struct blink_code overlay_wps_error(struct led *led) { enum wps_values val = event_get_value(wps); if (val == wps_error || val == wlan_sta_wps_error) return BLINK_CODE(.type = blink_4HZ); return BLINK_CODE_SKIP; } static struct blink_code overlay_wps(struct led *led) { enum wps_values val = event_get_value(wps); if (val == wps_start || val == wlan_sta_wps_start) return BLINK_CODE(.type = blink_2HZ); if (val == wps_success || val == wlan_sta_wps_success) return BLINK_CODE(.type = blink_on); return BLINK_CODE_SKIP; } static struct blink_code overlay_hardware_error(struct led *led) { int val = event_get_value(hardware_error); if (val <= 0) return BLINK_CODE_SKIP; // Means factory defaults if (val == 16) return BLINK_CODE_SKIP; return BLINK_CODE(.type = blink_hardware_error, .params = { val, 0 }); } static struct blink_code overlay_message_zentrale(struct led *led) { switch (event_get_value(message_zentrale)) { case message_warning_high_priority: case message_warning_medium_priority: case message_warning_low_priority: return BLINK_CODE(.type = blink_4HZ); default: return BLINK_CODE_SKIP; } } static struct blink_code overlay_display_suspend(struct led *led) { /// display is simply enabled if (event_get_value(display) != display_suspend) return BLINK_CODE_SKIP; // We force the display on regardless if (event_get_value(display_force) == display_suspend_on_idle) return BLINK_CODE_SKIP; return BLINK_CODE(.type = blink_off); } static struct blink_code overlay_power_state(struct led *led) { // Turn if if explicitly requested, otherwise default to on if (event_get_value(power_state) == power_off) return BLINK_CODE(.type = blink_off); return BLINK_CODE_SKIP; } static struct blink_code overlay_uplink_error(struct led *led) { enum dsl_values val = event_get_value(dsl); if (val == dsl_nicht_verbunden || val == dsl_fehler || val == dsl_kein_kabel) return BLINK_CODE(.type = blink_0_5HZ); return BLINK_CODE_SKIP; } static struct blink_code overlay_uplink_conneting(struct led *led) { if (event_get_value(dsl) == dsl_training) return BLINK_CODE(.type = blink_2HZ_double); return BLINK_CODE_SKIP; } static struct blink_code default_uplink(struct led *led) { if (event_get_value(dsl) == dsl_verbunden) return BLINK_CODE(.type = blink_on); return BLINK_CODE(.type = blink_0_5HZ); } static struct blink_code overlay_wds_repeater(struct led *led) { if (event_get_value(wlan_wds_repeater) == wlan_wds_repeater_enable) return BLINK_CODE(.type = blink_on); return BLINK_CODE_SKIP; } static struct blink_code overlay_gsm_error(struct led *led) { enum gsm_values val = event_get_value(gsm); if (val == gsm_sync_failed || val == gsm_isp_error || val == gsm_auth_failed) return BLINK_CODE(.type = blink_2HZ); if (val == gsm_syncing) return BLINK_CODE(.type = blink_1HZ); return BLINK_CODE_SKIP; } static struct blink_code overlay_gsm(struct led *led) { enum gsm_values val = event_get_value(gsm); if (val == gsm_off || val == gsm_unknown) return BLINK_CODE_SKIP; if (val == gsm_syncing) return BLINK_CODE(.type = blink_1HZ); return BLINK_CODE(.type = blink_on); } static struct blink_code overlay_wlan(struct led *led) { switch (event_get_value(wlan)) { case wlan_on: { enum wlan_sta_values val = event_get_value(wlan_sta); if (val == wlan_sta_unregister || val == wlan_sta_register_failed) return BLINK_CODE(.type = blink_0_5HZ); return BLINK_CODE(.type = blink_on); } case wlan_error: return BLINK_CODE(.type = blink_4HZ); case wlan_starting: case wlan_configuring: return BLINK_CODE(.type = blink_1HZ); case wlan_dfs_starting: return BLINK_CODE(.type = blink_2HZ_double); case wlan_stopping: return BLINK_CODE(.type = blink_off); default: return BLINK_CODE_SKIP; } } static struct blink_code overlay_wlan_on(struct led *led) { if (event_get_value(wlan) == wlan_on) return BLINK_CODE(.type = blink_on); return BLINK_CODE_SKIP; } static struct blink_code overlay_wlan_error(struct led *led) { switch (event_get_value(wlan)) { case wlan_error: return BLINK_CODE(.type = blink_4HZ); default: return BLINK_CODE_SKIP; } } static struct blink_code overlay_wlan_rssi_bar_common(struct led *led) { int level = event_get_value(wlan_rssi_level); enum wlan_sta_values sta = event_get_value(wlan_sta); // This led has no physical location if (led->options.location == 0) return BLINK_CODE_SKIP; if (event_get_value(wlan) != wlan_on) return BLINK_CODE_SKIP; // Can not do a bar without leds if (leds_max_location() == 0) return BLINK_CODE_SKIP; // We want to connect, but we are not ~> disconnected if (sta != wlan_sta_register && sta != wlan_sta_starting && sta != wlan_sta_stopping && sta != wlan_sta_unknown) return BLINK_CODE(.type = blink_0_5HZ); level = (level * (leds_max_location() + 1) / 100); if (level >= led->options.location) return BLINK_CODE(.type = blink_on); else return BLINK_CODE(.type = blink_off); } static struct blink_code overlay_wlan_rssi_bar_sta(struct led *led) { if (event_get_value(access_type) != access_type_wlan_bridge) return BLINK_CODE_SKIP; if (event_get_value(wlan_sta_base) != wlan_sta_base_configured) return BLINK_CODE_SKIP; return overlay_wlan_rssi_bar_common(led); } static struct blink_code overlay_wlan_rssi_bar_client(struct led *led) { if (event_get_value(access_type) != access_type_lan_bridge) return BLINK_CODE_SKIP; return overlay_wlan_rssi_bar_common(led); } static struct blink_code overlay_disable_wlan_failed(struct led *led) { enum wlan_sta_values sta = event_get_value(wlan_sta); if (event_get_value(wlan) != wlan_on) return BLINK_CODE_SKIP; if (event_get_value(access_type) != access_type_wlan_bridge) return BLINK_CODE_SKIP; if (event_get_value(wlan_sta_base) != wlan_sta_base_configured) return BLINK_CODE_SKIP; // Will be signaled by other led if (sta != wlan_sta_register && sta != wlan_sta_starting && sta != wlan_sta_stopping && sta != wlan_sta_unknown) return BLINK_CODE(.type = blink_off); return BLINK_CODE_SKIP; } static struct blink_code overlay_info_lan(struct led *led) { if (event_get_value(switch_info) != switch_info_to_lan) return BLINK_CODE_SKIP; return overlay_lan(led); } static struct blink_code overlay_info_pppoe(struct led *led) { if (event_get_value(switch_info) != switch_info_to_online) return BLINK_CODE_SKIP; if (event_get_value(pppoe) == pppoe_on) return BLINK_CODE(.type = blink_on); else return BLINK_CODE(.type = blink_off); } static struct blink_code overlay_info_wlan(struct led *led) { if (event_get_value(switch_info) != switch_info_to_wlan_active) return BLINK_CODE_SKIP; if (event_get_value(wlan) == wlan_on) return BLINK_CODE(.type = blink_on); else return BLINK_CODE(.type = blink_off); } static struct blink_code overlay_info_wlan_guest(struct led *led) { if (event_get_value(switch_info) != switch_info_to_wlan_guest_active) return BLINK_CODE_SKIP; if (event_get_value(wlan_guest) == wlan_guest_enabled) return BLINK_CODE(.type = blink_on); else return BLINK_CODE(.type = blink_off); } static struct blink_code overlay_info_wlan_guest_device(struct led *led) { if (event_get_value(switch_info) != switch_info_to_wlan_guest_device) return BLINK_CODE_SKIP; if (event_get_value(wlan_guest_device) == wlan_guest_device_present) return BLINK_CODE(.type = blink_on); else return BLINK_CODE(.type = blink_off); } static struct blink_code overlay_wlan_macfilter_max(struct led *led) { if (event_get_value(wlan_macfilter_max) != wlan_macfilter_max_reached) return BLINK_CODE_SKIP; return BLINK_CODE(.type = blink_2HZ_double); } static struct blink_code overlay_plc(struct led *led) { if (event_get_value(plc) == plc_on) return BLINK_CODE(.type = blink_on); if (event_get_value(plc) == plc_low_phyrate) return BLINK_CODE(.type = blink_on); return BLINK_CODE_SKIP; } struct led_type led_types[] = { { .name = "repeater-all-in-one", .options = { .connect_methods = CONNECT_METHODE_ALL, .flags = LED_FLAG_BARE_UPDATE, }, .overlays = OVERLAYS( set_current_color_error, overlay_hardware_error, set_current_color_normal, overlay_update, overlay_display_suspend, overlay_bootup, overlay_nexus_not_ready, overlay_factory_defaults, overlay_connect, set_current_color_error, overlay_connect_error, overlay_wps_error, overlay_wlan_error, set_current_color_warn, overlay_lan_bridge_no_cable, overlay_wlan_bridge_no_uplink, overlay_wlan_uplink_le_2, set_current_color_normal, overlay_wps, overlay_lan_bridge, overlay_disable_no_wlan, overlay_wlan_repeater, overlay_wlan_uplink_ge_2, default_2hz ), }, { .name = "repeater-one-no-rssi", .options = { .connect_methods = CONNECT_METHODE_ALL, .flags = LED_FLAG_BARE_UPDATE, }, .overlays = OVERLAYS( set_current_color_error, overlay_hardware_error, set_current_color_normal, overlay_update, overlay_display_suspend, overlay_bootup, overlay_nexus_not_ready, overlay_factory_defaults, overlay_connect, set_current_color_error, overlay_connect_error, overlay_wps_error, overlay_wlan_error, set_current_color_warn, overlay_lan_bridge_no_cable, overlay_wlan_bridge_no_uplink, overlay_plc_low_phyrate, set_current_color_normal, overlay_wps, overlay_lan_bridge, overlay_plc_bridge, overlay_disable_no_wlan, overlay_wlan_repeater, default_on ), }, { /* * Copy for fr3000 only which has no orange on this led and therefore * for odd reasons require the orange part for missing wlan to be shown * on the rssi led. * * Oh man! */ .name = "repeater-one-fr3000", .options = { .connect_methods = CONNECT_METHODE_ALL, .flags = LED_FLAG_BARE_UPDATE, }, .overlays = OVERLAYS( set_current_color_error, overlay_hardware_error, set_current_color_normal, overlay_update, overlay_display_suspend, overlay_bootup, overlay_nexus_not_ready, overlay_factory_defaults, overlay_connect, set_current_color_error, overlay_connect_error, overlay_wps_error, overlay_wlan_error, set_current_color_warn, overlay_lan_bridge_no_cable, set_current_color_normal, overlay_wps, overlay_lan_bridge, overlay_disable_no_wlan, overlay_wlan_repeater, default_on ), }, { .name = "repeater-rssi-color", .overlays = OVERLAYS( overlay_display_suspend, overlay_disable_no_wlan, overlay_nexus_not_ready_off, set_current_color_warn, overlay_wlan_uplink_le_2, overlay_wlan_bridge_no_uplink, overlay_disable_wlan_failed, set_current_color_normal, overlay_lan_bridge, overlay_wlan_uplink_ge_2, default_off ), }, { .name = "repeater-power", .options = { .flags = LED_FLAG_BARE_UPDATE, }, .overlays = OVERLAYS( overlay_update, overlay_hardware_error, overlay_display_suspend, overlay_bootup_slow, overlay_power_state, default_on ), }, { .name = "repeater-lan", .overlays = OVERLAYS( overlay_hardware_error, overlay_display_suspend, overlay_lan, default_off ), }, { .name = "repeater-wlan", .options = { .connect_methods = CONNECT_METHODE_ALL, }, .overlays = OVERLAYS( overlay_hardware_error, overlay_display_suspend, overlay_nexus_not_ready_off, overlay_connect, overlay_wps_error, overlay_wps, overlay_wlan, default_off ), }, { .name = "repeater-plc-wlan", .options = { .connect_methods = CONNECT_METHODE_ALL, }, .overlays = OVERLAYS( overlay_update_off, overlay_hardware_error, overlay_display_suspend, overlay_nexus_not_ready_off, overlay_connect, overlay_wlan_on, default_off ), }, { .name = "repeater-plc", .options = { .connect_methods = CONNECT_METHODE(2) | CONNECT_METHODE(5) | CONNECT_METHODE(6), .flags = LED_FLAG_BARE_UPDATE, }, .overlays = OVERLAYS( overlay_update_off, overlay_hardware_error, overlay_display_suspend, overlay_connect, overlay_plc, default_off ), }, { .name = "box-power", .overlays = OVERLAYS( // TODO: overlay overlay_gsm_error, overlay_uplink_error, overlay_hardware_error, overlay_display_suspend, // TODO: update overlay_power_state, // TODO: ata overlay_gsm, overlay_wds_repeater, overlay_uplink_conneting, default_uplink ), }, { .name = "box-wlan", .options = { .connect_methods = CONNECT_METHODE_ALL, }, .overlays = OVERLAYS( // TODO: overlay overlay_hardware_error, overlay_display_suspend, overlay_connect, overlay_wps_error, overlay_wps, overlay_wlan, default_off ), }, { .name = "box-fon", .options = { .connect_methods = CONNECT_METHODE(1), }, .overlays = OVERLAYS( // TODO: overlay overlay_hardware_error, overlay_display_suspend, overlay_connect, // TODO: dect_stick_and_surf // // voice_internet || voice_festnetz || voice_ab default_off ), }, { .name = "connect", .options = { .connect_methods = CONNECT_METHODE(1) | CONNECT_METHODE(2) | CONNECT_METHODE(5) | CONNECT_METHODE(6), }, .overlays = OVERLAYS( overlay_hardware_error, overlay_display_suspend, overlay_connect, default_off ), }, { .name = "info", .options = { .flags = LED_FLAG_BARE_UPDATE, }, .overlays = OVERLAYS( set_current_color_normal, overlay_update, // TODO: overlay overlay_hardware_error, overlay_message_zentrale, overlay_display_suspend, // TODO: usb_host_stick_and_surf // TODO: filesystem // TODO: dect_stick_and_surf // TODO: voip_freecall overlay_wlan_macfilter_max, // TODO: info_map_status == 1) && fon_info_tam_mwi // TODO: info_map_status == 2) && fon_info_fax_mwi // TODO: info_map_status == 3) && fon_info_klingelsperre_aktiv // TODO: info_map_status == 4) && fon_info_missed_call // TODO: info_map_status == 5) && fon_info_tam_mwi // TODO: info_map_status == 5) && fon_info_fax_mwi // TODO: info_map_status == 5) && fon_info_missed_call // TODO: info_map_status == 6) && voip_info_freecall // TODO: info_map_status == 7) && voip_info_srtp // TODO: info_map_status == 8) && dect_info // TODO: info_map_status == 9) && budget_info overlay_info_lan, overlay_info_pppoe, overlay_info_wlan, overlay_info_wlan_guest, overlay_info_wlan_guest_device, // TODO: info_map_status == 15) && usb_host // TODO: info_map_status == 16) && usb_client default_off ), }, { .name = "uplink-rssi", .overlays = OVERLAYS( set_current_color_normal, overlay_hardware_error, overlay_display_suspend, overlay_nexus_not_ready_off, /* * When no ap is configured, always turn off. * * Otherwise if lan uplink is available -> full * Otherwise if wlan uplink -> show actual rssi */ overlay_disable_no_wlan, overlay_lan_bridge, overlay_disable_wlan_failed, overlay_wlan_rssi_bar_sta, default_off ), }, { .name = "wlan-rssi", .overlays = OVERLAYS( set_current_color_normal, overlay_hardware_error, overlay_display_suspend, overlay_nexus_not_ready_off, overlay_wlan_rssi_bar_client, overlay_wlan_rssi_bar_sta, default_off ), }, { .name = "default-on", .options = { 0 }, .overlays = OVERLAYS( overlay_display_suspend, default_on ), }, { .name = "unknown", .options = { 0 }, .overlays = OVERLAYS(default_4hz), }, { .name = "always-on", .options = { 0 }, .overlays = OVERLAYS(default_on), }, { .name = "always-off", .options = { 0 }, .overlays = OVERLAYS(default_off), }, };