Im quite new on Android and I have some question for all of you who are experts!
Ok, my problem...
I implemented a client-server application based on socket programming. The server encode some packets, send them to the client through a socket and the clinet decode them.
I tested the code with two linux machines and it works fine but in my experiment it is required to include another node (this will be the Android). So the server (linux machine) will encode the packets and send through socket to client1(linux machine) and client2(Android).
For this reason I want to port the native binary of my code (which is in C++) to Android.
In which way could I do this?
Please give me some help!
Really im totally stucked!
Thanks,
Zenia
when you want to port native code C/C++ to android you want to look up android ndk and jni
http://developer.android.com/sdk/ndk/index.html
http://download.oracle.com/javase/1.5.0/docs/guide/jni/spec/functions.html
There are some examples in the ndk on how to do this.
be warned that C is fully supported but C++ support apis is very limited on android (the list is in the docs of the ndk) so you might have problems porting your code.
I would recommend using directly java if you can, since working with JNI is tedious lol
how else can you port this? start learning android i did a quick check noticed it's sdk uses java you can start by looking at
http://developer.android.com/reference/java/net/Socket.html
Thanks for the reply,
I first tried to write my own code totally in java using sockets, however i had to port some optimized libraries to Android and I could figure out how to do that (i could port a simple small library but not the one that I wanted). I gave up and I right now im trying to play with jni and ndk. however i dont know if indeed i could port my binary as it is non static (like hello world). Thats why im asking. if anyone else have some experince on that please let me know. thanks a lot,
Zenia
What you should probably do is install the SDK and NDK and build the hello-jni ndk example.
Then look up how to access the android logcat output from C, and write yourself a nice little printf-like wrapper for that (probably using the vargs version of the underlying function) so you can easily generate debug output from your native code.
Then graft your native executable onto the hello-jni example code, so you'll have a java wrapper that does very little other than start things with a call to the native code. Just remember not to do much processing in the UI thread or native code called under that thread, or you will risk an application not responding timeout.
It is also possible to (ab)use the ndk's gcc to produce stand alone native executables with no java wrapper, but this is discouraged. It's hard to find a reliable place to install them on a non-rooted phone, and android's process management isn't happy about unknown native processes. In other words, that's a path that's fine for personal experiments on your own device, but a difficult and non-future-proof one for an application deployed to others.
Related
I am trying to create a signal/textsecure client using qt and C++, however i cant seem to fibd any C++ bindings for it.
the only bindings i can find are for Go (https://github.com/nanu-c/textsecure/)
is there any way to connect C++ with signal?
edit:
i wanted to clarify some things:
-im talking about the messaging app called Signal (https://signal.org)
-i am trying to write an app for ubuntu touch and am developing on manjaro linux.
On Linux or Unix, you probably want to communicate with other remote applications using some communication protocol, such as HTTP or HTTPS or SOAP or JSONRPC or ONCRPC. Of course read about socket(7) and before that Advanced Linux Programming then about syscalls(2). Consider reading a textbook on Operating Systems
Be sure to study the source code related to Signal. Read their technical documentation.
You surely need to understand the details. So take a few days or weeks to read more about them.
If you want to use some web service, you need to read and understand its documentation and when and how you are allowed to use it. There could be legal or financial issues.
Then you might use HTTP related libraries (e.g. Wt or libonion server side, and libcurl or curlpp client side).
See also in April 2020 the ongoing HelpCovid free software project (for Linux), at least for inspiration. We are coding it in C++.
after a little more digging i found that textsecure bindings are now renamed to libsignal.
after finding that out i found a lib for c/c++
https://github.com/signalapp/libsignal-protocol-c
I would like, from a native Windows application using C++, to receive video/audio data sent from a browser located in a remote location. It seems like WebRTC is the way to go for this.
Most information I find is about how to interact with the browser to write WebRTC apps, but it may case the data would be received by my C++ app. Is it correct that I would need to use the WebRTC Native Code package for this, which is described as being 'for browser developers'? Document is located here: http://www.webrtc.org/webrtc-native-code-package
And what if I want to send video/audio data that I generate (ie not directly coming from a webcam and microphone), would I be able to send it to the remote location browser?
Any sample code out there which does something like I'm trying to accomplish?
The wording in that link is a bit misleading. They intend people that are developing browsers to use the native code, and advise those that are developing "applications" in a browser to use the WebRTC API.
I have worked with their native code for over a year to develop an Android application that is capable of performing audio and / or video calls between other Android devices and to browsers. So, I a pretty sure that it is completely possible to to take their native code and create a Windows application (especially since they have example code that does that for Linux and Mac -- look at peerconnection client and peerconnection server for this). You might have to write and re-write code to get it to work on Windows.
As for as data that you generate. In the Android project that I worked with, we didn't rely on the Android device / system to provide us with video, we captured and sent that out our selves using the "LibJingle" / WebRTC libraries. So, I know that that is possible, as long as you provide the libraries with video data in the correct format. I would imagine that one would be able to do the same with audio, but we never fiddled with that, so I cannot say for sure.
And as for example code, I can only suggest Luke Weber's gitbug repositories. Although it is for Android, it might be of some help to look at how he interfaces with the two libraries. Probably the better code to look at is the peerconnection client stuff that comes in the "LibJingle" second of the native code. [edit]: That is located in /talk/examples/peerconection/client/ .
If you get lost from my use of "LibJingle", that will show you when I started working with all of this code. Sometime around July of 2013 they migrated "LibJingle" into the WebRTC "talk" folder. From everything that I have seen, they are the same thing, just with the location and named changed.
I'm new to Arduino, and one thing I came across is this cool tool called Embedxcode, which basically allows you to compile and run sketches on the Arduino from Xcode instead of from the normal Arduino compiler.
The reason I'm using this is because I want the user to be able to do something on the Arduino (i.e. push a button) and the computer responds (i.e. call some function in Objective-C). Since as far as I know you can't do that from the Arduino compiler, I've decided to use Xcode because it can compile Objective-C and use the OSX SDK.
I got Embedxcode to work (the Arduino code compiles and uploads to the board fine), but I can't get Objective-C working. As in, I cannot create a new Objective-C class to pass data to without Xcode giving me errors (and no, renaming the C++ files to .mm did not work).
Does anybody know how to solve this? Or is there a better way to get Arduino to directly interact with OSX events?
embedXcode allows the use of the Xcode IDE for embedded development, but this doesn't include the OS X SDK or the OS X build toolchain. You are still using the AVR toolchain, but with Xcode in front to manage the project. That being said, you are limited to avr-gcc and avr-g++, no Objective-C. It is possible to pass data between C++ and Objective-C classes, but not in the context to which you are referring.
EDIT: If you really want to use Objective-C and Arduino, I suggest researching avr-gcc and Objective-C. According to the avr-gcc man page, Objective-C is supported. Although, getting this work will require meandering away from the cozy Arduino workspace.
It seems like you are misunderstanding the Arduino, and the microcontroller <-> PC relationship. The Arduino (and any microcontroller) is a small standalone computer running its own tiny operating system. So your question in light of that is: how do I get one computer to talk to another computer.
The IDE (XCode, the Arduino environment, etc.) has nothing to do with this. Those are just tools for writing and compiling code, and uploading it to the Arduino processor.
To connect any two computers, you have two options: through wires or through radio waves. The wired option is the easiest to implement and understand. You have two options here, direct USB connection and Ethernet. USB is the easiest to implement and understand and the barebones Arduino is capable of this. Ethernet would require addition hardware.
The wireless options would include Bluetooth, WiFi, XBee radio. These work well but are complicated to implement and require additional hardware.
So... I'd suggest you start with USB. There are many tutorials out there. On the OSX side you will need to write some software to communicate with the Arduino. This could be an app written in ObjectiveC or Java (e.g. using Processing) or Python, or any number of other programming languages. I'd suggest Processing as there are many Arduino <-> Processing tutorials on the web.
Key search terms for finding tutorials: Arduino serial port Processing
I am looking to communicate via RFCOMM to another Bluetooth device. I want to use C++ (VS2008) for the application. I already know of the 32feet library, but was unsure if it would work for C++. Does anyone know of a good starting point for this kind of project? Or possibly 32feet samples written in C++? I want a simple, easy to use API for Bluetooth using C++.
This question is rather old, I know.
Just wanted to update, that Qt Framework has now Qt Bluetooth for C++ that looks very promising -- http://doc.qt.io/qt-5/qtbluetooth-module.html
You can do Bluetooth programming using BT sockets into the OS Bluetooth stack. This page discusses socket usage:
http://msdn.microsoft.com/en-us/library/windows/desktop/aa362928(v=vs.85).aspx
This page has links to download Bluetooth SDK from Microsoft:
http://msdn.microsoft.com/en-us/library/windows/desktop/aa363058(v=vs.85).aspx
Building apps using the Microsoft stack works fairly well (XP and Vista work great, trying to run the same apps under Windows 7-64bit does not work so well...)
The real advantage to 32feet.net is that the Bluetooth support on Windows is heavily Balkanized - you never know on a given machine whether it is using the Microsoft, Broadcom, Toshiba, BlueSolei, or some other stack. While these are all mostly compatible over-the-air, the APIs are completely different for each. Building with 32feet.net lets your application run on a larger subset of machines... That said, I have not tried building it into a C++ application - sorry.
Im looking for code that connects to another computer via remote desktop connection and checks if the connection was successful or not.
I packet logged and found out there was a galaxy worth of packets so i was wondering if there was some easy code out there.
There really isn't anything easy about RDP, that protocol stack is huge and builds on the ITU OSI protocols, which includes a fair amount of ASN.1/BER.
Your best bet is the code that's in FreeRDP.
A bit of terminology: you want a "RDP client library for C++".
As others have mentioned, look into the "FreeRDP" and "rdesktop" projects.
With FreeRDP, you're going to get a suite of libraries (each one doing it's thing). With rdesktop, you're going to get a client app (which you have to break the C code out of, and "build" your C++ api around).
If this is a new project, I'd pick FreeRDP over rdesktop, as they have libraries available with your C++ interface already in place.
Do you need to check if an RDP server is present, but not authenticate? In this case all you'd need are the first couple of packets used to negotiate protocol security. You can find the code in FreeRDP in libfreerdp-core/nego.c.
#Blanker1231 : You should have look on rdesktop code , its in c but can be very easily modified to be used in a C++ code , all you have to do is bridge their Struct Stream effectively .
moreover I have worked on a Rdp 7+ implementation ages ago in qt/c++ for a , so recently just for fun of it i used all of my experience and wrote a RDP parser and code generator and open sourced it on https://github.com/shashanksingh/Code-Generator-for-RDP
Right now it dead simple and i am still working on it more intelligent . Word of caution it doesn't generate everything . Examples includes demo.def which on compilation will generate all the class os ms-fscc used in ms-rdp
#Blanker1231 if you ever feel like , just fork the implementation and start pushing stuff in