4S Device Communication Module Collection  Version 0.6-SNAPSHOT
Full documentation of the modules in the 4SDC collection (aimed at 4SDC module developers)
personalhealthdevice.h
Go to the documentation of this file.
1 /*
2  * Copyright 2014-2015 The 4S Foundation (www.4s-online.dk)
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
48 // TODO: Revisit all the documentation
49 #ifndef PERSONALHEALTHDEVICE_H
50 #define PERSONALHEALTHDEVICE_H
51 
52 #include "FSYS/basemsg.h"
53 #include "FSYS/handle.h"
54 
55 #include <cstdint>
56 #include <memory>
57 #include <string>
58 #include <vector>
59 
60 // FIXME: redefine/refactor errortype to the actual error type when chosen...
61 typedef uint32_t errortype;
62 
63 namespace PAL {
64 
65 
66 
67 
68 /* ************************************************************ */
69 /* Messages communicated between the PAL and session layers */
70 /* ************************************************************ */
71 
72 
74 public:
75  uint16_t datatype;
76 };
77 
79 public:
80  uint16_t datatype;
81 };
82 
84 public:
85  FSYS::Handle virtualDevice;
86  FSYS::Handle physicalDevice;
87  uint16_t datatype;
88  std::string virtualDisplayname;
89  std::string physicalDisplayname;
90 };
91 
93 public:
94  FSYS::Handle virtualDevice;
95  errortype error;
96 };
97 
99 public:
100  FSYS::Handle virtualDevice;
101  std::vector<uint8_t> apdu;
102  bool reliable;
103 };
104 
106 public:
107  FSYS::Handle virtualDevice;
108 };
109 
111 public:
112  std::string bluetoothAddress;
113  std::string bluetoothName;
114 };
115 
117 public:
118 
119 };
120 
122 public:
123 
124 };
125 
126 
127 
128 
129 /* ************************************************************ */
130 /* General Interface */
131 /* ************************************************************ */
132 
133 
134 class PhysicalPHD : public FSYS::Handle {
135 public:
136 
144 
151  PhysicalPHD(FSYS::Handle &h) : FSYS::Handle(h) {}
152 
156  virtual ~PhysicalPHD() {}
157 
173  virtual std::string getDisplayName() const noexcept =0;
174 };
175 
176 
177 
178 
202 class VirtualPHD : public FSYS::Handle {
203 public:
204 
212 
219  VirtualPHD(FSYS::Handle &h) : FSYS::Handle(h) {}
220 
224  virtual ~VirtualPHD() {}
225 
226  // The returned reference will be valid as long as this VirtualPHD object is alive
227  virtual PhysicalPHD &getPhysicalDevice() noexcept =0;
228  virtual const PhysicalPHD &getPhysicalDevice() const noexcept =0;
229 
241  virtual uint16_t getDatatype() const noexcept =0;
242 
262  virtual std::string getDisplayName() const noexcept =0;
263 };
264 
265 
266 
267 
295 protected:
296 
322  virtual void registerDatatype(uint16_t datatype) =0;
323 
334  virtual void unregisterDatatype(uint16_t datatype) noexcept =0;
335 
351  virtual void connectIndication(std::shared_ptr<VirtualPHD> device)
352  noexcept =0;
353 
384  virtual void disconnectIndication(std::shared_ptr<VirtualPHD> device,
385  errortype error=0) noexcept =0;
386 
399  virtual void apduReceived(std::shared_ptr<VirtualPHD> device,
400  std::shared_ptr<std::vector<uint8_t> > apdu,
401  bool reliableTransport) noexcept =0;
402 
416  virtual void sendApduPrimary(std::shared_ptr<VirtualPHD> device,
417  std::shared_ptr<std::vector<uint8_t> > apdu)
418  noexcept =0;
419 
429  virtual void disconnect(std::shared_ptr<VirtualPHD> device) noexcept =0;
430 
431 };
432 
433 
434 
435 
436 /* ************************************************************ */
437 /* Bluetooth "classic" */
438 /* ************************************************************ */
439 
440 
454 public:
455 
463 
471 
482  virtual std::string getBTAddress() const noexcept =0;
483 
492  virtual std::string getBTName() const noexcept =0;
493 };
494 
495 
496 
497 
514 
515 protected:
516 
532  virtual void sendApduStreaming(std::shared_ptr<VirtualPHD> device,
533  std::shared_ptr<std::vector<uint8_t> > apdu)
534  noexcept =0;
535 };
536 
537 
538 
539 
540 /* ************************************************************ */
541 /* USB */
542 /* ************************************************************ */
543 
553 class PHDUSBDevice : public PhysicalPHD {
554 public:
555  PHDUSBDevice() {}
557 
558 
559 };
560 
561 
576 protected:
577 
578 
579 };
580 
581 
582 
583 
584 /* ************************************************************ */
585 /* ZigBee */
586 /* ************************************************************ */
587 
597 class PHDZigBeeDevice : public PhysicalPHD {
598 public:
599  PHDZigBeeDevice() {}
601 
602 
603 };
604 
605 
620 protected:
621 
622 
623 };
624 
625 
626 
627 
628 /* ************************************************************ */
629 /* Abstract Provider and Handler classes */
630 /* ************************************************************ */
631 
643  protected PHDBluetoothConnector,
644  protected PHDUSBConnector,
645  protected PHDZigBeeConnector {
646 
647 public:
656  virtual ~PersonalHealthDeviceHandler();
657 
658 protected:
660  void registerDatatype(uint16_t datatype);
661  void unregisterDatatype(uint16_t datatype) noexcept;
662  void sendApduPrimary(std::shared_ptr<VirtualPHD> device,
663  std::shared_ptr<std::vector<uint8_t> > apdu) noexcept;
664  void disconnect(std::shared_ptr<VirtualPHD> device) noexcept;
665 
666  void sendApduStreaming(std::shared_ptr<VirtualPHD> device,
667  std::shared_ptr<std::vector<uint8_t> > apdu) noexcept;
668 
669 private:
670  // Opaque class will wrap the private parts
671  class PrivatePHDHandler;
672  PrivatePHDHandler *privateParts;
673 };
674 
675 
676 
677 
688  virtual protected PersonalHealthDeviceConnector {
689 
690 public:
698 
699 protected:
701  void connectIndication(std::shared_ptr<VirtualPHD> device) noexcept;
702 
703  void disconnectIndication(std::shared_ptr<VirtualPHD> device,
704  errortype error) noexcept;
705 
706  void apduReceived(std::shared_ptr<VirtualPHD> device,
707  std::shared_ptr<std::vector<uint8_t> > apdu,
708  bool reliableTransport) noexcept;
709 
710  // Opaque class will wrap the private parts
711  class PrivatePHDProvider;
712  PrivatePHDProvider *privateParts;
713 };
714 
715 
716 
717 
722  protected PHDBluetoothConnector,
724  friend PrivatePHDProvider;
725 };
726 
727 
728 
729 
730 
731 /*
732 class PlatformProviderLauncherBase {
733 public:
734  PlatformProviderLauncherBase();
735  virtual ~PlatformProviderLauncherBase();
736  // Skal der være private copy/assignment ctor og operator?
737 protected:
738  virtual Terminator makeBluetoothProvider();
739  virtual Terminator makeUSBProvider();
740  virtual Terminator makeZigBeeProvider();
741 
742 };
743 
744 
745 class PlatformProviderLauncher : public PlatformProviderLauncherBase {
746 private:
747  Terminator makeBluetoothProvider();
748  Terminator makeUSBProvider();
749  Terminator makeZigBeeProvider();
750 };
751 
752 */
753 
754 } // End of namespace
755 
756 
757 #endif // PERSONALHEALTHDEVICE_H
The base interface of a personal health device seen from the perspective of a transport module...
Definition: personalhealthdevice.h:202
The PersonalHealthDeviceConnector class specialization for communication with USB devices (PHDUSBDevi...
Definition: personalhealthdevice.h:575
The PersonalHealthDeviceConnector class specialization for communication with bluetooth devices (PHDB...
Definition: personalhealthdevice.h:513
Definition: personalhealthdevice.h:110
Definition: personalhealthdevice.h:134
The BaseMsg class is the base class for all messages.
Definition: basemsg.h:54
Definition: personalhealthdevice.h:98
PhysicalPHD(FSYS::Handle &h)
Constructor used to clone the handle.
Definition: personalhealthdevice.h:151
Definition: personalhealthdevice.h:116
Class that holds and assigns handles.
Definition: handle.h:55
Definition: personalhealthdevice.h:121
The abstract class, PAL-layer components must implement to provide communication with personal health...
Definition: personalhealthdevice.h:687
PHDBluetoothDevice()
Default constructor.
Definition: personalhealthdevice.h:462
Contains interface declaration for the FSYS::Handle class.
Definition: android.h:45
Contains interface declaration for the FSYS::BaseMsg class.
virtual ~VirtualPHD()
Virtual destructor.
Definition: personalhealthdevice.h:224
The PAL interface for communication with personal health devices.
Definition: personalhealthdevice.h:294
VirtualPHD()
Default constructor.
Definition: personalhealthdevice.h:211
Definition: personalhealthdevice.h:78
Definition: personalhealthdevice.h:83
Definition: basemsg.h:38
PHDBluetoothDevice(FSYS::Handle &h)
Constructor used to clone the handle.
Definition: personalhealthdevice.h:470
Definition: personalhealthdevice.cpp:590
Definition: personalhealthdevice.h:105
A ZigBee specialization of the PersonalHealthDevice.
Definition: personalhealthdevice.h:597
Definition: personalhealthdevice.h:73
A USB specialization of the PersonalHealthDevice.
Definition: personalhealthdevice.h:553
Definition: personalhealthdevice.h:92
The PersonalHealthDeviceConnector class specialization for communication with ZigBee devices (PHDZigB...
Definition: personalhealthdevice.h:619
Definition: personalhealthdevice.cpp:234
virtual ~PhysicalPHD()
Virtual destructor.
Definition: personalhealthdevice.h:156
Bluetooth specialization of the PersonalHealthDevice.
Definition: personalhealthdevice.h:453
PhysicalPHD()
Default constructor.
Definition: personalhealthdevice.h:143
Bluetooth specialisation of the PersonalHealthDeviceProviderBase.
Definition: personalhealthdevice.h:721
The abstract class, session-layer components must implement to handle communication with personal hea...
Definition: personalhealthdevice.h:642
VirtualPHD(FSYS::Handle &h)
Constructor used to clone the handle.
Definition: personalhealthdevice.h:219