[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [leshan-dev] 回复:Integration into Android(Leshan-client)
|
Hi
> But I think there's a problem with this step:
> NetworkConfig config = NetworkConfig.createStandardWithFile(inputstreamtofile(input,new File("Californium.properties")));
> NetworkConfig.setStandard(config);
Can you describe, what problem you think to have?
I'm not sure, why below a
java.io.FileNotFoundException: Californium.properties: open failed: EROFS (Read-only file system)
is thrown, but your "inputstreamtofile(input,new File("Californium.properties"))" is working (or is that the problem?).
(By the way:
"createStandardWithFile" already sets the standard, so you can remove the "NetworkConfig.setStandard(config)".)
My workaround was:
- Create a NetworkConfig with the compiled in default values
NetworkConfig config = new NetworkConfig();
- Load the "Californium.properties" via the Android Assets/InputStream into a standard java.util.Properties.
- Copy all properties from the loaded properties into the create NetworkConfig.
- Set that as standard NetworkConfig.setStandard(config); (here setStandard is required, because "new NetworkConfig"
itself is not related to the NetworkConfig.standard.)
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 (BFUD5J) ? ? ? ?
Sent: Mittwoch, 10. Mai 2017 03:31
To: leshan-dev <leshan-dev@xxxxxxxxxxx>
Subject: [leshan-dev] 回复:Integration into Android(Leshan-client)
Hello everybody!
I was in the process of integration to Android, made some changes.
1.I put the Californium.properties file in the assets directory.
When I was creating client, I read the configuration file from the assets directory and set it to NetworkConfig.
NetworkConfig.createStandardWithoutFile();
InputStream input = ObjectLoader.class.getResourceAsStream("/assets/Californium.properties");
if (input != null) {
NetworkConfig config = NetworkConfig.createStandardWithFile(inputstreamtofile(input,new File("Californium.properties")));
NetworkConfig.setStandard(config);
}
createAndStartClient(endpoint, localAddress, localPort, secureLocalAddress, secureLocalPort, false,
serverURI, pskIdentity, pskKey);
2.I also put the object file in the assets directory,and then load the JSON file from the assets directory to initialize LwM2mModel.
this.model = new LwM2mModel(ObjectLoader.loadDefault());
InputStream input = ObjectLoader.class.getResourceAsStream("/assets/oma-objects-spec.json");
if (input != null) {
try (Reader reader = new InputStreamReader(input)) {
models.addAll(loadJsonStream(input));
} catch (IOException e) {
LogUtils.d("Unable to load object models");
}
}
Finally, client successfully connected to the server.It finally worked.
But I think there's a problem with this step:
NetworkConfig config = NetworkConfig.createStandardWithFile(inputstreamtofile(input,new File("Californium.properties")));
NetworkConfig.setStandard(config);
Best regards
zmsoft
------------------ 原始邮件 ------------------
发件人: "迦南";<mailto:1084615055@xxxxxx>;
发送时间: 2017年5月5日(星期五) 下午4:04
收件人: "leshan-dev"<mailto:leshan-dev@xxxxxxxxxxx>;
主题: 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?