Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4fc8da2

Browse files
committed
Fix modem contrib
1 parent3558351 commit4fc8da2

File tree

10 files changed

+43
-47
lines changed

10 files changed

+43
-47
lines changed

‎contrib/src/modem/command.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#ifndef MODEM_COMMAND_H
22
#defineMODEM_COMMAND_H
33

4-
#include"Firebase.h"
4+
#include"FirebaseArduino.h"
55
#include"modem/output-stream.h"
66
#include"modem/input-stream.h"
77

@@ -10,19 +10,19 @@ namespace modem {
1010

1111
classCommand {
1212
public:
13-
Command(Firebase* fbase) : fbase_(fbase) {}
13+
Command(FirebaseArduino* fbase) : fbase_(fbase) {}
1414

1515
// Execute command, reading any additional data needed from stream.
1616
// Return false if execution failed.
1717
virtualboolexecute(const String& command,
1818
InputStream* in, OutputStream* out) = 0;
1919
protected:
20-
Firebase&fbase() {
20+
FirebaseArduino&fbase() {
2121
return *fbase_;
2222
}
2323

2424
private:
25-
Firebase* fbase_;
25+
FirebaseArduino* fbase_;
2626
};
2727

2828
}// modem

‎contrib/src/modem/db/DatabaseProtocol.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ void DatabaseProtocol::Execute(const String& command_name, InputStream* in,
4242
}
4343

4444
std::unique_ptr<Command>DatabaseProtocol::CreateCommand(const String& text,
45-
Firebase* fbase) {
45+
FirebaseArduino* fbase) {
4646
std::unique_ptr<Command> command;
4747
if (text =="GET") {
4848
command.reset(newGetCommand(fbase));

‎contrib/src/modem/db/DatabaseProtocol.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ class DatabaseProtocol : public SerialProtocol {
1313
const std::vector<String>&commands()constoverride;
1414
voidExecute(const String& command, InputStream* in, OutputStream* out)override;
1515
private:
16-
std::unique_ptr<Command>CreateCommand(const String& text,Firebase* fbase);
16+
std::unique_ptr<Command>CreateCommand(const String& text,FirebaseArduino* fbase);
1717

18-
std::unique_ptr<Firebase> fbase_;
18+
std::unique_ptr<FirebaseArduino> fbase_;
1919
};
2020

2121

‎contrib/src/modem/db/begin-command.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,14 @@ bool BeginCommand::execute(const String& command,
3333
returnfalse;
3434
}
3535

36-
new_firebase_.reset(newFirebase(host.c_str(), auth.c_str()));
36+
new_firebase_.reset(newFirebaseArduino());
37+
new_firebase_.get()->begin(host.c_str(), auth.c_str());
3738

3839
out->println("+OK");
3940
returntrue;
4041
}
4142

42-
std::unique_ptr<Firebase>BeginCommand::firebase() {
43+
std::unique_ptr<FirebaseArduino>BeginCommand::firebase() {
4344
returnstd::move(new_firebase_);
4445
}
4546

‎contrib/src/modem/db/commands.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#ifndef MODEM_DB_COMMANDS_H
22
#defineMODEM_DB_COMMANDS_H
33

4-
#include"Firebase.h"
4+
#include"FirebaseArduino.h"
55
#include"modem/command.h"
66
#include"modem/output-stream.h"
77
#include"modem/input-stream.h"
@@ -11,28 +11,28 @@ namespace modem {
1111

1212
classGetCommand :publicCommand {
1313
public:
14-
GetCommand(Firebase* fbase) : Command(fbase) {}
14+
GetCommand(FirebaseArduino* fbase) : Command(fbase) {}
1515

1616
boolexecute(const String& command, InputStream* in, OutputStream* out);
1717
};
1818

1919
classSetCommand :publicCommand {
2020
public:
21-
SetCommand(Firebase* fbase) : Command(fbase) {}
21+
SetCommand(FirebaseArduino* fbase) : Command(fbase) {}
2222

2323
boolexecute(const String& command, InputStream* in, OutputStream* out);
2424
};
2525

2626
classRemoveCommand :publicCommand {
2727
public:
28-
RemoveCommand(Firebase* fbase) : Command(fbase) {}
28+
RemoveCommand(FirebaseArduino* fbase) : Command(fbase) {}
2929

3030
boolexecute(const String& command, InputStream* in, OutputStream* out);
3131
};
3232

3333
classPushCommand :publicCommand {
3434
public:
35-
PushCommand(Firebase* fbase) : Command(fbase) {}
35+
PushCommand(FirebaseArduino* fbase) : Command(fbase) {}
3636

3737
boolexecute(const String& command, InputStream* in, OutputStream* out);
3838
};
@@ -44,15 +44,15 @@ class BeginCommand : public Command {
4444
boolexecute(const String& command, InputStream* in, OutputStream* out);
4545

4646
// This can only be called once.
47-
std::unique_ptr<Firebase>firebase();
47+
std::unique_ptr<FirebaseArduino>firebase();
4848

4949
private:
50-
std::unique_ptr<Firebase> new_firebase_;
50+
std::unique_ptr<FirebaseArduino> new_firebase_;
5151
};
5252

5353
classStreamCommand :publicCommand {
5454
public:
55-
StreamCommand(Firebase* fbase) : Command(fbase) {}
55+
StreamCommand(FirebaseArduino* fbase) : Command(fbase) {}
5656

5757
boolexecute(const String& command, InputStream* in, OutputStream* out);
5858
};

‎contrib/src/modem/db/get-command.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,15 @@ bool GetCommand::execute(const String& command,
1313
returnfalse;
1414
}
1515

16-
std::string path = in->readLine().c_str();
17-
std::unique_ptr<FirebaseGet>get(fbase().getPtr(path));
16+
String path = in->readLine();
17+
String value =fbase().getString(path);
1818

19-
if (get->error()) {
19+
if (fbase().error()) {
2020
out->print("-FAIL");
21-
out->println(get->error().message().c_str());
21+
out->println(fbase().error().c_str());
2222
returnfalse;
2323
}
2424

25-
Stringvalue(get->response().c_str());
2625
// TODO implement json parsing to pull and process value.
2726
out->print("+");
2827
out->println(value);

‎contrib/src/modem/db/push-command.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,14 @@ bool PushCommand::execute(const String& command,
1414
returnfalse;
1515
}
1616

17-
std::stringpath(in->readStringUntil('').c_str());
18-
std::stringdata(in->readLine().c_str());
17+
String path =in->readStringUntil('');
18+
String data =in->readLine();
1919

20-
std::unique_ptr<FirebasePush>push(
21-
fbase().pushPtr(path,EncodeForJson(data)));
20+
fbase().pushString(path, data);
2221

23-
if (push->error()) {
22+
if (fbase().error()) {
2423
out->print("-FAIL");
25-
out->println(push->error().message().c_str());
24+
out->println(fbase().error().c_str());
2625
returnfalse;
2726
}else {
2827
out->println("+OK");

‎contrib/src/modem/db/remove-command.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ bool RemoveCommand::execute(const String& command,
1414
}
1515

1616
String path = in->readLine();
17-
std::unique_ptr<FirebaseRemove>get(fbase().removePtr(path.c_str()));
17+
fbase().remove(path);
1818

19-
if (get->error()) {
19+
if (fbase().error()) {
2020
out->print("-FAIL");
21-
out->println(get->error().message().c_str());
21+
out->println(fbase().error().c_str());
2222
returnfalse;
2323
}
2424

‎contrib/src/modem/db/set-command.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,14 @@ bool SetCommand::execute(const String& command,
1414
returnfalse;
1515
}
1616

17-
std::stringpath(in->readStringUntil('').c_str());
18-
std::stringdata(in->readLine().c_str());
17+
String path =in->readStringUntil('');
18+
String data =in->readLine();
1919

20-
std::unique_ptr<FirebaseSet>set(fbase().setPtr(path,
21-
EncodeForJson(data)));
20+
fbase().setString(path, data);
2221

23-
if (set->error()) {
22+
if (fbase().error()) {
2423
out->print("-FAIL");
25-
out->println(set->error().message().c_str());
24+
out->println(fbase().error().c_str());
2625
returnfalse;
2726
}else {
2827
out->println("+OK");

‎contrib/src/modem/db/stream-command.cpp

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,24 @@ bool StreamCommand::execute(const String& command,
1414
}
1515

1616
std::string path = in->readLine().c_str();
17-
std::unique_ptr<FirebaseStream>stream(fbase().streamPtr(path));
17+
fbase().stream(path);
1818

19-
if (stream->error()) {
19+
if (fbase().error()) {
2020
out->print("-FAIL");
21-
out->println(stream->error().message().c_str());
21+
out->println(fbase().error().c_str());
2222
returnfalse;
2323
}
2424

2525
bool running =true;
2626
DynamicJsonBuffer buffer;
2727
while(running) {
28-
if (stream->available()) {
29-
std::string json;
30-
FirebaseStream::Event event = stream->read(json);
28+
if (fbase().available()) {
29+
FirebaseObject event =fbase().readEvent();
3130
out->print("+");
32-
out->print(FirebaseStream::EventToName(event).c_str());
31+
out->print(event.getString("event").c_str());
3332
out->print("");
34-
constauto& object = buffer.parseObject(json.c_str());
35-
String data = object["data"].asString();
36-
out->println(object["path"].asString());
33+
String data = event.getString("data");
34+
out->println(event.getString("path"));
3735
out->println(data.length());
3836
out->println(data);
3937
}elseif (in->available()) {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp