XIAO nrfr52840 Changing Serial port pins

I have been building a small portable LoRa packet receiver and SD card logger with an LCD display.

Its based on the XIAO nrf52840 plus and the LoRa, SD card logger and LCD display are working. The LCD is very visible outdoors, even in strong sunlight. Its Powered for portable use with two 14500 Lithium cells on the back.

So far so good, the basics are working.

However a receiver that has fixed LoRa settings, Frequency, Spreading Factor, Bandwidth and Code Rate etc is not so useful. To change the LoRa settings the board normally needs to be re-programmed. I get around this by using a series of serial menus in the program so that the LoRa settings can be changed via a PC serial terminal application. The changed settings can be saved in a FRAM store so that they become permanent. So no need to re-program the board.

When out and about its not that practical to plug into a PC or Laptop, so I wanted a way to use a Bluetooth Serial Terminal on an Android phone to do the changes.

Connecting a HC06 to the D6, D7 serial port (Serial1 ?) is easy enough and it does work.

My problem is that I want to be able to use a switch to change the serial port used by the menus, i.e. choose between the USB serial connection or the HC06 Bluetooth connection.

I have simplified the code to that below. When the unit is reset or powered it reads the switch and attempts to redirect mySerial to the D6 and D7 pins. It does not work.

Any ideas how it can be made to work ?

Sample program below. The full program has all the Serial.print() functions set to mySerial.print();

#include <Adafruit_TinyUSB.h>
#define mySerial Serial

#define REDLED 11    //P0.26
#define BLUELED 12   //P0.06
#define GREENLED 13  //P0.30

#define LEDON LOW
#define LEDOFF HIGH
#define SWITCH1 D0  //P0.02

#define RXPIN D7  //P1.12
#define TXPIN D6  //P1.11

uint16_t seconds;

void loop() {
  mySerial.print(seconds);
  mySerial.println(F(" - Red Flash"));
  seconds++;
  digitalWrite(REDLED, LEDON);
  delay(100);
  digitalWrite(REDLED, LEDOFF);
  delay(890);
}

void led_Flash(uint16_t flashes, uint16_t delaymS) {
  uint16_t index;

  for (index = 1; index <= flashes; index++) {
    digitalWrite(REDLED, LEDON);
    delay(delaymS);
    digitalWrite(REDLED, LEDOFF);
    delay(delaymS);
  }
}

void setup() {
  pinMode(SWITCH1, INPUT_PULLUP);

  pinMode(REDLED, OUTPUT);
  digitalWrite(REDLED, LEDON);
  led_Flash(4, 250);

  if (digitalRead(SWITCH1)) {
    mySerial.begin(115200);
    digitalWrite(GREENLED, LEDON);
    mySerial.print(F("USB UART selected"));
  } else {
    mySerial.setPins(RXPIN, TXPIN);
    mySerial.begin(9600);
    digitalWrite(BLUELED, LEDON);
    mySerial.print(F("Bluetooth selected"));
  }

  delay(2000);
  digitalWrite(GREENLED, LEDOFF);
  digitalWrite(BLUELED, LEDOFF);

  mySerial.println();
  mySerial.println(__FILE__);
}