SoftwareSerial magic numbers

There are 4 levels of acting -> goal -> strategy -> tactics -> operations

You did define your goal, but you were thinking tactics (how to program) and operations (details) . You skipped one level.

You must think of the strategies how such thing can be done and do "thought experiments" to find the tactics that belong to the strategy to make the strategy choice.

strategies can be : - brute force (test all), random search (aka darting;), hill climbing (change any param that improves the result), analytics etc

imho it is not over your head, it's not easy but you can do it, give it a try