summaryrefslogtreecommitdiff
path: root/system/include/hardware/bt_csis.h
blob: e9240972cded37117d8936df34d980c5f29fed29 (plain)
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
/*
 * Copyright 2021 HIMSA II K/S - www.himsa.com.
 * Represented by EHIMA - www.ehima.com
 *
 * 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.
 */

#pragma once

#include <hardware/bluetooth.h>

#include <array>
#include <optional>
#include <vector>

typedef std::array<uint8_t, 16> Octet16;

namespace bluetooth {
namespace csis {

/** Connection State */
enum class ConnectionState : uint8_t {
  DISCONNECTED = 0,
  CONNECTING,
  CONNECTED,
  DISCONNECTING,
};

enum class CsisGroupLockStatus {
  SUCCESS = 0,
  FAILED_INVALID_GROUP,
  FAILED_GROUP_EMPTY,
  FAILED_GROUP_NOT_CONNECTED,
  FAILED_LOCKED_BY_OTHER,
  FAILED_OTHER_REASON,
  LOCKED_GROUP_MEMBER_LOST,
};

static constexpr uint8_t CSIS_RANK_INVALID = 0x00;

class CsisClientCallbacks {
 public:
  virtual ~CsisClientCallbacks() = default;

  /** Callback for profile connection state change */
  virtual void OnConnectionState(const RawAddress& addr,
                                 ConnectionState state) = 0;

  /** Callback for the new available device */
  virtual void OnDeviceAvailable(const RawAddress& addr, int group_id,
                                 int group_size, int rank,
                                 const bluetooth::Uuid& uuid) = 0;

  /* Callback for available set member*/
  virtual void OnSetMemberAvailable(const RawAddress& address,
                                    int group_id) = 0;

  /* Callback for lock changed in the group */
  virtual void OnGroupLockChanged(int group_id, bool locked,
                                  CsisGroupLockStatus status) = 0;
};

class CsisClientInterface {
 public:
  virtual ~CsisClientInterface() = default;

  /** Register the Csis Client profile callbacks */
  virtual void Init(CsisClientCallbacks* callbacks) = 0;

  /** Connect to Csis Client */
  virtual void Connect(const RawAddress& addr) = 0;

  /** Disconnect from Csis Client */
  virtual void Disconnect(const RawAddress& addr) = 0;

  /** Lock/Unlock Csis group */
  virtual void LockGroup(int group_id, bool lock) = 0;

  /* Called when unbonded. */
  virtual void RemoveDevice(const RawAddress& address) = 0;

  /** Closes the interface */
  virtual void Cleanup(void) = 0;
};

} /* namespace csis */
} /* namespace bluetooth */