v1.7.01 (PSRAM support, timesync off)

This commit is contained in:
Klaus K Wilting committed 2018-12-22 14:37:47 +01:00
1 parent 9574a194fd
commit 3140ab9214
15 files changed
+126 -25

No files matched your search

+1
View File
@@ -12,5 +12,6 @@ void do_timesync(void);
uint64_t uptime(void);
void reset_counters(void);
int redirect_log(const char *fmt, va_list args);
uint32_t getFreeRAM();
#endif
+1
View File
@@ -2,6 +2,7 @@
#define _DISPLAY_H
#include <U8x8lib.h>
#include "cyclic.h"
extern uint8_t volatile DisplayState;
extern HAS_DISPLAY u8x8;
+2 -1
View File
@@ -8,6 +8,7 @@
#include <set>
#include <array>
#include <algorithm>
#include "Mallocator.h"
// sniffing types
#define MAC_SNIFF_WIFI 0
@@ -87,9 +88,9 @@ extern char display_line6[], display_line7[]; // screen buffers
extern uint8_t volatile channel; // wifi channel rotation counter
extern uint16_t volatile macs_total, macs_wifi, macs_ble,
batt_voltage; // display values
extern std::set<uint16_t> macs; // temp storage for MACs
extern hw_timer_t *channelSwitch, *sendCycle, *displaytimer;
extern std::set<uint16_t, std::less<uint16_t>, Mallocator<uint16_t>> macs;
extern std::array<uint64_t, 0xff>::iterator it;
extern std::array<uint64_t, 0xff> beacons;
+1 -1
View File
@@ -6,8 +6,8 @@
// Hash function for scrambling MAC addresses
#include "hash.h"
#include "senddata.h"
#include "cyclic.h"
#define MAC_SNIFF_WIFI 0
#define MAC_SNIFF_BLE 1
+54
View File
@@ -0,0 +1,54 @@
/*
This Mallocator code was taken from:
CppCon2014 Presentations
STL Features And Implementation Techniques
Stephan T. Lavavej
https://github.com/CppCon/CppCon2014
*/
#ifndef _MALLOCATOR_H
#define _MALLOCATOR_H
#include <stdlib.h> // size_t, malloc, free
#include <new> // bad_alloc, bad_array_new_length
#include "esp32-hal-psram.h" // ps_malloc
template <class T> struct Mallocator {
typedef T value_type;
Mallocator() noexcept {} // default ctor not required
template <class U> Mallocator(const Mallocator<U> &) noexcept {}
template <class U> bool operator==(const Mallocator<U> &) const noexcept {
return true;
}
template <class U> bool operator!=(const Mallocator<U> &) const noexcept {
return false;
}
T *allocate(const size_t n) const {
if (n == 0) {
return nullptr;
}
if (n > static_cast<size_t>(-1) / sizeof(T)) {
throw std::bad_array_new_length();
}
#ifndef BOARD_HAS_PSRAM
void *const pv = malloc(n * sizeof(T));
#else
void *const pv = ps_malloc(n * sizeof(T));
#endif
if (!pv) {
throw std::bad_alloc();
}
return static_cast<T *>(pv);
}
void deallocate(T *const p, size_t) const noexcept { free(p); }
};
#endif
+1
View File
@@ -7,6 +7,7 @@
#include "lorawan.h"
#include "macsniff.h"
#include <rom/rtc.h>
#include "cyclic.h"
// table of remote commands and assigned functions
typedef struct {