GNU Radio's BLUETOOTH Package
piconet.h
Go to the documentation of this file.
1/* -*- c++ -*- */
2/*
3 * Copyright 2013 Christopher D. Kilgour
4 * Copyright 2008, 2009 Dominic Spill, Michael Ossmann
5 * Copyright 2007 Dominic Spill
6 * Copyright 2005, 2006 Free Software Foundation, Inc.
7 *
8 * This file is part of gr-bluetooth
9 *
10 * This is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2, or (at your option)
13 * any later version.
14 *
15 * This software is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this software; see the file COPYING. If not, write to
22 * the Free Software Foundation, Inc., 51 Franklin Street,
23 * Boston, MA 02110-1301, USA.
24 */
25
26
27#ifndef INCLUDED_GR_BLUETOOTH_PICONET_H
28#define INCLUDED_GR_BLUETOOTH_PICONET_H
29
30#include <bluetooth/api.h>
31#include "bluetooth/packet.h"
32
33namespace gr {
34 namespace bluetooth {
35
37 {
38 private:
39 friend class base_rate_piconet;
40 friend class low_energy_piconet;
41
42 /* queue of packets to be decoded */
43 std::vector<packet::sptr> d_pkt_queue;
44
45 public:
46 typedef std::shared_ptr<piconet> sptr;
47
48 /* initialize the hop reversal process */
49 /* returns number of initial candidates for CLK1-27 */
50 virtual int init_hop_reversal(bool aliased) = 0;
51
52 /* look up channel for a particular hop */
53 virtual char hop(int clock) = 0;
54
55 /* return the observable channel (26-50) for a given channel (0-78) */
56 virtual char aliased_channel(char channel) = 0;
57
58 /* reset UAP/clock discovery */
59 virtual void reset() = 0;
60
61 /* add a packet to the queue */
63
64 /* pull the first packet from the queue (FIFO) */
66 };
67
69 public:
70 typedef std::shared_ptr<basic_rate_piconet> sptr;
71
72 /*!
73 * \brief Return a shared_ptr to a new instance of gr::bluetooth::basic_rate_piconet.
74 *
75 * To avoid accidental use of raw pointers, gr::bluetooth::basic_rate_piconet's
76 * constructor is in a private implementation
77 * class. gr::bluetooth::basic_rate_piconet::make is the public interface for
78 * creating new instances.
79 */
80 static sptr make(uint32_t LAP);
81
82 /* number of hops in the hopping sequence (i.e. number of possible values of CLK1-27) */
83 static const int SEQUENCE_LENGTH = 134217728;
84
85 /* narrow a list of candidate clock values based on a single observed hop */
86 virtual int winnow(int offset, char channel) = 0;
87
88 /* narrow a list of candidate clock values based on all observed hops */
89 virtual int winnow() = 0;
90
91 /* offset between CLKN (local) and CLK of piconet */
92 virtual uint32_t get_offset() = 0;
93 virtual void set_offset(uint32_t offset) = 0;
94
95 /* UAP */
96 virtual uint8_t get_UAP() = 0;
97 virtual void set_UAP(uint8_t uap) = 0;
98
99 /* NAP */
100 virtual uint16_t get_NAP() = 0;
101 virtual void set_NAP(uint16_t nap) = 0;
102
103 /* use classic_packet headers to determine UAP */
105
106 /* discovery status */
107 virtual bool have_UAP() = 0;
108 virtual bool have_NAP() = 0;
109 virtual bool have_clk6() = 0;
110 virtual bool have_clk27() = 0;
111
112 // -------------------------------------------------------------------
113
114 /* initialize the hop reversal process */
115 /* returns number of initial candidates for CLK1-27 */
116 virtual int init_hop_reversal(bool aliased) = 0;
117
118 /* look up channel for a particular hop */
119 virtual char hop(int clock) = 0;
120
121 /* return the observable channel (26-50) for a given channel (0-78) */
122 virtual char aliased_channel(char channel) = 0;
123
124 /* reset UAP/clock discovery */
125 virtual void reset() = 0;
126 };
127
129 public:
130 typedef std::shared_ptr<low_energy_piconet> sptr;
131
132 /*!
133 * \brief Return a shared_ptr to a new instance of gr::bluetooth::low_energy_piconet.
134 *
135 * To avoid accidental use of raw pointers, gr::bluetooth::low_energy_piconet's
136 * constructor is in a private implementation
137 * class. gr::bluetooth::low_energy_piconet::make is the public interface for
138 * creating new instances.
139 */
140 static sptr make(const uint32_t aa);
141
142 // -------------------------------------------------------------------
143
144 /* initialize the hop reversal process */
145 /* returns number of initial candidates for CLK1-27 */
146 virtual int init_hop_reversal(bool aliased) = 0;
147
148 /* look up channel for a particular hop */
149 virtual char hop(int clock) = 0;
150
151 /* return the observable channel (26-50) for a given channel (0-78) */
152 virtual char aliased_channel(char channel) = 0;
153
154 /* reset alignment discovery */
155 virtual void reset() = 0;
156 };
157
158 } // namespace bluetooth
159} // namespace gr
160
161#endif /* INCLUDED_GR_BLUETOOTH_PICONET_H */
162
#define BLUETOOTH_API
Definition api.h:19
Definition piconet.h:68
static const int SEQUENCE_LENGTH
Definition piconet.h:83
virtual uint32_t get_offset()=0
virtual int winnow(int offset, char channel)=0
virtual uint16_t get_NAP()=0
virtual void set_UAP(uint8_t uap)=0
virtual void set_offset(uint32_t offset)=0
virtual char aliased_channel(char channel)=0
std::shared_ptr< basic_rate_piconet > sptr
Definition piconet.h:70
virtual void set_NAP(uint16_t nap)=0
static sptr make(uint32_t LAP)
Return a shared_ptr to a new instance of gr::bluetooth::basic_rate_piconet.
virtual bool UAP_from_header(classic_packet::sptr packet)=0
virtual int init_hop_reversal(bool aliased)=0
virtual char hop(int clock)=0
std::shared_ptr< classic_packet > sptr
Definition packet.h:169
static sptr make(const uint32_t aa)
Return a shared_ptr to a new instance of gr::bluetooth::low_energy_piconet.
std::shared_ptr< low_energy_piconet > sptr
Definition piconet.h:130
virtual int init_hop_reversal(bool aliased)=0
virtual char hop(int clock)=0
virtual char aliased_channel(char channel)=0
Definition packet.h:38
std::shared_ptr< packet > sptr
Definition packet.h:52
Definition piconet.h:37
virtual void reset()=0
virtual char hop(int clock)=0
friend class low_energy_piconet
Definition piconet.h:40
std::shared_ptr< piconet > sptr
Definition piconet.h:46
friend class base_rate_piconet
Definition piconet.h:39
virtual char aliased_channel(char channel)=0
virtual int init_hop_reversal(bool aliased)=0
void enqueue(packet::sptr pkt)
packet::sptr dequeue()
Definition multi_block.h:34
Definition multi_block.h:33