Update for new tcp sh message system
This commit is contained in:
parent
11b648c3ba
commit
127f1b56a3
2 changed files with 7 additions and 11 deletions
16
main.cpp
16
main.cpp
|
|
@ -2,7 +2,6 @@
|
||||||
#include <pipewire/context.h>
|
#include <pipewire/context.h>
|
||||||
#include <pipewire/core.h>
|
#include <pipewire/core.h>
|
||||||
#include <pipewire/pipewire.h>
|
#include <pipewire/pipewire.h>
|
||||||
#include <iostream>
|
|
||||||
#include <spa/param/audio/format-utils.h>
|
#include <spa/param/audio/format-utils.h>
|
||||||
#include <spa/param/audio/raw.h>
|
#include <spa/param/audio/raw.h>
|
||||||
|
|
||||||
|
|
@ -11,10 +10,9 @@
|
||||||
#include "Socket.h"
|
#include "Socket.h"
|
||||||
#include "spa/support/loop.h"
|
#include "spa/support/loop.h"
|
||||||
|
|
||||||
|
|
||||||
#define BUFFER_SIZE 2048
|
#define BUFFER_SIZE 2048
|
||||||
|
|
||||||
#define SENSOR_STRING "bcst: SENSOR TYPE: 254 ID: "
|
#define MSG_STRING "MSG JSON LEN "
|
||||||
|
|
||||||
struct PwlPriv
|
struct PwlPriv
|
||||||
{
|
{
|
||||||
|
|
@ -46,12 +44,11 @@ static void send_sensor(TCPSocket* socket, uint8_t id, bool state)
|
||||||
|
|
||||||
lastState = state;
|
lastState = state;
|
||||||
|
|
||||||
std::string sendbuf(SENSOR_STRING);
|
std::string json = "{ \"Type\": \"Sensor\", \"SensorType\": 254, ";
|
||||||
sendbuf.append(std::to_string(static_cast<unsigned int>(id)));
|
json.append("\"Id\": " + std::to_string(static_cast<unsigned int>(id)) + ", ");
|
||||||
sendbuf.append(" FIELD: ");
|
json.append("\"Field\":" + std::to_string(static_cast<unsigned int>(state)));
|
||||||
sendbuf.append(std::to_string(static_cast<unsigned int>(state)));
|
json.append(" }\n");
|
||||||
sendbuf.push_back('\n');
|
std::string sendbuf(MSG_STRING + std::to_string(json.length()) + "\n" + json);
|
||||||
Log(Log::DEBUG, false)<<sendbuf;
|
|
||||||
socket->send(sendbuf.c_str(), sendbuf.size());
|
socket->send(sendbuf.c_str(), sendbuf.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -140,7 +137,6 @@ static void node_event_info(void* data, const struct pw_node_info *info)
|
||||||
prev_state = info->state;
|
prev_state = info->state;
|
||||||
Log(Log::INFO)<<"node "<<info->id<<" is in state "<<pw_node_state_as_string(info->state);
|
Log(Log::INFO)<<"node "<<info->id<<" is in state "<<pw_node_state_as_string(info->state);
|
||||||
|
|
||||||
std::string sendbuf(SENSOR_STRING);
|
|
||||||
switch(info->state)
|
switch(info->state)
|
||||||
{
|
{
|
||||||
case PW_NODE_STATE_RUNNING:
|
case PW_NODE_STATE_RUNNING:
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ struct Config
|
||||||
std::string sink_name;
|
std::string sink_name;
|
||||||
bool use_active = false;
|
bool use_active = false;
|
||||||
std::string host = "localhost";
|
std::string host = "localhost";
|
||||||
unsigned short port = 6856;
|
unsigned short port = 38940;
|
||||||
uint8_t id = 0;
|
uint8_t id = 0;
|
||||||
unsigned int timeout = 60;
|
unsigned int timeout = 60;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue