~thomas-voss/location-service/fix-1347887

« back to all changes in this revision

Viewing changes to include/location_service/com/ubuntu/location/connectivity/wireless_network.h

This MP consolidates multiple related changes together, with the goal of:

(1.) Make the service instance accessible via a cli. Useful for testing scenarios.
(2.) To cut down time-to-first-fix (ttff) by:
  (2.1) Leveraging SUPL and other supplementary data downloaded over ordinary data connections.
  (2.2) Enabling network-based positioning providers to acquire fast position estimates.

In more detail:

* Added tests for daemon and cli.
* Unified daemon and cli header and implementation files.
* Add a command-line interface to the service.
* Split up provider selection policy to rely on an interface ProviderEnumerator to ease in testing.
* Trimmed down on types.
* Removed connectivity API draft to prepare for simpler approach.
* Refactored includes.
* Added a configuration option to handle cell and wifi ID reporting.
* Add a mock for a connectivity API exposed to providers and reporters.
* Add units for connectivity api.
* Refactor cell class into namespace radio. Fixes: 1226204, 1248973, 1281817

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright © 2012-2013 Canonical Ltd.
 
3
 *
 
4
 * This program is free software: you can redistribute it and/or modify it
 
5
 * under the terms of the GNU Lesser General Public License version 3,
 
6
 * as published by the Free Software Foundation.
 
7
 *
 
8
 * This program is distributed in the hope that it will be useful,
 
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
 * GNU Lesser General Public License for more details.
 
12
 *
 
13
 * You should have received a copy of the GNU Lesser General Public License
 
14
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
15
 *
 
16
 * Authored by: Thomas Voß <thomas.voss@canonical.com>
 
17
 */
 
18
#ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_CONNECTIVITY_WIRELESS_NETWORK_H_
 
19
#define LOCATION_SERVICE_COM_UBUNTU_LOCATION_CONNECTIVITY_WIRELESS_NETWORK_H_
 
20
 
 
21
#include <com/ubuntu/location/connectivity/bounded_integer.h>
 
22
 
 
23
#include <core/property.h>
 
24
 
 
25
#include <iosfwd>
 
26
#include <string>
 
27
 
 
28
namespace com
 
29
{
 
30
namespace ubuntu
 
31
{
 
32
namespace location
 
33
{
 
34
namespace connectivity
 
35
{
 
36
struct WirelessNetwork
 
37
{
 
38
    typedef std::shared_ptr<WirelessNetwork> Ptr;
 
39
 
 
40
    /** @brief Enumerates all known operational modes of networks/aps. */
 
41
    enum class Mode
 
42
    {
 
43
        /** Mode is unknown. */
 
44
        unknown = 0,
 
45
        /** Indicates the object is part of an Ad-Hoc 802.11 network without a central coordinating access point. */
 
46
        adhoc = 1,
 
47
        /** The wireless device or access point is in infrastructure mode. */
 
48
        infrastructure = 2
 
49
    };
 
50
 
 
51
    /** @cond */
 
52
    struct Tag
 
53
    {
 
54
        /** @brief Tags a frequency measurement for a wireless network. */
 
55
        struct Frequency {};
 
56
        /** @brief Tags the signal strength of a wireless network. */
 
57
        struct SignalStrength {};
 
58
    };
 
59
    /** @endcond */
 
60
 
 
61
    /** Frequency that an individual AP operates on. */
 
62
    typedef BoundedInteger
 
63
    <
 
64
        Tag::Frequency,
 
65
        2412,
 
66
        5825
 
67
    > Frequency;
 
68
 
 
69
    /** Strength of signal for an individual AP. */
 
70
    typedef BoundedInteger
 
71
    <
 
72
        Tag::SignalStrength,
 
73
        0,
 
74
        100
 
75
    > SignalStrength;
 
76
 
 
77
    /** @cond */
 
78
    WirelessNetwork() = default;
 
79
    WirelessNetwork(const WirelessNetwork&) = delete;
 
80
    WirelessNetwork(WirelessNetwork&&) = delete;
 
81
 
 
82
    virtual ~WirelessNetwork() = default;
 
83
 
 
84
    WirelessNetwork& operator=(const WirelessNetwork&) = delete;
 
85
    WirelessNetwork& operator=(WirelessNetwork&&) = delete;
 
86
    /** @endcond */
 
87
 
 
88
    /** @brief Timestamp when the network became visible. */
 
89
    virtual const core::Property<std::chrono::system_clock::time_point>& last_seen() const = 0;
 
90
 
 
91
    /** @brief Returns the BSSID of the network */
 
92
    virtual const core::Property<std::string>& bssid() const = 0;
 
93
 
 
94
    /** @brief Returns the SSID of the network. */
 
95
    virtual const core::Property<std::string>& ssid() const = 0;
 
96
 
 
97
    /** @brief Returns the mode of the network. */
 
98
    virtual const core::Property<Mode>& mode() const = 0;
 
99
 
 
100
    /** @brief Returns the frequency that the network/AP operates upon. */
 
101
    virtual const core::Property<Frequency>& frequency() const = 0;
 
102
 
 
103
    /** @brief Returns the signal quality of the network/AP in percent. */
 
104
    virtual const core::Property<SignalStrength>& signal_strength() const = 0;
 
105
};
 
106
 
 
107
/** @brief Pretty-prints the given mode to the given output stream. */
 
108
std::ostream& operator<<(std::ostream& out, WirelessNetwork::Mode mode);
 
109
 
 
110
/** @brief Pretty-prints the given wireless network to the given output stream. */
 
111
std::ostream& operator<<(std::ostream& out, const WirelessNetwork& wifi);
 
112
}
 
113
}
 
114
}
 
115
}
 
116
 
 
117
#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_CONNECTIVITY_WIRELESS_NETWORK_H_