Skip to content
This repository was archived by the owner on Dec 9, 2018. It is now read-only.

Support TCP connections #17

Open
dbrgn opened this issue Jun 18, 2017 · 5 comments · May be fixed by #20
Open

Support TCP connections #17

dbrgn opened this issue Jun 18, 2017 · 5 comments · May be fixed by #20

Comments

@dbrgn
Copy link
Contributor

dbrgn commented Jun 18, 2017

I started porting the TCPClient, but kind of got stuck in the complexity of the issue.

Is this the correct direction / approach?

@japaric
Copy link
Contributor

japaric commented Jun 23, 2017

Where and how did you get stuck?

I personally would start by directly calling the socket API until I can stablish a connection to some server while verifying that all the socket calls don't return errors and figuring out what arguments make sense to use with the socket API. Then I would continue to do some basic I/O through the socket. Only after I have understood how the socket API works would I try to create a Rust version of the TCPClient API. But just putting up a minimal connection example that directly uses the socket API would be a great start!

@dbrgn
Copy link
Contributor Author

dbrgn commented Jun 23, 2017

This is their library: https://github.com/spark/firmware/blob/develop/wiring/src/spark_wiring_tcpclient.cpp I wanted to port it to Rust (as directly as possible for now, without making it idiomatic).

That code looks pretty straightforward, the tricky part (for me) is the network / wifi stuff: https://github.com/spark/firmware/blob/develop/wiring/src/spark_wiring_wifi.cpp I can't find the place anymore, but somehow I found a rabbit hole that led to calls to the WICED library, which is pretty big. Maybe bindings to that could be generated with bindgen?

@japaric
Copy link
Contributor

japaric commented Jun 24, 2017

You could try to directly bind to their C++ firmware library for the TCPClient stuff. Bindgen supports C++ libraries but I haven't used it like that before so I can't provide further advice on that.

@dbrgn
Copy link
Contributor Author

dbrgn commented Jun 29, 2017

Ok, initial attempt with current bindgen:

$ cd particle-firmware
$ bindgen --use-core --ctypes-prefix ::ctypes \
    firmware/wiring/inc/spark_wiring_tcpclient.h -- \
    -I firmware/system/inc/ \
    -I firmware/hal/inc/ \
    -I firmware/services/inc/ \
    -I firmware/hal/shared/ \
    -x c++ -std c++14
thread 'main' panicked at 'TranslationUnit::parse failed',
/checkout/src/libcore/option.rs:794
note: Run with `RUST_BACKTRACE=1` for a backtrace.

Any idea?

@japaric
Copy link
Contributor

japaric commented Jun 29, 2017

No idea. The error message is not particularly helpful. The documentation says that you will likely need to whitelist some std stuff to make this work but doesn't suggest what should be whitelisted (everything's whitelisted by default). You'll probably have more luck asking around on IRC or looking for a project that creates C++ bindings to see how it does it.

@rnestler rnestler linked a pull request Oct 3, 2017 that will close this issue
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants