]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
update
authorAnthony Minessale <anthony.minessale@gmail.com>
Tue, 5 Jun 2007 01:31:25 +0000 (01:31 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Tue, 5 Jun 2007 01:31:25 +0000 (01:31 +0000)
git-svn-id: http://svn.openzap.org/svn/openzap/trunk@210 a93c3328-9c30-0410-af19-c9cd2b2d52af

libs/openzap/src/dsp/fsk.c
libs/openzap/src/dsp/fsk.h

index 8f4dfcad057a5ef3674ba392cf84b71de521b225..a53fa81e7b9c22b22f5ba1bf00ce96f499e26ec2 100644 (file)
@@ -306,7 +306,39 @@ dsp_fsk_sample (dsp_fsk_handle_t *handle, double normalized_sample)
 
        if (handle->cellpos > 1.0) {
                handle->cellpos -= 1.0;
-               (*handle->attr.bithandler) (handle->attr.bithandler_arg, handle->current_bit);
+               
+
+               switch (handle->state) {
+               case FSK_STATE_DATA:
+                       (*handle->attr.bithandler) (handle->attr.bithandler_arg, handle->current_bit);
+                       break;
+               case FSK_STATE_CHANSEIZE:
+                       if (handle->last_bit != handle->current_bit) {
+
+
+                               handle->conscutive_state_bits++;
+                       } else {
+                               handle->conscutive_state_bits = 0;
+                       }
+                       if (handle->conscutive_state_bits > 15) {
+                               handle->state = FSK_STATE_CARRIERSIG;
+                               handle->conscutive_state_bits = 0;
+                       }
+                       break;
+               case FSK_STATE_CARRIERSIG:
+                       if (handle->current_bit) {
+                               handle->conscutive_state_bits++;
+                       } else {
+                               handle->conscutive_state_bits = 0;
+                       }
+                       if (handle->conscutive_state_bits > 15) {
+                               handle->state = FSK_STATE_DATA;
+                               handle->conscutive_state_bits = 0;
+                       }
+                       break;
+               }
+
+               handle->last_bit = handle->current_bit;
        }
 }
 
index e9cf0c0c1cd7ab011abb834daf64064fef6405e4..b494593ebf6757c55f94f9411d332784364c74af 100644 (file)
 #define        __FSK_H__
 #include "uart.h"
 
+typedef enum {
+       FSK_STATE_CHANSEIZE = 0,
+       FSK_STATE_CARRIERSIG,
+       FSK_STATE_DATA
+} fsk_state_t;
+
 typedef struct dsp_fsk_attr_s
 {
        int                                     sample_rate;                                    /* sample rate in HZ */
@@ -46,7 +52,8 @@ typedef struct dsp_fsk_attr_s
 
 typedef struct
 {
-       dsp_fsk_attr_t  attr;                                                   /* attributes structure */
+       fsk_state_t                     state;
+       dsp_fsk_attr_t          attr;                                                   /* attributes structure */
        double                          *correlates[4];                                 /* one for each of sin/cos for mark/space */
        int                                     corrsize;                                               /* correlate size (also number of samples in ring buffer) */
        double                          *buffer;                                                /* sample ring buffer */
@@ -55,8 +62,10 @@ typedef struct
        double                          celladj;                                                /* bit cell adjustment for each sample */
        int                                     previous_bit;                                   /* previous bit (for detecting a transition to sync-up cell position) */
        int                                     current_bit;                                    /* current bit */
+       int                                     last_bit;
        int                                     downsampling_count;                             /* number of samples to skip */
        int                                     current_downsample;                             /* current skip count */
+       int                                     conscutive_state_bits;                  /* number of bits in a row that matches the pattern for the current state */
 }      dsp_fsk_handle_t;
 
 /*