Undo merge
This commit is contained in:
1 parent
d9404b1a32
commit
7bdff00161
60 files changed
+1911
-1679
No files matched your search
+42
-17
@@ -3,29 +3,54 @@
|
||||
|
||||
#include "globals.h"
|
||||
#include <Wire.h>
|
||||
#include "bsec_integration.h"
|
||||
|
||||
extern const uint8_t bsec_config_iaq[454];
|
||||
#include "../lib/Bosch-BSEC/src/bsec.h"
|
||||
|
||||
extern bmeStatus_t
|
||||
bme_status; // Make struct for storing gps data globally available
|
||||
extern TaskHandle_t BmeTask;
|
||||
|
||||
// --- Bosch BSEC library configuration ---
|
||||
// 3,3V supply voltage; 3s max time between sensor_control calls; 4 days
|
||||
// calibration. Change this const if not applicable for your application (see
|
||||
// BME680 datasheet)
|
||||
const uint8_t bsec_config_iaq[454] = {
|
||||
1, 7, 4, 1, 61, 0, 0, 0, 0, 0, 0, 0, 174, 1, 0,
|
||||
0, 48, 0, 1, 0, 137, 65, 0, 63, 205, 204, 204, 62, 0, 0,
|
||||
64, 63, 205, 204, 204, 62, 0, 0, 225, 68, 0, 192, 168, 71, 64,
|
||||
49, 119, 76, 0, 0, 0, 0, 0, 80, 5, 95, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 28, 0, 2, 0, 0, 244, 1, 225, 0, 25, 0,
|
||||
0, 128, 64, 0, 0, 32, 65, 144, 1, 0, 0, 112, 65, 0, 0,
|
||||
0, 63, 16, 0, 3, 0, 10, 215, 163, 60, 10, 215, 35, 59, 10,
|
||||
215, 35, 59, 9, 0, 5, 0, 0, 0, 0, 0, 1, 88, 0, 9,
|
||||
0, 229, 208, 34, 62, 0, 0, 0, 0, 0, 0, 0, 0, 218, 27,
|
||||
156, 62, 225, 11, 67, 64, 0, 0, 160, 64, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 94, 75, 72, 189, 93, 254, 159, 64, 66, 62, 160, 191,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 33, 31, 180, 190, 138, 176, 97,
|
||||
64, 65, 241, 99, 190, 0, 0, 0, 0, 0, 0, 0, 0, 167, 121,
|
||||
71, 61, 165, 189, 41, 192, 184, 30, 189, 64, 12, 0, 10, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 229, 0, 254, 0, 2, 1, 5, 48,
|
||||
117, 100, 0, 44, 1, 112, 23, 151, 7, 132, 3, 197, 0, 92, 4,
|
||||
144, 1, 64, 1, 64, 1, 144, 1, 48, 117, 48, 117, 48, 117, 48,
|
||||
117, 100, 0, 100, 0, 100, 0, 48, 117, 48, 117, 48, 117, 100, 0,
|
||||
100, 0, 48, 117, 48, 117, 100, 0, 100, 0, 100, 0, 100, 0, 48,
|
||||
117, 48, 117, 48, 117, 100, 0, 100, 0, 100, 0, 48, 117, 48, 117,
|
||||
100, 0, 100, 0, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44,
|
||||
1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1,
|
||||
44, 1, 8, 7, 8, 7, 8, 7, 8, 7, 8, 7, 8, 7, 8,
|
||||
7, 8, 7, 8, 7, 8, 7, 8, 7, 8, 7, 8, 7, 8, 7,
|
||||
112, 23, 112, 23, 112, 23, 112, 23, 112, 23, 112, 23, 112, 23, 112,
|
||||
23, 112, 23, 112, 23, 112, 23, 112, 23, 112, 23, 112, 23, 255, 255,
|
||||
255, 255, 255, 255, 255, 255, 220, 5, 220, 5, 220, 5, 255, 255, 255,
|
||||
255, 255, 255, 220, 5, 220, 5, 255, 255, 255, 255, 255, 255, 255, 255,
|
||||
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
||||
255, 255, 255, 255, 255, 255, 255, 255, 255, 44, 1, 0, 0, 0, 0,
|
||||
239, 79, 0, 0};
|
||||
|
||||
// Helper functions declarations
|
||||
int bme_init();
|
||||
void bme_loop(void *pvParameters);
|
||||
int8_t i2c_read(uint8_t dev_id, uint8_t reg_addr, uint8_t *reg_data,
|
||||
uint16_t len);
|
||||
int8_t i2c_write(uint8_t dev_id, uint8_t reg_addr, uint8_t *reg_data,
|
||||
uint16_t len);
|
||||
void output_ready(int64_t timestamp, float iaq, uint8_t iaq_accuracy,
|
||||
float temperature, float humidity, float pressure,
|
||||
float raw_temperature, float raw_humidity, float gas,
|
||||
bsec_library_return_t bsec_status, float static_iaq,
|
||||
float co2_equivalent, float breath_voc_equivalent);
|
||||
uint32_t state_load(uint8_t *state_buffer, uint32_t n_buffer);
|
||||
void state_save(const uint8_t *state_buffer, uint32_t length);
|
||||
uint32_t config_load(uint8_t *config_buffer, uint32_t n_buffer);
|
||||
void user_delay_ms(uint32_t period);
|
||||
int64_t get_timestamp_us();
|
||||
int checkIaqSensorStatus(void);
|
||||
void loadState(void);
|
||||
void updateState(void);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,77 @@
|
||||
// Copyright 2018-2018 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef __COEXIST_INTERNAL_H__
|
||||
#define __COEXIST_INTERNAL_H__
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
COEX_PREFER_WIFI = 0,
|
||||
COEX_PREFER_BT,
|
||||
COEX_PREFER_BALANCE,
|
||||
COEX_PREFER_NUM,
|
||||
} coex_prefer_t;
|
||||
|
||||
/**
|
||||
* @brief Init software coexist
|
||||
* extern function for internal use.
|
||||
*
|
||||
* @return Init ok or failed.
|
||||
*/
|
||||
esp_err_t coex_init(void);
|
||||
|
||||
/**
|
||||
* @brief De-init software coexist
|
||||
* extern function for internal use.
|
||||
*/
|
||||
void coex_deinit(void);
|
||||
|
||||
/**
|
||||
* @brief Pause software coexist
|
||||
* extern function for internal use.
|
||||
*/
|
||||
void coex_pause(void);
|
||||
|
||||
/**
|
||||
* @brief Resume software coexist
|
||||
* extern function for internal use.
|
||||
*/
|
||||
void coex_resume(void);
|
||||
|
||||
/**
|
||||
* @brief Get software coexist version string
|
||||
* extern function for internal use.
|
||||
* @return : version string
|
||||
*/
|
||||
const char *coex_version_get(void);
|
||||
|
||||
/**
|
||||
* @brief Coexist performance preference set from libbt.a
|
||||
* extern function for internal use.
|
||||
*
|
||||
* @param prefer : the prefer enumeration value
|
||||
* @return : ESP_OK - success, other - failed
|
||||
*/
|
||||
esp_err_t coex_preference_set(coex_prefer_t prefer);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __COEXIST_INTERNAL_H__ */
|
||||
@@ -7,10 +7,15 @@
|
||||
#include "spislave.h"
|
||||
#include <lmic.h>
|
||||
|
||||
#ifdef HAS_BME
|
||||
#include "bme680mems.h"
|
||||
#endif
|
||||
|
||||
void doHousekeeping(void);
|
||||
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
|
||||
@@ -2,6 +2,7 @@
|
||||
#define _DISPLAY_H
|
||||
|
||||
#include <U8x8lib.h>
|
||||
#include "cyclic.h"
|
||||
|
||||
extern uint8_t volatile DisplayState;
|
||||
extern HAS_DISPLAY u8x8;
|
||||
|
||||
+26
-19
@@ -8,6 +8,13 @@
|
||||
#include <set>
|
||||
#include <array>
|
||||
#include <algorithm>
|
||||
#include "mallocator.h"
|
||||
//#include "inc/bsec_datatypes.h"
|
||||
#include "../lib/Bosch-BSEC/src/inc/bsec_datatypes.h"
|
||||
|
||||
// sniffing types
|
||||
#define MAC_SNIFF_WIFI 0
|
||||
#define MAC_SNIFF_BLE 1
|
||||
|
||||
// bits in payloadmask for filtering payload data
|
||||
#define GPS_DATA (0x01)
|
||||
@@ -49,6 +56,7 @@ typedef struct {
|
||||
uint8_t runmode; // 0=normal, 1=update
|
||||
uint8_t payloadmask; // bitswitches for payload data
|
||||
char version[10]; // Firmware version
|
||||
uint8_t bsecstate[BSEC_MAX_STATE_BLOB_SIZE + 1]; // BSEC state for BME680 sensor
|
||||
} configData_t;
|
||||
|
||||
// Struct holding payload for data send queue
|
||||
@@ -67,14 +75,14 @@ typedef struct {
|
||||
} gpsStatus_t;
|
||||
|
||||
typedef struct {
|
||||
float iaq; // IAQ signal
|
||||
uint8_t iaq_accuracy; // accuracy of IAQ signal
|
||||
float temperature; // temperature signal
|
||||
float humidity; // humidity signal
|
||||
float pressure; // pressure signal
|
||||
float raw_temperature; // raw temperature signal
|
||||
float raw_humidity; // raw humidity signal
|
||||
float gas; // raw gas sensor signal
|
||||
float iaq; // IAQ signal
|
||||
uint8_t iaq_accuracy; // accuracy of IAQ signal
|
||||
float temperature; // temperature signal
|
||||
float humidity; // humidity signal
|
||||
float pressure; // pressure signal
|
||||
float raw_temperature; // raw temperature signal
|
||||
float raw_humidity; // raw humidity signal
|
||||
float gas; // raw gas sensor signal
|
||||
} bmeStatus_t;
|
||||
|
||||
// global variables
|
||||
@@ -82,26 +90,25 @@ extern configData_t cfg; // current device configuration
|
||||
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;
|
||||
batt_voltage; // display values
|
||||
extern hw_timer_t *channelSwitch, *sendCycle, *displaytimer;
|
||||
extern SemaphoreHandle_t I2Caccess;
|
||||
|
||||
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;
|
||||
|
||||
extern TaskHandle_t irqHandlerTask, wifiSwitchTask;
|
||||
|
||||
// application includes
|
||||
#include "led.h"
|
||||
#include "payload.h"
|
||||
#include "blescan.h"
|
||||
|
||||
#ifdef HAS_GPS
|
||||
#include "gpsread.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAS_BME
|
||||
#include "bme680mems.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAS_LORA
|
||||
#include "lorawan.h"
|
||||
#endif
|
||||
@@ -114,10 +121,6 @@ extern TaskHandle_t irqHandlerTask, wifiSwitchTask;
|
||||
#include "button.h"
|
||||
#endif
|
||||
|
||||
#ifdef BLECOUNTER
|
||||
#include "blescan.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAS_BATTERY_PROBE
|
||||
#include "battery.h"
|
||||
#endif
|
||||
@@ -130,4 +133,8 @@ extern TaskHandle_t irqHandlerTask, wifiSwitchTask;
|
||||
#include "sensor.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAS_BME
|
||||
#include "bme680mems.h"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
+1
-1
@@ -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
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <esp_spi_flash.h> // needed for reading ESP32 chip attributes
|
||||
#include <esp_event_loop.h> // needed for Wifi event handler
|
||||
#include <esp32-hal-timer.h> // needed for timers
|
||||
#include <esp_coexist.h> // needed for showing coex sw version
|
||||
|
||||
#include "globals.h"
|
||||
#include "wifiscan.h"
|
||||
|
||||
@@ -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
-1
@@ -39,7 +39,7 @@ public:
|
||||
void reset(void);
|
||||
uint8_t getSize(void);
|
||||
uint8_t *getBuffer(void);
|
||||
void addCount(uint16_t value1, uint16_t value2);
|
||||
void addCount(uint16_t value, uint8_t sniffytpe);
|
||||
void addConfig(configData_t value);
|
||||
void addStatus(uint16_t voltage, uint64_t uptime, float cputemp, uint32_t mem,
|
||||
uint8_t reset1, uint8_t reset2);
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -7,9 +7,6 @@
|
||||
// Hash function for scrambling MAC addresses
|
||||
#include "hash.h"
|
||||
|
||||
#define MAC_SNIFF_WIFI 0
|
||||
#define MAC_SNIFF_BLE 1
|
||||
|
||||
void wifi_sniffer_init(void);
|
||||
void IRAM_ATTR wifi_sniffer_packet_handler(void *buff, wifi_promiscuous_pkt_type_t type);
|
||||
void switchWifiChannel(void * parameter);
|
||||
|
||||
Reference in new issue
Block a user