mirror of
https://github.com/meshtastic/firmware.git
synced 2025-09-04 10:38:57 +00:00
Allow Portduino to set the TCP port
This commit is contained in:
parent
31dc37150b
commit
2696b04138
@ -411,7 +411,7 @@ void setup()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef ARCH_PORTDUINO
|
#ifdef ARCH_PORTDUINO
|
||||||
initApiServer();
|
initApiServer(TCPPort);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Start airtime logger thread.
|
// Start airtime logger thread.
|
||||||
|
@ -20,6 +20,8 @@ extern bool isUSBPowered;
|
|||||||
|
|
||||||
extern uint8_t nodeTelemetrySensorsMap[TelemetrySensorType_LPS22+1];
|
extern uint8_t nodeTelemetrySensorsMap[TelemetrySensorType_LPS22+1];
|
||||||
|
|
||||||
|
extern int TCPPort; // set by Portduino
|
||||||
|
|
||||||
// Global Screen singleton.
|
// Global Screen singleton.
|
||||||
extern graphics::Screen *screen;
|
extern graphics::Screen *screen;
|
||||||
// extern Observable<meshtastic::PowerStatus> newPowerStatus; //TODO: move this to main-esp32.cpp somehow or a helper class
|
// 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;
|
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
|
/** 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,
|
* use portduino specific init code (such as gpioBind) to setup portduino on their host machine,
|
||||||
* before running 'arduino' code.
|
* before running 'arduino' code.
|
||||||
@ -86,6 +115,9 @@ void portduinoSetup()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
{
|
{
|
||||||
|
// Set the random seed equal to TCPPort to have a different seed per instance
|
||||||
|
randomSeed(TCPPort);
|
||||||
|
|
||||||
auto fakeBusy = new SimGPIOPin(SX126X_BUSY, "fakeBusy");
|
auto fakeBusy = new SimGPIOPin(SX126X_BUSY, "fakeBusy");
|
||||||
fakeBusy->writePin(LOW);
|
fakeBusy->writePin(LOW);
|
||||||
fakeBusy->setSilent(true);
|
fakeBusy->setSilent(true);
|
||||||
|
Loading…
Reference in New Issue
Block a user