1 /*
2  * Copyright (C) 2017 The Android Open Source Project
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 
17 #ifndef ANDROID_LOWPAN_BEACON_INFO_H
18 #define ANDROID_LOWPAN_BEACON_INFO_H
19 
20 #include <binder/Parcelable.h>
21 #include <utils/String16.h>
22 #include <utils/StrongPointer.h>
23 #include <set>
24 
25 #include "LowpanIdentity.h"
26 
27 namespace android {
28 
29 namespace net {
30 
31 namespace lowpan {
32 
33 /*
34  * C++ implementation of the Java class android.net.lowpan.LowpanBeaconInfo
35  */
36 class LowpanBeaconInfo : public Parcelable {
37 public:
38     static const int32_t FLAG_CAN_ASSIST = 1;
39 
40     class Builder;
41     LowpanBeaconInfo() = default;
42     virtual ~LowpanBeaconInfo() = default;
43     LowpanBeaconInfo(const LowpanBeaconInfo& x) = default;
44 
45     bool operator==(const LowpanBeaconInfo& rhs);
46     bool operator!=(const LowpanBeaconInfo& rhs) { return !(*this == rhs); }
47 
48 public:
49     // Overrides
50     status_t writeToParcel(Parcel* parcel) const override;
51     status_t readFromParcel(const Parcel* parcel) override;
52 
53 private:
54     LowpanBeaconInfo(const Builder& builder);
55 
56 private:
57     // Data
58     LowpanIdentity mIdentity;
59     int32_t mRssi;
60     int32_t mLqi;
61     std::vector<uint8_t> mBeaconAddress;
62     std::set<int32_t> mFlags;
63 };
64 
65 class LowpanBeaconInfo::Builder {
66     friend class LowpanBeaconInfo;
67 public:
68     Builder();
69     Builder& setName(const std::string& value);
70     Builder& setType(const std::string& value);
71     Builder& setType(const ::android::String16& value);
72     Builder& setXpanid(const std::vector<uint8_t>& value);
73     Builder& setXpanid(const uint8_t* valuePtr, int32_t valueLen);
74     Builder& setPanid(int32_t value);
75     Builder& setChannel(int32_t value);
76     Builder& setLowpanIdentity(const LowpanIdentity& value);
77 
78     Builder& setRssi(int32_t value);
79     Builder& setLqi(int32_t value);
80     Builder& setBeaconAddress(const std::vector<uint8_t>& value);
81     Builder& setBeaconAddress(const uint8_t* valuePtr, int32_t valueLen);
82     Builder& setFlag(int32_t value);
83     Builder& clearFlag(int32_t value);
84 
85     LowpanBeaconInfo build(void) const;
86 private:
87     LowpanIdentity::Builder mIdentityBuilder;
88 
89     int32_t mRssi;
90     int32_t mLqi;
91     std::vector<uint8_t> mBeaconAddress;
92     std::set<int32_t> mFlags;
93 };
94 
95 }  // namespace lowpan
96 
97 }  // namespace net
98 
99 }  // namespace android
100 
101 #endif  // ANDROID_LOWPAN_BEACON_INFO_H
102