-
Notifications
You must be signed in to change notification settings - Fork 5
/
af_msg_types.h
83 lines (67 loc) · 3.27 KB
/
af_msg_types.h
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
/**
* Copyright 2018 Afero, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef AF_MSG_TYPE_H
#define AF_MSG_TYPE_H
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef uint8_t msg_type_t;
#define SYNC_REQUEST 0x30
#define SYNC_ACK 0x31
#define MSG_TYPE_UNKNOWN 0
#define MSG_TYPE_ERROR 1
// Messaging channel messages
#define MESSAGE_CHANNEL_BASE 11
#define MSG_TYPE_SET (MESSAGE_CHANNEL_BASE + 0)
#define MSG_TYPE_GET (MESSAGE_CHANNEL_BASE + 1)
#define MSG_TYPE_UPDATE (MESSAGE_CHANNEL_BASE + 2)
// Only between device and MCU
#define DEVICE_MCU_BASE 41
#define MSG_TYPE_UPDATE_REJECTED (DEVICE_MCU_BASE + 0)
#define MSG_TYPE_SET_DEFAULT (DEVICE_MCU_BASE + 1)
#define MSG_TYPE_LAST_VALID_DEVICE_MCU MSG_TYPE_SET_DEFAULT
// We changed the value in protocol v2 but still need to handle talking to pre-v2 ASRs
#define MSG_TYPE_UPDATE_REJECTED_V1 14
// Success states
#define UPDATE_STATE_UPDATED 0
// Failure states
#define UPDATE_STATE_INTERRUPTED 1
#define UPDATE_STATE_UNKNOWN_UUID 2
#define UPDATE_STATE_LENGTH_EXCEEDED 3
#define UPDATE_STATE_CONFLICT 4
#define UPDATE_STATE_FAILED 5
#define UPDATE_STATE_FORBIDDEN 6
#define UPDATE_REASON_UNKNOWN 0x00
#define UPDATE_REASON_LOCAL_OR_MCU_UPDATE 0x01 // local or unsolicited UPDATE from MCU
#define UPDATE_REASON_SERVICE_SET 0x02 // response to Service SET
#define UPDATE_REASON_MCU_SET 0x03 // response to MCU SET
#define UPDATE_REASON_RELINK 0x04
#define UPDATE_REASON_BIND_FOLLOW 0x05 // a bound attribute was changed
#define UPDATE_REASON_FAKE_UPDATE 0x06 // fake update launched
#define UPDATE_REASON_NOTIFY_MCU_WE_REBOOTED 0x07 // notify MCU we rebooted. Never goes to Service
#define UPDATE_REASON_LOCAL_SET 0x08 // response to Local SET
#define UPDATE_REASON_REBOOTED 0x09
#define UPDATE_REASON_CRC_FAIL 0x0A // CRC failure
#define UPDATE_REASON_GET_RESPONSE 0x0B // response to GET
#define UPDATE_REASON_LAST_VALID UPDATE_REASON_GET_RESPONSE // always last
#define UPDATE_REASON_INTERNAL_SET_REJECTED 0xfd // Set failed and we should revert to the current value
#define UPDATE_REASON_INTERNAL_SET_FAIL 0xfe // Set failed
#define UPDATE_REASON_INTERNAL_NO_CHANGE 0xff // do not change current value (not to be sent to Service)
#ifdef __cplusplus
} /* end of extern "C" */
#endif
#endif /* AF_MSG_TYPE_H */