development reverted to cyberman development
This commit is contained in:
parent
ed46e10a9b
commit
fc7a8b361b
9
build.py
9
build.py
@ -98,11 +98,10 @@ env.Replace(BINTRAY_API_TOKEN=apitoken)
|
||||
|
||||
# get runtime credentials and put them to compiler directive
|
||||
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'-DWIFI_SSID=\\"' + mykeys["OTA_WIFI_SSID"] + '\\"',
|
||||
u'-DWIFI_PASS=\\"' + mykeys["OTA_WIFI_PASS"] + '\\"',
|
||||
u'-DBINTRAY_USER=\\"' + mykeys["BINTRAY_USER"] + '\\"',
|
||||
u'-DBINTRAY_REPO=\\"' + mykeys["BINTRAY_REPO"] + '\\"',
|
||||
u'-DBINTRAY_PACKAGE=\\"' + package + '\\"',
|
||||
u'-DARDUINO_LMIC_PROJECT_CONFIG_H=' + lmicconfig,
|
||||
u'-I \"' + srcdir + '\"'
|
||||
|
@ -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);
|
||||
|
@ -18,8 +18,7 @@
|
||||
#include "irqhandler.h"
|
||||
#include "led.h"
|
||||
#include "spislave.h"
|
||||
#include "uart.h"
|
||||
#if(HAS_LORA)
|
||||
#if (HAS_LORA)
|
||||
#include "lorawan.h"
|
||||
#endif
|
||||
#include "timekeeper.h"
|
||||
|
@ -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
|
||||
|
||||
|
@ -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",
|
||||
@ -390,4 +399,4 @@
|
||||
"disabled": false,
|
||||
"hidden": false
|
||||
}
|
||||
]
|
||||
]
|
@ -677,4 +677,4 @@ const char *getCrName(rps_t rps) {
|
||||
return t[getCr(rps)];
|
||||
}
|
||||
|
||||
#endif // HAS_LORA
|
||||
#endif // HAS_LORA
|
@ -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
|
||||
@ -164,4 +134,4 @@ bool mac_add(uint8_t *paddr, int8_t rssi, bool sniff_type) {
|
||||
// True if MAC WiFi/BLE was new
|
||||
return added; // function returns bool if a new and unique Wifi or BLE mac was
|
||||
// counted (true) or not (false)
|
||||
}
|
||||
}
|
@ -465,11 +465,7 @@ void setup() {
|
||||
// show compiled features
|
||||
ESP_LOGI(TAG, "Features:%s", features);
|
||||
|
||||
macsniff_setup();
|
||||
|
||||
uart_setup();
|
||||
|
||||
} // setup()
|
||||
vTaskDelete(NULL);
|
||||
|
||||
} // setup()
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
[ota]
|
||||
OTA_WIFI_SSID = MyHomeWifi
|
||||
OTA_WIFI_PASS = FooBar42!
|
||||
OTA_TRIGGER_MAC = FFFFFFFF
|
||||
|
||||
[bintray]
|
||||
BINTRAY_USER = MyBintrayUser
|
||||
|
@ -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); }
|
||||
|
||||
@ -315,8 +308,8 @@ void PayloadConvert::writeBitmap(bool a, bool b, bool c, bool d, bool e, bool f,
|
||||
|
||||
#elif ((PAYLOAD_ENCODER == 3) || (PAYLOAD_ENCODER == 4))
|
||||
|
||||
void PayloadConvert::addByte(uint8_t value) {
|
||||
/*
|
||||
void PayloadConvert::addByte(uint8_t value) {
|
||||
/*
|
||||
not implemented
|
||||
*/ }
|
||||
|
||||
@ -493,4 +486,4 @@ void PayloadConvert::addTime(time_t value) {
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
@ -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__;
|
||||
|
83
src/uart.cpp
83
src/uart.cpp
@ -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
|
||||
}
|
15
src/uart.h
15
src/uart.h
@ -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
|
Loading…
Reference in New Issue
Block a user