110-per_chain_signal_strength.patch 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. --- a/station.c
  2. +++ b/station.c
  3. @@ -91,6 +91,33 @@ void parse_bitrate(struct nlattr *bitrat
  4. " VHT-NSS %d", nla_get_u8(rinfo[NL80211_RATE_INFO_VHT_NSS]));
  5. }
  6. +static char *get_chain_signal(struct nlattr *attr_list)
  7. +{
  8. + struct nlattr *attr;
  9. + static char buf[64];
  10. + char *cur = buf;
  11. + int i = 0, rem;
  12. + const char *prefix;
  13. +
  14. + if (!attr_list)
  15. + return "";
  16. +
  17. + nla_for_each_nested(attr, attr_list, rem) {
  18. + if (i++ > 0)
  19. + prefix = ", ";
  20. + else
  21. + prefix = "[";
  22. +
  23. + cur += snprintf(cur, sizeof(buf) - (cur - buf), "%s%d", prefix,
  24. + (int8_t) nla_get_u8(attr));
  25. + }
  26. +
  27. + if (i)
  28. + snprintf(cur, sizeof(buf) - (cur - buf), "] ");
  29. +
  30. + return buf;
  31. +}
  32. +
  33. static int print_sta_handler(struct nl_msg *msg, void *arg)
  34. {
  35. struct nlattr *tb[NL80211_ATTR_MAX + 1];
  36. @@ -118,7 +145,10 @@ static int print_sta_handler(struct nl_m
  37. [NL80211_STA_INFO_LOCAL_PM] = { .type = NLA_U32},
  38. [NL80211_STA_INFO_PEER_PM] = { .type = NLA_U32},
  39. [NL80211_STA_INFO_NONPEER_PM] = { .type = NLA_U32},
  40. + [NL80211_STA_INFO_CHAIN_SIGNAL] = { .type = NLA_NESTED },
  41. + [NL80211_STA_INFO_CHAIN_SIGNAL_AVG] = { .type = NLA_NESTED },
  42. };
  43. + char *chain;
  44. nla_parse(tb, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0),
  45. genlmsg_attrlen(gnlh, 0), NULL);
  46. @@ -165,12 +195,19 @@ static int print_sta_handler(struct nl_m
  47. if (sinfo[NL80211_STA_INFO_TX_FAILED])
  48. printf("\n\ttx failed:\t%u",
  49. nla_get_u32(sinfo[NL80211_STA_INFO_TX_FAILED]));
  50. +
  51. + chain = get_chain_signal(sinfo[NL80211_STA_INFO_CHAIN_SIGNAL]);
  52. if (sinfo[NL80211_STA_INFO_SIGNAL])
  53. - printf("\n\tsignal: \t%d dBm",
  54. - (int8_t)nla_get_u8(sinfo[NL80211_STA_INFO_SIGNAL]));
  55. + printf("\n\tsignal: \t%d %sdBm",
  56. + (int8_t)nla_get_u8(sinfo[NL80211_STA_INFO_SIGNAL]),
  57. + chain);
  58. +
  59. + chain = get_chain_signal(sinfo[NL80211_STA_INFO_CHAIN_SIGNAL_AVG]);
  60. if (sinfo[NL80211_STA_INFO_SIGNAL_AVG])
  61. - printf("\n\tsignal avg:\t%d dBm",
  62. - (int8_t)nla_get_u8(sinfo[NL80211_STA_INFO_SIGNAL_AVG]));
  63. + printf("\n\tsignal avg:\t%d %sdBm",
  64. + (int8_t)nla_get_u8(sinfo[NL80211_STA_INFO_SIGNAL_AVG]),
  65. + chain);
  66. +
  67. if (sinfo[NL80211_STA_INFO_T_OFFSET])
  68. printf("\n\tToffset:\t%lld us",
  69. (unsigned long long)nla_get_u64(sinfo[NL80211_STA_INFO_T_OFFSET]));