MCPcopy Create free account
hub / github.com/BruceDevices/firmware / ssh_setup

Function ssh_setup

src/modules/wifi/clients.cpp:1181–1233  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1179}
1180
1181void ssh_setup(String host) {
1182 if (!wifiConnected) wifiConnectMenu();
1183 if (!initClientMutex()) {
1184 displayError("SSH mutex creation failed.", true);
1185 returnToMenu = true;
1186 return;
1187 }
1188
1189 resetClientScreen("SSH");
1190 if (host != "") {
1191 ssh_host = host;
1192 } else {
1193 String my_net =
1194 WiFi.gatewayIP().toString().substring(0, WiFi.gatewayIP().toString().lastIndexOf(".") + 1);
1195 ssh_host = keyboard(my_net, 100, "SSH HOST (IP or Hostname)");
1196 if (ssh_host == "\x1B") return;
1197 }
1198
1199 ssh_port = num_keyboard("22", 5, "SSH PORT");
1200 if (ssh_port == "\x1B") return;
1201 ssh_user = keyboard("", 76, "SSH USER");
1202 if (ssh_user == "\x1B") return;
1203 ssh_password = keyboard("", 76, "SSH PASSWORD", true);
1204 if (ssh_password == "\x1B") return;
1205
1206 IPAddress resolvedIp;
1207 if (WiFi.hostByName(ssh_host.c_str(), resolvedIp)) {
1208 ssh_host = resolvedIp.toString();
1209 } else {
1210 displayError("Failed to resolve hostname.", true);
1211 Serial.printf("Failed to resolve hostname: %s", ssh_host.c_str());
1212 returnToMenu = true;
1213 return;
1214 }
1215
1216 sessionHost = ssh_host;
1217 sessionUser = ssh_user;
1218 sessionPort = static_cast<uint16_t>(ssh_port.toInt());
1219
1220 resetClientState(ClientProtocol::SSH);
1221 TaskHandle_t workerHandle = nullptr;
1222 xTaskCreate(sshWorkerTask, "SSH Task", SSH_TASK_STACK_SIZE, nullptr, 1, &workerHandle);
1223 setClientTaskHandle(workerHandle);
1224
1225 if (workerHandle == nullptr) {
1226 displayError("SSH Task creation failed.", true);
1227 returnToMenu = true;
1228 return;
1229 }
1230
1231 startSessionLog(ClientProtocol::SSH);
1232 runSessionUiLoop("SSH");
1233}
1234
1235void ssh_loop(void *pvParameters) { sshWorkerTask(pvParameters); }
1236

Callers

nothing calls this directly

Calls 11

wifiConnectMenuFunction · 0.85
initClientMutexFunction · 0.85
displayErrorFunction · 0.85
resetClientScreenFunction · 0.85
num_keyboardFunction · 0.85
resetClientStateFunction · 0.85
setClientTaskHandleFunction · 0.85
startSessionLogFunction · 0.85
runSessionUiLoopFunction · 0.85
keyboardFunction · 0.50
printfMethod · 0.45

Tested by

no test coverage detected