title: Get signal level of the connected WiFi network
body: <p>Using wpa_supplicant 2.4 on ARM Debian.</p>
  
  <p>Is there a way to get signal level, in decibels or percents, of the wireless network I’m currently connected to?</p>
  
  <p>STATUS command only returns the following set of values: bssid, freq, ssid, id, mode, pairwise_cipher, group_cipher, key_mgmt, wpa_state, ip_address, p2p_device_address, address, uuid</p>
  
  <p>I can run SCAN afterwards, wait for results and search by SSID. But that’s slow and error-prone, I'd like to do better.</p>
  
  <p>The driver should already know that information (because connected, and adjusting transmit levels for energy saving), is there a way to just query for that?</p>
  
  <p><strong>This question is not about general computing hardware and software.</strong> I'm using wpa_supplicant through a C API defined in <code>wpa_ctrl.h</code> header, interacting with the service through a pair of unix domain sockets (one for commands, another one for unsolicited events).</p>
  
  <p>One reason I don’t like my current <code>SCAN</code> + <code>SCAN_RESULT</code> solution, it doesn’t work for hidden SSID networks. Scan doesn’t find the network, therefore I’m not getting signal level this way. Another issue is minor visual glitch at application startup. My app is launched by systemd, <code>After=multi-user.target</code>. Unless it’s the very first launch, Linux is already connected to Wi-Fi by then. In my app’s GUI (the product will feature a touch screen), I render a phone-like status bar, that includes WiFi signal strength icon. Currently, it initially shows minimal level (I know it's connected because <code>STATUS</code> command shows SSID), only after ~1 second I’m getting <code>CTRL-EVENT-SCAN-RESULTS</code> event from wpa_supplicant, run <code>SCAN_RESULT</code> command and update signal strength to the correct value.</p>
  
  <p>On the API level my code is straightforward. I have two threads for that, both call <code>wpa_ctrl_open</code>, the command thread calls <code>wpa_ctrl_request</code>, the event thread has an endless loop that calls <a href="http://man7.org/linux/man-pages/man2/poll.2.html" rel="nofollow noreferrer"><code>poll</code></a> passing <code>wpa_ctrl_get_fd()</code> descriptor and <code>POLLIN</code> event mask, followed by <code>wpa_ctrl_pending</code> and <code>wpa_ctrl_recv</code>.</p>
  
  <p>And here's the list of files in /sys/class/net/wlan0:</p>
  
  <pre><code>./mtu
  ./type
  ./phys_port_name
  ./netdev_group
  ./flags
  ./power/control
  ./power/async
  ./power/runtime_enabled
  ./power/runtime_active_kids
  ./power/runtime_active_time
  ./power/autosuspend_delay_ms
  ./power/runtime_status
  ./power/runtime_usage
  ./power/runtime_suspended_time
  ./speed
  ./dormant
  ./name_assign_type
  ./proto_down
  ./addr_assign_type
  ./phys_switch_id
  ./dev_id
  ./duplex
  ./gro_flush_timeout
  ./iflink
  ./phys_port_id
  ./addr_len
  ./address
  ./operstate
  ./carrier_changes
  ./broadcast
  ./queues/rx-0/rps_flow_cnt
  ./queues/rx-0/rps_cpus
  ./queues/rx-1/rps_flow_cnt
  ./queues/rx-1/rps_cpus
  ./queues/rx-2/rps_flow_cnt
  ./queues/rx-2/rps_cpus
  ./queues/rx-3/rps_flow_cnt
  ./queues/rx-3/rps_cpus
  ./queues/tx-0/xps_cpus
  ./queues/tx-0/tx_maxrate
  ./queues/tx-0/tx_timeout
  ./queues/tx-0/byte_queue_limits/limit
  ./queues/tx-0/byte_queue_limits/limit_max
  ./queues/tx-0/byte_queue_limits/limit_min
  ./queues/tx-0/byte_queue_limits/hold_time
  ./queues/tx-0/byte_queue_limits/inflight
  ./queues/tx-1/xps_cpus
  ./queues/tx-1/tx_maxrate
  ./queues/tx-1/tx_timeout
  ./queues/tx-1/byte_queue_limits/limit
  ./queues/tx-1/byte_queue_limits/limit_max
  ./queues/tx-1/byte_queue_limits/limit_min
  ./queues/tx-1/byte_queue_limits/hold_time
  ./queues/tx-1/byte_queue_limits/inflight
  ./queues/tx-2/xps_cpus
  ./queues/tx-2/tx_maxrate
  ./queues/tx-2/tx_timeout
  ./queues/tx-2/byte_queue_limits/limit
  ./queues/tx-2/byte_queue_limits/limit_max
  ./queues/tx-2/byte_queue_limits/limit_min
  ./queues/tx-2/byte_queue_limits/hold_time
  ./queues/tx-2/byte_queue_limits/inflight
  ./queues/tx-3/xps_cpus
  ./queues/tx-3/tx_maxrate
  ./queues/tx-3/tx_timeout
  ./queues/tx-3/byte_queue_limits/limit
  ./queues/tx-3/byte_queue_limits/limit_max
  ./queues/tx-3/byte_queue_limits/limit_min
  ./queues/tx-3/byte_queue_limits/hold_time
  ./queues/tx-3/byte_queue_limits/inflight
  ./tx_queue_len
  ./uevent
  ./statistics/rx_fifo_errors
  ./statistics/collisions
  ./statistics/rx_errors
  ./statistics/rx_compressed
  ./statistics/rx_dropped
  ./statistics/tx_packets
  ./statistics/tx_errors
  ./statistics/rx_missed_errors
  ./statistics/rx_over_errors
  ./statistics/tx_carrier_errors
  ./statistics/tx_heartbeat_errors
  ./statistics/rx_crc_errors
  ./statistics/multicast
  ./statistics/tx_fifo_errors
  ./statistics/tx_aborted_errors
  ./statistics/rx_bytes
  ./statistics/tx_compressed
  ./statistics/tx_dropped
  ./statistics/rx_packets
  ./statistics/tx_bytes
  ./statistics/tx_window_errors
  ./statistics/rx_frame_errors
  ./statistics/rx_length_errors
  ./dev_port
  ./ifalias
  ./ifindex
  ./link_mode
  ./carrier
  </code></pre>