How to make a generic code for multiple feeds or connected devices to a CoAP client, such that we can control them via the same function with the incoming parameters.
Like in the GET method of CoAP it sends Get-feedname/device name, where we can receive the message and send accordingly.
Related
We want our SignalR Hub (Microsoft.AspNetCore.SignalR.Hub) to be a middle-man of sorts; in addition to pushing and receiving messages to/from clients, it should consume messages from a separate web socket server using ClientWebSocket. It processes those messages, then sends derived messages to clients via SignalR.
One problem is that the ClientWebSocket is injected and then configured in the constructor, but the constructor is called several times, which throws an error when trying to configure ClientWebSocket when it is already open.
Another problem is that when ClientWebSocket.ConnectAsync is called, SignalR no longer receives messages.
Is there a way to get these to work in the Hub? Or do we have to design it differently to not use SignalR and ClientWebSocket in the same class?
SignalR is a protocol over any transport. What that means is that you can connect with ClientWebSocket but you will need to manually write and parse the protocol messages. The protocol is documented at https://github.com/dotnet/aspnetcore/blob/main/src/SignalR/docs/specs/HubProtocol.md
I have a situation
When i am making the diagnostic request from canoe. ECU responding with the response(Request correctly received but response pending). After some time i am getting positive response from the ECU. I just want to send the positive response from the current bus to another bus by cutting out the response pending response. How can i do that using capl?
You need to implement a gateway. I.e. a node connected to the two busses. For one bus, the node acts as a tester (sending requests and listens to responses) for the other bus, the node acts as ECU.
You listen for responses in one bus by using on diagResponse CAN1.* and if it is a positive response you send it to the other bus by using diagSendResponse CAN2.<responseMessage>
Replace CAN1 and CAN2 with the actual bus names.
Also check the Applications Note called Diagnostics Gateway or something like that coming with CANoe.
Another option is to do this not on the application layer but on the data layer. I.e. not by listening and forwarding diagnostics messages but by listening to the transported data.
What makes more sense for you depends on your exact setup; but details are unknown.
ZeroMQs Pub/Sub pattern makes it easy for the server to reply to the right client. However, it is less obvious how to handle communication that cannot be resolved within two steps, i.e. protocols where multiple request/reply pairs are necessary.
For example, consider a case where the client is a worker which asks the server for new work of a specific type, the server replies with the parameters of the work, the client then sends the results and the server checks these and replies whether they were correct.
Obviously, I can't just use recv,send,recv,send sequentially and assume that the first and the second recv are from the same client. What would be the idiomatic way to use multiple recv,send pairs without having to handle messages from other clients inbetween?
Multiple Request/Reply pairs can be made through the use of ZMQ_ROUTER sockets. I recommend using ZMQ_REQ sockets on the clients for bidirectional communication.
If you want to have multiple clients accessing a single server you could use a router socket on the server and request sockets on the clients.
Check out the ZMQ guide's section on this pattern:
http://zguide.zeromq.org/php:chapter3#The-Asynchronous-Client-Server-Pattern
All the clients will interact with the server in the same pattern as Pub/Subs except they will all point at a single server Router socket.
The server on the other hand will receive three messages for every single message a client sends. These parts represent:
Part0 = Identity of connection (random number of which client it is)
Part1 = Empty frame
Part2 = Data of the ZMQ message.
Reference:
http://zguide.zeromq.org/php:chapter3#ROUTER-Broker-and-REQ-Workers
The identity can be used to differentiate between clients accessing on a single port. Repacking the message in the same order and responding on the router socket (with a different data frame) will automatically route it to the client who sent the message.
Pusher service works as illustrated here:
Does it make sense to use it in reverse direction (and switched data channels)? My use case is as follows:
end users (actually mobile, not browser) send messages to Pusher via HTTP-based REST API
my firewalled machine is connected to Pusher via WebSockets API, subscribes channel and receives messages in realtime
This way I can work with Sandbox plan (only 1 persistent connection is used) but mobile app must contain Puser app key.
From what I understand, anyone can use this key to register subscribe same message stream via websockets. Is there a reverse mode, where receiving messages requires knowing the secret? Maybe other service would suit better?
A more secure solution would be for the mobile clients to use client events. Client events can only be triggered on private channels where the subscription to the channel has to be authenticated.The authentication requests should got to an HTTP endpoint that you control so that you can validate the subscription request.
You firewalled machine can either then have a WebSocket connection and receive the client events over that connection. Or it could receive the client events via client event WebHooks if it exposes an HTTP endpoint.
I've tried to develop a GSM modem library for handling SMS built around system.io.ports.serialport.
It does'nt handle unsolicited responses very well, in particular incoming calls.
I have resorted to sending AT hangup commands for each incoming call, however the unsolicited responses still popup even while you are performing other tasks.
This makes it quite difficult to handle correctly.
You probably want a separate thread that acts as a session handler, with a message queue interface towards the rest of your app. It should wait on inputs from either your application (to initiate a session) or your modem (incoming calls). When it's rebuffing an incoming call, session initiation requests from your application can wait.