140 Character Limit #34
-
Is this a hard limit of the technology? I'm wondering what would have to transpire in order for the limit to be doubled. Is this as simple as modifying the header file where the limit is set? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Currently, the actual limit for the message length is 183 bytes. The reason is that we append 40% ECC bytes at the end of the message and the total length becomes 1.4*183 = 256. At this point, the error correction library that is used stops working. If you want to send longer messages than this, you need to make the following changes:
Points 1, 2 and 3 are easy to solve using the following patch: diff --git a/include/ggwave/ggwave.h b/include/ggwave/ggwave.h
index 5753993..adefb08 100644
--- a/include/ggwave/ggwave.h
+++ b/include/ggwave/ggwave.h
@@ -241,11 +241,11 @@ public:
static constexpr auto kDefaultVolume = 10;
static constexpr auto kDefaultSoundMarkerThreshold = 3.0f;
static constexpr auto kDefaultMarkerFrames = 16;
- static constexpr auto kDefaultEncodedDataOffset = 3;
+ static constexpr auto kDefaultEncodedDataOffset = 4;
static constexpr auto kMaxSamplesPerFrame = 2048;
static constexpr auto kMaxDataBits = 256;
- static constexpr auto kMaxDataSize = 256;
- static constexpr auto kMaxLengthVarible = 140;
+ static constexpr auto kMaxDataSize = 420;
+ static constexpr auto kMaxLengthVarible = 300;
static constexpr auto kMaxLengthFixed = 16;
static constexpr auto kMaxSpectrumHistory = 4;
static constexpr auto kMaxRecordedFrames = 2048;
diff --git a/src/ggwave.cpp b/src/ggwave.cpp
index 2f7b914..154c104 100644
--- a/src/ggwave.cpp
+++ b/src/ggwave.cpp
@@ -421,8 +421,9 @@ bool GGWave::init(int dataSize, const char * dataBuffer, const TxProtocol & txPr
std::fill(m_txDataEncoded.begin(), m_txDataEncoded.end(), 0);
if (m_txDataLength > 0) {
- m_txData[0] = m_txDataLength;
- for (int i = 0; i < m_txDataLength; ++i) m_txData[i + 1] = text[i];
+ m_txData[0] = m_txDataLength/256;
+ m_txData[1] = m_txDataLength%256;
+ for (int i = 0; i < m_txDataLength; ++i) m_txData[i + 2] = text[i];
m_hasNewTxData = true;
}
@@ -535,13 +536,13 @@ bool GGWave::encode(const CBWaveformOut & cbWaveformOut) {
int totalDataFrames = ((totalBytes + m_txProtocol.bytesPerTx - 1)/m_txProtocol.bytesPerTx)*m_txProtocol.framesPerTx;
if (m_isFixedPayloadLength == false) {
- RS::ReedSolomon rsLength(1, m_encodedDataOffset - 1);
+ RS::ReedSolomon rsLength(2, m_encodedDataOffset - 2);
rsLength.Encode(m_txData.data(), m_txDataEncoded.data());
}
// first byte of m_txData contains the length of the payload, so we skip it:
RS::ReedSolomon rsData = RS::ReedSolomon(m_txDataLength, nECCBytesPerTx);
- rsData.Encode(m_txData.data() + 1, m_txDataEncoded.data() + m_encodedDataOffset);
+ rsData.Encode(m_txData.data() + 2, m_txDataEncoded.data() + m_encodedDataOffset);
float factor = kBaseSampleRate/m_sampleRateOut;
uint32_t offset = 0;
@@ -1021,10 +1022,11 @@ void GGWave::decode_variable() {
}
if (itx*rxProtocol.bytesPerTx > m_encodedDataOffset && knownLength == false) {
- RS::ReedSolomon rsLength(1, m_encodedDataOffset - 1);
- if ((rsLength.Decode(m_txDataEncoded.data(), m_rxData.data()) == 0) && (m_rxData[0] > 0 && m_rxData[0] <= 140)) {
+ RS::ReedSolomon rsLength(2, m_encodedDataOffset - 2);
+ if ((rsLength.Decode(m_txDataEncoded.data(), m_rxData.data()) == 0)) {
knownLength = true;
- decodedLength = m_rxData[0];
+ decodedLength = m_rxData[1] + (int(m_rxData[0])*256);
const int nTotalBytesExpected = m_encodedDataOffset + decodedLength + ::getECCBytesForLength(decodedLength);
const int nTotalFramesExpected = 2*m_nMarkerFrames + ((nTotalBytesExpected + rxProtocol.bytesPerTx - 1)/rxProtocol.bytesPerTx)*rxProtocol.framesPerTx; However point 4 might be difficult. I don't fully understand how the ECC library works and what would it take to extend it. Another approach would be to split the message in 256-byte chunks and encode them sequentially. |
Beta Was this translation helpful? Give feedback.
Currently, the actual limit for the message length is 183 bytes. The reason is that we append 40% ECC bytes at the end of the message and the total length becomes 1.4*183 = 256. At this point, the error correction library that is used stops working.
If you want to send longer messages than this, you need to make the following changes:
kMaxLengthVarible
to desired lengthkMaxDataSize
to at least1.4*kMaxLengthVarible
Points 1, 2 and 3 are easy to solve using the following patch:
diff --git a/include/ggwave/ggwave.h b/include/ggwave/…