remove old code

master
Andrew Woodlee 2 weeks ago
parent cc12e420fd
commit 5451c04eaf

@ -38,25 +38,6 @@ lib_deps =
milesburton/DallasTemperature@^3.11.0
build_src_filter = +<transformerMonitor.cpp> -<.git/> -<.svn/> -<tests/>
[env:dev-ATM90E36]
build_flags = -D DEV ${env.build_flags}
lib_deps =
knolleary/pubsubclient
bblanchon/ArduinoJson @ ^6.21.3
paulstoffregen/OneWire@^2.3.8
milesburton/DallasTemperature@^3.11.0
build_src_filter = +<*> -<.git/> -<.svn/> -<tests/>
[env:dev-ATM90E26]
build_flags = -D DEV ${env.build_flags} -D ATM90E26_EIC
lib_deps =
SPI
knolleary/pubsubclient
https://github.com/whatnick/ATM90E26_Arduino
bblanchon/ArduinoJson @ ^6.21.3
paulstoffregen/OneWire@^2.3.8
milesburton/DallasTemperature@^3.11.0
build_src_filter = +<*> -<.git/> -<.svn/> -<tests/>
[env:TestAT90E26_UART]
build_flags = -D DEV ${env.build_flags}
@ -69,17 +50,6 @@ lib_deps =
milesburton/DallasTemperature@^3.11.0
build_src_filter = -<*> -<.git/> -<.svn/> +<tests/AT90E26_UART.cpp>
[env:TestAT90E36]
build_flags = -D DEV ${env.build_flags}
lib_deps =
SPI
knolleary/pubsubclient
https://github.com/CircuitSetup/ATM90E36
bblanchon/ArduinoJson @ ^6.21.3
paulstoffregen/OneWire@^2.3.8
milesburton/DallasTemperature@^3.11.0
build_src_filter = -<*> -<.git/> -<.svn/> +<tests/AT90E36.cpp>
[env:TestTemps]
build_flags = -D DEV ${env.build_flags}
lib_deps =
@ -91,26 +61,6 @@ lib_deps =
milesburton/DallasTemperature@^3.11.0
build_src_filter = -<*> -<.git/> -<.svn/> +<tests/temps.cpp>
[env:TestSPI]
build_flags = -D DEV ${env.build_flags}
lib_deps =
SPI
build_src_filter = -<*> -<.git/> -<.svn/> +<tests/spi.cpp>
[env:TestEncryption]
build_flags = -D DEV ${env.build_flags}
lib_deps =
SPI
knolleary/pubsubclient
https://github.com/CircuitSetup/ATM90E36
bblanchon/ArduinoJson @ ^6.21.3
paulstoffregen/OneWire@^2.3.8
milesburton/DallasTemperature@^3.11.0
GCM
AES
Crypto
build_src_filter = -<*> -<.git/> -<.svn/> +<tests/encryption.cpp>
[env:TestRGBled]
build_flags = -D DEV ${env.build_flags}
build_src_filter = -<*> -<.git/> -<.svn/> +<tests/RGBled.cpp>

@ -1,98 +0,0 @@
/* ATM90E36 Energy Monitor Demo Application
The MIT License (MIT)
Copyright (c) 2016 whatnick and Ryzee
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <SPI.h>
#define DEBUG_SERIAL
#include <ATM90E36.h>
ATM90E36 eic;
void setup() {
/* Initialize the serial port to host */
/*
The ATM90E36 has to be setup via SPI.
SPI for the ESP32:
- CLK: 33
- MISO: 19
- MOSI: 23
- CS: 5
*/
// PM0 - 17
// PM1 - 21
// set normal detection mode for ATM90E36
pinMode(21, OUTPUT);
pinMode(34, INPUT);
pinMode(17, OUTPUT);
digitalWrite(17, HIGH);
digitalWrite(21, HIGH);
delay(2000);
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB
}
Serial.println("Start ATM90E36");
/*Initialise the ATM90E36 + SPI port */
// ss pin is the first parameter
SPI.begin(SCK, MISO, MOSI, SS);
delay(1000);
/*
CS pin - 33 for ESP32
Line Frequency - 60 Hz for NA - 5509 - see MMode0 section (4.2.3) in data sheet for ATM90E36
PGA Gain - adjusts ADC gain for current and voltage
Current gain -
Note: values are adjusted from https://github.com/DitroniX/IPEM-IoT-Power-Energy-Monitor/blob/main/Code/IPEM_1_Test_Code_ATM90E32_ATM90E36/include/IPEM_Hardware.h
*/
unsigned short PgaGain = 0b1101010101010101;
unsigned short frequency = 0b0001010110000101;
unsigned short VoltageGain = 19900;
eic.begin(SS, frequency, PgaGain, VoltageGain, 0x100,0x100, 0x100, 0x100);
delay(1000);
}
void loop() {
/*Repeatedly fetch some values from the ATM90E36 */
double voltageA,freq,voltageB,voltageC,currentA,currentB,currentC,power,pf,new_current,new_power;
int sys0=eic.GetSysStatus0();
int sys1=eic.GetSysStatus1();
int en0=eic.GetMeterStatus0();
int en1=eic.GetMeterStatus1();
Serial.println("S0:0x"+String(sys0,HEX));
delay(10);
Serial.println("S1:0x"+String(sys1,HEX));
delay(10);
Serial.println("E0:0x"+String(en0,HEX));
delay(10);
Serial.println("E1:0x"+String(en1,HEX));
voltageA=eic.GetLineVoltageA();
Serial.println("VA:"+String(voltageA)+"V");
voltageB=eic.GetLineVoltageB();
Serial.println("VB:"+String(voltageB)+"V");
voltageC=eic.GetLineVoltageC();
Serial.println("VC:"+String(voltageC)+"V");
delay(10);
currentA = eic.GetLineCurrentA();
Serial.println("IA:"+String(currentA)+"A");
currentB = eic.GetLineCurrentB();
Serial.println("IB:"+String(currentB)+"A");
currentC = eic.GetLineCurrentC();
Serial.println("IC:"+String(currentC)+"A");
delay(10);
freq=eic.GetFrequency();
delay(10);
Serial.println("f"+String(freq)+"Hz");
// Serial.println("Warn: "+String(digitalRead(34)));
Serial.println("Waiting 6s");
delay(6000);
}

@ -1,123 +0,0 @@
#include <Arduino.h>
#include <Crypto.h>
#include <AES.h>
#include <GCM.h>
struct TestVector
{
const char *name;
uint8_t key[32];
uint8_t authdata[20];
uint8_t iv[12];
uint8_t tag[16];
size_t authsize;
size_t tagsize;
size_t ivsize;
};
static TestVector const testVectorGCM PROGMEM = {
.name = "AES-256 GCM",
.key = {0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c,
0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08,
0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c,
0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08},
.authdata = {0xfe, 0xed, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef,
0xfe, 0xed, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef,
0xab, 0xad, 0xda, 0xd2},
.iv = {0xca, 0xfe, 0xba, 0xbe, 0xfa, 0xce, 0xdb, 0xad,
0xde, 0xca, 0xf8, 0x88},
.tag = {0x76, 0xfc, 0x6e, 0xce, 0x0f, 0x4e, 0x17, 0x68,
0xcd, 0xdf, 0x88, 0x53, 0xbb, 0x2d, 0x55, 0x1b},
.authsize = 20,
.tagsize = 16,
.ivsize = 12
};
TestVector testVector;
byte buffer[128];
void encrypt(AuthenticatedCipher *cipher, const struct TestVector *test, size_t datasize)
{
memcpy_P(&testVector, test, sizeof(TestVector));
test = &testVector;
size_t posn, len;
uint8_t tag[16];
crypto_feed_watchdog();
cipher->clear();
cipher->setKey(test->key, cipher->keySize());
cipher->setIV(test->iv, test->ivsize);
for (posn = 0; posn < test->authsize; posn += datasize) {
len = test->authsize - posn;
if (len > datasize)
len = datasize;
cipher->addAuthData(test->authdata + posn, len);
}
Serial.print("Cisla: ");
for(uint8_t i=0; i<60; i++) Serial.printf("%X",buffer[i]);
Serial.println();
for (posn = 0; posn < datasize; posn += datasize) {
len = datasize - posn;
if (len > datasize) len = datasize;
crypto_feed_watchdog();
cipher->encrypt((uint8_t*)buffer + posn, buffer + posn, len);
crypto_feed_watchdog();
}
Serial.println("Vystup:\n");
// Decrypt
for(uint8_t i=0; i<sizeof(buffer); i++) printf("0x%X,",buffer[i]);
}
void decrypt(AuthenticatedCipher *cipher, const struct TestVector *test, size_t datasize){
bool ok;
memcpy_P(&testVector, test, sizeof(TestVector));
test = &testVector;
size_t posn, len;
uint8_t tag[16];
crypto_feed_watchdog();
cipher->clear();
cipher->setKey(test->key, cipher->keySize());
cipher->setIV(test->iv, test->ivsize);
for (posn = 0; posn < test->authsize; posn += datasize) {
len = test->authsize - posn;
if (len > datasize)
len = datasize;
cipher->addAuthData(test->authdata + posn, len);
}
for (posn = 0; posn < datasize; posn += datasize) {
len = datasize - posn;
if (len > datasize)
len = datasize;
cipher->decrypt((uint8_t*)buffer + posn, buffer + posn, len);
}
Serial.print("\nVystup: ");
for(uint8_t i=0; i<60;i++) Serial.printf("%c",(char)buffer[i]);
Serial.println();
}
void setup(){
Serial.begin(115200);
Serial.println("Začínam\n");
GCM <AES256> *gcm=0;
gcm= new GCM<AES256>();
gcm->setKey(testVectorGCM.key, 32);
gcm->setIV(testVectorGCM.iv,testVectorGCM.ivsize);
crypto_feed_watchdog();
memset(buffer, (int)'\0', sizeof(buffer));
char vstup[30]="Tak to netuším"; //String containing Non-Asci characters
for(uint8_t i=0; i<30; i++) buffer[i]=vstup[i];
encrypt(gcm,&testVectorGCM,30);
decrypt(gcm,&testVectorGCM,30);
delete gcm;
}
void loop(){
delay(1000);
Serial.print(".");
}

@ -1,145 +0,0 @@
// /* MQTT over SSL Example
// This example code is in the Public Domain (or CC0 licensed, at your option.)
// Unless required by applicable law or agreed to in writing, this
// software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
// CONDITIONS OF ANY KIND, either express or implied.
// */
// #include <stdio.h>
// #include <stdint.h>
// #include <stddef.h>
// #include <string.h>
// #include <esp_system.h>
// #include <esp_partition.h>
// #include <nvs_flash.h>
// #include <esp_event.h>
// #include <esp_netif.h>
// #include <esp_log.h>
// #include <mqtt_client.h>
// #include <esp_tls.h>
// #include <esp_ota_ops.h>
// #include <sys/param.h>
// #include <transformerMonitorServerCert.h>
// static const char *TAG = "mqtts_example";
// #define MQTT_BROKER_URI "mqtt://"
// /*
// * @brief Event handler registered to receive MQTT events
// *
// * This function is called by the MQTT client event loop.
// *
// * @param handler_args user data registered to the event.
// * @param base Event base for the handler(always MQTT Base in this example).
// * @param event_id The id for the received event.
// * @param event_data The data for the event, esp_mqtt_event_handle_t.
// */
// static void mqtt_event_handler(void *handler_args, esp_event_base_t base, int32_t event_id, void *event_data)
// {
// ESP_LOGD(TAG, "Event dispatched from event loop base=%s, event_id=%" PRIi32, base, event_id);
// esp_mqtt_event_handle_t event = (esp_mqtt_event_handle_t)event_data;
// esp_mqtt_client_handle_t client = event->client;
// int msg_id;
// switch ((esp_mqtt_event_id_t)event_id) {
// case MQTT_EVENT_CONNECTED:
// ESP_LOGI(TAG, "MQTT_EVENT_CONNECTED");
// msg_id = esp_mqtt_client_subscribe(client, "/topic/qos0", 0);
// ESP_LOGI(TAG, "sent subscribe successful, msg_id=%d", msg_id);
// msg_id = esp_mqtt_client_subscribe(client, "/topic/qos1", 1);
// ESP_LOGI(TAG, "sent subscribe successful, msg_id=%d", msg_id);
// msg_id = esp_mqtt_client_unsubscribe(client, "/topic/qos1");
// ESP_LOGI(TAG, "sent unsubscribe successful, msg_id=%d", msg_id);
// break;
// case MQTT_EVENT_DISCONNECTED:
// ESP_LOGI(TAG, "MQTT_EVENT_DISCONNECTED");
// break;
// case MQTT_EVENT_SUBSCRIBED:
// ESP_LOGI(TAG, "MQTT_EVENT_SUBSCRIBED, msg_id=%d", event->msg_id);
// msg_id = esp_mqtt_client_publish(client, "/topic/qos0", "data", 0, 0, 0);
// ESP_LOGI(TAG, "sent publish successful, msg_id=%d", msg_id);
// break;
// case MQTT_EVENT_UNSUBSCRIBED:
// ESP_LOGI(TAG, "MQTT_EVENT_UNSUBSCRIBED, msg_id=%d", event->msg_id);
// break;
// case MQTT_EVENT_PUBLISHED:
// ESP_LOGI(TAG, "MQTT_EVENT_PUBLISHED, msg_id=%d", event->msg_id);
// break;
// case MQTT_EVENT_DATA:
// ESP_LOGI(TAG, "MQTT_EVENT_DATA");
// printf("TOPIC=%.*s\r\n", event->topic_len, event->topic);
// printf("DATA=%.*s\r\n", event->data_len, event->data);
// break;
// case MQTT_EVENT_ERROR:
// ESP_LOGI(TAG, "MQTT_EVENT_ERROR");
// if (event->error_handle->error_type == MQTT_ERROR_TYPE_TCP_TRANSPORT) {
// ESP_LOGI(TAG, "Last error code reported from esp-tls: 0x%x", event->error_handle->esp_tls_last_esp_err);
// ESP_LOGI(TAG, "Last tls stack error number: 0x%x", event->error_handle->esp_tls_stack_err);
// ESP_LOGI(TAG, "Last captured errno : %d (%s)", event->error_handle->esp_transport_sock_errno,
// strerror(event->error_handle->esp_transport_sock_errno));
// } else if (event->error_handle->error_type == MQTT_ERROR_TYPE_CONNECTION_REFUSED) {
// ESP_LOGI(TAG, "Connection refused error: 0x%x", event->error_handle->connect_return_code);
// } else {
// ESP_LOGW(TAG, "Unknown error type: 0x%x", event->error_handle->error_type);
// }
// break;
// default:
// ESP_LOGI(TAG, "Other event id:%d", event->event_id);
// break;
// }
// }
// static void mqtt_app_start(void)
// {
// esp_mqtt_client_config_t mqtt_cfg = {
// .uri = MQTT_BROKER_URI,
// .port = 1883,
// .cert_pem = root_ca,
// };
// mqtt_cfg.protocol_ver = (esp_mqtt_protocol_ver_t)CONFIG_MQTT_PROTOCOL_311;
// ESP_LOGI(TAG, "[APP] Free memory: %" PRIu32 " bytes", esp_get_free_heap_size());
// esp_mqtt_client_handle_t client = esp_mqtt_client_init(&mqtt_cfg);
// /* The last argument may be used to pass data to the event handler, in this example mqtt_event_handler */
// esp_mqtt_client_register_event(client, MQTT_EVENT_ERROR, mqtt_event_handler, client);
// esp_mqtt_client_register_event(client, MQTT_EVENT_CONNECTED, mqtt_event_handler, client);
// esp_mqtt_client_register_event(client, MQTT_EVENT_DISCONNECTED, mqtt_event_handler, client);
// esp_mqtt_client_register_event(client, MQTT_EVENT_SUBSCRIBED, mqtt_event_handler, client);
// esp_mqtt_client_register_event(client, MQTT_EVENT_UNSUBSCRIBED, mqtt_event_handler, client);
// esp_mqtt_client_register_event(client, MQTT_EVENT_PUBLISHED, mqtt_event_handler, client);
// esp_mqtt_client_register_event(client, MQTT_EVENT_DATA, mqtt_event_handler, client);
// esp_mqtt_client_register_event(client, MQTT_EVENT_BEFORE_CONNECT, mqtt_event_handler, client);
// esp_mqtt_client_start(client);
// }
// void app_main(void)
// {
// ESP_LOGI(TAG, "[APP] Startup..");
// ESP_LOGI(TAG, "[APP] Free memory: %" PRIu32 " bytes", esp_get_free_heap_size());
// ESP_LOGI(TAG, "[APP] IDF version: %s", esp_get_idf_version());
// esp_log_level_set("*", ESP_LOG_INFO);
// esp_log_level_set("esp-tls", ESP_LOG_VERBOSE);
// esp_log_level_set("mqtt_client", ESP_LOG_VERBOSE);
// esp_log_level_set("mqtt_example", ESP_LOG_VERBOSE);
// esp_log_level_set("transport_base", ESP_LOG_VERBOSE);
// esp_log_level_set("transport", ESP_LOG_VERBOSE);
// esp_log_level_set("outbox", ESP_LOG_VERBOSE);
// ESP_ERROR_CHECK(nvs_flash_init());
// ESP_ERROR_CHECK(esp_netif_init());
// ESP_ERROR_CHECK(esp_event_loop_create_default());
// mqtt_app_start();
// }
Loading…
Cancel
Save