Change the handling of the options command.

This commit is contained in:
Jonathan Naylor
2016-11-10 17:54:15 +00:00
parent 394ed568ca
commit 7f5d3cc5f5
2 changed files with 17 additions and 11 deletions

View File

@@ -361,6 +361,7 @@ void CDMRNetwork::clock(unsigned int ms)
} else if (::memcmp(m_buffer, "RPTACK", 6U) == 0) { } else if (::memcmp(m_buffer, "RPTACK", 6U) == 0) {
switch (m_status) { switch (m_status) {
case WAITING_LOGIN: case WAITING_LOGIN:
LogDebug("DMR, Sending authorisation");
::memcpy(m_salt, m_buffer + 6U, sizeof(uint32_t)); ::memcpy(m_salt, m_buffer + 6U, sizeof(uint32_t));
writeAuthorisation(); writeAuthorisation();
m_status = WAITING_AUTHORISATION; m_status = WAITING_AUTHORISATION;
@@ -368,10 +369,18 @@ void CDMRNetwork::clock(unsigned int ms)
m_retryTimer.start(); m_retryTimer.start();
break; break;
case WAITING_AUTHORISATION: case WAITING_AUTHORISATION:
if (m_options.empty()) { LogDebug("DMR, Sending configuration");
writeConfig(); writeConfig();
m_status = WAITING_CONFIG; m_status = WAITING_CONFIG;
m_timeoutTimer.start();
m_retryTimer.start();
break;
case WAITING_CONFIG:
if (m_options.empty()) {
LogMessage("DMR, Logged into the master successfully");
m_status = RUNNING;
} else { } else {
LogDebug("DMR, Sending options");
writeOptions(); writeOptions();
m_status = WAITING_OPTIONS; m_status = WAITING_OPTIONS;
} }
@@ -379,12 +388,6 @@ void CDMRNetwork::clock(unsigned int ms)
m_retryTimer.start(); m_retryTimer.start();
break; break;
case WAITING_OPTIONS: case WAITING_OPTIONS:
writeConfig();
m_status = WAITING_CONFIG;
m_timeoutTimer.start();
m_retryTimer.start();
break;
case WAITING_CONFIG:
LogMessage("DMR, Logged into the master successfully"); LogMessage("DMR, Logged into the master successfully");
m_status = RUNNING; m_status = RUNNING;
m_timeoutTimer.start(); m_timeoutTimer.start();
@@ -473,7 +476,10 @@ bool CDMRNetwork::writeAuthorisation()
bool CDMRNetwork::writeOptions() bool CDMRNetwork::writeOptions()
{ {
char buffer[300U]; char buffer[300U];
::sprintf(buffer, "RPTO%s", m_options.c_str());
::memcpy(buffer + 0U, "RPTO", 4U);
::memcpy(buffer + 4U, m_id, 4U);
::strcpy(buffer + 8U, m_options.c_str());
return write((unsigned char*)buffer, (unsigned int)::strlen(buffer)); return write((unsigned char*)buffer, (unsigned int)::strlen(buffer));
} }

View File

@@ -71,8 +71,8 @@ private:
WAITING_CONNECT, WAITING_CONNECT,
WAITING_LOGIN, WAITING_LOGIN,
WAITING_AUTHORISATION, WAITING_AUTHORISATION,
WAITING_OPTIONS,
WAITING_CONFIG, WAITING_CONFIG,
WAITING_OPTIONS,
RUNNING RUNNING
}; };