Skip to content

Instantly share code, notes, and snippets.

@PolynomialDivision
Created December 25, 2020 18:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PolynomialDivision/059e034311eefff17d6fc28d23ea2547 to your computer and use it in GitHub Desktop.
Save PolynomialDivision/059e034311eefff17d6fc28d23ea2547 to your computer and use it in GitHub Desktop.
if (iw->survey(ifname, buf, &val)) {
val = 0;
} else {
for (int i = 0, x = 1; i < len; i += sizeof(struct iwinfo_survey_entry), x++) {
e = (struct iwinfo_survey_entry *) &buf[i];
if(e->mhz == freq)
{
uint64_t dividend = e->busy_time - *last_channel_time_busy;
uint64_t divisor = e->active_time - *last_channel_time;
*last_channel_time = e->active_time;
*last_channel_time_busy = e->busy_time;
if(divisor)
ret = (int)(dividend * 255 / divisor);
break;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment