How to get Disconnect Event from BLE layer - Bluez/Linux - disconnect

A previous question How to get Disconnect Event from GATT Server on Bluez/Linux addresses the disconnect event for Bluez stack.
However since the disconnection detection is at the GATT layer it takes a while for the disconnection to be detected at the GATT Layer. Delayed disconnection detection would be an issue for many applications.
Bluez provides HCI API to connect/disconnect at BLE layer:
int hci_le_create_conn();
int hci_disconnect();
How does an application catch an HCI event indicating that a BLE connection made by hci_le_create_conn() is now disconnected.

Related

What is the openssl API to configure the Heartbeat idle timeout

I am using a openssl library to implement tls server.
How to configure the Heartbeat request timeout and retry count using openssl API to control the keepalive message flow?
I'm assuming you really do mean TLS as you said and not DTLS. Using heartbeats in TLS is quite unusual, although OpenSSL does support it in version 1.0.2. That support is removed from OpenSSL 1.1.0 so, for that reason, I would advise against using it in a new application. Use TCP keep alives instead.
The Heartbeat API is really quite simple. You can do three things:
1) Send a heartbeat using SSL_heartbeat()
2) Find out if a previously sent heartbeat is still pending a response using SSL_get_tlsext_heartbeat_pending()
and
3) Set the Heartbeat mode to disallow the peer from sending heartbeat requests using SSL_set_tlsext_heartbeat_no_requests()
Anything else is up to the application. Retries should not be necessary in TLS because it is designed to run over a reliable transport layer. If the connection is alive, it will get there. If it isn't, it won't. The TCP layer will handle retransmission of lost packets. Timeouts should also really be done at the TCP layer. If the TCP connection times out the SSL connection will fail.

Are there any simple libev/libevent implementations supporting websockets?

I am looking for an echo server example using libev or libevent that accepts websocket connections: a websocket client connects, sends a message and receives it back. SSL websockets should also be supported. Is there such thing available? If not, what's the most minimal websocket C library that can be plugged into a libev or libevent echo examples?

Client Server program using messages queues

I am trying to design a Client Server kind of application in which my Server is a daemon that accepts client requests, send client's data over a serial channel to the other side(which is an MCU and its firmware will reply to the Server request over the same serial channel). My client can be a CLI application or any other system program.
My idea of design is -
Use message queues for communication between Client and Server since this is a local application and message queues are bidirectional and fast.
Implement a LIBRARY that acts as an interface between multiple clients and the server. This basically does the stuff of packetizing client data into a message(own defined protocol), create message queues, connect to server, send/receive data and then pass it to the respective client(using call backs). This library also exposes API that can be used by clients. Thus this library gives me the flexibility to add support for any new clients keeping the server program unchanged.
Server gets the data over serial from other side and passes it to the library over message queue. The library uses callbacks to send data to the client.
EDIT:
I am thinking of creating Message queues on the fly when any client requests arrive. If I do this, how does the Server daemon(which has already started at linux boot up) gets information about this message queue? Does the message queue has a name that is persistent across and used by other programs? I want to implement clients that will be blocked until it gets response from the server.
Could you guys please review this design and tell me whether my approach is correct. Please reply if you have any other recommendations.
Thanks in advance.

Any reason why latency in updating timelineitem to my glass device?

i see latency issue - when i send a timelineitem from my glassware app, it takes a long time to appear on glass device.
I see the item in developer playground (https://developers.google.com/glass/playground)
Is it isolated issue on my WiFi (unlikely)? or some optimization done at Mirror server which queues timelineitems and sending in a specific interval to glass device?
Thanks
After doing some more investigation (In my case, i have setup private network inside enterprise network), i found out that some of the ports are blocked by firewall settings for incoming traffic from outside network, so glass device was not getting notifications from the Mirror Server.
It is possible either Channel API or XMPP is used in receiving notification messages from Mirror server to Glass. Those ports might have blocked by my firewall settings. I ran wireshark, still it is not clear which protocol or port is used in receiving notifications.
Also it is possible that glass device could get (HTTP GET) newly available cards from the mirror server by polling on specific time interval or other cases(changing WIFI network, etc).
I called Glass help, i could not get any feedback.
I would really appreciate if someone (from Google) could shed some light (port and protocol details) on how Glass gets notification from mirror server when new timeline card is available.
This is a known issue:
https://code.google.com/p/google-glass-api/issues/detail?id=185
Issue has been fixed by updating to XE10.

WCF: Exception handling on OneWay OperationContract

I am having a WCF duplex service with Silverlight client and .NET 3.5 WCF service.
The scenario I have is: during the duplex push OneWay operation from server to client if an exception happens in client notification handler the channel gets silently faulted so any further duplex calls from server timeout and fail. (As explained here One-Way Operations and Exceptions)
My question(s):
Can I just decorate with FaultContract a OneWay OperationContract, wrap the exception on client and prevent faulting of the channel?
if not, what would be some other way to catch the exception which occurred on the client during the duplex push from server?
When you use OneWay OperationContract, the receiver should not reply nor the sender of the request should expect one.
You can't.
Your best bet is you can create another OneWay OperationContract between client and the service so that the service can send the fault to the client.

Resources