SparkFun Iridium 9604  v1.0.0
Library for the Iridium 9604 Hybrid LTE-M Cellular + Iridium Satellite (SBD) + GNSS IoT module
Loading...
Searching...
No Matches
sfe_ip_address.h
Go to the documentation of this file.
1
22#pragma once
23
24#include "sfe_platform.h"
25
26#if defined(SFE_IRIDIUM_ARDUINO)
27
28#include <IPAddress.h>
29
31{
32 typedef IPAddress sfe_ip_address_t;
33} // namespace SparkFun_Iridium_9604
34
35#elif defined(SFE_IRIDIUM_ESP_IDF)
36
38{
39 class SfeIPAddress
40 {
41 public:
42 SfeIPAddress(void)
43 {
44 _address[0] = _address[1] = _address[2] = _address[3] = 0;
45 }
46 SfeIPAddress(uint8_t first, uint8_t second, uint8_t third, uint8_t fourth)
47 {
48 _address[0] = first;
49 _address[1] = second;
50 _address[2] = third;
51 _address[3] = fourth;
52 }
53
54 uint8_t operator[](int index) const { return _address[index & 3]; }
55 uint8_t &operator[](int index) { return _address[index & 3]; }
56
57 bool operator==(const SfeIPAddress &other) const
58 {
59 return (_address[0] == other._address[0]) && (_address[1] == other._address[1]) &&
60 (_address[2] == other._address[2]) && (_address[3] == other._address[3]);
61 }
62 bool operator!=(const SfeIPAddress &other) const { return !(*this == other); }
63
64 // Dotted-decimal: "192.168.0.1"
65 std::string toString(void) const
66 {
67 char buf[16];
68 snprintf(buf, sizeof(buf), "%u.%u.%u.%u", _address[0], _address[1], _address[2], _address[3]);
69 return std::string(buf);
70 }
71
72 private:
73 uint8_t _address[4];
74 };
75
76 typedef SfeIPAddress sfe_ip_address_t;
77} // namespace SparkFun_Iridium_9604
78
79#endif
Definition: nmeaMessage.h:30