-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsdcard.cpp
More file actions
44 lines (37 loc) · 996 Bytes
/
Copy pathsdcard.cpp
File metadata and controls
44 lines (37 loc) · 996 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include "sdcard.hpp"
sqlite3* DatabaseReader::connection;
char* MicroSDCardReader::lastError;
int MicroSDCardReader::initializeMicroSDReader()
{
if (!SD.begin(CS))
{
setLastError("Failed to initalize MicroSD Card Reader. Is the MicroSD Card inserted correctly?");
return 0;
}
if(SD.cardType() == CARD_NONE)
{
setLastError("No MicroSD Card Attached...");
return 0;
}
return 1;
}
int DatabaseReader::queryDatabase(char* query, int (*callback)(void *, int, char **, char **))
{
int status = sqlite3_exec(DatabaseReader::connection, query, callback, NULL, NULL);
if (status != SQLITE_OK)
{
std::stringstream ss;
ss << "SQLite Error: " << sqlite3_errmsg(DatabaseReader::connection);
setLastError((char*)ss.str().c_str());
return 0;
}
return 1;
}
void MicroSDCardReader::setLastError(char* errorMessage)
{
MicroSDCardReader::lastError = errorMessage;
}
char* MicroSDCardReader::getLastError()
{
return MicroSDCardReader::lastError;
}