THANK YOU!!!!!

It fixed the problem. Effectively I just removed the deinit and init; and added the esp_ble_gap_set_device_name and it works fine.
Obviously between 2.0.0 and 2.0.4 something had changed. It now runs 2.0.4 nicely.
Whilst doing this fix earlier, your code did not initially work. I had changed the ESP board driver from 2.0.0. to 2.0.4 during the IDE session. The bizarre issue was the serial port if (inChar == '\n') was being evaluated as false when the inChar was in fact line feed, despite the serial port working fine. I even scoped the serial feed and did an echo using Serial.print() to prove the program was receiving a linefeed character. The cause can only be a compiler issue. Maybe I should have thought of restarting the IDE when I changed the ESP32 driver. I did that and it all works fine now.
I don't know who you are, who your work for, or what country you live in, but your help has been really appreciated. I owe you a beer. I also notice your expertise has helped many other folks in this forum.
warm regards,
David