TEST-2
parent
1f4c38f71e
commit
b0bdfaae44
|
@ -0,0 +1,10 @@
|
||||||
|
|
||||||
|
#ifndef BUILD_NUMBER
|
||||||
|
#define BUILD_NUMBER "28"
|
||||||
|
#endif
|
||||||
|
#ifndef VERSION
|
||||||
|
#define VERSION "v0.3.2.28- - 2021-09-06 23:22:02.459488"
|
||||||
|
#endif
|
||||||
|
#ifndef VERSION_SHORT
|
||||||
|
#define VERSION_SHORT "v0.3.2.28-"
|
||||||
|
#endif
|
|
@ -33,51 +33,31 @@ String decapsulateKISS(const String &frame);
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
String encode_kiss(const String &tnc2FormattedFrame)
|
String encode_kiss(const String &tnc2FormattedFrame) {
|
||||||
{
|
|
||||||
String ax25Frame = "";
|
String ax25Frame = "";
|
||||||
char control_id = 0x03;
|
|
||||||
if (validateTNC2Frame(tnc2FormattedFrame)) {
|
if (validateTNC2Frame(tnc2FormattedFrame)) {
|
||||||
String address = "";
|
String address = "";
|
||||||
bool dst_addres_written = false;
|
bool dst_addres_written = false;
|
||||||
for (int p = 0; p <= tnc2FormattedFrame.indexOf(':'); p++)
|
for (int p = 0; p <= tnc2FormattedFrame.indexOf(':'); p++) {
|
||||||
{
|
|
||||||
char currentChar = tnc2FormattedFrame.charAt(p);
|
char currentChar = tnc2FormattedFrame.charAt(p);
|
||||||
if (currentChar == ':' || currentChar == '>' || currentChar == ',')
|
if (currentChar == ':' || currentChar == '>' || currentChar == ',') {
|
||||||
{
|
if (!dst_addres_written && (currentChar == ',' || currentChar == ':')) {
|
||||||
if (!dst_addres_written && (currentChar == ',' || currentChar == ':'))
|
|
||||||
{
|
|
||||||
// ax25 frame DST SRC
|
// ax25 frame DST SRC
|
||||||
// tnc2 frame SRC DST
|
// tnc2 frame SRC DST
|
||||||
ax25Frame = encode_address_ax25(address) + ax25Frame;
|
ax25Frame = encode_address_ax25(address) + ax25Frame;
|
||||||
dst_addres_written = true;
|
dst_addres_written = true;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
ax25Frame += encode_address_ax25(address);
|
ax25Frame += encode_address_ax25(address);
|
||||||
}
|
}
|
||||||
address = "";
|
address = "";
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
address += currentChar;
|
address += currentChar;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//Parse APRS CONTROL ID
|
|
||||||
if (tnc2FormattedFrame.lastIndexOf("SABM") > 1) { control_id = 0x2f; }
|
|
||||||
else if (tnc2FormattedFrame.lastIndexOf("DISC") > 1) { control_id = 0x43; }
|
|
||||||
else if (tnc2FormattedFrame.lastIndexOf("DM") > 1) { control_id = 0x0f; }
|
|
||||||
else if (tnc2FormattedFrame.lastIndexOf("UA") > 1) { control_id = 0x63; }
|
|
||||||
else if (tnc2FormattedFrame.lastIndexOf("FRMR") > 1) { control_id = 0x87; }
|
|
||||||
else if (tnc2FormattedFrame.lastIndexOf("XID") > 1) { control_id = 0xaf; }
|
|
||||||
else if (tnc2FormattedFrame.lastIndexOf("TEST") > 1) { control_id = 0xe3; }
|
|
||||||
else if (tnc2FormattedFrame.lastIndexOf("RR") > 1) { control_id = 0x01; }
|
|
||||||
else if (tnc2FormattedFrame.lastIndexOf("II") > 1) { control_id = 0xf0; }
|
|
||||||
else { control_id = 0x03; }
|
|
||||||
//END
|
|
||||||
auto lastAddressChar = (uint8_t) ax25Frame.charAt(ax25Frame.length() - 1);
|
auto lastAddressChar = (uint8_t) ax25Frame.charAt(ax25Frame.length() - 1);
|
||||||
ax25Frame.setCharAt(ax25Frame.length() - 1, (char) (lastAddressChar | IS_LAST_ADDRESS_POSITION_MASK));
|
ax25Frame.setCharAt(ax25Frame.length() - 1, (char) (lastAddressChar | IS_LAST_ADDRESS_POSITION_MASK));
|
||||||
ax25Frame += (char) control_id;
|
ax25Frame += (char) APRS_CONTROL_FIELD;
|
||||||
ax25Frame += (char) APRS_INFORMATION_FIELD;
|
ax25Frame += (char) APRS_INFORMATION_FIELD;
|
||||||
ax25Frame += tnc2FormattedFrame.substring(tnc2FormattedFrame.indexOf(':') + 1);
|
ax25Frame += tnc2FormattedFrame.substring(tnc2FormattedFrame.indexOf(':') + 1);
|
||||||
}
|
}
|
||||||
|
@ -86,6 +66,15 @@ String encode_kiss(const String &tnc2FormattedFrame)
|
||||||
return kissFrame;
|
return kissFrame;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//HACK for working Packet mode
|
||||||
|
String encode_kiss_pkt(const String &tnc2FormattedFrame)
|
||||||
|
{
|
||||||
|
String TNC2Frame = "";
|
||||||
|
String ax25Frame = encapsulateKISS(tnc2FormattedFrame, CMD_DATA);
|
||||||
|
TNC2Frame += ax25Frame;
|
||||||
|
return TNC2Frame;
|
||||||
|
}
|
||||||
|
|
||||||
String encapsulateKISS(const String &ax25Frame, uint8_t TNCCmd)
|
String encapsulateKISS(const String &ax25Frame, uint8_t TNCCmd)
|
||||||
{
|
{
|
||||||
String kissFrame = "";
|
String kissFrame = "";
|
||||||
|
@ -149,20 +138,7 @@ String decapsulateKISS(const String &frame)
|
||||||
*/
|
*/
|
||||||
String decode_kiss(const String &inputKISSTNCFrame, bool &dataFrame) {
|
String decode_kiss(const String &inputKISSTNCFrame, bool &dataFrame) {
|
||||||
String TNC2Frame = "";
|
String TNC2Frame = "";
|
||||||
String control_f = "";
|
|
||||||
//UI-FRAMES
|
|
||||||
bool ui_sabm = false;
|
|
||||||
bool ui_disc = false;
|
|
||||||
bool ui_dm = false;
|
|
||||||
bool ui_ua = false;
|
|
||||||
bool ui_frmr = false;
|
|
||||||
bool ui_xid = false;
|
|
||||||
bool ui_test = false;
|
|
||||||
//S-FRAMES
|
|
||||||
bool us_rr = false;
|
|
||||||
//I-Frame
|
|
||||||
bool ui_i = false;
|
|
||||||
//END FRAMES
|
|
||||||
if (validateKISSFrame(inputKISSTNCFrame)) {
|
if (validateKISSFrame(inputKISSTNCFrame)) {
|
||||||
dataFrame = inputKISSTNCFrame.charAt(1) == CMD_DATA;
|
dataFrame = inputKISSTNCFrame.charAt(1) == CMD_DATA;
|
||||||
if (dataFrame){
|
if (dataFrame){
|
||||||
|
@ -177,43 +153,24 @@ String decode_kiss(const String &inputKISSTNCFrame, bool &dataFrame) {
|
||||||
TNC2Frame += ',' + digi_addr;
|
TNC2Frame += ',' + digi_addr;
|
||||||
digi_info_index += 7;
|
digi_info_index += 7;
|
||||||
}
|
}
|
||||||
//parse for conrol frame
|
|
||||||
for (int i = 16; i < inputKISSTNCFrame.length() - 1; ++i)
|
|
||||||
{
|
|
||||||
ui_sabm = inputKISSTNCFrame.charAt(i) == U_SABM;
|
|
||||||
ui_disc = inputKISSTNCFrame.charAt(i) == U_DISC;
|
|
||||||
ui_dm = inputKISSTNCFrame.charAt(i) == U_DM;
|
|
||||||
ui_ua = inputKISSTNCFrame.charAt(i) == U_UA;
|
|
||||||
ui_frmr = inputKISSTNCFrame.charAt(i) == U_FRMR;
|
|
||||||
ui_xid = inputKISSTNCFrame.charAt(i) == U_XID;
|
|
||||||
ui_test = inputKISSTNCFrame.charAt(i) == U_TEST;
|
|
||||||
//S-Frame TEST
|
|
||||||
us_rr = inputKISSTNCFrame.charAt(i) == S_RR;
|
|
||||||
//I-Frame TEST
|
|
||||||
ui_i = inputKISSTNCFrame.charAt(i) == I_I;
|
|
||||||
}
|
|
||||||
if (ui_sabm) { control_f = "<SABM>"; }
|
|
||||||
else if (ui_disc) { control_f = "<DISC>"; }
|
|
||||||
else if (ui_dm) { control_f = "<DM>"; }
|
|
||||||
else if (ui_ua) { control_f = "<UA>"; }
|
|
||||||
else if (ui_frmr) { control_f = "<FRMR>"; }
|
|
||||||
else if (ui_xid) { control_f = "<XID>"; }
|
|
||||||
else if (ui_test) { control_f = "<TEST>"; }
|
|
||||||
else if (us_rr) { control_f = "<RR>"; }
|
|
||||||
else if (ui_i) { control_f = "<II>"; }
|
|
||||||
else { control_f = ' '; }
|
|
||||||
//control frames
|
|
||||||
TNC2Frame += ':';
|
TNC2Frame += ':';
|
||||||
TNC2Frame += control_f;
|
|
||||||
//END
|
|
||||||
TNC2Frame += ax25Frame.substring(digi_info_index + 2);
|
TNC2Frame += ax25Frame.substring(digi_info_index + 2);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
// command frame, currently ignored
|
// command frame, currently ignored
|
||||||
TNC2Frame += inputKISSTNCFrame;
|
TNC2Frame += inputKISSTNCFrame;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return TNC2Frame;
|
||||||
|
}
|
||||||
|
//HACK for PACKEt MODE
|
||||||
|
String decode_kiss_pkt(const String &inputKISSTNCFrame, bool &dataFrame) {
|
||||||
|
String TNC2Frame = "";
|
||||||
|
dataFrame = inputKISSTNCFrame.charAt(1) == CMD_DATA;
|
||||||
|
if (dataFrame){
|
||||||
|
String ax25Frame = decapsulateKISS(inputKISSTNCFrame);
|
||||||
|
TNC2Frame += ax25Frame;
|
||||||
|
}
|
||||||
return TNC2Frame;
|
return TNC2Frame;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,5 +27,8 @@
|
||||||
//END
|
//END
|
||||||
String encode_kiss(const String& tnc2FormattedFrame);
|
String encode_kiss(const String& tnc2FormattedFrame);
|
||||||
String decode_kiss(const String &inputKISSTNCFrame, bool &dataFrame);
|
String decode_kiss(const String &inputKISSTNCFrame, bool &dataFrame);
|
||||||
|
//PACKET MODE
|
||||||
|
String encode_kiss_pkt(const String& tnc2FormattedFrame);
|
||||||
|
String decode_kiss_pkt(const String &inputKISSTNCFrame, bool &dataFrame);
|
||||||
|
|
||||||
String encapsulateKISS(const String &ax25Frame, uint8_t TNCCmd);
|
String encapsulateKISS(const String &ax25Frame, uint8_t TNCCmd);
|
|
@ -34,7 +34,7 @@ void handleKISSData(char character, int bufferIndex) {
|
||||||
inTNCData->concat(character);
|
inTNCData->concat(character);
|
||||||
if (character == (char) FEND && inTNCData->length() > 3) {
|
if (character == (char) FEND && inTNCData->length() > 3) {
|
||||||
bool isDataFrame = false;
|
bool isDataFrame = false;
|
||||||
const String &TNC2DataFrame = decode_kiss(*inTNCData, isDataFrame);
|
const String &TNC2DataFrame = decode_kiss_pkt(*inTNCData, isDataFrame);
|
||||||
|
|
||||||
if (isDataFrame) {
|
if (isDataFrame) {
|
||||||
auto *buffer = new String();
|
auto *buffer = new String();
|
||||||
|
@ -82,7 +82,7 @@ void handleKISSData(char character, int bufferIndex) {
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
if (xQueueReceive(tncReceivedQueue, &loraReceivedFrameString, (1 / portTICK_PERIOD_MS)) == pdPASS) {
|
if (xQueueReceive(tncReceivedQueue, &loraReceivedFrameString, (1 / portTICK_PERIOD_MS)) == pdPASS) {
|
||||||
const String &kissEncoded = encode_kiss(*loraReceivedFrameString);
|
const String &kissEncoded = encode_kiss_pkt(*loraReceivedFrameString);
|
||||||
Serial.print(kissEncoded);
|
Serial.print(kissEncoded);
|
||||||
#ifdef ENABLE_BLUETOOTH
|
#ifdef ENABLE_BLUETOOTH
|
||||||
if (SerialBT.hasClient()){
|
if (SerialBT.hasClient()){
|
||||||
|
|
Loading…
Reference in New Issue