-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathrss_client_messages.py
113 lines (107 loc) · 5.25 KB
/
rss_client_messages.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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
import datetime
import raspidata
import json
import rss_cli_config as ccfg
#
# All client messages are handled in here.
#
# Message Formats
# ---------------
# 1 - Timestamp
# 2 - Device ID
# 3 - Message Type
#
# Client message types
# --------------------
# 0001 CHB - Client Heart Bit (Client is alive)
# 0002 CHM - Client Hello Message (Client is online)
# 0003 CZM - Client Zap Message (Client is shut down)
# 0004 ADM - Acceleration Data Message (Acceleration data)
# 0005 CCA - Client Config Affirm
# ... (other to come)
#
# Data message Format for all Client Message Types
# ------------------------------------------------
#
# # 0001 - CHB - Client Heart Bit
# +--------------+-------+--------------------------------------------------------+
# | Field |Length | Description |
# +--------------+-------+--------------------------------------------------------+
# | Datetime | 16 | 'HH/MM/DD hh:mi:ss.uuuuuu' |
# | Device ID | 16 | 16 byte device ID |
# | 0001 | Var | Literally 'CHB' |
# # +-------------------------------------------------------------------------------+
#
# 0002 CHM - Client Hello Message
# +--------------+-------+--------------------------------------------------------+
# | Field |Length | Description |
# +--------------+-------+--------------------------------------------------------+
# | Datetime | 16 | 'HH/MM/DD hh:mi:ss.uuuuuu' |
# | Device ID | 16 | 16 byte device ID |
# | 0002 | Var | Literally 'CHM' |
# +--------------+-------+--------------------------------------------------------+
#
# 0003 CZM - Client Zap Message (Client is shut down)
# +--------------+-------+--------------------------------------------------------+
# | Field |Length | Description |
# +--------------+-------+--------------------------------------------------------+
# | Datetime | 16 | 'HH/MM/DD hh:mi:ss.uuuuuu' |
# | Device ID | 16 | 16 byte device ID |
# | 0003 | Var | Literally 'CZM' |
# +--------------+-------+--------------------------------------------------------+
#
# 0004 ADM - Acceleration Data Message (Acceleration data)
# +--------------+-------+--------------------------------------------------------+
# | Field |Length | Description |
# +--------------+-------+--------------------------------------------------------+
# | Datetime | 16 | 'HH/MM/DD hh:mi:ss.uuuuuu' |
# | Device ID | 16 | 16 byte device ID |
# | 0004 | Var | Literally 'ADM' |
# | Accel Data | Var | Array containing acceleration data (X,Y,Z.O) |
# +--------------+-------+--------------------------------------------------------+
#
# 0005 CCA - Client Configuration Affirm
# +--------------+-------+--------------------------------------------------------+
# | Field |Length | Description |
# +--------------+-------+--------------------------------------------------------+
# | Datetime | 16 | 'HH/MM/DD hh:mi:ss.uuuuuu' |
# | Device ID | 16 | 16 byte device ID |
# | 0004 | Var | Literally 'CCA' |
# | Config Data | Var | Array containing client configuration |
# +--------------+-------+--------------------------------------------------------+
###########################################################################
# WARNIG ! THIS FILE IS NOT CURRENTLY USED !
# Its presence it is for debugging/testing only
# Althought, it will be used in some future version
###########################################################################
#def heart_bit():
# """Client Heart Bit"""
# msg = {'cmd': 'CHB', 'timestamp': str(datetime.datetime.now()), 'clid': raspidata.get_serial()}
# return msg
#
#
#def hello_message():
# """Client Hello Message"""
# msg = {'cmd': 'CHM', 'timestamp': str(datetime.datetime.now()), 'clid': raspidata.get_serial()}
# return msg
#
#
#def zap_message():
# """Client Zap Message"""
# msg = {'cmd': 'CZM', 'timestamp': str(datetime.datetime.now()), 'clid': raspidata.get_serial()}
# return msg
#
#
#def accel_data_message(data):
# """Acceleration Data Message"""
# msg = {'cmd': 'ADM', 'timestamp': str(datetime.datetime.now()), 'clid': raspidata.get_serial(), 'acceldata': str(data)}
# return msg
#
#
#def config_affirm_message(data): #def config_affirm_message(data):
# """Client Configuration Affirm"""
# ###
# pkt_hdr = {'cmd': 'CCA', 'timestamp': str(datetime.datetime.now()), 'clid': raspidata.get_serial(), 'data' : data}
#
# msg = dict(city = ccfg.cityname, latitude = ccfg.latitude, longitude = ccfg.longitude, config = data)
# return msg