Hi I'm receiving the following error in my code:
/tmp/266590520/build/sketch/Radio.cpp: In member function 'void RadioContainer::radio_receive()':
/tmp/266590520/build/sketch/Radio.cpp:134:14: error: redeclaration of 'byte confirmation'
byte confirmation = BicycleComputer::status;
^
/tmp/266590520/build/sketch/Radio.cpp:129:14: note: 'byte confirmation' previously declared here
byte confirmation = BicycleComputer::status;
^
exit status 1
Here is the relevant code:
switch (radio_data_rx[0])
{
case MSGID_PING:
byte confirmation = BicycleComputer::status;
radio.writeAckPayload(1, &confirmation, RADIO_COMMAND_BYTES);
break;
case MSGID_MSG:
byte confirmation = BicycleComputer::status;
radio.writeAckPayload(1, &confirmation, RADIO_COMMAND_BYTES);
break;
case MSGID_SPD_DST:
alloc_spd_dst_data_tx();
radio.writeAckPayload(1, &radio_data_tx, SIZEOF_SPD_DST_DATA);
break;
}
From what I know each switch statement branch has its own scope, in this case it's making it so that the scope is shared. Please any clarification on this topic would be greatly welcomed.