Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
SensorNode
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Proof of Concept
SensorNode
Commits
342d96e8
Commit
342d96e8
authored
Nov 08, 2015
by
PhiBo
🚀
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initialize rpc handler
parent
d7ab7e85
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
4 deletions
+39
-4
src/main.ino
src/main.ino
+16
-4
src/sensor_node.cpp
src/sensor_node.cpp
+15
-0
src/sensor_node.h
src/sensor_node.h
+8
-0
No files found.
src/main.ino
View file @
342d96e8
...
...
@@ -6,7 +6,7 @@
#define RPC_SERIAL_PORT Serial
#define RPC_SERIAL_BAUD 9600
#define RPC_NUM_HANDLERS
20
#define RPC_NUM_HANDLERS
2
#define RPC_NUM_FUNCTIONS 0
#define PIN_NODE_MODE 4
...
...
@@ -20,10 +20,10 @@
SoftwareSerial
mySerial
(
10
,
11
);
//ArduRPC rpc = ArduRPC(RPC_NUM_HANDLERS, RPC_NUM_FUNCTIONS)
;
//ArduRPC_Serial rpc_serial = ArduRPC_Serial(RPC_SERIAL_PORT, rpc)
;
ArduRPC
*
rpc
;
ArduRPC_Serial
*
rpc_serial
;
//ArduRPC_SensorNode sensor_node = ArduRPC_SensorNode()
;
ArduRPC_SensorNode
*
rpc_sensor_node
;
ArduRPCRequest
*
rpc_request
;
ArduRPCRequest_Serial
*
h
;
...
...
@@ -54,6 +54,10 @@ void setup() {
sensor_node
=
new
SensorNode
();
sensor_node
->
loadConfig
();
}
else
{
rpc
=
new
ArduRPC
(
RPC_NUM_HANDLERS
,
RPC_NUM_FUNCTIONS
);
rpc_serial
=
new
ArduRPC_Serial
(
RPC_SERIAL_PORT
,
*
rpc
);
rpc_sensor_node
=
new
ArduRPC_SensorNode
(
*
rpc
,
""
);
}
/*sensor_dht = new DHT(6, DHT22);
sensor_dht->begin();*/
...
...
@@ -83,5 +87,13 @@ void loop() {
digitalWrite
(
PIN_ESP8266_CH_PD
,
LOW
);
delay
(
5000
);
}
else
{
digitalWrite
(
PIN_ESP8266_SET
,
HIGH
);
digitalWrite
(
PIN_ESP8266_MODE
,
HIGH
);
digitalWrite
(
PIN_ESP8266_CH_PD
,
HIGH
);
// Wait for bootloader
delay
(
250
);
digitalWrite
(
PIN_ESP8266_SET
,
LOW
);
rpc_serial
->
loop
();
}
}
src/sensor_node.cpp
View file @
342d96e8
...
...
@@ -40,6 +40,7 @@ void SensorNode::loadConfig()
sensor_type
|=
(
uint8_t
)
EEPROM_read
(
pos
);
pos
++
;
if
(
sensor_type
==
0
)
{
this
->
sensors
[
i
]
=
NULL
;
pos
+=
8
;
continue
;
}
...
...
@@ -249,3 +250,17 @@ uint8_t SensorWifiModuleRemote::submitValue(uint8_t *data, uint8_t length)
return
0
;
}
ArduRPC_SensorNode
::
ArduRPC_SensorNode
(
ArduRPC
&
rpc
,
char
*
name
)
:
ArduRPCHandler
()
{
this
->
type
=
0x9999
;
this
->
registerSelf
(
rpc
,
name
,
(
void
*
)
this
);
}
uint8_t
ArduRPC_SensorNode
::
call
(
uint8_t
cmd_id
)
{
if
(
cmd_id
==
0x10
)
{
return
RPC_RETURN_SUCCESS
;
}
return
RPC_RETURN_COMMAND_NOT_FOUND
;
}
src/sensor_node.h
View file @
342d96e8
...
...
@@ -84,4 +84,12 @@ class SensorDHT : public BaseSensor
DHT
*
dht
;
};
class
ArduRPC_SensorNode
:
public
ArduRPCHandler
{
public:
ArduRPC_SensorNode
(
ArduRPC
&
rpc
,
char
*
name
);
uint8_t
call
(
uint8_t
);
};
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment