Skip to content

Commit

Permalink
Tweaks to the POCSAG receiver. #118
Browse files Browse the repository at this point in the history
  • Loading branch information
travisgoodspeed committed Sep 2, 2019
1 parent 26a4405 commit aea5c3d
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 12 deletions.
12 changes: 11 additions & 1 deletion bin/goodwatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,20 @@ def chr16(word):
PKTCTRL0, 0x00, # Packet automation control, fixed length without CRC.
PKTLEN, 60, # PKTLEN Packet length.


#Matches on the packet, after the pramble.
SYNC1, 0x83, # 832d first
SYNC0, 0x2d,
ADDR, 0xea, # ea27 next, but we can only match one piece of it.

#This would match on the preamble, while the packet is still in flight.
#Handy for manually seeing the SYNC pattern, and the technique that firmware
#will use to wake up.
#SYNC1, 0xAA,
#SYNC0, 0xAA,
#ADDR, 0xAA,


TEST2, 0x81, #Who knows?
TEST1, 0x35,
TEST0, 0x09,
Expand Down Expand Up @@ -480,7 +490,7 @@ def radiotx(self,message,length=32):
goodwatch.radiotx(pocsagpacket.decode('hex'),32);
time.sleep(1);
if args.pocsag!=None:
print "WARNING: POCSAG DOESN'T WORK YET";
#print "WARNING: POCSAG DOESN'T WORK YET";
time.sleep(1);
goodwatch.radioonoff(1);
print "Configuring radio.";
Expand Down
33 changes: 22 additions & 11 deletions firmware/apps/pager.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,12 @@ static const uint8_t pocsag_settings[]={
TEST0, 0x09,



MCSM1, 0x30, // MCSM1, return to IDLE after packet. Or with 2 for TX carrier tes.
MCSM0, 0x10, // MCSM0 Calibrate before RX or TX.
MCSM1, 0x30, // MCSM1, return to IDLE after packet.
//MCSM0, 0x10, // MCSM0 Calibrate before RX or TX.
//MCSM0, 0x30, // MCSM0 Calibrate after every 4th packet.
//MCSM0, 0x31, // MCSM0 Calibrate after every 4th packet, keep osc on.
//MCSM0, 0x3C, // MCSM0
MCSM0, 0x1C, // MCSM0 Calibrate every packet.
IOCFG2, 0x29, // IOCFG2 GDO2 output pin configuration.
IOCFG0, 0x06, // IOCFG0 GDO0 output pin configuration.

Expand All @@ -89,17 +91,21 @@ static const uint8_t pocsag_settings_packet[]={
SYNC0, 0x2d, //2FSK definitions, the first two bytes become 832d.
ADDR, 0xea, //EA27 is next, and we can at least match the first byte.

PKTCTRL1, 0x01, //Exact address check, no appended status.

0, 0
};

/* Settings to match on the preamble, for waking up.
*/
static const uint8_t pocsag_settings_preamble[]={
PKTLEN, 3, // PKTLEN Packet length.
PKTLEN, 1, // PKTLEN Packet length of one, so that we match as soon as possible.

SYNC1, 0xAA, // Triggers an early match if the preamble is heard.
SYNC0, 0xAA,
ADDR, 0xAA,

PKTCTRL1, 0x00, //No address check, no appended status.

0, 0
};
Expand All @@ -125,9 +131,9 @@ void pager_packetrx(uint8_t *packet, int len){
*/
app_cleartimer();



/* When the first byte is AA, it's because we've matched on the
preamble. This indicates that a packet is coming within the next
480ms, and we ought to stay awake for it.
Expand Down Expand Up @@ -185,7 +191,7 @@ void pager_packetrx(uint8_t *packet, int len){

//Zero the packet just so bugs are clear.
memset(packet,0xFF,len);
printf("\n%ld: %s\n",
printf("%ld: %s\n\n",
pocsag_lastid, pocsag_buffer
);

Expand Down Expand Up @@ -250,7 +256,6 @@ void pager_draw(){
the end of this function, we'll give up and sleep for a while.
*/


//Start looking for the preamble.
//radio_on();
radio_writesettings(pocsag_settings);
Expand All @@ -263,9 +268,11 @@ void pager_draw(){
//Then wait long enough for the packet.
/* 100 works
75 works
50 doesn't
60 seems to work reliably, 3.9mA or 25h
55 loses some packets, 3.7mA or 26h
50 can be tempermental, 3.6mA or 27h
*/
for(i=0;i<75;i++)
for(i=0;i<60;i++)
__delay_cycles(1000);
}

Expand All @@ -282,6 +289,7 @@ void pager_draw(){
}

switch(state){
case 0: //OFF
case 1: //IDLE
/* The idle state still draws 1mA, so we would prefer to shut down
the receiver entirely if that's possible. For now, we'll just
Expand All @@ -300,6 +308,9 @@ void pager_draw(){
//radio_off();
}
break;
default:
printf("state=%d\n",
state);
}

}
Expand Down

0 comments on commit aea5c3d

Please sign in to comment.