sforkowany z mirror/meshtastic-firmware
				
			Allow Portduino to set the TCP port
							rodzic
							
								
									31dc37150b
								
							
						
					
					
						commit
						2696b04138
					
				| 
						 | 
				
			
			@ -411,7 +411,7 @@ void setup()
 | 
			
		|||
#endif
 | 
			
		||||
 | 
			
		||||
#ifdef ARCH_PORTDUINO
 | 
			
		||||
    initApiServer();
 | 
			
		||||
    initApiServer(TCPPort);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
    // Start airtime logger thread.
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -20,6 +20,8 @@ extern bool isUSBPowered;
 | 
			
		|||
 | 
			
		||||
extern uint8_t nodeTelemetrySensorsMap[TelemetrySensorType_LPS22+1];
 | 
			
		||||
 | 
			
		||||
extern int TCPPort; // set by Portduino
 | 
			
		||||
 | 
			
		||||
// Global Screen singleton.
 | 
			
		||||
extern graphics::Screen *screen;
 | 
			
		||||
// extern Observable<meshtastic::PowerStatus> newPowerStatus; //TODO: move this to main-esp32.cpp somehow or a helper class
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -51,6 +51,35 @@ class PolledIrqPin : public GPIOPin
 | 
			
		|||
 | 
			
		||||
static GPIOPin *loraIrq;
 | 
			
		||||
 | 
			
		||||
int TCPPort = 4403; 
 | 
			
		||||
 | 
			
		||||
static error_t parse_opt(int key, char *arg, struct argp_state *state) {
 | 
			
		||||
  switch (key) {
 | 
			
		||||
  case 'p':
 | 
			
		||||
    if (sscanf(arg, "%d", &TCPPort) < 1)
 | 
			
		||||
        return ARGP_ERR_UNKNOWN; 
 | 
			
		||||
    else
 | 
			
		||||
        printf("Using TCP port %d\n", TCPPort);
 | 
			
		||||
    break;
 | 
			
		||||
  case ARGP_KEY_ARG:
 | 
			
		||||
    return 0;
 | 
			
		||||
  default:
 | 
			
		||||
    return ARGP_ERR_UNKNOWN;
 | 
			
		||||
  }
 | 
			
		||||
  return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void portduinoCustomInit() {
 | 
			
		||||
    static struct argp_option options[] = {{"port", 'p', "PORT", 0, "The TCP port to use."}, {0}};
 | 
			
		||||
    static void *childArguments; 
 | 
			
		||||
    static char doc[] = "Meshtastic native build.";
 | 
			
		||||
    static char args_doc[] = "...";
 | 
			
		||||
    static struct argp argp = {options, parse_opt, args_doc, doc, 0, 0, 0};
 | 
			
		||||
    const struct argp_child child = {&argp, OPTION_ARG_OPTIONAL, 0, 0};
 | 
			
		||||
    portduinoAddArguments(child, childArguments);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/** apps run under portduino can optionally define a portduinoSetup() to
 | 
			
		||||
 * use portduino specific init code (such as gpioBind) to setup portduino on their host machine,
 | 
			
		||||
 * before running 'arduino' code.
 | 
			
		||||
| 
						 | 
				
			
			@ -86,6 +115,9 @@ void portduinoSetup()
 | 
			
		|||
#endif
 | 
			
		||||
 | 
			
		||||
    {
 | 
			
		||||
        // Set the random seed equal to TCPPort to have a different seed per instance
 | 
			
		||||
        randomSeed(TCPPort);
 | 
			
		||||
 | 
			
		||||
        auto fakeBusy = new SimGPIOPin(SX126X_BUSY, "fakeBusy");
 | 
			
		||||
        fakeBusy->writePin(LOW);
 | 
			
		||||
        fakeBusy->setSilent(true);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Ładowanie…
	
		Reference in New Issue