Uniot Core
0.8.1
Loading...
Searching...
No Matches
CrashStorage.h
Go to the documentation of this file.
1/*
2 * This is a part of the Uniot project.
3 * Copyright (C) 2016-2020 Uniot <contact@uniot.io>
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
30
31#pragma once
32
33
34#if defined (ESP8266)
35#include <user_interface.h>
36#include <Storage.h>
37
38#include <Arduino.h>
39
40namespace uniot
41{
53void uniotCrashCallback(struct rst_info *resetInfo, uint32_t stackStart, uint32_t stackEnd);
54
65class CrashStorage : public Storage
66{
67public:
73 CrashStorage(const String &path)
74 : Storage(path)
75 {
76 }
77
78 virtual ~CrashStorage()
79 {
80 }
81
90 bool store() override;
91
100 bool clean() override;
101
110 bool printCrashDataIfExists() const;
111
112protected:
124 Bytes buildDumpData() const;
125
126 struct rst_info *mResetInfo;
127 uint32_t mStackStart;
128 uint32_t mStackEnd;
129
130private:
131 friend void uniotCrashCallback(struct rst_info *resetInfo, uint32_t stackStart, uint32_t stackEnd);
132
140 void setCrashInfo(struct rst_info* resetInfo, uint32_t stackStart, uint32_t stackEnd)
141 {
142 mResetInfo = resetInfo;
143 mStackStart = stackStart;
144 mStackEnd = stackEnd;
145 }
146};
147
148} // namespace uniot
149
150#endif // defined(ESP8266)
Definition Bytes.h:38
bool store() override
Stores crash information to a file.
Definition CrashStorage.cpp:33
bool printCrashDataIfExists() const
Outputs crash data to Serial if it exists.
Definition CrashStorage.cpp:48
uint32_t mStackEnd
End address of stack to be dumped.
Definition CrashStorage.h:128
struct rst_info * mResetInfo
ESP8266 reset/crash information.
Definition CrashStorage.h:126
bool clean() override
Clears crash information and removes file.
Definition CrashStorage.cpp:39
friend void uniotCrashCallback(struct rst_info *resetInfo, uint32_t stackStart, uint32_t stackEnd)
ESP8266 crash callback function registered with system.
Definition CrashStorage.cpp:26
uint32_t mStackStart
Start address of stack to be dumped.
Definition CrashStorage.h:127
CrashStorage(const String &path)
Constructs a CrashStorage object.
Definition CrashStorage.h:73
virtual ~CrashStorage()
Definition CrashStorage.h:78
Bytes buildDumpData() const
Generates formatted crash information including stack dump.
Definition CrashStorage.cpp:59
Storage(const String &path)
Constructs a Storage object for a specific file.
Definition Storage.h:74
void uniotCrashCallback(struct rst_info *resetInfo, uint32_t stackStart, uint32_t stackEnd)
ESP8266 crash callback function registered with system.
Definition CrashStorage.cpp:26
Contains all classes and functions related to the Uniot Core.