Rev 266 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 266 | Rev 381 | ||
---|---|---|---|
Line 32... | Line 32... | ||
32 | 32 | ||
33 | public byte resend_timeout=0; |
33 | public byte resend_timeout=0; |
34 | int last_count=0; |
34 | int last_count=0; |
35 | 35 | ||
36 | 36 | ||
- | 37 | ||
- | 38 | int last_fm_send=-1; |
|
37 | public boolean resend_check(int ref_count) |
39 | public boolean resend_check(int ref_count) |
38 | { |
40 | { |
39 | if (( last_count!=ref_count)||(resend_timeout<0)) |
41 | if (( last_count!=ref_count)||(resend_timeout<0)) |
40 | { |
42 | { |
41 | if (resend_timeout<0) mk.stats.resend_count++; |
43 | if (resend_timeout<0) mk.stats.resend_count++; |
Line 53... | Line 55... | ||
53 | // public final static int BASE_SLEEP=50; |
55 | // public final static int BASE_SLEEP=50; |
54 | //#else |
56 | //#else |
55 | public final static int BASE_SLEEP=10; |
57 | public final static int BASE_SLEEP=10; |
56 | //#endif |
58 | //#endif |
57 | 59 | ||
- | 60 | int intitial_paramset_try=0; |
|
58 | public void run() |
61 | public void run() |
59 | { |
62 | { |
60 | mk.log("starting Watchdog"); |
63 | mk.log("starting Watchdog"); |
61 | // get all params |
64 | // get all params |
62 | int act_debug_name=0; |
65 | int act_debug_name=0; |
Line 64... | Line 67... | ||
64 | while(true) |
67 | while(true) |
65 | { |
68 | { |
66 | try { |
69 | try { |
67 | Thread.sleep(BASE_SLEEP); |
70 | Thread.sleep(BASE_SLEEP); |
68 | // sleeper=BASE_SLEEP; |
71 | // sleeper=BASE_SLEEP; |
69 | if (mk.connected&&(!mk.force_disconnect)) |
72 | if (mk.connected&&(!mk.force_disconnect))//&&(mk.bootloader_stage==BOOTLOADER_STAGE_NONE)) |
70 | { |
73 | { |
71 | - | ||
72 | // mk.log("watchdog pre main loop"); |
74 | // // mk.log("watchdog pre main loop"); |
73 | if (mk.init_bootloader) |
75 | // if (mk.init_bootloader) |
74 | { |
76 | // { |
75 | mk.jump_bootloader(); |
77 | // mk.jump_bootloader(); |
76 | mk.init_bootloader=false; |
78 | // mk.init_bootloader=false; |
77 | } |
79 | // } |
- | 80 | //else |
|
78 | else if ( mk.version.major==-1 ) |
81 | if ( mk.version.major==-1 ) |
79 | mk.get_version(); |
82 | mk.get_version(); |
80 | else if (mk.ufo_prober.is_navi()&&(mk.error_str==null)) |
83 | else if (mk.is_navi()&&(mk.error_str==null)) |
81 | mk.get_error_str(); |
84 | mk.get_error_str(); |
82 | 85 | ||
83 | else if (mk.ufo_prober.is_mk()&&(mk.params.last_parsed_paramset==-1)) |
86 | else if (mk.is_mk()&&(mk.params.last_parsed_paramset==-1)&&(intitial_paramset_try<7)) |
84 | { |
87 | { |
85 | mk.get_params(0xFF-1); |
88 | mk.get_params(0xFF-1); |
86 | Thread.sleep(150); |
89 | Thread.sleep(150); |
87 | - | ||
- | 90 | intitial_paramset_try++; |
|
88 | act_paramset=0; // warning - if dropped problem |
91 | act_paramset=0; // warning - if dropped problem |
89 | } |
92 | } |
90 | else switch (mk.user_intent) |
93 | else switch (mk.user_intent) |
91 | { |
94 | { |
92 | case USER_INTENT_PARAMS: |
95 | case USER_INTENT_PARAMS: |
Line 163... | Line 166... | ||
163 | mk.LCD.trigger_LCD(); |
166 | mk.LCD.trigger_LCD(); |
164 | 167 | ||
165 | break; |
168 | break; |
166 | 169 | ||
167 | case USER_INTENT_GPSOSD: |
170 | case USER_INTENT_GPSOSD: |
168 | mk.set_gpsosd_interval(1); |
171 | mk.set_gpsosd_interval(mk.primary_abo); |
169 | break; |
172 | break; |
170 | case USER_INTENT_GRAPH: |
173 | case USER_INTENT_GRAPH: |
171 | mk.set_debug_interval(1); |
174 | mk.set_debug_interval(mk.primary_abo); |
- | 175 | break; |
|
- | 176 | ||
- | 177 | case USER_INTENT_FOLLOWME: |
|
- | 178 | ||
- | 179 | // once a second |
|
- | 180 | if (last_fm_send!=(System.currentTimeMillis()/1000)) |
|
- | 181 | { |
|
- | 182 | last_fm_send=(int)(System.currentTimeMillis()/1000); |
|
- | 183 | mk.send_follow_me(60); |
|
- | 184 | } |
|
- | 185 | ||
- | 186 | ||
- | 187 | ||
172 | break; |
188 | break; |
173 | 189 | ||
174 | default: |
190 | default: |
175 | // mk.log("uncactched intent " +mk.root.canvas.user_intent ); |
191 | // mk.log("uncactched intent " +mk.root.canvas.user_intent ) |
176 | break; |
192 | break; |
177 | } |
193 | } |
178 | 194 | ||
- | 195 | ||
179 | 196 | ||
180 | 197 | ||
181 | if (bytes_in_count_buff==mk.stats.bytes_in) |
198 | if (bytes_in_count_buff==mk.stats.bytes_in) |
182 | if ((conn_check_timeout++)*BASE_SLEEP>3000) |
199 | if ((conn_check_timeout++)*BASE_SLEEP>3000) |
183 | { |
200 | { |
184 | conn_check_timeout=0; |
201 | conn_check_timeout=0; |
185 | mk.close_connections(false); |
202 | mk.close_connections(false); |
186 | 203 | ||
187 | } |
204 | } |
188 | else |
205 | else |
189 | conn_check_timeout=0; |
206 | conn_check_timeout=0; |
190 | bytes_in_count_buff=mk.stats.debug_data_count; |
207 | bytes_in_count_buff=mk.stats.debug_data_count; |
191 | 208 | ||
192 | 209 | ||
193 | } |
210 | } |
194 | 211 | ||
195 | 212 | ||
196 | } // 3000 |
213 | } // 3000 |