OM2M MOOC playground

Zwifi
909 views

Open Source Your Knowledge, Become a Contributor

Technology knowledge has to be shared and made accessible for free. Join the movement.

Create Content

OM2M demonstator

Test OM2M client integration
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package fr.laas.om2m.mooc.semantics;
import java.io.File;
import java.io.IOException;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import fr.laas.om2m.client.ClientFactory;
import fr.laas.om2m.client.OM2MClient;
import fr.laas.om2m.mooc.semantics.configuration.Configuration;
public class Controler {
private static Logger LOGGER = LogManager.getLogger(Controler.class);
private Configuration config;
private OM2MClient om2mIn;
private OM2MClient om2mMn;
public Controler(String configPath){
ObjectMapper mapper = new ObjectMapper();
try {
this.config = mapper.readValue(new File(configPath), Configuration.class);
this.om2mIn = ClientFactory.createClient(new File("om2m-in.json"));
this.om2mMn = ClientFactory.createClient(new File("om2m-mn.json"));
} catch (JsonParseException e) {
e.printStackTrace();
} catch (JsonMappingException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
public Configuration getConfig(){
return this.config;
}
public OM2MClient getClient(String name){
if(name.equals("in")){
return this.om2mIn;
} else if (name.equals("mn-1")){
return this.om2mMn;
} else {
LOGGER.error("Unknown OM2M client");
return null;
}
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Open Source Your Knowledge: become a Contributor and help others learn. Create New Content