Task #2509
closed
Task #1989: Basic NFD control app for Android
Implement jni equivalent of daemon/main.cpp to start NFD/NRD
Added by Alex Afanasyev almost 10 years ago.
Updated over 9 years ago.
Description
Few things that needs to be resolved as part of this commit:
- what configuration parameters should be configurable inside NFD control app
- how these customization parameters are represented on Java side
- how they are passed to JNI function
Related issues
1 (1 open — 0 closed)
Ivan, do you have suggestion on second item in the list?
- Status changed from In Progress to Code review
- % Done changed from 0 to 60
Hey Alex,
Just off the top of my head, 2 possibilities came to mind:
Asset File
One way is to have the configurations in a file present in the asset/ directory of the Android project. This way, the app can read in the data from the file and pass it as a string argument when starting the NFD.
Asset Directory
The other way is for the NFD to read directly from the configuration file in the asset/ directory.
Cheers,
Ivan
No, this shouldn't be "configuration file". The only thing I want to do is to pass some in-memory structure from java to c++. What exactly this memory structure is depends on what settings we actually want to configure and how exactly this information is stored on java side (can it be List<> of some kind?)
On Java's side there shouldn't be too much of an issue. I'm thinking that List<>, Map<> and the likes will all work. We can even have custom classes that are made Serializable or Parcelable for storage or passing around between Activities, etc. However, the passing to C++ can be tricky depending on your requirements. I usually do it as simple strings with fixed delimiters and parse it at the native layer.
If this does not meet your requirement, there are other methods that I know of, like mapping of a class in Java with that of a C struct. However, this is very mechanical and there are some tools to assist us in speeding up this process, such as: https://code.google.com/p/jnaerator/
- Status changed from Code review to In Progress
- % Done changed from 60 to 90
- Parent task set to #1989
- Target version set to 0.1
- Related to Feature #2746: Allow configuration of NFD parameters added
- Status changed from In Progress to Closed
- % Done changed from 90 to 100
Also available in: Atom
PDF