WXK
2023-08-10 f91c026378ada7cf97de4cc28c4e3bea38fee9b2
Src/application/dw_app.c
@@ -81,7 +81,7 @@
    SINGLEPOLL,
}tag_state=STARTPOLL;
static dwt_config_t config = {
   2,               /* Channel number. */
   5,               /* Channel number. */
   DWT_PRF_64M,     /* Pulse repetition frequency. */
   DWT_PLEN_128,    /* Preamble length. */
   DWT_PAC8,        /* Preamble acquisition chunk size. Used in RX only. */
@@ -718,7 +718,7 @@
    {
        nearbase_distlist[nearmsg_i] = 0x1ffff;
    }
//mainbase_id = 0x9818;
//mainbase_id = 0x1;
   memcpy(&tx_near_msg[ANCHOR_ID_IDX],&mainbase_id,2);
   memcpy(&tx_near_msg[TAG_ID_IDX],&dev_id,2);
   tx_near_msg[MESSAGE_TYPE_IDX] = POS_MSG;
@@ -831,11 +831,11 @@
   tx_near_msg[BATTARY_IDX] = bat_percent;
   tx_near_msg[BUTTON_IDX] = userkey_state|stationary_flag<<1|gotosleep_flag<<2|motor_flag<<5;
   tx_near_msg[SEQUENCE_IDX] = frame_seq_nb;
  tx_near_msg[SEQUENCEH_IDX] = (frame_seq_nb++)>>8;
    tx_near_msg[SEQUENCEH_IDX] = (frame_seq_nb++)>>8;
   tx_near_msg[NEARBASENUM_INDEX] = nearbase_num;
   memcpy(&tx_near_msg[NEARBASEID_INDEX],&nearbaseid_list,nearbase_num*2);
  memcpy(&tx_near_msg[NEARBASEID_INDEX+nearbase_num*2],&nearbase_distlist,nearbase_num*4+4);
  memcpy(&tx_near_msg[NEARBASEID_INDEX+nearbase_num*6+4],&rec_anc_signalpower,nearbase_num*2+2);
    memcpy(&tx_near_msg[NEARBASEID_INDEX+nearbase_num*2],&nearbase_distlist,nearbase_num*4+4);
    memcpy(&tx_near_msg[NEARBASEID_INDEX+nearbase_num*6+4],&rec_anc_signalpower,nearbase_num*2+2);
    
    if(intheight!=0)
@@ -1049,7 +1049,7 @@
         #endif
         }else if(mainbase_lost_count>5*tag_frequency)
         {
         //   tag_state = DISCPOLL;
            tag_state = DISCPOLL;
         }   
         if(mainbase_lost_count!=0)
         {
@@ -1070,9 +1070,19 @@
            {
               if( pack_index == MOTOR_ONTIME_INDEX)
               {
                       // if(motor_keeptime==0)
                        if(motor_keeptime==0)
                            motor_keeptime = rec_remotepara[3];
               }else{
               }else if( pack_index == 2*COM_INTERVAL)
                    {
                        if(memcmp(&g_com_map[COM_INTERVAL],&rec_remotepara[3],2)!=0)
                        {
                            memcpy((uint8_t*)&g_com_map + pack_index, &rec_remotepara[3], pack_length);
                            save_com_map_to_flash();
                            tag_frequency = 1000/g_com_map[COM_INTERVAL];
                            bigslot_num = TOTAL_SLOTNUM/tag_frequency;
                        }
                    }
                    else{
                        if(pack_index<200)
                        {
                            memcpy((uint8_t*)&g_com_map + pack_index, &rec_remotepara[3], pack_length);
@@ -1085,14 +1095,14 @@
               }
            }
         }
            if(get_newdist>2)
            if(get_newdist>=2)
            {
                notenoughdist_count = 0;
            }else{
                if(notenoughdist_count++>3)
                if(notenoughdist_count++>10)
                {
                    notenoughdist_count = 0;
             //       tag_state = DISCPOLL;
                    tag_state = DISCPOLL;
                }
            }
         for(i=0;i<nearbase_num;i++)
@@ -1248,6 +1258,8 @@
          //  Poll();
            break;
   }
    FZNearPoll();
    dwt_forcetrxoff();
     userkey_state = !GET_USERKEY;
   dwt_entersleep();
}