Here the idea is to have the response processing logic close to the caller function. In order to be coordinate the refactoring with you I refactored one function for sample. Please check and tell me if we can do it for the rest of the commands.
Please read the changes done in lines 715 and 899. The idea is to add a logic function after we run executeCommand (line 899) which returns the item added to execution queue. This function will be executed in line 715 on the dataReceived function. As we are attaching the logic function to the item in the queue, this type of checking modem.queue[0].command.substr(0, 3) == 'ATH' is not needed any more.
This way adding a new command is easier and also possible for the consumer out of the repo.
SMS sending and receiving is a bit different, I suggest to not refactor them at the moment.
Please tell me you opinion and if you agree I refactor the rest of the commands (except send / receive SMS).
Beside, I do not have a possibility to check all of the commands, do you have that opportunity to test all of them after I refactored?
Here the idea is to have the response processing logic close to the caller function. In order to be coordinate the refactoring with you I refactored one function for sample. Please check and tell me if we can do it for the rest of the commands.
Please read the changes done in lines 715 and 899. The idea is to add a
logic
function after we runexecuteCommand
(line 899) which returns theitem
added to execution queue. This function will be executed in line 715 on thedataReceived
function. As we are attaching thelogic
function to theitem
in the queue, this type of checkingmodem.queue[0].command.substr(0, 3) == 'ATH'
is not needed any more.This way adding a new command is easier and also possible for the consumer out of the repo.
SMS sending and receiving is a bit different, I suggest to not refactor them at the moment.
Please tell me you opinion and if you agree I refactor the rest of the commands (except send / receive SMS).
Beside, I do not have a possibility to check all of the commands, do you have that opportunity to test all of them after I refactored?