Add FRC Driver Station connection support.

The 2017 FRC Driver Station supports getting the robot IP via a TCP
connection that returns JSON.  Use this to support overriding the
server IP address used for client connections.

Default to using this approach for client connections in the NetworkTable
interfaces.

Add support for setting the server address without stopping and
restarting the client.

SetTeam now also round-robins by default.
This commit is contained in:
Peter Johnson
2016-11-04 16:01:42 -07:00
parent 34acd9d47c
commit 77edf1e103
15 changed files with 538 additions and 66 deletions

View File

@@ -14,6 +14,7 @@
#include "support/timestamp.h"
#include "Log.h"
#include "Dispatcher.h"
#include "DsClient.h"
#include "Notifier.h"
#include "RpcServer.h"
#include "Storage.h"
@@ -246,16 +247,34 @@ void StartServer(StringRef persist_filename, const char* listen_address,
void StopServer() { Dispatcher::GetInstance().Stop(); }
void StartClient() { Dispatcher::GetInstance().StartClient(); }
void StartClient(const char* server_name, unsigned int port) {
Dispatcher::GetInstance().StartClient(server_name, port);
auto& d = Dispatcher::GetInstance();
d.SetServer(server_name, port);
d.StartClient();
}
void StartClient(ArrayRef<std::pair<StringRef, unsigned int>> servers) {
Dispatcher::GetInstance().StartClient(servers);
auto& d = Dispatcher::GetInstance();
d.SetServer(servers);
d.StartClient();
}
void StopClient() { Dispatcher::GetInstance().Stop(); }
void SetServer(const char* server_name, unsigned int port) {
Dispatcher::GetInstance().SetServer(server_name, port);
}
void SetServer(ArrayRef<std::pair<StringRef, unsigned int>> servers) {
Dispatcher::GetInstance().SetServer(servers);
}
void StartDSClient(unsigned int port) { DsClient::GetInstance().Start(port); }
void StopDSClient() { DsClient::GetInstance().Stop(); }
void StopRpcServer() { RpcServer::GetInstance().Stop(); }
void StopNotifier() { Notifier::GetInstance().Stop(); }