Skip to content
Snippets Groups Projects
Commit 20a8ef70 authored by Niels Post's avatar Niels Post
Browse files

- Implemented SET_ID command

- Set the default robot id to 0 (robots now get their IDS from the controller)
parent 76527c70
No related branches found
No related tags found
1 merge request!1Development
Pipeline #34 failed
......@@ -17,8 +17,7 @@ enum class CommandCategory : uint8_t {
*/
enum GeneralCommand {
REBOOT = 0,
DISCOVER = 1,
RESET_ID = 2
SET_ID = 1
};
/**
......
......@@ -8,16 +8,15 @@ Response CommandController_General::handle(const Command &cmd, ResponseCallback
case REBOOT:
rstc_start_software_reset(RSTC);
break;
case DISCOVER:
if(pmsvSettings.robot_id == 0) {
return {cmd.message_id, SuccessCode::SUCCESS};
case SET_ID:
if(pmsvSettings.robot_id != 0) {
return {cmd.message_id, SuccessCode::NO_RESPONSE};
}
return {cmd.message_id, SuccessCode::NO_RESPONSE};
case RESET_ID:
pmsvSettings.robot_id = 0;
pmsvSettings.robot_id = cmd.parameters[0];
configRobotId.store();
Response res{cmd.message_id, SuccessCode::SUCCESS};
callback(res);
rstc_start_software_reset(RSTC);
break;
}
return {cmd.message_id, SuccessCode::UNKNOWN_COMMAND};
}
......@@ -34,9 +33,9 @@ std::pair<uint8_t, uint8_t> CommandController_General::getParameterLimits(uint8_
switch (cmd_id) {
case REBOOT:
case DISCOVER:
case RESET_ID:
return {0, 0};
case SET_ID:
return {1, 1};
default:
return {255, 255};
......
......@@ -20,7 +20,7 @@
////################################################################## Configuration ###################################
PMSVSettings default_settings{
0xE4,
0,
1.434684f,
1.4545f,
0,
......@@ -37,7 +37,7 @@ auto c_min_speed = registerConfig("MIN_SPEED", default_settings.min_speed);
auto c_max_speed = registerConfig("MAX_SPEED", default_settings.max_speed);
NRFConfiguration nrf_config{
RF24_PA_HIGH,
RF24_PA_MAX,
50,
0xE0E0F1F1E4LL,
0xE0E0F1F1E4LL,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment