This commit is contained in:
Klaus K Wilting 2018-12-09 13:48:03 +01:00
parent 664d58bb4f
commit e733dba9f4
12 changed files with 102 additions and 21 deletions

View File

@ -56,7 +56,7 @@ Hardware dependent settings (pinout etc.) are stored in board files in /hal dire
<A HREF="https://www.thingiverse.com/thing:2670713">Heltec</A>, <A HREF="https://www.thingiverse.com/thing:2811127">TTGOv2</A>, <A HREF="https://www.thingiverse.com/thing:3005574">TTGOv2.1</A>, <A HREF="https://www.thingiverse.com/thing:3041339">T-BEAM</A> for example.<br> <A HREF="https://www.thingiverse.com/thing:2670713">Heltec</A>, <A HREF="https://www.thingiverse.com/thing:2811127">TTGOv2</A>, <A HREF="https://www.thingiverse.com/thing:3005574">TTGOv2.1</A>, <A HREF="https://www.thingiverse.com/thing:3041339">T-BEAM</A> for example.<br>
<b>Power consumption</b> was metered at around 450 - 1000mW, depending on board and user settings in paxcounter.conf. <b>Power consumption</b> was metered at around 450 - 1000mW, depending on board and user settings in paxcounter.conf.
By default bluetooth sniffing is disabled (line *#define BLECOUNTER* in paxcounter.conf is commented out). Enabling bluetooth costs 30% more power + 30% flash storage for the software stack. Proof of concept showed that for passenger flow metering purpose wifi sniffing shows better results than bluetooth sniffing. If you enable bluetooth be aware that this goes on expense of wifi sniffing results, because then wifi stack gets less access to RF ressources of ESP32. By default bluetooth sniffing is disabled (line *#define BLECOUNTER* in paxcounter.conf is commented out). Enabling bluetooth costs 30% more power + 30% flash storage for the software stack. Proof of concept showed that for passenger flow metering wifi sniffing shows better results than bluetooth sniffing. If you enable bluetooth be aware that this goes on expense of wifi sniffing results, because then wifi and bt stack must share the 2,4 GHz RF ressources of ESP32. If you need to sniff wifi and bt in parallel and need best possible results, use two boards - one for wifi only and one for bt only - and add counted results.
# Preparing # Preparing

View File

@ -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__ */

View File

@ -4,6 +4,7 @@
#include <esp_spi_flash.h> // needed for reading ESP32 chip attributes #include <esp_spi_flash.h> // needed for reading ESP32 chip attributes
#include <esp_event_loop.h> // needed for Wifi event handler #include <esp_event_loop.h> // needed for Wifi event handler
#include <esp32-hal-timer.h> // needed for timers #include <esp32-hal-timer.h> // needed for timers
#include <esp_coexist.h> // needed for showing coex sw version
#include "globals.h" #include "globals.h"
#include "wifiscan.h" #include "wifiscan.h"

View File

@ -29,7 +29,7 @@ description = Paxcounter is a proof-of-concept ESP32 device for metering passeng
[common] [common]
; for release_version use max. 10 chars total, use any decimal format like "a.b.c" ; for release_version use max. 10 chars total, use any decimal format like "a.b.c"
release_version = 1.6.98 release_version = 1.6.991
; DEBUG LEVEL: For production run set to 0, otherwise device will leak RAM while running! ; DEBUG LEVEL: For production run set to 0, otherwise device will leak RAM while running!
; 0=None, 1=Error, 2=Warn, 3=Info, 4=Debug, 5=Verbose ; 0=None, 1=Error, 2=Warn, 3=Info, 4=Debug, 5=Verbose
debug_level = 0 debug_level = 0
@ -43,7 +43,7 @@ platform_espressif32 = https://github.com/platformio/platform-espressif32.git#fe
board_build.partitions = min_spiffs.csv board_build.partitions = min_spiffs.csv
monitor_speed = 115200 monitor_speed = 115200
lib_deps_lora = lib_deps_lora =
MCCI LoRaWAN LMIC library@2.3.1 MCCI LoRaWAN LMIC library@^2.3.1
lib_deps_display = lib_deps_display =
U8g2@>=2.25.0 U8g2@>=2.25.0
lib_deps_rgbled = lib_deps_rgbled =
@ -205,7 +205,8 @@ monitor_speed = ${common.monitor_speed}
[env:ttgobeam] [env:ttgobeam]
platform = ${common.platform_espressif32} platform = ${common.platform_espressif32}
framework = arduino framework = arduino
board = esp32dev ;board = esp32dev
board = t-beam
board_build.partitions = ${common.board_build.partitions} board_build.partitions = ${common.board_build.partitions}
upload_speed = 921600 upload_speed = 921600
lib_deps = lib_deps =
@ -238,7 +239,7 @@ monitor_speed = ${common.monitor_speed}
[env:lopy] [env:lopy]
platform = ${common.platform_espressif32} platform = ${common.platform_espressif32}
framework = arduino framework = arduino
board = lopy4 board = lopy
board_build.partitions = ${common.board_build.partitions} board_build.partitions = ${common.board_build.partitions}
upload_speed = 921600 upload_speed = 921600
lib_deps = lib_deps =

View File

@ -50,6 +50,11 @@ function Decoder(bytes, port) {
return decode(bytes, [float, uint16, ufloat, ufloat], ['temperature', 'pressure', 'humidity', 'air']); return decode(bytes, [float, uint16, ufloat, ufloat], ['temperature', 'pressure', 'humidity', 'air']);
} }
if (port === 8) {
// battery voltage
return decode(bytes, [uint16], ['voltage']);
}
} }

View File

@ -18,9 +18,9 @@
#define HAS_BUTTON (0) // button "PROG" on board #define HAS_BUTTON (0) // button "PROG" on board
// Pins for I2C interface of OLED Display // Pins for I2C interface of OLED Display
#define OLED_SDA (4) #define MY_OLED_SDA (4)
#define OLED_SCL (15) #define MY_OLED_SCL (15)
#define OLED_RST (16) #define MY_OLED_RST (16)
// Pins for LORA chip SPI interface come from board file, we need some // Pins for LORA chip SPI interface come from board file, we need some
// additional definitions for LMIC // additional definitions for LMIC

View File

@ -222,13 +222,6 @@ void onEvent(ev_t ev) {
: PSTR("TX_COMPLETE")); : PSTR("TX_COMPLETE"));
sprintf(display_line6, " "); // clear previous lmic status sprintf(display_line6, " "); // clear previous lmic status
// if (LMIC.dataLen) {
// ESP_LOGI(TAG, "Received %d bytes of payload, RSSI %d SNR %d",
// LMIC.dataLen, (signed char)LMIC.rssi, (signed
// char)LMIC.snr);
// sprintf(display_line6, "RSSI %d SNR %d", (signed char)LMIC.rssi,
// (signed char)LMIC.snr);
if (LMIC.dataLen) { if (LMIC.dataLen) {
ESP_LOGI(TAG, "Received %d bytes of payload, RSSI -%d SNR %d", ESP_LOGI(TAG, "Received %d bytes of payload, RSSI -%d SNR %d",
LMIC.dataLen, LMIC.rssi, LMIC.snr / 4); LMIC.dataLen, LMIC.rssi, LMIC.snr / 4);

View File

@ -106,7 +106,7 @@ void setup() {
(chip_info.features & CHIP_FEATURE_EMB_FLASH) ? "embedded" (chip_info.features & CHIP_FEATURE_EMB_FLASH) ? "embedded"
: "external"); : "external");
ESP_LOGI(TAG, "ESP32 SDK: %s", ESP.getSdkVersion()); ESP_LOGI(TAG, "ESP32 SDK: %s", ESP.getSdkVersion());
ESP_LOGI(TAG, "Wifi/BT software coexist version: %s", coex_version_get()); ESP_LOGI(TAG, "Wifi/BT software coexist version: %s", esp_coex_version_get());
ESP_LOGI(TAG, "Free RAM: %d bytes", ESP.getFreeHeap()); ESP_LOGI(TAG, "Free RAM: %d bytes", ESP.getFreeHeap());
#ifdef HAS_GPS #ifdef HAS_GPS

View File

@ -15,7 +15,7 @@
// Set this to include BLE counting and vendor filter functions // Set this to include BLE counting and vendor filter functions
#define VENDORFILTER 1 // comment out if you want to count things, not people #define VENDORFILTER 1 // comment out if you want to count things, not people
//#define BLECOUNTER 1 // activate if you want BLE count, at expense of power & memory #define BLECOUNTER 1 // activate if you want to use BLE count, at expense of memory
// BLE scan parameters // BLE scan parameters
#define BLESCANTIME 0 // [seconds] scan duration, 0 means infinite [default], see note below #define BLESCANTIME 0 // [seconds] scan duration, 0 means infinite [default], see note below

View File

@ -31,6 +31,8 @@ uint8_t sensor_mask(uint8_t sensor_no) {
return (uint8_t)MEMS_DATA; return (uint8_t)MEMS_DATA;
case 7: case 7:
return (uint8_t)ALARM_DATA; return (uint8_t)ALARM_DATA;
default:
return 0;
} }
} }

View File

@ -87,8 +87,7 @@ void spi_slave_task(void *param) {
// wait until spi master clocks out the data, and read results in rx buffer // wait until spi master clocks out the data, and read results in rx buffer
ESP_LOGI(TAG, "Prepared SPI transaction for %zu byte(s)", transaction_size); ESP_LOGI(TAG, "Prepared SPI transaction for %zu byte(s)", transaction_size);
ESP_LOG_BUFFER_HEXDUMP(TAG, txbuf, transaction_size, ESP_LOG_DEBUG); ESP_LOG_BUFFER_HEXDUMP(TAG, txbuf, transaction_size, ESP_LOG_DEBUG);
esp_err_t ret = ESP_ERROR_CHECK_WITHOUT_ABORT(spi_slave_transmit(HSPI_HOST, &spi_transaction, portMAX_DELAY));
spi_slave_transmit(HSPI_HOST, &spi_transaction, portMAX_DELAY);
ESP_LOG_BUFFER_HEXDUMP(TAG, rxbuf, transaction_size, ESP_LOG_DEBUG); ESP_LOG_BUFFER_HEXDUMP(TAG, rxbuf, transaction_size, ESP_LOG_DEBUG);
ESP_LOGI(TAG, "Transaction finished with size %zu bits", ESP_LOGI(TAG, "Transaction finished with size %zu bits",
spi_transaction.trans_len); spi_transaction.trans_len);

View File

@ -2,6 +2,7 @@
#include "globals.h" #include "globals.h"
#include "wifiscan.h" #include "wifiscan.h"
#include <esp_coexist.h> #include <esp_coexist.h>
#include "coexist_internal.h"
// Local logging tag // Local logging tag
static const char TAG[] = "wifi"; static const char TAG[] = "wifi";
@ -50,8 +51,10 @@ void wifi_sniffer_init(void) {
// .filter_mask = WIFI_PROMIS_FILTER_MASK_MGMT}; // only MGMT frames // .filter_mask = WIFI_PROMIS_FILTER_MASK_MGMT}; // only MGMT frames
.filter_mask = WIFI_PROMIS_FILTER_MASK_ALL}; // we use all frames .filter_mask = WIFI_PROMIS_FILTER_MASK_ALL}; // we use all frames
ESP_ERROR_CHECK( ESP_ERROR_CHECK(esp_coex_preference_set(
esp_coex_preference_set((esp_coex_prefer_t) ESP_COEX_PREFER_WIFI)); // configure Wifi/BT coexist lib ESP_COEX_PREFER_BALANCE)); // configure Wifi/BT coexist lib
coex_deinit();
ESP_ERROR_CHECK(esp_wifi_init(&cfg)); // configure Wifi with cfg ESP_ERROR_CHECK(esp_wifi_init(&cfg)); // configure Wifi with cfg
ESP_ERROR_CHECK( ESP_ERROR_CHECK(