Commit a33055ad authored by PhiBo's avatar PhiBo 🚀

Set credentials

parent b902b230
......@@ -11,6 +11,9 @@ uint8_t ArduRPC_SensorNode::call(uint8_t cmd_id)
uint8_t sensor_id;
uint16_t eeprom_pos;
uint8_t i, data;
char s[64] = {0};
uint8_t len;
if (cmd_id == 0x09) {
/* getMaxSensorCount() */
......@@ -102,6 +105,37 @@ uint8_t ArduRPC_SensorNode::call(uint8_t cmd_id)
eeprom_pos++;
}
return RPC_RETURN_SUCCESS;
} else if (cmd_id == 0x21) {
/* getUUID() */
} else if (cmd_id == 0x22) {
/* getKey() */
} else if (cmd_id == 0x23) {
/* setCredentials() */
/* UUID */
len = this->_rpc->getParam_string(s, 64);
eeprom_pos = NODE_EEPROM_UUID_OFFSET;
EEPROM.update(NODE_EEPROM_UUID_OFFSET, len);
eeprom_pos++;
for(i = 0; i < len; i++) {
EEPROM.update(eeprom_pos, s[i]);
eeprom_pos++;
}
/* API Key */
len = this->_rpc->getParam_string(s, 64);
eeprom_pos = NODE_EEPROM_KEY_OFFSET;
EEPROM.update(NODE_EEPROM_KEY_OFFSET, len);
eeprom_pos++;
for(i = 0; i < len; i++) {
EEPROM.update(eeprom_pos, s[i]);
eeprom_pos++;
}
return RPC_RETURN_SUCCESS;
}
return RPC_RETURN_COMMAND_NOT_FOUND;
}
......
......@@ -14,8 +14,8 @@
#endif
#define NODE_EEPROM_UUID_OFFSET 0
#define NODE_EEPROM_API_KEY_OFFSET 32
#define NODE_EEPROM_BASIC_SENSOR_OFFSET 64
#define NODE_EEPROM_KEY_OFFSET 65
#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
......
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