-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpython.html
More file actions
199 lines (171 loc) · 8.08 KB
/
python.html
File metadata and controls
199 lines (171 loc) · 8.08 KB
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
<html xmlns="http://www.w3.org/1999/html">
<title>Mysensors.info | Python</title>
<head>
<link rel="icon" href="http://www.mysensors.info/img/logo.png">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<script type="text/javascript" src="http://netdna.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
<link href="http://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.3.0/css/font-awesome.min.css" rel="stylesheet" type="text/css">
<link href="http://pingendo.github.io/pingendo-bootstrap/themes/default/bootstrap.css" rel="stylesheet" type="text/css">
</head><body>
<div class="section">
<div class="container">
<div class="row">
<div class="col-md-4 text-justify" style="background-color: #337AFB; border: 4px solid #000000;">
<br>
<img src="http://www.mysensors.info/img/logo.png" class="img-responsive img-thumbnail">
<h4>Connect, right now with #sensors you care about.</h4>
<br>
</div>
<div class="col-md-8 text-justify">
<br>
<ul class="lead nav nav-pills">
<li>
<a href="index.html">Home</a>
</li>
<li >
<a href="senz.html">SenZ</a>
</li>
<li>
<a href="android.html">Android</a>
</li>
<li class="active">
<a href="#">Python</a>
</li>
<li>
<a href="downloads.html">Downloads</a>
</li>
<li>
<a href="contact.html">Contact</a>
</li>
</ul>
<br>
<h4>MySensor switch provides security and privacy in IoT applications. With
help of MySensors, IoT devices can communicate each other with guaranteeing
end to end security. MySensor supports IoT devices such as Smartphones(android)
and Raspberry-pi.</h4>
</div>
</div>
</div>
</div>
<div class="section" id="top">
<div class="container">
<div class="row">
<p class="col-md-12">
<h1>Python Client</h1>
<br>
<p>
Now senz service is available on Python also. Developers could use this to integrate it into their apps or
simply build apps on it</p>
<br>
<p align="justify">You should read this if you are going to build your app on the python client platform.</p>
<img src="img/network.png" class="img-responsive img-thumbnail" height="40%" width="40%">
<br>
<br>
<p align="justify">In the python client Code (senz-client) , all you need is to take in to granted
the senzHandler class. Where receiving senz massages are read here and the appropriate actions are handled.
So what you have to do is you will have to write your code here to combine your app to this senz. Sometimes
if you are using a different type of language and still you can write code here and connect your app
accordingly.</p>
<p>If You observe the Directory structure of the source code you will find it like this</p>
<center><img src="img/dir.png" class="img-responsive img-thumbnail"></center>
<br>
<br>
<h3>Running the basic python client application.</h3>
<br>
<p align="justify">Once you have downloaded the application, the first thing you have to do is thatssave it in to a desired directory. Then open the command line or a text editor like gedit and edit the following file.
<code>Config.cfg</code> located in the project directory itself. There you will have to enter the switch details</p>
<pre><code>
#udp mysensors info
[connections]
host=localhost
port=9090
state=INITIAL
senzy=test
server=mysensors
[client]
name=phonesenZ
[server]
port=9090
host=server_ip_here
name=mysensors</code></pre>
<p>First you will have to enter the client name which is important to create keys used in communication in the [Client] section</p>
<br>
<pre><code>
[client]
name=name_of_your_client</code></pre>
<br>
<p>So here You will have to define the servers ip address in the [server] section</p>
<pre><code>
[server]
port=9090
host=ip_of_the_server></code></pre>
<br>
<p align="justify">You are about to run the client now.</p>
<p align="justify">To run the client You have to be in the projects directory. For example you will have to be in the senz-client directory.</p>
<code>$ cd Desktop/senz-client</code>
<p align="justify">Then in the command line you will have to run</p>
<code>$ python senzc/client.py</code>
<p>Now your client is up and running.</p>
<h3>Using python client on your application</h3>
<p>Running just the client doesn't make you anything. So you have to use it in your app. For that you have do some
simple things. As we discussed earlier the directory structure of source is as below.There in the handlers
directory you will find the codes that needs to be edited in order to plug the client in to your application.</p>
<img src="img/handler.png" class="img-responsive img-thumbnail">
<br>
<p align="justify">In the senz-handler file you will find the senzHandler class. This the place where you would
have to code what happens when a senz is received. Here you can set how the incoming data to be handled,
how the reply is to be sent and so on. In case if you want to handle your reply massages you can define
them also in another separate file in a directory also.</p>
<img src="img/handleSenz.png" class="img-responsive img-thumbnail">
<br>
<p align="justify">Then you will also have to define what happens after massage is done or after handling the
senze. This is wheter you need to close the connection , print something on commandline or a call back ,
log etc.</p>
<img src="img/postHandle.png" class="img-responsive img-thumbnail">
<br>
<p align="justify">If you were successful doing these
You are now up with a working client.</p>
<br>
<br>
<footer class="section section-primary" id="bootom">
<div class="container">
<div class="row">
<div class="col-sm-6 col-md-8">
<h1>Sustianable Computing Research Laboratory </h1>
<p>35,Reid Avenue, Colombo 7, Sri Lanka
<br>Phone : +94112581124</p>
</div>
<div class="col-sm-6 col-md-4">
<p class="text-info text-right">
<br>
<br>
</p>
<div class="row">
<div class="col-md-10 hidden-lg hidden-md hidden-sm text-left">
<a href="#"><i class="fa fa-3x fa-fw fa-instagram text-inverse"></i></a>
<a href="#"><i class="fa fa-3x fa-fw fa-twitter text-inverse"></i></a>
<a href="#"><i class="fa fa-3x fa-fw fa-facebook text-inverse"></i></a>
<a href="#"><i class="fa fa-3x fa-fw fa-github text-inverse"></i></a>
</div>
</div>
<div class="row">
<div class="col-md-10 hidden-xs text-right">
<a href="#"><i class="fa fa-3x fa-fw fa-instagram text-inverse"></i></a>
<a href="#"><i class="fa fa-3x fa-fw fa-twitter text-inverse"></i></a>
<a href="#"><i class="fa fa-3x fa-fw fa-facebook text-inverse"></i></a>
<a href="#"><i class="fa fa-3x fa-fw fa-github text-inverse"></i></a>
</div>
</div>
</div>
</div>
</div>
</footer>
<font face="Times New Roman, serif">
<font face="Times New Roman, serif"></font>
</font>
</div>
</div>
</div>
</body></html>