Commit 36931802 authored by PhiBo's avatar PhiBo 🚀

Write payload size to eeprom

parent 74ea02f4
......@@ -54,9 +54,14 @@ uint8_t ArduRPC_SensorNode::call(uint8_t cmd_id)
this->_rpc->writeResult(RPC_ARRAY);
this->_rpc->writeResult(RPC_UINT8);
this->_rpc->writeResult(NODE_EEPROM_SENSOR_CONFIG_SIZE);
i = NODE_EEPROM_SENSOR_CONFIG_SIZE;
i = EEPROM.read(eeprom_pos);
eeprom_pos++;
if (i > NODE_EEPROM_SENSOR_CONFIG_PAYLOAD_SIZE) {
i = NODE_EEPROM_SENSOR_CONFIG_PAYLOAD_SIZE;
}
this->_rpc->writeResult(i);
while(i--) {
data = EEPROM.read(eeprom_pos);
this->_rpc->writeResult(data);
......@@ -88,11 +93,15 @@ uint8_t ArduRPC_SensorNode::call(uint8_t cmd_id)
eeprom_pos++;
}
/* Write sensor options */
/* Write sensor options length */
i = this->_rpc->getParam_uint8();
if (i > NODE_EEPROM_SENSOR_CONFIG_SIZE) {
i = NODE_EEPROM_SENSOR_CONFIG_SIZE;
if (i > NODE_EEPROM_SENSOR_CONFIG_PAYLOAD_SIZE) {
i = NODE_EEPROM_SENSOR_CONFIG_PAYLOAD_SIZE;
}
EEPROM.update(eeprom_pos, i);
eeprom_pos++;
/* Write sensor options */
while(i--) {
data = this->_rpc->getParam_uint8();
// ToDo: remove debug print()
......
......@@ -15,10 +15,11 @@
#define NODE_EEPROM_UUID_OFFSET 0
#define NODE_EEPROM_KEY_OFFSET 65
#define NODE_EEPROM_BASIC_SENSOR_OFFSET 256
#define NODE_EEPROM_BASIC_SENSOR_OFFSET 256
// We use uint16_t as sensor type id
#define NODE_EEPROM_SENSOR_TYPE_SIZE 2
#define NODE_EEPROM_SENSOR_CONFIG_SIZE 8
#define NODE_EEPROM_SENSOR_TYPE_SIZE 2
#define NODE_EEPROM_SENSOR_CONFIG_SIZE 8
#define NODE_EEPROM_SENSOR_CONFIG_PAYLOAD_SIZE (NODE_EEPROM_SENSOR_CONFIG_SIZE - 1)
#define NODE_MAX_SENSOR_COUNT 32
#define NODE_CACHE_VALUE_SIZE 9
......
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