Skip to content

Commit

Permalink
decoding of DMR packets
Browse files Browse the repository at this point in the history
  • Loading branch information
on4akh committed Aug 1, 2014
1 parent f12786a commit 79e62c8
Show file tree
Hide file tree
Showing 6 changed files with 357 additions and 49 deletions.
67 changes: 40 additions & 27 deletions BPTC1969.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@

#include "master_server.h"

struct BPTC1969{
bool responseRequested;
int dataPacketFormat;
int sapId;
int appendBlocks;
};

bool * extractInfo(bool bits[264]){

static bool info[196];
Expand All @@ -42,11 +49,6 @@ bool * extractInfo(bool bits[264]){
bytePos++;
}

for(i=166;i<264;i++){
info[bytePos] = bits[i];
//printf("%i",info[bytePos]);
bytePos++;
}
//printf("\n");
return info;
}
Expand Down Expand Up @@ -105,55 +107,64 @@ bool * extractPayload(bool * deInterData){
}


bool * decodeBPTC1969(bool bits[264]){
struct BPTC1969 decodeBPTC1969(bool bits[264]){

bool *infoBits; //196 info bits
bool *deInterleavedBits; //196 bits
static bool *payloadBits; //96 bits
int blocksToFollow=0,a;
unsigned char dpf=0,sap=0,bitPadding=0;
struct BPTC1969 BPTC1969decode;

infoBits = extractInfo(bits);
deInterleavedBits = deInterleave(infoBits);
payloadBits = extractPayload(deInterleavedBits);

printf("Payload bits\n");
/*printf("Payload bits\n");
for(a=0;a<96;a++){
printf("%i",*(payloadBits+a));
}
printf("\n");
if(*(payloadBits+1) == 1) syslog(LOG_NOTICE,"response requested"); else syslog(LOG_NOTICE,"NO response requested");
printf("\n");*/
if(*(payloadBits+1) == 1){
BPTC1969decode.responseRequested = true;
//syslog(LOG_NOTICE,"response requested");
}
else{
BPTC1969decode.responseRequested = false;
//syslog(LOG_NOTICE,"NO response requested");
}

for(a=4;a<8;a++){
if(*(payloadBits + a) == true) dpf = dpf + (char)(8 / pow(2,a-4));
}
printf("Data Packet Format: ");
//syslog(LOG_NOTICE,"Data Packet Format: ");
BPTC1969decode.dataPacketFormat = dpf;
switch (dpf){
case 0:
syslog(LOG_NOTICE,"Unified Data Transport\n");
//syslog(LOG_NOTICE,"Unified Data Transport\n");
break;

case 1:
syslog(LOG_NOTICE,"Response packet\n");
//syslog(LOG_NOTICE,"Response packet\n");
break;

case 2:
syslog(LOG_NOTICE,"Data packet with unconfirmed delivery\n");
//syslog(LOG_NOTICE,"Data packet with unconfirmed delivery\n");
break;

case 3:
syslog(LOG_NOTICE,"Data packet with confirmed delivery\n");
//syslog(LOG_NOTICE,"Data packet with confirmed delivery\n");
break;

case 13:
syslog(LOG_NOTICE,"Short Data: Defined\n");
//syslog(LOG_NOTICE,"Short Data: Defined\n");
break;
case 14:
syslog(LOG_NOTICE,"Short Data: Raw or Status/Precoded\n");
//syslog(LOG_NOTICE,"Short Data: Raw or Status/Precoded\n");
break;

case 15:
syslog(LOG_NOTICE,"Proprietary Data Packet\n");
//syslog(LOG_NOTICE,"Proprietary Data Packet\n");
break;

}
Expand All @@ -162,48 +173,50 @@ bool * decodeBPTC1969(bool bits[264]){
if(*(payloadBits + a) == true) sap = sap + (char)(8 / pow(2,a-8));
}

syslog(LOG_NOTICE,"SAP id: ");
//syslog(LOG_NOTICE,"SAP id: ");
BPTC1969decode.sapId = sap;
switch (sap){

case 0:
syslog(LOG_NOTICE,"Unified Data Transport\n");
//syslog(LOG_NOTICE,"Unified Data Transport\n");
break;

case 2:
syslog(LOG_NOTICE,"TCP/IP header compression\n");
//syslog(LOG_NOTICE,"TCP/IP header compression\n");
break;

case 3:
syslog(LOG_NOTICE,"UDP/IP header compression\n");
//syslog(LOG_NOTICE,"UDP/IP header compression\n");
break;

case 4:
syslog(LOG_NOTICE,"IP based Packet data\n");
//syslog(LOG_NOTICE,"IP based Packet data\n");
break;

case 5:
syslog(LOG_NOTICE,"Address Resolution Protocol(ARP)\n");
//syslog(LOG_NOTICE,"Address Resolution Protocol(ARP)\n");
break;

case 9:
syslog(LOG_NOTICE,"Proprietary Packet data\n");
//syslog(LOG_NOTICE,"Proprietary Packet data\n");
break;

case 10:
syslog(LOG_NOTICE,"Short Data\n");
//syslog(LOG_NOTICE,"Short Data\n");
break;

}
if (dpf == 13){
for(a=12;a<16;a++){//only AB in 2nd octet
if(*(payloadBits + a) == true) blocksToFollow = blocksToFollow + (char)(8 / pow(2,a-12));
}
syslog(LOG_NOTICE,"Appended blocks : %i\n",blocksToFollow);
BPTC1969decode.appendBlocks = blocksToFollow;
syslog(LOG_NOTICE,"Appended blocks : %i\n",blocksToFollow);

for(a=72;a<80;a++){
if(*(payloadBits + a) == true) bitPadding = bitPadding + (char)(128 / pow(2,a-12));
}
}

return payloadBits;
return BPTC1969decode;
}
49 changes: 47 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ CmpOptions := -g $(Preprocessors)
LinkOptions :=
IncludePath := "$(IncludeSwitch)." "$(IncludeSwitch)."
RcIncludePath :=
Libs :=$(LibrarySwitch)pthread $(LibrarySwitch)sqlite3
Libs :=$(LibrarySwitch)pthread $(LibrarySwitch)sqlite3 $(LibrarySwitch)m
LibPath := "$(LibraryPathSwitch)."


##
## User defined environment variables
##
CodeLiteDir:=/usr/share/codelite
Objects=$(IntermediateDirectory)/main$(ObjectSuffix) $(IntermediateDirectory)/dmr$(ObjectSuffix) $(IntermediateDirectory)/rdac$(ObjectSuffix) $(IntermediateDirectory)/smaster$(ObjectSuffix) $(IntermediateDirectory)/sqlite$(ObjectSuffix) $(IntermediateDirectory)/webserv$(ObjectSuffix) $(IntermediateDirectory)/htmlreplace$(ObjectSuffix) $(IntermediateDirectory)/htmlpost$(ObjectSuffix)
Objects=$(IntermediateDirectory)/main$(ObjectSuffix) $(IntermediateDirectory)/dmr$(ObjectSuffix) $(IntermediateDirectory)/rdac$(ObjectSuffix) $(IntermediateDirectory)/smaster$(ObjectSuffix) $(IntermediateDirectory)/sqlite$(ObjectSuffix) $(IntermediateDirectory)/webserv$(ObjectSuffix) $(IntermediateDirectory)/htmlreplace$(ObjectSuffix) $(IntermediateDirectory)/htmlpost$(ObjectSuffix) $(IntermediateDirectory)/convbin$(ObjectSuffix) $(IntermediateDirectory)/BPTC1969$(ObjectSuffix) $(IntermediateDirectory)/decode34Rate$(ObjectSuffix) $(IntermediateDirectory)/hyteraDecode$(ObjectSuffix)

##
## Main Build Targets
Expand Down Expand Up @@ -126,6 +126,38 @@ $(IntermediateDirectory)/htmlpost$(DependSuffix): htmlpost.c
$(IntermediateDirectory)/htmlpost$(PreprocessSuffix): htmlpost.c
@$(C_CompilerName) $(CmpOptions) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/htmlpost$(PreprocessSuffix) "htmlpost.c"

$(IntermediateDirectory)/convbin$(ObjectSuffix): convbin.c $(IntermediateDirectory)/convbin$(DependSuffix)
$(C_CompilerName) $(SourceSwitch) "convbin.c" $(CmpOptions) $(ObjectSwitch)$(IntermediateDirectory)/convbin$(ObjectSuffix) $(IncludePath)
$(IntermediateDirectory)/convbin$(DependSuffix): convbin.c
@$(C_CompilerName) $(CmpOptions) $(IncludePath) -MT$(IntermediateDirectory)/convbin$(ObjectSuffix) -MF$(IntermediateDirectory)/convbin$(DependSuffix) -MM "convbin.c"

$(IntermediateDirectory)/convbin$(PreprocessSuffix): convbin.c
@$(C_CompilerName) $(CmpOptions) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/convbin$(PreprocessSuffix) "convbin.c"

$(IntermediateDirectory)/BPTC1969$(ObjectSuffix): BPTC1969.c $(IntermediateDirectory)/BPTC1969$(DependSuffix)
$(C_CompilerName) $(SourceSwitch) "BPTC1969.c" $(CmpOptions) $(ObjectSwitch)$(IntermediateDirectory)/BPTC1969$(ObjectSuffix) $(IncludePath)
$(IntermediateDirectory)/BPTC1969$(DependSuffix): BPTC1969.c
@$(C_CompilerName) $(CmpOptions) $(IncludePath) -MT$(IntermediateDirectory)/BPTC1969$(ObjectSuffix) -MF$(IntermediateDirectory)/BPTC1969$(DependSuffix) -MM "BPTC1969.c"

$(IntermediateDirectory)/BPTC1969$(PreprocessSuffix): BPTC1969.c
@$(C_CompilerName) $(CmpOptions) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/BPTC1969$(PreprocessSuffix) "BPTC1969.c"

$(IntermediateDirectory)/decode34Rate$(ObjectSuffix): decode34Rate.c $(IntermediateDirectory)/decode34Rate$(DependSuffix)
$(C_CompilerName) $(SourceSwitch) "decode34Rate.c" $(CmpOptions) $(ObjectSwitch)$(IntermediateDirectory)/decode34Rate$(ObjectSuffix) $(IncludePath)
$(IntermediateDirectory)/decode34Rate$(DependSuffix): decode34Rate.c
@$(C_CompilerName) $(CmpOptions) $(IncludePath) -MT$(IntermediateDirectory)/decode34Rate$(ObjectSuffix) -MF$(IntermediateDirectory)/decode34Rate$(DependSuffix) -MM "decode34Rate.c"

$(IntermediateDirectory)/decode34Rate$(PreprocessSuffix): decode34Rate.c
@$(C_CompilerName) $(CmpOptions) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/decode34Rate$(PreprocessSuffix) "decode34Rate.c"

$(IntermediateDirectory)/hyteraDecode$(ObjectSuffix): hyteraDecode.c $(IntermediateDirectory)/hyteraDecode$(DependSuffix)
$(C_CompilerName) $(SourceSwitch) "hyteraDecode.c" $(CmpOptions) $(ObjectSwitch)$(IntermediateDirectory)/hyteraDecode$(ObjectSuffix) $(IncludePath)
$(IntermediateDirectory)/hyteraDecode$(DependSuffix): hyteraDecode.c
@$(C_CompilerName) $(CmpOptions) $(IncludePath) -MT$(IntermediateDirectory)/hyteraDecode$(ObjectSuffix) -MF$(IntermediateDirectory)/hyteraDecode$(DependSuffix) -MM "hyteraDecode.c"

$(IntermediateDirectory)/hyteraDecode$(PreprocessSuffix): hyteraDecode.c
@$(C_CompilerName) $(CmpOptions) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/hyteraDecode$(PreprocessSuffix) "hyteraDecode.c"


-include $(IntermediateDirectory)/*$(DependSuffix)
##
Expand Down Expand Up @@ -156,6 +188,19 @@ clean:
$(RM) $(IntermediateDirectory)/htmlpost$(ObjectSuffix)
$(RM) $(IntermediateDirectory)/htmlpost$(DependSuffix)
$(RM) $(IntermediateDirectory)/htmlpost$(PreprocessSuffix)
$(RM) $(IntermediateDirectory)/convbin$(ObjectSuffix)
$(RM) $(IntermediateDirectory)/convbin$(DependSuffix)
$(RM) $(IntermediateDirectory)/convbin$(PreprocessSuffix)
$(RM) $(IntermediateDirectory)/BPTC1969$(ObjectSuffix)
$(RM) $(IntermediateDirectory)/BPTC1969$(DependSuffix)
$(RM) $(IntermediateDirectory)/BPTC1969$(PreprocessSuffix)
$(RM) $(IntermediateDirectory)/decode34Rate$(ObjectSuffix)
$(RM) $(IntermediateDirectory)/decode34Rate$(DependSuffix)
$(RM) $(IntermediateDirectory)/decode34Rate$(PreprocessSuffix)
$(RM) $(IntermediateDirectory)/hyteraDecode$(ObjectSuffix)
$(RM) $(IntermediateDirectory)/hyteraDecode$(DependSuffix)
$(RM) $(IntermediateDirectory)/hyteraDecode$(PreprocessSuffix)

$(RM) $(OutputFile)


Loading

0 comments on commit 79e62c8

Please sign in to comment.