mirror of
https://github.com/g4klx/MMDVMHost.git
synced 2026-04-07 15:34:04 +00:00
Add support for passthrough of serial data from MQTT to the spare serial port on an MMDVM modem/hotspot.
This commit is contained in:
parent
1afe34f514
commit
3c48b8f61b
11 changed files with 59 additions and 126 deletions
|
|
@ -99,6 +99,26 @@ bool CMQTTConnection::publish(const char* topic, const char* text)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool CMQTTConnection::publish(const char* topic, const unsigned char* data, unsigned int len)
|
||||
{
|
||||
assert(topic != NULL);
|
||||
assert(data != NULL);
|
||||
|
||||
if (!m_connected)
|
||||
return false;
|
||||
|
||||
char topicEx[100U];
|
||||
::sprintf(topicEx, "%s/%s", m_name.c_str(), topic);
|
||||
|
||||
int rc = ::mosquitto_publish(m_mosq, NULL, topicEx, len, data, static_cast<int>(m_qos), false);
|
||||
if (rc != MOSQ_ERR_SUCCESS) {
|
||||
::fprintf(stderr, "MQTT Error publishing: %s\n", ::mosquitto_strerror(rc));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CMQTTConnection::close()
|
||||
{
|
||||
if (m_mosq != NULL) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue