Compare commits
No commits in common. "c57205059e33c6937e8eea54e9b3845b4638ae5e" and "03264a797c0711fe96172a83ac0e0d574dada5b9" have entirely different histories.
c57205059e
...
03264a797c
34
.gitignore
vendored
34
.gitignore
vendored
@ -1,34 +0,0 @@
|
||||
# ---> C++
|
||||
# Prerequisites
|
||||
*.d
|
||||
|
||||
# Compiled Object files
|
||||
*.slo
|
||||
*.lo
|
||||
*.o
|
||||
*.obj
|
||||
|
||||
# Precompiled Headers
|
||||
*.gch
|
||||
*.pch
|
||||
|
||||
# Compiled Dynamic libraries
|
||||
*.so
|
||||
*.dylib
|
||||
*.dll
|
||||
|
||||
# Fortran module files
|
||||
*.mod
|
||||
*.smod
|
||||
|
||||
# Compiled Static libraries
|
||||
*.lai
|
||||
*.la
|
||||
*.a
|
||||
*.lib
|
||||
|
||||
# Executables
|
||||
*.exe
|
||||
*.out
|
||||
*.app
|
||||
|
20
keywords.txt
20
keywords.txt
@ -1,20 +0,0 @@
|
||||
#######################################
|
||||
# Syntax Coloring Map
|
||||
#######################################
|
||||
|
||||
#######################################
|
||||
# Datatypes (KEYWORD1)
|
||||
#######################################
|
||||
|
||||
#######################################
|
||||
# Methods and Functions (KEYWORD2)
|
||||
#######################################
|
||||
|
||||
#######################################
|
||||
# Instances (KEYWORD2)
|
||||
#######################################
|
||||
|
||||
|
||||
#######################################
|
||||
# Constants (LITERAL1)
|
||||
#######################################
|
22
library.json
22
library.json
@ -1,22 +0,0 @@
|
||||
{
|
||||
"name":"encipheredEEPROMStrings",
|
||||
"description":"Store and retrieve EEPROM strings",
|
||||
"keywords":"eeprom,storage",
|
||||
"authors":
|
||||
{
|
||||
"name": "Pavel Brychta",
|
||||
"maintainer": true
|
||||
},
|
||||
"repository":
|
||||
{
|
||||
"type": "git",
|
||||
"url": "http://git.xpablo.cz/xPablo.cz/encipheredEEPROMStrings.git"
|
||||
},
|
||||
"version": "1.0",
|
||||
"license": "MIT",
|
||||
"frameworks": "arduino",
|
||||
"platforms": ["espressif8266","espressif32"],
|
||||
"build": {
|
||||
"libCompatMode": 2
|
||||
}
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
name=encipheredEEPROMStrings
|
||||
version=1.0
|
||||
author=Pavel Brychta
|
||||
maintainer=Pavel Brychta
|
||||
sentence=Store and retrieve EEPROM strings
|
||||
paragraph=Store and retrieve EEPROM strings
|
||||
category=Other
|
||||
url=http://git.xpablo.cz/xPablo.cz/encipheredEEPROMStrings
|
||||
architectures=esp8266,esp32
|
@ -1,82 +0,0 @@
|
||||
#include "encipheredEEPROMStrings.h"
|
||||
#include <EEPROM.h>
|
||||
#if defined(ESP8266)
|
||||
extern "C" {
|
||||
#include "user_interface.h"
|
||||
}
|
||||
#define ESP_getChipId() (ESP.getChipId())
|
||||
#else
|
||||
#include <esp_wifi.h>
|
||||
#define ESP_getChipId() ((uint32_t)ESP.getEfuseMac())
|
||||
#endif
|
||||
|
||||
String EES_readString(unsigned int start, size_t maxlen)
|
||||
{
|
||||
uint8_t key[4];
|
||||
unsigned int enciphidx = 0;
|
||||
String result;
|
||||
unsigned int top = EEPROM.read(start);
|
||||
unsigned int i;
|
||||
|
||||
result.reserve(maxlen);
|
||||
uint32_t cid = ESP_getChipId();
|
||||
uint32_t *pkey = (uint32_t *)&key[0];
|
||||
*pkey = cid;
|
||||
if ((top > 0) && (top < (maxlen - 2)))
|
||||
{
|
||||
uint8_t b;
|
||||
for (i = start + 1; i < + start + top + 1; ++i)
|
||||
{
|
||||
b = EEPROM.read(i);
|
||||
|
||||
b ^= key[enciphidx];
|
||||
++enciphidx;
|
||||
enciphidx %= sizeof(key);
|
||||
|
||||
result.concat(char(b));
|
||||
}
|
||||
b = EEPROM.read(i) ^ key[enciphidx];
|
||||
if (b != 0)
|
||||
{
|
||||
result = F(""); // spatna ukoncovaci nula - neplatny retezec
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
bool EES_storeString(unsigned int start, size_t maxlen, String &string)
|
||||
{
|
||||
uint8_t key[4];
|
||||
unsigned int enciphidx = 0;
|
||||
unsigned int si = 0;
|
||||
unsigned int top;
|
||||
char c;
|
||||
bool result = false; // retezec nebyl ulozeny cely (nevesel s do bufferu)
|
||||
unsigned int i;
|
||||
|
||||
if (string.length() > maxlen - 2)
|
||||
top = maxlen - 2;
|
||||
else
|
||||
{
|
||||
result = true; // retezec se do urceneho mista vejde
|
||||
top = string.length();
|
||||
}
|
||||
|
||||
uint32_t cid = ESP_getChipId();
|
||||
uint32_t *pkey = (uint32_t *)&key[0];
|
||||
*pkey = cid;
|
||||
EEPROM.write(start, (uint8_t)top); // ulozime delku retezce (pouzite pr kontrolu pri vycitani)
|
||||
for (i = start + 1; i < start + top + 1; ++i)
|
||||
{
|
||||
c = string[si];
|
||||
c ^= key[enciphidx];
|
||||
++enciphidx;
|
||||
enciphidx %= sizeof(key);
|
||||
EEPROM.write(i, c);
|
||||
++si;
|
||||
}
|
||||
c = 0 ^ key[enciphidx];
|
||||
EEPROM.write(i, c); // ukoncovaci a kontrolni nula
|
||||
|
||||
return result;
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
/* Knihovna pro ukladani a cteni retezcu do/z EEPROM.
|
||||
* Retezce jsou ulozeny jednoduse sifrovane pomoci XOR sifry.
|
||||
* @author Pavel Brychta http://www.xpabo.cz
|
||||
*/
|
||||
#include <Arduino.h>
|
||||
|
||||
/**
|
||||
* @brief Cteni sifrovanych retezcu z EEPROM
|
||||
*
|
||||
* @param[in] start Pocatecni adresa retezce v EEPROM
|
||||
* @param[in] maxlen Maximalni delka retezce
|
||||
*
|
||||
* @return Vycteny a desifrovany retezec
|
||||
*/
|
||||
String EES_readString(unsigned int start, size_t maxlen);
|
||||
|
||||
/**
|
||||
* @brief Zapis retezcu do EEPROM
|
||||
*
|
||||
* @param[in] start Pocatecni adresa retezce v EEPROM
|
||||
* @param[in] maxlen Maximalni delka retezce
|
||||
* @param string Ukladany retezec
|
||||
*
|
||||
* @return Priznak, zda se zapis podaril
|
||||
*/
|
||||
bool EES_storeString(unsigned int start, size_t maxlen, String &string);
|
Loading…
Reference in New Issue
Block a user