Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions segger/streaming/streaming_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
#ifndef _STREAMING_CONFIG_H_
#define _STREAMING_CONFIG_H_

#ifndef WEBSOCKET_STREAMING
#define WEBSOCKET_STREAMING 1
#endif

#ifndef JSONRPC_PORT
#define JSONRPC_PORT "http"
#endif
Expand Down Expand Up @@ -69,4 +73,8 @@
#define STREAMING_TCP_PORT 7412
#endif

#ifndef STREAMING_PORT
#define STREAMING_PORT 7414
#endif

#endif
11 changes: 8 additions & 3 deletions segger/streaming/streaming_handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* limitations under the License.
*/

#include "RTOS.h"
#include "streaming_handler.h"
#include "IP.h"
#include "IP_Webserver.h"
Expand All @@ -31,6 +32,9 @@ struct streaming_callbacks *streaming_cbs;
static char stream_id[9];

#if WEBSOCKET_STREAMING

static OS_MAILBOX mb; // Mailbox to hand over connection handle from webserver task to streaming task

#define IP_WEBSOCKET_CLOSE_CODE_TRY_AGAIN_LATER 1013

static int websocket_acceptKey_generator(WEBS_OUTPUT *pOutput, void *pSecWebSocketKey, int SecWebSocketKeyLen,
Expand All @@ -40,6 +44,8 @@ static int websocket_acceptKey_generator(WEBS_OUTPUT *pOutput, void *pSecWebSock
return IP_WEBSOCKET_GenerateAcceptKey(pSecWebSocketKey, SecWebSocketKeyLen, pBuffer, BufferSize);
}



static void streaming_dispatch_handle(WEBS_OUTPUT *pOutput, void *pConnection)
{
WEBS_USE_PARA(pOutput);
Expand All @@ -58,9 +64,8 @@ static void streaming_dispatch_handle(WEBS_OUTPUT *pOutput, void *pConnection)
}
}

static OS_MAILBOX mb; // Mailbox to hand over connection handle from webserver task to streaming task
static long buff;
static webSocketHook;
static WEBS_WEBSOCKET_HOOK webSocketHook;
static const IP_WEBS_WEBSOCKET_API StreamingWebSocketApi = {websocket_acceptKey_generator,
streaming_dispatch_handle};
#endif
Expand Down Expand Up @@ -121,7 +126,7 @@ void streaming_start(void)
// Error might indicate we ran out of network buffers or the socket is closed
signals_purge_stream(stream);
stream_free(stream);
#ifdef WEBSOCKET_STREAMING
#if WEBSOCKET_STREAMING
OS_MAILBOX_Purge(&mb);
#endif
}
Expand Down
5 changes: 3 additions & 2 deletions segger/streaming/streaming_packet.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* limitations under the License.
*/

#include "streaming_config.h"
#include "streaming_packet.h"
#include "IP_WEBSOCKET.h"
#include "SEGGER_UTIL.h"
Expand Down Expand Up @@ -57,7 +58,7 @@ static int serialize_header(tl_packet_t *packet, unsigned char *dst, size_t buff
// the streaming header size depends on the payload size
size_t tl_header_size = (packet->payload_size) > UINT8_MAX ? 8 : 4;

#ifdef WEBSOCKET_STREAMING
#if WEBSOCKET_STREAMING
// the websocket header size depends on the size of its payload, which contains the streaming header
size_t websocket_payload_size = tl_header_size + packet->payload_size;
size_t websocket_header_size = websocket_payload_size < 126 ? 2 : 4;
Expand All @@ -71,7 +72,7 @@ static int serialize_header(tl_packet_t *packet, unsigned char *dst, size_t buff
return -1;
}

#ifdef WEBSOCKET_STREAMING
#if WEBSOCKET_STREAMING
// serialize the websocket header
*dst++ = 0x80 + IP_WEBSOCKET_FRAME_TYPE_BINARY; // FIN and binary packet
if (websocket_payload_size < 126) {
Expand Down
2 changes: 1 addition & 1 deletion segger/streaming/streaming_signals.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ int signals_subscribe(const struct stream *stream, const char *signalId)
streaming_cbs->on_subscribe(stream, &related_signal[i]);
_signal_subscribe(stream, &related_signal[i], 0); // valueIndex is fixed to 0 and gets ignored
}
if (!signal->subscribed && signal->definition.signaltype == signal_type_value) {
if (!signal->subscribed && signal->definition->signaltype == signal_type_value) {
table->subscribed_value_signal_count++;
}
}
Expand Down
1 change: 0 additions & 1 deletion segger/streaming/streaming_signals.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ void signals_init(void);
void signals_send_all_avail(const struct stream *stream);
int signals_subscribe(const struct stream *stream, const char *signalId);
int signals_unsubscribe(const struct stream *stream, const char *signalId);
signal_t *signals_add_signal(signal_definition_t *def, signal_table_t *table);
signal_table_t *signals_add_table(signal_definition_t *def, unsigned int count, const char *table_name);
bool signal_has_subscription(signal_t *signal);
unsigned int signal_get_signal_no(signal_t *signal);
Expand Down
5 changes: 3 additions & 2 deletions segger/streaming/streaming_websocket_rx.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
* limitations under the License.
*/

#include "streaming_config.h"
#include "streaming_websocket_rx.h"
#ifdef WEBSOCKET_STREAMING
#if WEBSOCKET_STREAMING
#include "IP_WEBSOCKET.h"
#endif
#include <stdbool.h>
Expand All @@ -39,7 +40,7 @@ int streaming_rx_callback(long Socket, IP_PACKET *pPacket, int code)
goto CloseSocket;
}

#ifdef WEBSOCKET_STREAMING
#if WEBSOCKET_STREAMING
unsigned char *ptr = pPacket->pData;
size_t paket_len = pPacket->NumBytes;
U16 head = (ptr[0] << 8) + ptr[1];
Expand Down