Commit 342d96e8 authored by PhiBo's avatar PhiBo 🚀

Initialize rpc handler

parent d7ab7e85
......@@ -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();
}
}
......@@ -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;
}
......@@ -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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment