aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJacob Erlbeck <jerlbeck@sysmocom.de>2016-02-03 15:25:04 +0100
committerJacob Erlbeck <jerlbeck@sysmocom.de>2016-02-08 00:45:39 +0100
commit2305afd86c3d3541d01fee0dee408a4510f96d4e (patch)
tree47122e60e494d28c603d78b4f9489785146cbf7e /src
parent4cc46d3e2ab3762733d1e496d4d4a6f749faba47 (diff)
cs: Add family related methods
Add family handling and the related methods family, isFamilyCompatible, isCombinable, decToSingleBlock to GprsCodingScheme. Sponsored-by: On-Waves ehf
Diffstat (limited to 'src')
-rw-r--r--src/gprs_coding_scheme.cpp78
-rw-r--r--src/gprs_coding_scheme.h11
2 files changed, 73 insertions, 16 deletions
diff --git a/src/gprs_coding_scheme.cpp b/src/gprs_coding_scheme.cpp
index aaa8b20..4f1db1d 100644
--- a/src/gprs_coding_scheme.cpp
+++ b/src/gprs_coding_scheme.cpp
@@ -30,23 +30,38 @@ static struct {
unsigned int data_bytes;
const char *name;
GprsCodingScheme::HeaderType data_hdr;
+ GprsCodingScheme::Family family;
} mcs_info[GprsCodingScheme::NUM_SCHEMES] = {
- {{0, 0}, {0, 0}, 0, "UNKNOWN", GprsCodingScheme::HEADER_INVALID},
- {{23, 0}, {23, 0}, 20, "CS-1", GprsCodingScheme::HEADER_GPRS_DATA},
- {{33, 7}, {33, 7}, 30, "CS-2", GprsCodingScheme::HEADER_GPRS_DATA},
- {{39, 3}, {39, 3}, 36, "CS-3", GprsCodingScheme::HEADER_GPRS_DATA},
- {{53, 7}, {53, 7}, 50, "CS-4", GprsCodingScheme::HEADER_GPRS_DATA},
-
- {{26, 1}, {26, 1}, 22, "MCS-1", GprsCodingScheme::HEADER_EGPRS_DATA_TYPE_3},
- {{32, 1}, {32, 1}, 28, "MCS-2", GprsCodingScheme::HEADER_EGPRS_DATA_TYPE_3},
- {{41, 1}, {41, 1}, 37, "MCS-3", GprsCodingScheme::HEADER_EGPRS_DATA_TYPE_3},
- {{48, 1}, {48, 1}, 44, "MCS-4", GprsCodingScheme::HEADER_EGPRS_DATA_TYPE_3},
-
- {{60, 7}, {59, 6}, 56, "MCS-5", GprsCodingScheme::HEADER_EGPRS_DATA_TYPE_2},
- {{78, 7}, {77, 6}, 74, "MCS-6", GprsCodingScheme::HEADER_EGPRS_DATA_TYPE_2},
- {{118, 2}, {117, 4}, 56, "MCS-7", GprsCodingScheme::HEADER_EGPRS_DATA_TYPE_1},
- {{142, 2}, {141, 4}, 68, "MCS-8", GprsCodingScheme::HEADER_EGPRS_DATA_TYPE_1},
- {{154, 2}, {153, 4}, 74, "MCS-9", GprsCodingScheme::HEADER_EGPRS_DATA_TYPE_1},
+ {{0, 0}, {0, 0}, 0, "UNKNOWN",
+ GprsCodingScheme::HEADER_INVALID, GprsCodingScheme::FAMILY_INVALID},
+ {{23, 0}, {23, 0}, 20, "CS-1",
+ GprsCodingScheme::HEADER_GPRS_DATA, GprsCodingScheme::FAMILY_INVALID},
+ {{33, 7}, {33, 7}, 30, "CS-2",
+ GprsCodingScheme::HEADER_GPRS_DATA, GprsCodingScheme::FAMILY_INVALID},
+ {{39, 3}, {39, 3}, 36, "CS-3",
+ GprsCodingScheme::HEADER_GPRS_DATA, GprsCodingScheme::FAMILY_INVALID},
+ {{53, 7}, {53, 7}, 50, "CS-4",
+ GprsCodingScheme::HEADER_GPRS_DATA, GprsCodingScheme::FAMILY_INVALID},
+
+ {{26, 1}, {26, 1}, 22, "MCS-1",
+ GprsCodingScheme::HEADER_EGPRS_DATA_TYPE_3, GprsCodingScheme::FAMILY_C},
+ {{32, 1}, {32, 1}, 28, "MCS-2",
+ GprsCodingScheme::HEADER_EGPRS_DATA_TYPE_3, GprsCodingScheme::FAMILY_B},
+ {{41, 1}, {41, 1}, 37, "MCS-3",
+ GprsCodingScheme::HEADER_EGPRS_DATA_TYPE_3, GprsCodingScheme::FAMILY_A},
+ {{48, 1}, {48, 1}, 44, "MCS-4",
+ GprsCodingScheme::HEADER_EGPRS_DATA_TYPE_3, GprsCodingScheme::FAMILY_C},
+
+ {{60, 7}, {59, 6}, 56, "MCS-5",
+ GprsCodingScheme::HEADER_EGPRS_DATA_TYPE_2, GprsCodingScheme::FAMILY_B},
+ {{78, 7}, {77, 6}, 74, "MCS-6",
+ GprsCodingScheme::HEADER_EGPRS_DATA_TYPE_2, GprsCodingScheme::FAMILY_A},
+ {{118, 2}, {117, 4}, 56, "MCS-7",
+ GprsCodingScheme::HEADER_EGPRS_DATA_TYPE_1, GprsCodingScheme::FAMILY_B},
+ {{142, 2}, {141, 4}, 68, "MCS-8",
+ GprsCodingScheme::HEADER_EGPRS_DATA_TYPE_1, GprsCodingScheme::FAMILY_A},
+ {{154, 2}, {153, 4}, 74, "MCS-9",
+ GprsCodingScheme::HEADER_EGPRS_DATA_TYPE_1, GprsCodingScheme::FAMILY_A},
};
static struct {
@@ -167,6 +182,11 @@ GprsCodingScheme::HeaderType GprsCodingScheme::headerTypeData() const
return mcs_info[m_scheme].data_hdr;
}
+GprsCodingScheme::Family GprsCodingScheme::family() const
+{
+ return mcs_info[m_scheme].family;
+}
+
void GprsCodingScheme::inc(Mode mode)
{
if (!isCompatible(mode))
@@ -232,3 +252,29 @@ const char *GprsCodingScheme::modeName(Mode mode)
default: return "???";
}
}
+
+bool GprsCodingScheme::isFamilyCompatible(GprsCodingScheme o) const
+{
+ if (*this == o)
+ return true;
+
+ if (family() == FAMILY_INVALID)
+ return false;
+
+ return family() == o.family();
+}
+
+bool GprsCodingScheme::isCombinable(GprsCodingScheme o) const
+{
+ return numDataBlocks() == o.numDataBlocks();
+}
+
+void GprsCodingScheme::decToSingleBlock(bool *needStuffing)
+{
+ switch (m_scheme) {
+ case MCS7: *needStuffing = false; m_scheme = MCS5; break;
+ case MCS8: *needStuffing = true; m_scheme = MCS6; break;
+ case MCS9: *needStuffing = false; m_scheme = MCS6; break;
+ default: *needStuffing = false; break;
+ }
+}
diff --git a/src/gprs_coding_scheme.h b/src/gprs_coding_scheme.h
index 348aefb..e9a06a5 100644
--- a/src/gprs_coding_scheme.h
+++ b/src/gprs_coding_scheme.h
@@ -50,6 +50,13 @@ public:
NUM_HEADER_TYPES
};
+ enum Family {
+ FAMILY_INVALID,
+ FAMILY_A,
+ FAMILY_B,
+ FAMILY_C,
+ };
+
GprsCodingScheme(Scheme s = UNKNOWN);
operator bool() const {return m_scheme != UNKNOWN;}
@@ -65,11 +72,14 @@ public:
bool isEgprsGmsk() const {return isEgprs() && m_scheme <= MCS4;}
bool isCompatible(Mode mode) const;
bool isCompatible(GprsCodingScheme o) const;
+ bool isFamilyCompatible(GprsCodingScheme o) const;
+ bool isCombinable(GprsCodingScheme o) const;
void inc(Mode mode);
void dec(Mode mode);
void inc();
void dec();
+ void decToSingleBlock(bool *needStuffing);
unsigned int sizeUL() const;
unsigned int sizeDL() const;
@@ -87,6 +97,7 @@ public:
const char *name() const;
HeaderType headerTypeData() const;
HeaderType headerTypeControl() const;
+ Family family() const;
static GprsCodingScheme getBySizeUL(unsigned size);
static GprsCodingScheme getGprsByNum(unsigned num);