Skip to content

Commit

Permalink
feat: Add RSSI field
Browse files Browse the repository at this point in the history
  • Loading branch information
JahazielLem committed Nov 22, 2024
1 parent 5a1f149 commit 8895d08
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
5 changes: 4 additions & 1 deletion firmware/components/ieee_sniffer/ieee_sniffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ uint8_t ieee_sniffer_get_channel() {
return current_channel;
}

int8_t ieee_sniffer_get_rssi() {
return esp_ieee802154_get_recent_rssi();
}

void ieee_sniffer_set_channel(int channel) {
current_channel = channel;
if (channel < IEEE_SNIFFER_CHANNEL_MIN) {
Expand Down Expand Up @@ -112,7 +116,6 @@ void ieee_sniffer_channel_hop() {
ieee_sniffer_configure();
esp_ieee802154_disable();
while (true) {
// vTaskDelay(10 / portTICK_PERIOD_MS);
esp_ieee802154_enable();
ieee_sniffer_set_channel(current_channel + 1);
esp_ieee802154_receive();
Expand Down
2 changes: 2 additions & 0 deletions firmware/components/ieee_sniffer/ieee_sniffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ void ieee_sniffer_stop(void);
void ieee_sniffer_set_channel(int channel);

uint8_t ieee_sniffer_get_channel();
int8_t ieee_sniffer_get_rssi();

void ieee_sniffer_channel_hop();

#endif // IEEE_SNIFFER_H
17 changes: 13 additions & 4 deletions firmware/main/modules/gps/war_bee/warbee_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,16 @@ static int current_channel = IEEE_SNIFFER_CHANNEL_DEFAULT;
static char addressing_mode[4][15] = {"None", "Reserved", "Short/16-bit",
"Long/64-bit"};

const char* csv_header = FORMAT_VERSION ",appRelease=" APP_VERSION
",model=" MODEL ",release=" RELEASE;
const char* csv_header = FORMAT_VERSION
",appRelease=" APP_VERSION ",model=" MODEL ",release=" RELEASE
",device=" DEVICE ",display=" DISPLAY ",board=" BOARD ",brand=" BRAND
",star=" STAR ",body=" BODY ",subBody=" SUB_BODY
"\n"
// IEEE 802.15.4 fields
"Source,DestinationPAN,Channel,"
// GPS fields
"CurrentLatitude,CurrentLongitude,AltitudeMeters,AccuracyMeters,RCOIs,"
"MfgrId,Type";

static void warbee_packet_dissector(uint8_t* packet, uint8_t packet_length) {
uint8_t position = 0;
Expand Down Expand Up @@ -71,6 +79,7 @@ static void warbee_packet_dissector(uint8_t* packet, uint8_t packet_length) {
case FRAME_TYPE_MAC_COMMAND:
printf("Beacon Request\n");
printf("└Channel: %d\n", ieee_sniffer_get_channel());
printf("RSSI: %d\n", ieee_sniffer_get_rssi());
uint8_t sequence_number = packet[position];
position += sizeof(uint8_t);
printf("Sequence number: %u\n", sequence_number);
Expand All @@ -87,8 +96,8 @@ static void warbee_packet_dissector(uint8_t* packet, uint8_t packet_length) {
break;
// Device is sending to a short address
case ADDR_MODE_SHORT:
pan_id = *((uint8_t*) &packet[position]);
position += sizeof(uint8_t);
pan_id = *((uint16_t*) &packet[position]);
position += sizeof(uint16_t);
short_dst_addr = *((uint16_t*) &packet[position]);
position += sizeof(uint16_t);
if (pan_id == 0xFFFF && short_dst_addr == 0xFFFF) {
Expand Down

0 comments on commit 8895d08

Please sign in to comment.