Skip to content

Commit

Permalink
inc/opendefs: add new neighbors logging
Browse files Browse the repository at this point in the history
  • Loading branch information
fjmolinas committed Dec 4, 2020
1 parent ff10980 commit 5645407
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion inc/opendefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,6 @@ enum {
// l2b
ERR_SCHEDULE_ADD_DUPLICATE_SLOT = 0x20, // the slot {0} to be added is already in schedule
ERR_NEIGHBORS_FULL = 0x21, // neighbors table is full (max number of neighbor is {0})

ERR_NO_SENT_PACKET = 0x22, // there is no sent packet in queue
ERR_NO_RECEIVED_PACKET = 0x23, // there is no received packet in queue
ERR_SCHEDULE_OVERFLOWN = 0x24, // schedule overflown
Expand Down Expand Up @@ -290,6 +289,7 @@ enum {
ERR_INVALID_PARAM = 0x53, // received an invalid parameter
ERR_COPY_TO_SPKT = 0x54, // copy packet content to small packet (pkt len {} < max len {})
ERR_COPY_TO_BPKT = 0x55, // copy packet content to big packet (pkt len {} > max len {})
ERR_NEW_NEIGHBOR = 0x56, // New neighbor {1:04x} with RSSI {0},
};

//=========================== typedef =========================================
Expand Down
9 changes: 9 additions & 0 deletions openstack/02b-MAChigh/neighbors.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "IEEE802154E.h"
#include "openrandom.h"
#include "msf.h"
#include "openserial.h"

//=========================== variables =======================================

Expand Down Expand Up @@ -681,6 +682,14 @@ void registerNewNeighbor(open_addr_t *address,
if (rssi < GOODNEIGHBORMINRSSI) {
break;
}
open_addr_t addr_16;
addr_16.type = ADDR_16B;
packetfunctions_mac64bToMac16b(address, &addr_16);
uint16_t short_addr = ((addr_16.addr_16b[0] << 8) & 0xff00) |
(addr_16.addr_16b[1] & 0x00ff);
LOG_VERBOSE(COMPONENT_NEIGHBORS, ERR_NEW_NEIGHBOR,
(errorparameter_t) rssi,
(errorparameter_t) short_addr);
// add this neighbor
neighbors_vars.neighbors[i].used = TRUE;
neighbors_vars.neighbors[i].insecure = insecure;
Expand Down

0 comments on commit 5645407

Please sign in to comment.