-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.py
More file actions
43 lines (37 loc) · 1013 Bytes
/
Copy pathmain.py
File metadata and controls
43 lines (37 loc) · 1013 Bytes
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
from pybleno import *
import sys
import signal
from EchoCharacteristic import *
print('bleno - echo');
def StateOn(bleno):
bleno.on('stateChange', onStateChange)
bleno.on('advertisingStart', onAdvertisingStart)
bleno.start()
print ('Hit <ENTER> to disconnect')
def SatateOff(bleno):
bleno.stopAdvertising()
bleno.disconnect()
def onStateChange(state):
print('on -> stateChange: ' + state);
if (state == 'poweredOn'):
bleno.startAdvertising('Wallet', ['ec00'])
else:
bleno.stopAdvertising();
def onAdvertisingStart(error):
print('on -> advertisingStart: ' + ('error ' + error if error else 'success'));
if not error:
bleno.setServices([
BlenoPrimaryService({
'uuid': 'ec00',
'characteristics': [
EchoCharacteristic('ec0F')
]
})
])
bleno = Bleno()
StateOn(bleno)
if (sys.version_info > (3, 0)):
input()
else:
raw_input()
SatateOff(bleno)