-
Notifications
You must be signed in to change notification settings - Fork 7
/
IAQ_SIGFOX_config.py
98 lines (81 loc) · 3.5 KB
/
IAQ_SIGFOX_config.py
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
import lib.pm_g3 as pm_sensor
import lib.th_htu21d as tmp_sensor
import lib.light_tcs34725 as light_sensor
#import gas_tvoc_sgp30 as gas_sensor
import lib.gas_co2_s8 as gas_sensor
import pyupm_i2clcd as upmLCD
Version = "5.2b.1"
Sense_PM = 1
Sense_Tmp = 1
Sense_Light = 1
Sense_Gas = 1
Use_RTC_DS3231 = 1
GPS_LAT = 25.1933
GPS_LON = 121.7870
APP_ID = "IAQ_SIGFOX"
DEVICE = "LinkIt_Smart_7688"
DEVICE_ID = "DEVICE_ID1234"
DEVICE_IP = ''
Interval_LCD = 5
Restful_URL = "http://pm25.lass-net.org/Upload/SigFox.php"
Restful_interval = 60 # 60 seconds
SecureKey = "NoKey"
FS_SD = "/mnt/mmcblk0p1"
#################################
# don't make any changes in the following codes
import uuid
import re
import os
from multiprocessing import Queue
float_re_pattern = re.compile("^-?\d+\.\d+$")
num_re_pattern = re.compile("^-?\d+\.\d+$|^-?\d+$")
mac = open('/sys/class/net/eth0/address').readline().upper().strip()
DEVICE_ID = mac.replace(':','')
f = os.popen('ifconfig eth0 | grep "inet\ addr" | cut -d: -f2 | cut -d" " -f1')
DEVICE_IP=f.read()
if(DEVICE_IP == ''):
f = os.popen('ifconfig apcli0 | grep "inet\ addr" | cut -d: -f2 | cut -d" " -f1')
DEVICE_IP=f.read()
if Use_RTC_DS3231 == 1:
import mraa
import hmac
import hashlib
import base64
import urllib
DS3231_I2C_ADDR = 0x68
rtc = mraa.I2c(0)
rtc.address(DS3231_I2C_ADDR)
SecureKey = chr(rtc.readReg(0x07)) + chr(rtc.readReg(0x08)) + chr(rtc.readReg(0x09)) + chr(rtc.readReg(0x0A)) + chr(rtc.readReg(0x0B)) + chr(rtc.readReg(0x0C)) + chr(rtc.readReg(0x0D))
SecureKey = urllib.quote_plus(SecureKey)
print "SecureKey = " , SecureKey
pm_q = Queue(maxsize=5)
tmp_q = Queue(maxsize=5)
light_q = Queue(maxsize=5)
gas_q = Queue(maxsize=5)
tvoc_q = Queue(maxsize=5)
fields ={ "Tmp" : "s_t0",
"RH" : "s_h0",
"PM1.0" : "s_d2",
"PM2.5" : "s_d0",
"PM10" : "s_d1",
"Lux" : "s_l0",
"RGB_R" : "s_lr",
"RGB_G" : "s_lg",
"RGB_B" : "s_lb",
"RGB_C" : "s_lc",
"CO2" : "s_g8",
"TVOC" : "s_gg",
}
values = { "app" : APP_ID,
"device_id" : DEVICE_ID,
"device" : DEVICE,
"ver_format" : 3,
"fmt_opt" : 0,
"gps_lat" : GPS_LAT,
"gps_lon" : GPS_LON,
"FAKE_GPS" : 1,
"gps_fix" : 1,
"gps_num" : 100,
"date" : "1900-01-01",
"time" : "00:00:00",
}