herald  2.0.0
ble_protocols.h
1 // Copyright 2021 Herald Project Contributors
2 // SPDX-License-Identifier: Apache-2.0
3 //
4 
5 #ifndef HERALD_BLE_PROTOCOLS_H
6 #define HERALD_BLE_PROTOCOLS_H
7 
8 #include "../datatype/target_identifier.h"
9 #include "../engine/activities.h"
10 
11 namespace herald {
12 namespace ble {
13 
14 using namespace herald::datatype;
15 using namespace herald::engine;
16 
17 // using HeraldConnectionCallback = std::function<void(const TargetIdentifier& toTarget, bool connNowOpen)>;
18 
23 public:
24  HeraldProtocolV1Provider() = default;
25  virtual ~HeraldProtocolV1Provider() = default;
26 
27  // FOR STD::ASYNC platforms:-
28 
29  // /** Opens a new connection. Returns true if successful or already connected */
30  // virtual void openConnection(const TargetIdentifier& toTarget, const HeraldConnectionCallback& connCallback) = 0;
31  // /** Closes a connection. Returns true if successful or already disconnected */
32  // virtual void closeConnection(const TargetIdentifier& toTarget, const HeraldConnectionCallback& connCallback) = 0;
33 
34  // virtual void serviceDiscovery(Activity, CompletionCallback) = 0;
35  // virtual void readPayload(Activity, CompletionCallback) = 0;
36  // virtual void immediateSend(Activity, CompletionCallback) = 0;
37  // virtual void immediateSendAll(Activity, CompletionCallback) = 0;
38 
39  // FOR OTHER PLATFORMS:-
40 
42  virtual bool openConnection(const TargetIdentifier& toTarget) = 0;
44  virtual bool closeConnection(const TargetIdentifier& toTarget) = 0;
45 
47  virtual void restartScanningAndAdvertising() = 0;
48 
49  virtual std::optional<Activity> serviceDiscovery(Activity) = 0;
50  virtual std::optional<Activity> readPayload(Activity) = 0;
51  // virtual std::optional<Activity> immediateSend(Activity) = 0;
52  // virtual std::optional<Activity> immediateSendAll(Activity) = 0;
53 };
54 
55 }
56 }
57 
58 #endif
Definition: ble_protocols.h:22
virtual bool closeConnection(const TargetIdentifier &toTarget)=0
virtual void restartScanningAndAdvertising()=0
virtual bool openConnection(const TargetIdentifier &toTarget)=0
Definition: target_identifier.h:17
Contains all low-level Herald datatype implementations.
Definition: base64_string.h:14
Engine classes provide for task scheduling, including complex inter-dependent tasks.
Definition: activities.h:18
Acts as a non-global memory arena for arbitrary classes.
Definition: aggregates.h:15
An activity that needs to be performed due to some state being achieved in a Sensor.
Definition: activities.h:75