-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathIoTTalkV2SA.cs
74 lines (58 loc) · 2.07 KB
/
IoTTalkV2SA.cs
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using UnityEngine.Networking;
using UnityEngine;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
public class IoTTalkV2SA : MonoBehaviour {
public string api_url = "https://iottalk2.tw/csm";
public string device_name = "DummyTest";
public string device_model = "Dummy_Device";
public int push_interval = 1000; // millisecond
public string extra_setup_webpage = "";
public string device_webpage = "";
public string username = null;
public string id = null;
public List<string> idf_list;
public List<string> odf_list;
public Dictionary<string, int> interval;
public Dictionary<string, System.Object> df;
public delegate object DeviceFeatureFunc(params object[] args);
private List<Vector3> position;
System.Random r = new System.Random();
void Awake(){
// init
df = new Dictionary<string, System.Object>();
idf_list = new List<string>();
odf_list = new List<string>();
interval = new Dictionary<string, int>();
// IDF push interval
interval.Add("Dummy_Sensor", 1000);
//---------------------------------------
// device feature function
//---------------------------------------
df.Add("DummySensor-I", ConvertFunctionToObject(this.Dummy_Sensor));
df.Add("DummyControl-O", ConvertFunctionToObject(this.Dummy_Control));
// idf name list
idf_list.Add("DummySensor-I");
// odf name list
odf_list.Add("DummyControl-O");
}
void Update(){
}
public System.Object ConvertFunctionToObject(DeviceFeatureFunc f){
return (System.Object)f;
}
public void on_register(){
Debug.Log("register successfully");
}
public object Dummy_Sensor(params object[] args){
return r.NextDouble()*10;
}
public object Dummy_Control(params object[] args){
Debug.Log(args[0]);
return null;
}
}