Skip to content
This repository has been archived by the owner on Nov 2, 2021. It is now read-only.

BT connection manager does not split up multi-command packages. #50

Open
mfeuer opened this issue Sep 19, 2015 · 1 comment
Open

BT connection manager does not split up multi-command packages. #50

mfeuer opened this issue Sep 19, 2015 · 1 comment

Comments

@mfeuer
Copy link
Contributor

mfeuer commented Sep 19, 2015

components/dlink_bt/src/bt_connection.erl:handle_info(..., {data, Data}) does not split up multiple JSON-RPC commands bundled into a single RFCOMM transmit and invokes dlink_bt_rpc:handle_socket() separately for each command.

This problem has been fixed in components/dlink_tcp/connection.erl, where a receive buffer is kept in the process state and complete commands are extracted and forwarded to dlink_tcp_rpc:handle_socket(), with residual data being returned to state to be prepended to the next received network packet.

The TCP solution should be copied to the BT connection code.

This bug fix must be back ported to release-0.4.0, creating release-0.4.1

@uwiger
Copy link
Collaborator

uwiger commented Sep 21, 2015

A question: In the Erlang world, it's more commonplace to use e.g. {packet, 4}, adding some size bytes at the beginning of the message. This allows the receiver to know exactly how much to fetch, and eliminates the need for parsing to determine whether a complete message has arrived (which also opens some possibilities, e.g. when sending binary data which doesn't fit nicely inside JSON).

In Erlang, the size header processing is built in, so the user code only needs to pass the option when opening the socket. The socket logic then takes care of stripping the size header and delivering whole packets.

http://www.erlang.org/doc/man/inet.html#setopts-2

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants