development reverted to cyberman development

This commit is contained in:
Marius Gripp 2019-10-10 17:34:01 +02:00
parent ed46e10a9b
commit fc7a8b361b
13 changed files with 31 additions and 167 deletions

View File

@ -100,7 +100,6 @@ env.Replace(BINTRAY_API_TOKEN=apitoken)
env.Append(BUILD_FLAGS=[
u'-DWIFI_SSID=\\"' + mykeys["OTA_WIFI_SSID"] + '\\"',
u'-DWIFI_PASS=\\"' + mykeys["OTA_WIFI_PASS"] + '\\"',
u'-DOTA_TRIGGER_MAC=\\"' + mykeys["OTA_TRIGGER_MAC"] + '\\"',
u'-DBINTRAY_USER=\\"' + mykeys["BINTRAY_USER"] + '\\"',
u'-DBINTRAY_REPO=\\"' + mykeys["BINTRAY_REPO"] + '\\"',
u'-DBINTRAY_PACKAGE=\\"' + package + '\\"',

View File

@ -12,7 +12,6 @@
#define MAC_SNIFF_WIFI 0
#define MAC_SNIFF_BLE 1
void macsniff_setup(void);
uint16_t get_salt(void);
uint64_t macConvert(uint8_t *paddr);
bool mac_add(uint8_t *paddr, int8_t rssi, bool sniff_type);

View File

@ -18,7 +18,6 @@
#include "irqhandler.h"
#include "led.h"
#include "spislave.h"
#include "uart.h"
#if (HAS_LORA)
#include "lorawan.h"
#endif

View File

@ -55,7 +55,6 @@ public:
void addButton(uint8_t value);
void addSensor(uint8_t[]);
void addTime(time_t value);
void addTimeDiff(int32_t value);
#if (PAYLOAD_ENCODER == 1) // format plain

View File

@ -14,17 +14,26 @@
"to": "down",
"tot": "str"
},
"page-titlebar-backgroundColor":{
"value":"#0094CE",
"edited":false
{
"t": "set",
"p": "payload.confirmed",
"pt": "msg",
"to": "false",
"tot": "bool"
},
"page-backgroundColor":{
"value":"#fafafa",
"edited":false
{
"t": "set",
"p": "payload.schedule",
"pt": "msg",
"to": "replace",
"tot": "str"
},
"page-sidebar-backgroundColor":{
"value":"#ffffff",
"edited":false
{
"t": "move",
"p": "payload",
"pt": "msg",
"to": "payload.payload_raw",
"tot": "msg"
},
{
"t": "move",

View File

@ -6,21 +6,10 @@
#include "vendor_array.h"
#endif
#include <sstream>
#include <iostream>
// Local logging tag
static const char TAG[] = __FILE__;
uint16_t salt;
uint64_t fota_trigger_mac;
void macsniff_setup() {
std::stringstream ss;
ss << std::hex << OTA_TRIGGER_MAC;
ss >> fota_trigger_mac;
std::cout << static_cast<int>(fota_trigger_mac) << std::endl;
}
uint16_t get_salt(void) {
salt = (uint16_t)random(65536); // get new 16bit random for salting hashes
@ -93,25 +82,6 @@ bool mac_add(uint8_t *paddr, int8_t rssi, bool sniff_type) {
// Count only if MAC was not yet seen
if (added) {
ESP_LOGD(TAG, "new Mac: %x:%x:%x:%x:%x:%x",
paddr[0],
paddr[1],
paddr[2],
paddr[3],
paddr[4],
paddr[5]
);
// is newly found MAC the OTA trigger?
uint64_t addr48 = (((uint64_t)paddr[3]) | ((uint64_t)paddr[2] << 8) |
((uint64_t)paddr[1] << 16) | ((uint64_t)paddr[0] << 24));
if((int)(addr48-fota_trigger_mac) == 0)
{
ESP_LOGI(TAG, "OTA-MAC found, Update triggered");
// initiate OTA update
uint8_t cmd[2] = {9, 9};
rcommand(cmd, 2);
}
// increment counter and one blink led
if (sniff_type == MAC_SNIFF_WIFI) {
macs_wifi++; // increment Wifi MACs counter

View File

@ -465,11 +465,7 @@ void setup() {
// show compiled features
ESP_LOGI(TAG, "Features:%s", features);
macsniff_setup();
uart_setup();
} // setup()
vTaskDelete(NULL);
} // setup()

View File

@ -1,7 +1,6 @@
[ota]
OTA_WIFI_SSID = MyHomeWifi
OTA_WIFI_PASS = FooBar42!
OTA_TRIGGER_MAC = FFFFFFFF
[bintray]
BINTRAY_USER = MyBintrayUser

View File

@ -16,14 +16,7 @@ uint8_t *PayloadConvert::getBuffer(void) { return buffer; }
/* ---------------- plain format without special encoding ---------- */
void PayloadConvert::addTimeDiff(int32_t value) {
buffer[cursor++] = (byte)((value & 0xFF000000) >> 24);
buffer[cursor++] = (byte)((value & 0x00FF0000) >> 16);
buffer[cursor++] = (byte)((value & 0x0000FF00) >> 8);
buffer[cursor++] = (byte)((value & 0x000000FF));
}
#if PAYLOAD_ENCODER == 1
#if (PAYLOAD_ENCODER == 1)
void PayloadConvert::addByte(uint8_t value) { buffer[cursor++] = (value); }

View File

@ -12,7 +12,6 @@ algorithm in applications without granted license by the patent holder.
#if (TIME_SYNC_LORASERVER) && (HAS_LORA)
#include "timesync.h"
#include "uart.h"
// Local logging tag
static const char TAG[] = __FILE__;

View File

@ -1,83 +0,0 @@
#include "rtctime.h"
#include <Arduino.h>
#include <sys/time.h>
#include <lmic/oslmic.h>
#include "globals.h"
#include "uart.h"
#include "driver/uart.h"
static const char TAG[] = __FILE__;
TaskHandle_t UartTask = NULL;
void uart_setup() {
// setup UART connection
uart_config_t uart_config = {
.baud_rate = 9600,
.data_bits = UART_DATA_7_BITS,
.parity = UART_PARITY_EVEN,
.stop_bits = UART_STOP_BITS_1,
.flow_ctrl = UART_HW_FLOWCTRL_DISABLE
};
uart_param_config(UART_NUM_1, &uart_config);
uart_set_pin(UART_NUM_1, CLOCK_DCF_TXD, CLOCK_DCF_RXD, CLOCK_DCF_RTS, CLOCK_DCF_CTS);
uart_driver_install(UART_NUM_1, CLOCK_BUF_SIZE * 2, 0, 0, NULL, 0);
}
void time_uart_send(void * pvParameters) {
struct timeval curTime;
const char* format = "\bOAL%y%m%dF%H%M%S\r";
char timestamp[64] = {0};
TickType_t xLastWakeTime = xTaskGetTickCount();
for(;;) {
struct timeval tv;
struct timezone tz;
if(gettimeofday(&tv, &tz) != 0) {
ESP_LOGI(TAG, "ERROR gettimeofday");
}
time_t nowTime = tv.tv_sec;
strftime(timestamp, sizeof(timestamp), format, localtime(&nowTime));
ESP_LOGI(TAG, "Current Time: %s", timestamp);
int len = strlen(timestamp)+1;
// Send Data via UART
uart_write_bytes(UART_NUM_1, timestamp, len);
// gettimeofday(&curTime, &tz);
int sleep = 1000 - (curTime.tv_usec/1000);
ostime_t now = os_getTime();
ESP_LOGD(TAG, "Sleep Time: %d, now: %d\n", sleep, now);
vTaskDelayUntil( &xLastWakeTime, (TickType_t)(sleep/portTICK_PERIOD_MS) );
// Read UART for testing purposes
/**
uint8_t *data = (uint8_t *) malloc(CLOCK_BUF_SIZE);
// Read Data via UART
uart_read_bytes(UART_NUM_1, data, CLOCK_BUF_SIZE, 20 / portTICK_RATE_MS);
const char * dataC = (const char *) data;
ESP_LOGI(TAG, "Data Read: %s", dataC);
free(data);
**/
}
vTaskDelete(NULL);
}
void time_uart_send_start() {
if (UartTask) {
return;
}
xTaskCreatePinnedToCore(time_uart_send, // task function
"time_uart_send", // name of task
2048, // stack size of task
(void *)1, // parameter of the task
2, // priority of the task
&UartTask, // task handle
1); // CPU core
}

View File

@ -1,15 +0,0 @@
#ifndef UART_H
#define UART_H
// UART for Clock DCF
#define CLOCK_DCF_TXD (GPIO_NUM_4)
#define CLOCK_DCF_RXD (GPIO_NUM_15)
#define CLOCK_DCF_RTS (UART_PIN_NO_CHANGE)
#define CLOCK_DCF_CTS (UART_PIN_NO_CHANGE)
#define CLOCK_BUF_SIZE (1024)
void time_uart_send(void * pvParameters);
void time_uart_send_start();
void uart_setup();
#endif