Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [leshan-dev] Integration into Android(Leshan-client)

Hi,

For californium you may have a look at PR #302 there.
For the leshan client demo, exchange in LeshanClientDemo. createAndStartClient the initialization of the model:

        // Initialize model
        List<ObjectModel> models = ObjectLoader.loadDefault();
        models.addAll(ObjectLoader.loadDdfResources("/models", modelPaths));

with ObjectModels loaded from the android AssetManager using ObjectLoader methods with InputStream.
Add the read ObjectModel to your own list.

Therefore also move all standard DDF (see ObjectLoader) to the android assets.

Mit freundlichen Grüßen / Best regards 

Achim Kraus

(INST/ECS4) 
Bosch Software Innovations GmbH | Stuttgarter Straße 130 | 71332 Waiblingen | GERMANY | http://www.bosch-si.com 

Sitz: Berlin, Registergericht: Amtsgericht Charlottenburg; HRB 148411 B
Geschäftsführung: Dr.-Ing. Rainer Kallenbach, Michael Hahn



From: leshan-dev-bounces@xxxxxxxxxxx [mailto:leshan-dev-bounces@xxxxxxxxxxx] On Behalf Of Kraus Achim (INST/ECS4)
Sent: Freitag, 5. Mai 2017 11:07
To: leshan developer discussions <leshan-dev@xxxxxxxxxxx>
Subject: Re: [leshan-dev] Integration into Android(Leshan-client)

Hi,

I tried to use leshan on android some time ago.

There are some "environment assumptions" which are not valid for android.
Therefore I changed/patched it to use the AssetManager:

1. Californium.properties
Before using californium, read Properties from InputStream (AssetManager).
Copy read property entries into a NetworkConfig.
Set NetworkConfig as standard. (NetworkConfig.setStandard(config);)
No patch in californium itself is required, just that workaround.
(May be we change NetworkConfig to be read from InputStream)
2. LwM2mModel must be also moved to AssetManager
I add reads from InputStream and then used that model.
But I'm not sure, if this requires a leshan patch.


Mit freundlichen Grüßen / Best regards 

Achim Kraus

(INST/ECS4) 
Bosch Software Innovations GmbH | Stuttgarter Straße 130 | 71332 Waiblingen | GERMANY | http://www.bosch-si.com 

Sitz: Berlin, Registergericht: Amtsgericht Charlottenburg; HRB 148411 B
Geschäftsführung: Dr.-Ing. Rainer Kallenbach, Michael Hahn


From: mailto:leshan-dev-bounces@xxxxxxxxxxx [mailto:leshan-dev-bounces@xxxxxxxxxxx] On Behalf Of (BFUD5J) ? ? ? ?
Sent: Freitag, 5. Mai 2017 10:04
To: leshan-dev <mailto:leshan-dev@xxxxxxxxxxx>
Subject: [leshan-dev] Integration into Android(Leshan-client)

Hello everybody!


Storing standard properties in file Californium.properties
Is this step necessary?
When I was running at Android studio, I found that this file could not be created.

Here is the log from logcat
05-05 15:11:31.280 D/mwqi: Loading OMA standard object models
05-05 15:11:31.397 D/mwqi: min.zhu objectId=0
05-05 15:11:31.398 D/mwqi: min.zhu objectId=1
05-05 15:11:31.398 D/mwqi: min.zhu objectId=3
05-05 15:11:31.398 D/mwqi: min.zhu objectId=5
05-05 15:11:31.398 D/mwqi: min.zhu objectId=6
05-05 15:11:31.400 D/mwqi: min.zhu leshanClientBuilder localAddress=/0.0.0.0:0
05-05 15:11:31.401 D/mwqi: min.zhu leshanClientBuilder localSecureAddress=/0.0.0.0:0
05-05 15:11:31.401 D/mwqi: min.zhu leshanClient endpoint=min.zhuand localAddress=/0.0.0.0:0and localSecureAddress=/0.0.0.0:0
05-05 15:11:31.401 D/mwqi: min.zhu leshanClient Create CoAP non secure endpoint localAddress=/0.0.0.0:0
05-05 15:11:31.404 I/NetworkConfig: Storing standard properties in file Californium.properties
05-05 15:11:31.407 W/NetworkConfig: Error while storing properties to /Californium.properties
java.io.FileNotFoundException: Californium.properties: open failed: EROFS (Read-only file system)
at libcore.io.IoBridge.open(IoBridge.java:456)
at java.io.FileOutputStream.(FileOutputStream.java:87)
at java.io.FileOutputStream.(FileOutputStream.java:72)
at java.io.FileWriter.(FileWriter.java:42)
at org.eclipse.californium.core.network.config.NetworkConfig.store(NetworkConfig.java:218)
at org.eclipse.californium.core.network.config.NetworkConfig.store(NetworkConfig.java:205)
at org.eclipse.californium.core.network.config.NetworkConfig.createStandardWithFile(NetworkConfig.java:170)
at org.eclipse.californium.core.network.config.NetworkConfig.getStandard(NetworkConfig.java:125)
at org.eclipse.californium.core.network.CoapEndpoint.(CoapEndpoint.java:166)
at org.eclipse.leshan.client.californium.LeshanClient.(LeshanClient.java:87)
at org.eclipse.leshan.client.californium.LeshanClientBuilder.build(LeshanClientBuilder.java:120)
        at android.view.View.performClick(View.java:4780)
        at android.view.View$PerformClick.run(View.java:19866)
        at android.os.Handler.handleCallback(Handler.java:739)
        at android.os.Handler.dispatchMessage(Handler.java:95)
        at android.os.Looper.loop(Looper.java:135)
        at android.app.ActivityThread.main(ActivityThread.java:5254)
        at java.lang.reflect.Method.invoke(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:372)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
Caused by: android.system.ErrnoException: open failed: EROFS (Read-only file system)
at libcore.io.Posix.open(Native Method)
at libcore.io.BlockGuardOs.open(BlockGuardOs.java:186)
at libcore.io.IoBridge.open(IoBridge.java:442)
at java.io.FileOutputStream.(FileOutputStream.java:87) 
at java.io.FileOutputStream.(FileOutputStream.java:72) 
at java.io.FileWriter.(FileWriter.java:42) 
at org.eclipse.californium.core.network.config.NetworkConfig.store(NetworkConfig.java:218) 
at org.eclipse.californium.core.network.config.NetworkConfig.store(NetworkConfig.java:205) 
at org.eclipse.californium.core.network.config.NetworkConfig.createStandardWithFile(NetworkConfig.java:170) 
at org.eclipse.californium.core.network.config.NetworkConfig.getStandard(NetworkConfig.java:125) 
at org.eclipse.californium.core.network.CoapEndpoint.(CoapEndpoint.java:166) 
at org.eclipse.leshan.client.californium.LeshanClient.(LeshanClient.java:87) 
at org.eclipse.leshan.client.californium.LeshanClientBuilder.build(LeshanClientBuilder.java:120) 
        at android.view.View.performClick(View.java:4780) 
        at android.view.View$PerformClick.run(View.java:19866) 
        at android.os.Handler.handleCallback(Handler.java:739) 
        at android.os.Handler.dispatchMessage(Handler.java:95) 
        at android.os.Looper.loop(Looper.java:135) 
        at android.app.ActivityThread.main(ActivityThread.java:5254) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at java.lang.reflect.Method.invoke(Method.java:372) 
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698) 
05-05 15:11:31.447 D/mwqi: Starting Leshan client ...
05-05 15:11:31.448 I/CoapServer: Starting server
05-05 15:11:31.448 I/CoapEndpoint: Starting endpoint at /0.0.0.0:0
05-05 15:11:31.459 I/DTLSConnector: DTLS connector listening on [{0}] with MTU [{1}] using (inbound) datagram buffer size [{2} bytes]
05-05 15:11:31.464 I/CoapEndpoint: Starting endpoint at /0.0.0.0:0
05-05 15:11:31.475 D/mwqi: Leshan client started.
Although the client has started.But did not successfully connect to the server.
Connected clients: 0
Is it because this property file does not create the cause of success?



Back to the top