I am new to this device, so please bear with me during the inevitable simple misunderstandings!
I am scanning for bluetooth devices and getting sensible numbers of devices with MAC addresses that tally with other methods. However, I am getting a mixture of positive and negative values for the RSSI. I have researched other questions on this and other fora, but all seem to be all positive rather than a mix. Analysing the data more closely reveals that the values for both negative and positive values rarely, if ever, change. One device in particular has been reporting the same RSSI of +86 for ten of thousands of scans over the past few hours. This is with many revisions of the code, so I very much doubt it is memory corruption, etc. This is my scanning callback:
static void scan_recv_cb(const struct bt_le_scan_recv_info *info,
struct net_buf_simple *buf)
{
static uint32_t last_debug_log = 0;
static uint32_t total_scan_count = 0;
uint32_t current_time = k_uptime_get_32();
total_scan_count++;
char addr_str[BT_ADDR_LE_STR_LEN];
bt_addr_le_to_str(&info->addr, addr_str, sizeof(addr_str));
/* Log every scan for specific problematic device (using string comparison) */
if (strcmp(addr_str, "28:56:5A:30:43:2E (random)") == 0 ||
strcmp(addr_str, "28:56:5A:30:43:2E (public)") == 0) {
LOG_INF("PROBLEMATIC DEVICE SCAN: %s, RSSI: %hhd, Time: %u ms, Count: %u",
addr_str, info->rssi, current_time, total_scan_count);
}
update_beacon_info(&info->addr, info->rssi, NULL, 0);
}
If I put in a test such as `if (info->rssi) ...` then it behaves as though the value is positive, so it isn't some problem with conversion on trying to print it out using printf or LOG_DBG.