printKey() moved

This commit is contained in:
Klaus K Wilting 2018-08-02 12:48:27 +02:00
parent c322eb5a83
commit 952ebe77f9
5 changed files with 14 additions and 14 deletions

View File

@ -107,18 +107,6 @@ void get_hard_deveui(uint8_t *pdeveui) {
#ifdef VERBOSE #ifdef VERBOSE
// Display a key
void printKey(const char *name, const uint8_t *key, uint8_t len, bool lsb) {
const uint8_t *p;
char keystring[len + 1] = "", keybyte[3];
for (uint8_t i = 0; i < len; i++) {
p = lsb ? key + len - i - 1 : key + i;
sprintf(keybyte, "%02X", *p);
strncat(keystring, keybyte, 2);
}
ESP_LOGI(TAG, "%s: %s", name, keystring);
}
// Display OTAA keys // Display OTAA keys
void printKeys(void) { void printKeys(void) {
// LMIC may not have used callback to fill // LMIC may not have used callback to fill

View File

@ -14,7 +14,6 @@ void os_getDevKey(u1_t *buf);
void os_getArtEui(u1_t *buf); void os_getArtEui(u1_t *buf);
void os_getDevEui(u1_t *buf); void os_getDevEui(u1_t *buf);
void printKeys(void); void printKeys(void);
void printKey(const char *name, const uint8_t *key, uint8_t len, bool lsb);
void lorawan_loop(void *pvParameters); void lorawan_loop(void *pvParameters);
#endif #endif

View File

@ -24,6 +24,18 @@ int8_t isBeacon(uint64_t mac) {
return -1; return -1;
} }
// Display a key
void printKey(const char *name, const uint8_t *key, uint8_t len, bool lsb) {
const uint8_t *p;
char keystring[len + 1] = "", keybyte[3];
for (uint8_t i = 0; i < len; i++) {
p = lsb ? key + len - i - 1 : key + i;
sprintf(keybyte, "%02X", *p);
strncat(keystring, keybyte, 2);
}
ESP_LOGI(TAG, "%s: %s", name, keystring);
}
uint64_t macConvert(uint8_t *paddr) { uint64_t macConvert(uint8_t *paddr) {
return ((uint64_t)paddr[0]) | ((uint64_t)paddr[1] << 8) | return ((uint64_t)paddr[0]) | ((uint64_t)paddr[1] << 8) |
((uint64_t)paddr[2] << 16) | ((uint64_t)paddr[3] << 24) | ((uint64_t)paddr[2] << 16) | ((uint64_t)paddr[3] << 24) |

View File

@ -15,5 +15,6 @@
uint16_t reset_salt(void); uint16_t reset_salt(void);
uint64_t macConvert(uint8_t *paddr); uint64_t macConvert(uint8_t *paddr);
bool mac_add(uint8_t *paddr, int8_t rssi, bool sniff_type); bool mac_add(uint8_t *paddr, int8_t rssi, bool sniff_type);
void printKey(const char *name, const uint8_t *key, uint8_t len, bool lsb);
#endif #endif

View File

@ -183,7 +183,7 @@ void set_beacon(uint8_t val[]) {
memmove(val, val + 1, 6); // strip off storage id memmove(val, val + 1, 6); // strip off storage id
beacons[id] = macConvert(val); // store beacon MAC in array beacons[id] = macConvert(val); // store beacon MAC in array
ESP_LOGI(TAG, "Remote command: set beacon ID#%d", id); ESP_LOGI(TAG, "Remote command: set beacon ID#%d", id);
//printKey("MAC", val, 6, false); // show beacon MAC printKey("MAC", val, 6, false); // show beacon MAC
}; };
void set_monitor(uint8_t val[]) { void set_monitor(uint8_t val[]) {