-
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* testing logs * testing log * fix native compile errors * fix native issues * add lock slash image * handle no channel, create nodes while restoring msg * fix log removal / close file * fix LogRotate readNext(); refactor timestamp * add date * update sscanf * 100k logs * increase packet queue size * update calibration data
- Loading branch information
Showing
17 changed files
with
956 additions
and
136 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
#ifdef __has_include | ||
#if __has_include("lvgl.h") | ||
#ifndef LV_LVGL_H_INCLUDE_SIMPLE | ||
#define LV_LVGL_H_INCLUDE_SIMPLE | ||
#endif | ||
#endif | ||
#endif | ||
|
||
#if defined(LV_LVGL_H_INCLUDE_SIMPLE) | ||
#include "lvgl.h" | ||
#elif defined(LV_BUILD_TEST) | ||
#include "../lvgl.h" | ||
#else | ||
#include "lvgl/lvgl.h" | ||
#endif | ||
|
||
|
||
#ifndef LV_ATTRIBUTE_MEM_ALIGN | ||
#define LV_ATTRIBUTE_MEM_ALIGN | ||
#endif | ||
|
||
#ifndef LV_ATTRIBUTE_IMG_LOCK_SLASH_IMAGE | ||
#define LV_ATTRIBUTE_IMG_LOCK_SLASH_IMAGE | ||
#endif | ||
|
||
static const | ||
LV_ATTRIBUTE_MEM_ALIGN LV_ATTRIBUTE_LARGE_CONST LV_ATTRIBUTE_IMG_LOCK_SLASH_IMAGE | ||
uint8_t img_lock_slash_image_map[] = { | ||
|
||
0xdb,0xde,0x3c,0xe7,0xfb,0xde,0xfb,0xde,0x1c,0xe7,0xdb,0xde,0x00,0x00,0x00,0x00,0xdb,0xde,0xba,0xd6,0xfb,0xde,0xfb,0xde,0xfb,0xde,0xfb,0xde,0xba,0xd6,0xdb,0xde,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | ||
0x3c,0xe7,0x1c,0xe7,0xfb,0xde,0xfb,0xde,0x1c,0xe7,0x3c,0xe7,0xdb,0xde,0xfb,0xde,0xfb,0xde,0x1c,0xe7,0xfb,0xde,0xfb,0xde,0xfb,0xde,0xfb,0xde,0x1c,0xe7,0xfb,0xde,0x1c,0xe7,0xdb,0xde,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | ||
0xfb,0xde,0xfb,0xde,0xfb,0xde,0x1c,0xe7,0xfb,0xde,0x1c,0xe7,0x3c,0xe7,0xfb,0xde,0xfb,0xde,0xfb,0xde,0x1c,0xe7,0x1c,0xe7,0x1c,0xe7,0x1c,0xe7,0xfb,0xde,0xfb,0xde,0x1c,0xe7,0x9e,0xf7,0xdb,0xde,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | ||
0xfb,0xde,0xfb,0xde,0x1c,0xe7,0x1c,0xe7,0x1c,0xe7,0xfb,0xde,0x1c,0xe7,0x3c,0xe7,0xfb,0xde,0x1c,0xe7,0x1c,0xe7,0x1c,0xe7,0x1c,0xe7,0x1c,0xe7,0x1c,0xe7,0x1c,0xe7,0xfb,0xde,0x1c,0xe7,0x1c,0xe7,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | ||
0x1c,0xe7,0x1c,0xe7,0xfb,0xde,0x1c,0xe7,0x1c,0xe7,0x1c,0xe7,0xfb,0xde,0x1c,0xe7,0xfb,0xde,0xfb,0xde,0xfb,0xde,0xfb,0xde,0xfb,0xde,0xfb,0xde,0x1c,0xe7,0x1c,0xe7,0x1c,0xe7,0xfb,0xde,0xfb,0xde,0xdb,0xde,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | ||
0xdb,0xde,0x3c,0xe7,0x1c,0xe7,0xfb,0xde,0x1c,0xe7,0x1c,0xe7,0x1c,0xe7,0xfb,0xde,0x1c,0xe7,0xba,0xd6,0x1c,0xe7,0xfb,0xde,0xfb,0xde,0x1c,0xe7,0xfb,0xde,0x1c,0xe7,0x1c,0xe7,0xfb,0xde,0x1c,0xe7,0xba,0xd6,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | ||
0x00,0x00,0xfb,0xde,0x3c,0xe7,0x1c,0xe7,0xfb,0xde,0x1c,0xe7,0x1c,0xe7,0x1c,0xe7,0xfb,0xde,0xfb,0xde,0x5d,0xef,0xdb,0xde,0xdb,0xde,0x5d,0xef,0x1c,0xe7,0xfb,0xde,0x1c,0xe7,0x1c,0xe7,0xfb,0xde,0xfb,0xde,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | ||
0x00,0x00,0x00,0x00,0xfb,0xde,0x3c,0xe7,0xfb,0xde,0xfb,0xde,0x1c,0xe7,0x1c,0xe7,0x1c,0xe7,0xfb,0xde,0x1c,0xe7,0x3c,0xe7,0xdb,0xde,0xfb,0xde,0xfb,0xde,0xfb,0xde,0x1c,0xe7,0x1c,0xe7,0xfb,0xde,0xfb,0xde,0xba,0xd6,0x00,0x00,0x00,0x00,0x00,0x00, | ||
0x00,0x00,0x00,0x00,0xdb,0xde,0xba,0xd6,0xfb,0xde,0xfb,0xde,0x1c,0xe7,0x1c,0xe7,0x1c,0xe7,0x1c,0xe7,0xfb,0xde,0x1c,0xe7,0x3c,0xe7,0xfb,0xde,0x18,0xc6,0xfb,0xde,0x1c,0xe7,0x1c,0xe7,0xfb,0xde,0xfb,0xde,0xba,0xd6,0xdb,0xde,0x00,0x00,0x00,0x00, | ||
0x00,0x00,0xba,0xd6,0xba,0xd6,0x3c,0xe7,0xfb,0xde,0xfb,0xde,0x1c,0xe7,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,0x1c,0xe7,0x1c,0xe7,0xfb,0xde,0xfb,0xde,0x00,0x00, | ||
0x00,0x00,0xfb,0xde,0xfb,0xde,0x1c,0xe7,0x1c,0xe7,0xfb,0xde,0xfb,0xde,0x00,0x00,0x00,0x00,0xfb,0xde,0x3c,0xe7,0x1c,0xe7,0xfb,0xde,0x1c,0xe7,0x1c,0xe7,0x1c,0xe7,0xfb,0xde,0xfb,0xde,0xfb,0xde,0x1c,0xe7,0x1c,0xe7,0xfb,0xde,0xfb,0xde,0x00,0x00, | ||
0x00,0x00,0xfb,0xde,0xfb,0xde,0x1c,0xe7,0x1c,0xe7,0x1c,0xe7,0x1c,0xe7,0x00,0x00,0x00,0x00,0x00,0x00,0xfb,0xde,0x3c,0xe7,0x1c,0xe7,0xfb,0xde,0x1c,0xe7,0x1c,0xe7,0x1c,0xe7,0xfb,0xde,0x5d,0xef,0xfb,0xde,0xfb,0xde,0xdb,0xde,0xfb,0xde,0x00,0x00, | ||
0x00,0x00,0xfb,0xde,0xfb,0xde,0x1c,0xe7,0x1c,0xe7,0xfb,0xde,0xfb,0xde,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfb,0xde,0x3c,0xe7,0x1c,0xe7,0xfb,0xde,0x1c,0xe7,0x1c,0xe7,0x1c,0xe7,0xfb,0xde,0x1c,0xe7,0xfb,0xde,0xfb,0xde,0xfb,0xde,0x00,0x00, | ||
0x00,0x00,0xfb,0xde,0xfb,0xde,0x1c,0xe7,0x1c,0xe7,0xfb,0xde,0xfb,0xde,0x59,0xce,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfb,0xde,0x3c,0xe7,0x1c,0xe7,0xfb,0xde,0x1c,0xe7,0x1c,0xe7,0x1c,0xe7,0xfb,0xde,0x1c,0xe7,0x3c,0xe7,0xdb,0xde,0x00,0x00, | ||
0x00,0x00,0xfb,0xde,0xfb,0xde,0x1c,0xe7,0x1c,0xe7,0xfb,0xde,0xfb,0xde,0xfb,0xde,0xfb,0x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fb,0xde,0xfb,0xde,0x1c,0xe7,0x3c,0xe7, | ||
0x00,0x00,0x00,0x00,0x00,0x00,0xba,0xd6,0xfb,0xde,0xfb,0xde,0xfb,0xde,0xfb,0xde,0xfb,0xde,0xfb,0xde,0xfb,0xde,0xfb,0xde,0xfb,0xde,0xfb,0xde,0xfb,0xde,0xfb,0xde,0xfb,0xde,0xfb,0xde,0xfb,0xde,0x1c,0xe7,0xfb,0xde,0xfb,0xde,0x3c,0xe7,0xdb,0xde, | ||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0e,0x0e,0x00,0x00,0x00,0x00,0x00,0x00,0x0a,0x1b,0x1b,0x0a,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | ||
0x00,0x0e,0xac,0xb8,0x27,0x00,0x00,0x00,0x15,0x72,0xbf,0xde,0xde,0xbf,0x73,0x17,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0e,0xb8,0xff,0xc3,0x26,0x00,0x00,0x85,0xff,0xfe,0xe8,0xe8,0xfe,0xff,0xc0,0x2d,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | ||
0x00,0x00,0x27,0xc3,0xff,0xc3,0x26,0x00,0x50,0xa6,0x59,0x25,0x25,0x58,0xc8,0xff,0xc0,0x17,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x26,0xc3,0xff,0xc3,0x26,0x00,0x02,0x00,0x00,0x00,0x00,0x22,0xc8,0xff,0x73,0x00,0x00,0x00,0x00,0x00,0x00, | ||
0x00,0x00,0x00,0x00,0x26,0xc2,0xff,0xc3,0x26,0x00,0x00,0x00,0x00,0x00,0x00,0x58,0xfe,0xbf,0x0a,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x34,0xea,0xff,0xc3,0x26,0x00,0x00,0x00,0x00,0x00,0x24,0xe8,0xdd,0x1b,0x00,0x00,0x00,0x00,0x00, | ||
0x00,0x00,0x00,0x00,0x00,0x1f,0xe1,0xff,0xff,0xc3,0x26,0x00,0x00,0x00,0x00,0x33,0xe6,0xe4,0x21,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x37,0xac,0xfa,0xff,0xff,0xff,0xc3,0x26,0x00,0x00,0x41,0xdb,0xfe,0xfa,0xac,0x37,0x00,0x00,0x00,0x00, | ||
0x00,0x00,0x00,0x37,0xdd,0xff,0xee,0xe2,0xe0,0xea,0xff,0xc3,0x26,0x00,0x42,0xd7,0xe3,0xee,0xff,0xdd,0x37,0x00,0x00,0x00,0x00,0x00,0x04,0xa6,0xff,0xa7,0x32,0x20,0x1d,0x35,0xc2,0xff,0xc3,0x26,0x00,0x18,0x20,0x32,0xa7,0xff,0xa6,0x04,0x00,0x00, | ||
0x00,0x00,0x15,0xd6,0xf0,0x32,0x00,0x00,0x00,0x00,0x26,0xc3,0xff,0xc3,0x26,0x00,0x00,0x00,0x32,0xf0,0xd6,0x15,0x00,0x00,0x00,0x00,0x1d,0xe1,0xe4,0x20,0x00,0x00,0x00,0x00,0x00,0x26,0xc3,0xff,0xc3,0x26,0x00,0x00,0x20,0xe5,0xe1,0x1e,0x00,0x00, | ||
0x00,0x00,0x1f,0xe2,0xe2,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x26,0xc3,0xff,0xc3,0x26,0x00,0x18,0xd7,0xd7,0x18,0x00,0x00,0x00,0x00,0x1f,0xe2,0xe2,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x26,0xc3,0xff,0xc3,0x26,0x00,0x42,0x41,0x02,0x00,0x00, | ||
0x00,0x00,0x1f,0xe2,0xe2,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x26,0xc3,0xff,0xc3,0x26,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1d,0xe1,0xe4,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x26,0xc3,0xff,0xc3,0x26,0x00,0x00,0x00,0x00, | ||
0x00,0x00,0x15,0xd6,0xf0,0x32,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x24,0xc0,0xff,0xc3,0x26,0x00,0x00,0x00,0x00,0x00,0x04,0xa6,0xff,0xa7,0x32,0x20,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1d,0x5a,0xee,0xff,0xc3,0x27,0x00,0x00, | ||
0x00,0x00,0x00,0x37,0xdd,0xff,0xf0,0xe4,0xe2,0xe2,0xe2,0xe2,0xe2,0xe2,0xe2,0xe2,0xe4,0xef,0xff,0xf9,0xff,0xb8,0x0e,0x00,0x00,0x00,0x00,0x00,0x37,0xa6,0xd6,0xe1,0xe2,0xe2,0xe2,0xe2,0xe2,0xe2,0xe2,0xe2,0xe1,0xd6,0xa4,0x56,0xb7,0xac,0x0e,0x00, | ||
0x00,0x00,0x00,0x00,0x00,0x04,0x15,0x1d,0x1e,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1e,0x1d,0x15,0x04,0x00,0x0e,0x0e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | ||
|
||
}; | ||
|
||
const lv_image_dsc_t img_lock_slash_image = { | ||
.header.magic = LV_IMAGE_HEADER_MAGIC, | ||
.header.cf = LV_COLOR_FORMAT_RGB565A8, | ||
.header.flags = 0, | ||
.header.w = 24, | ||
.header.h = 24, | ||
.header.stride = 48, | ||
.data_size = sizeof(img_lock_slash_image_map), | ||
.data = img_lock_slash_image_map, | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#pragma once | ||
|
||
#include <functional> | ||
#include <stdint.h> | ||
|
||
/** | ||
* Generic interface base class for any log entries (stored via class LogRotate) | ||
*/ | ||
class ILogEntry | ||
{ | ||
public: | ||
virtual size_t size(void) const = 0; | ||
virtual size_t serialize(std::function<size_t(const uint8_t *, size_t)> write) const = 0; | ||
virtual size_t deserialize(std::function<size_t(uint8_t *, size_t)> read) = 0; | ||
virtual ~ILogEntry() = default; | ||
|
||
protected: | ||
ILogEntry(void) = default; | ||
|
||
private: | ||
ILogEntry(const ILogEntry &) = delete; | ||
ILogEntry &operator=(const ILogEntry &) = delete; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
#pragma once | ||
|
||
#include "ILogEntry.h" | ||
#include <assert.h> | ||
#include <ctime> | ||
#include <memory.h> | ||
|
||
constexpr uint32_t messagePayloadSize = 233; | ||
|
||
/** | ||
* @brief Header for storing message logs containing the actual size of the payload | ||
* Note: this struct does have vtable pointers, i.e. sizeof(LogMessageHeader)-8 is the real data size | ||
*/ | ||
struct LogMessageHeader : public ILogEntry { | ||
uint16_t _size; | ||
time_t time; | ||
uint32_t from; | ||
uint32_t to; | ||
uint8_t ch; | ||
enum MsgStatus : uint8_t { eNone, eDefault, eHeard, eNoResponse, eAcked, eFailed, eDeleted, eUnread } status; | ||
bool trashFlag; | ||
uint32_t reserved; | ||
}; | ||
|
||
/** | ||
* @brief Structure for storing message logs containing the actual payload | ||
*/ | ||
struct LogMessage : public LogMessageHeader { | ||
uint8_t bytes[messagePayloadSize]; | ||
}; | ||
|
||
/** | ||
* Log message envelope that implements the actual interface for ILogEntry | ||
* (size, serialize and deserialize) | ||
*/ | ||
class LogMessageEnv : public LogMessage | ||
{ | ||
public: | ||
LogMessageEnv(void) = default; | ||
LogMessageEnv(uint32_t _from, uint32_t _to, uint16_t _ch, time_t _time, MsgStatus _status, bool _trashFlag, uint32_t _len, | ||
const uint8_t *msg) | ||
{ | ||
assert(_len < messagePayloadSize); | ||
_size = (uint16_t)_len; | ||
time = _time; | ||
from = _from; | ||
to = _to; | ||
ch = _ch; | ||
status = _status; | ||
trashFlag = _trashFlag; | ||
reserved = 0; | ||
memcpy(bytes, msg, _len); | ||
} | ||
|
||
size_t size(void) const override { return sizeof(LogMessageHeader) - 8 + _size; } | ||
|
||
virtual size_t serialize(std::function<size_t(const uint8_t *, size_t)> write) const override | ||
{ | ||
return write((uint8_t *)&_size, sizeof(LogMessageHeader) - 8) + write(bytes, _size); | ||
} | ||
|
||
virtual size_t deserialize(std::function<size_t(uint8_t *, size_t)> read) override | ||
{ | ||
return read((uint8_t *)&_size, sizeof(LogMessageHeader) - 8) + read(bytes, _size); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
#pragma once | ||
|
||
#include "FS.h" | ||
#include "ILogEntry.h" | ||
#include <stdint.h> | ||
|
||
/** | ||
* Generic LogRotate class that writes log-rotation like files into (arduino) FS storage file system | ||
* @param fs arduino file system FS/LittleFS or derived classes | ||
* @param logDir directory to store the logs (absolute path) | ||
* @param maxLen the maximum length of the variable log entry length | ||
* The maximum storage is limited by: | ||
* @param maxSize the total storage in bytes (default is 200kB) | ||
* @param maxFiles number of log files (default is 50) | ||
* @param maxFileSize per log file (default size is 4000 bytes to fit into a physical block | ||
* including fs descriptor data) | ||
* | ||
* If the maximum storage is exceeded then old files are deleted to fit the new log entry. | ||
* Note: for performance reasons the logs are not renumbered | ||
*/ | ||
class LogRotate | ||
{ | ||
public: | ||
LogRotate(fs::FS &fs, const char *logDir, uint32_t maxLen, | ||
uint32_t maxSize = 102400, uint32_t maxFiles = 25, uint32_t maxFileSize = 4000); | ||
//uint32_t maxSize = 4096, uint32_t maxFiles = 10, uint32_t maxFileSize = 400); | ||
|
||
// initialize the log directory | ||
void init(void); | ||
// write a log entry to fs | ||
bool write(const ILogEntry &entry); | ||
// read the next log entry from fs | ||
bool readNext(ILogEntry &entry); | ||
// remove all logs from fs | ||
bool clear(void); | ||
// request log count | ||
uint32_t count(void); | ||
// request current log number | ||
uint32_t current(void); | ||
|
||
private: | ||
LogRotate(const LogRotate &) = delete; | ||
LogRotate &operator=(const LogRotate &) = delete; | ||
|
||
// create filename from number | ||
String logFileName(uint32_t num); | ||
// remove oldest log and return freed size | ||
size_t removeLog(void); | ||
// scan all files in logdir to get min/max log | ||
void scanLogDir(uint32_t &num, uint32_t &minLog, uint32_t &maxLog, uint32_t &size, uint32_t &total); | ||
|
||
const uint32_t c_maxLen; // maximum size a single log entry could be | ||
const uint32_t c_maxSize; // max storage size in bytes (default is 100kB) | ||
const uint32_t c_maxFiles; // max log files number (default is 50) | ||
const uint32_t c_maxFileSize; // max file size per log file | ||
|
||
fs::FS &_fs; | ||
File rootDir; // directory (for reading logs) | ||
File currentFile; // current file (when reading) | ||
String rootDirName; // path of log directory | ||
String currentLogName; // current log file name (when writing) | ||
uint32_t numFiles; // number of log files | ||
uint32_t minLogNum; // logfile with smallest number | ||
uint32_t maxLogNum; // logfile with largest number after init() | ||
uint32_t currentLogRead; // current log number (when reading) | ||
uint32_t currentLogWrite; // current log number (when writing) | ||
uint32_t currentSize; // size of current written log file | ||
uint32_t totalSize; // size of all logs | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.