Felícito Manzano
/
DTK_Guaria2_ABInBev
Proyecto ABInBev para la tarjeta Guaria 1/2.
Embed:
(wiki syntax)
Show/hide line numbers
fmu130_exe.cpp
Go to the documentation of this file.
00001 /** 00002 * @file fmu130_exe.cpp 00003 * @author Felícito Manzano (felicito.manzano@detektor.com.sv) 00004 * @brief 00005 * @version 0.1 00006 * @date 2020-10-03 00007 * 00008 * @copyright Copyright (c) 2020 00009 * 00010 */ 00011 00012 #include "mbed.h" 00013 #include "fmu130_exe.hpp " ////// 00014 #include "BufferedSerial.h" 00015 //#include "GT521FX.hpp" 00016 #include "New_GT521Fx.hpp " 00017 #include "jq8400_voice.hpp " 00018 #include "voice_cn_pa.hpp" 00019 #include "teltonika_fmu130.hpp " 00020 #include "fingerprint_frame.hpp " 00021 #include "avl_fmu130.hpp " 00022 #include "USBSerial.h" 00023 #include "eeprom.h" 00024 #include "flash_eeprom.h" 00025 #include "eeprom_exe.hpp" 00026 #include "flash_ee_exe.hpp " 00027 #include "custom_def.hpp " 00028 00029 00030 /** 00031 * @brief 00032 * Objetos Entradas Digitales / Seriales 00033 */ 00034 extern BufferedSerial avl_uart; 00035 extern BufferedSerial voice_uart; 00036 extern DigitalOut out1_fingerprint; 00037 extern DigitalOut out2_ble_reset; 00038 extern DigitalOut out3_gt521fx; 00039 extern DigitalOut out4_gt521fx; 00040 extern BufferedSerial fingerprint; 00041 extern USBSerial myPC_debug; 00042 extern Ticker tick_idle_shutdown; 00043 extern Ticker tick_idle_reminder; 00044 extern Ticker tick_safety_tip; 00045 extern Ticker tick_rain_sensor; 00046 extern Ticker tick_autoreset_ble; 00047 extern EEPROM ep; 00048 00049 #define DEBUG_FMU130_CPP 1 00050 #define FMU_FP_READER_GT521 1 00051 00052 /** 00053 * @brief 00054 * Variables Externas de Recepción 00055 */ 00056 extern bool rg9_raining; 00057 extern bool ignition; 00058 extern bool estado_actual_ignicion; 00059 extern char fmu130_payload[1024]; 00060 extern int fmu130_payload_type; 00061 extern int incoming_bytes; 00062 extern int temp_JQ8400_Volume; 00063 00064 /** 00065 * @brief 00066 * Variables externas de comandos AVL 00067 */ 00068 extern const char hardware_version[]; 00069 extern const char firmware_version[]; 00070 extern char avl_fmu130_header[2]; 00071 extern char avl_fmu130_imei[16]; 00072 extern int avl_fmu130_id; 00073 extern int avl_fmu130_status; 00074 00075 /** 00076 * @brief 00077 * Variables externas con comandos del lector de huellas y 00078 * funciones de habilitación 00079 */ 00080 extern int bluetooth_cmd_id; 00081 extern int fingerprint_id; 00082 extern char fingerprint_cmd[4]; 00083 extern char fingerprint_hex[997]; 00084 extern char fingerprint_asc[499]; 00085 extern bool flag_idle_force_shutdown; 00086 extern bool flag_idle_reminder; 00087 extern bool flag_fingerprint_Sleep; 00088 extern bool functionality_fingerprint_reader; 00089 extern bool fingerprint_remotly_disable; 00090 extern bool functionality_force_driver_buclke; 00091 extern bool functionality_idle_shutdown; 00092 extern bool functionality_idle_reminder; 00093 extern bool functionality_rain_sensor; 00094 extern bool functionality_seatbelt_reading; 00095 extern int wet_Speed_Limit; 00096 extern int wet_Speed_Warning; 00097 extern int dry_Speed_Limit; 00098 extern int dry_Speed_Warning; 00099 extern char wet_Speed_CMD[30]; 00100 extern char dry_Speed_CMD[30]; 00101 extern bool flag_query_rain_sensor; 00102 extern bool flag_safety_tip_enable; 00103 extern bool functionality_safety_tip; 00104 extern float time_safety_tip; 00105 extern float time_sample_rain; 00106 extern bool fingerprint_override; 00107 extern int fp_override_limit; 00108 extern bool functionality_geo_warning; 00109 extern bool functionality_rainSensor_silentMode; 00110 extern bool functionality_ble_autoreset; 00111 extern float time_ble_autoreset; 00112 extern bool finterprint_flag_working; 00113 extern bool fingerprint_flag_poweroff; 00114 // Cinturones 00115 extern bool pilot_buckle_type; 00116 extern int pilot_buckleUp; 00117 extern int pilot_unfasten; 00118 extern bool copilot_buckle_type; 00119 extern int copilot_buckleUp; 00120 extern int copilot_unfasten; 00121 extern bool crew_buckle_type; 00122 extern int crew_buckleUp; 00123 extern int crew_unfasten; 00124 00125 00126 // Variables de flash 00127 extern uint16_t VirtAddVarTab[]; 00128 extern uint16_t VarDataTab[]; 00129 extern uint32_t eprom_AddressArray[]; 00130 extern const bool external_eeprom; 00131 00132 /** 00133 * @brief 00134 * Variables locales 00135 */ 00136 const char TCA_ID_FP_WORKING_STATUS[] = "TCA|111|"; 00137 const char TCA_ID_FP_SERVER_ADD[] = "TCA|112|"; 00138 const char TCA_ID_FP_ENROLL_CNT[] = "TCA|114|"; 00139 const char TCA_ID_FP_SERVER_DEL[] = "TCA|115|"; 00140 const char TCA_ID_IDLE_SHUTDOWN[] = "TCA|123|"; 00141 const char TCA_ID_FORCE_SEATBELT[] = "TCA|126|"; 00142 const char TCA_ID_FORCE_IDLE_SHUTDOWN[] = "TCA|127|"; 00143 const char TCA_ID_RAIN_SENSOR_ENA[] = "TCA|128|"; 00144 const char TCA_ID_SEATBELT_READ_ENA[] = "TCA|129|"; 00145 const char TCA_ID_VOLUME_SET[] = "TCA|130|"; 00146 const char TCA_ID_QUERY_SPEED_LIMIT[] = "TCA|131|"; 00147 const char TCA_ID_QUERY_IDLE_TIMER[] = "TCA|132|"; 00148 const char TCA_ID_IDLE_REMINDER[] = "TCA|133|2"; 00149 const char TCA_ID_IDLE_REMINDER_ENA[] = "TCA|133|1"; 00150 const char TCA_ID_IDLE_REMINDER_DIS[] = "TCA|133|0"; 00151 const char TCA_ID_SAFETY_TIP_REMINDER[] = "TCA|134|2"; 00152 const char TCA_ID_SAFETY_TIP_ENABLE[] = "TCA|134|1"; 00153 const char TCA_ID_SAFETY_TIP_DISABLE[] = "TCA|134|0"; 00154 const char TCA_ID_QUERY_SAFETY_TIP[] = "TCA|136|"; 00155 const char TCA_ID_Q_FINGERPRINT_STATUS[] = "TCA|137|"; 00156 const char TCA_ID_Q_RAINSENSOR_STATUS[] = "TCA|138|"; 00157 const char TCA_ID_Q_IDLE_SHUTDOWN_ST[] = "TCA|139|"; 00158 const char TCA_ID_Q_FORCE_SEATBELT_ST[] = "TCA|140|"; 00159 const char TCA_ID_Q_VOLUME_LEVEL[] = "TCA|141|"; 00160 const char TCA_ID_CHECK_ENROLLED_ID[] = "TCA|142|"; 00161 const char TCA_ID_HARDWARE_VERSION[] = "TCA|143|"; 00162 const char TCA_ID_FIRMWARE_VERSION[] = "TCA|144|"; 00163 const char TCA_ID_DIN_CONFIGURATION[] = "TCA|145|"; 00164 const char TCA_ID_Q_RAIN_SAMPLE_TIMER[] = "TCA|146|"; 00165 const char TCA_ID_FP_OVERRIDE_ENABLE[] = "TCA|147|1"; 00166 const char TCA_ID_FP_OVERRIDE_DISABLE[] = "TCA|147|0"; 00167 const char TCA_ID_Q_FP_OVERRIDE[] = "TCA|148|"; 00168 const char TCA_ID_GEO_WARNING_DISABLE[] = "TCA|135|0"; 00169 const char TCA_ID_GEO_WARNING_ENABLE[] = "TCA|135|1"; 00170 const char TCA_ID_GEO_WARNING_QUERY_OFF[] = "TCA|135|2"; 00171 const char TCA_ID_GEO_WARNING_QUERY_ON[] = "TCA|135|3"; 00172 const char TCA_ID_GEO_WARNING_GETIN[] = "TCA|151|0;"; 00173 const char TCA_ID_GEO_WARNING_EVENT[] = "TCA|151|1;"; 00174 const char TCA_ID_GEO_WARNING_GETOUT[] = "TCA|151|2;"; 00175 const char TCA_ID_RAIN_SILENT_MODE_ENA[] = "TCA|152|1"; 00176 const char TCA_ID_RAIN_SILENT_MODE_DIS[] = "TCA|152|0"; 00177 const char TCA_ID_RAIN_SILENT_MODE_Q[] = "TCA|153|"; 00178 const char TCA_ID_BLE_AUTORESET_DIS[] = "TCA|155|0"; 00179 const char TCA_ID_BLE_AUTORESET_ENA[] = "TCA|155|1"; 00180 const char TCA_ID_BLE_AUTORESET_qDIS[] = "TCA|156|0,"; 00181 const char TCA_ID_BLE_AUTORESET_qENA[] = "TCA|156|1,"; 00182 const char TCA_ID_IDLE_REMINDER_TIME[] = "TCA|158|"; 00183 // cinturones individuales 00184 const char TCA_ID_PILOT_BUCKLE_NO[] = "TCA|145|2"; 00185 const char TCA_ID_PILOT_BUCKLE_NC[] = "TCA|145|3"; 00186 const char TCA_ID_COPILOT_BUCKLE_NO[] = "TCA|145|4"; 00187 const char TCA_ID_COPILOT_BUCKLE_NC[] = "TCA|145|5"; 00188 const char TCA_ID_CREW_BUCKLE_NO[] = "TCA|145|6"; 00189 const char TCA_ID_CREW_BUCKLE_NC[] = "TCA|145|7"; 00190 // Comandos 00191 const char FMU_ENGINE_LOCK[] = "setdigout 0?? ? ? ? ? ? ?"; 00192 const char FMU_ENGINE_UNLOCK[] = "setdigout 1?? ? ? ? ? ? ?"; 00193 char fmu_buffer[64]; 00194 // Otras 00195 long longitud_huella = 498; 00196 bool trama_con_huella = false; 00197 float wait_idle_shutdown; 00198 float wait_idle_reminder; 00199 int tipo_trama_entrante = 0; 00200 int resultado = 0; 00201 int consultar_ID_FP = 0; 00202 int enrolado = -1; 00203 int id_geozone = 0; 00204 00205 // Variables externas 00206 extern const char hardware_version[]; 00207 extern const char firmware_version[]; 00208 extern const char release_date[]; 00209 00210 00211 00212 /** 00213 * @brief 00214 * 00215 */ 00216 void activate_idle_shutdown() { 00217 flag_idle_force_shutdown = true; 00218 } 00219 00220 void activate_idle_reminder() { 00221 flag_idle_reminder = true; 00222 } 00223 00224 void queryRG9(){ 00225 flag_query_rain_sensor = true; 00226 } 00227 00228 void BLE_reset() { // Aplicar reset a módulo BLE 00229 out2_ble_reset = true; 00230 #ifdef DEBUG_FMU130_CPP 00231 myPC_debug.printf("\r\nBLE - Reset\r\n"); 00232 #endif 00233 wait_ms(BLE_RESET_PULSE_WIDTH); 00234 out2_ble_reset = false; 00235 } 00236 00237 00238 /** 00239 * @brief 00240 * 00241 */ 00242 void exe_idle_shutdown() { 00243 flag_idle_force_shutdown = false; 00244 tick_idle_shutdown.detach(); 00245 if (functionality_idle_shutdown) { 00246 if (ignition) { 00247 tx_fmu130_command(FMU_ENGINE_LOCK, &avl_uart); 00248 jq8400_addQueue (VOICE_IDLE_ENGINE_SHUTDOWN); 00249 sprintf(fmu_buffer, "%s1", TCA_ID_IDLE_SHUTDOWN); 00250 tx_fmu130_message (fmu_buffer, &avl_uart); 00251 #ifdef DEBUG_FMU130_CPP 00252 myPC_debug.printf("IDLE - Apagado por exceso de Ralenti\r\n"); 00253 myPC_debug.printf("%s\r\n", fmu_buffer); 00254 #endif 00255 } else { 00256 #ifdef DEBUG_FMU130_CPP 00257 myPC_debug.printf("IDLE - Ignicion OFF - No se envia apagado.\r\n"); 00258 #endif 00259 } 00260 } 00261 } 00262 00263 void exe_idle_reminder() { 00264 flag_idle_reminder = false; 00265 jq8400_addQueue (VOICE_IDLE_REMINDER); 00266 sprintf(fmu_buffer, "%s", TCA_ID_IDLE_REMINDER); 00267 tx_fmu130_message (fmu_buffer, &avl_uart); 00268 #ifdef DEBUG_FMU130_CPP 00269 myPC_debug.printf("IDLE - Recordatorio por exceso de Ralenti\r\n"); 00270 myPC_debug.printf("%s\r\n", fmu_buffer); 00271 #endif 00272 } 00273 00274 /** 00275 * @brief 00276 * 00277 */ 00278 void boot_message() { 00279 sprintf(fmu_buffer, "TCA|100|%s", firmware_version); 00280 tx_fmu130_message (fmu_buffer, &avl_uart); 00281 #ifdef DEBUG_FMU130_CPP 00282 myPC_debug.printf("\r\n\r\nDETEKTOR I+D. TEAM CAPTURA\r\n"); 00283 myPC_debug.printf("Proyecto ABInBev PA\r\n"); 00284 myPC_debug.printf("Version %s - %s\r\n\r\n", firmware_version, release_date); 00285 myPC_debug.printf("%s\r\n", fmu_buffer); 00286 #endif 00287 } 00288 00289 00290 /** 00291 * @brief 00292 * 00293 */ 00294 void process_FMU130 () { 00295 memset(fmu_buffer, '\0', sizeof(fmu_buffer)); 00296 memset(fmu130_payload, '\0', sizeof(fmu130_payload)); 00297 00298 /** 00299 * @brief 00300 * 00301 */ 00302 incoming_bytes = read_avl_uart (&avl_uart, fmu130_payload); 00303 00304 if (incoming_bytes > 0) { 00305 #ifdef DEBUG_FMU130_CPP 00306 myPC_debug.printf("\r\nBLE - Bytes entrantes: %d\r\n", incoming_bytes); 00307 #endif 00308 tipo_trama_entrante = identify_fmu130_payload (fmu130_payload); 00309 00310 /** 00311 * @brief Construct a new switch object 00312 * 00313 */ 00314 switch (tipo_trama_entrante) { 00315 case TRAMA_AVL_FMU130 : 00316 #ifdef DEBUG_FMU130_CPP 00317 myPC_debug.printf("BLE - Evento AVL\r\n"); 00318 #endif 00319 if (verify_fmu130_payload (fmu130_payload)) { 00320 parse_fmu130_payload (fmu130_payload, avl_fmu130_header, avl_fmu130_imei, &avl_fmu130_id, &avl_fmu130_status); 00321 #ifdef DEBUG_FMU130_CPP 00322 myPC_debug.printf("BLE - FMU_ID:%d Status:%d\r\n", avl_fmu130_id, avl_fmu130_status); 00323 #endif 00324 switch (avl_fmu130_id) { 00325 case AVLID_OVERSPEED: // Exceso de velocidad 00326 if (rg9_raining) { 00327 if (functionality_rainSensor_silentMode) { 00328 #ifdef DEBUG_FMU130_CPP 00329 myPC_debug.printf("BLE - Modo Silencioso Activado - No se notifica\r\n"); 00330 #endif 00331 // 00332 } else { 00333 jq8400_addQueue (VOICE_OVERSPEED_ALERT_WET); 00334 } 00335 } else { 00336 jq8400_addQueue (VOICE_OVERSPEED_ALERT); 00337 } 00338 break; 00339 00340 case AVLID_TOWING: // Movimiento ilegal 00341 // No se notifica 00342 #ifdef DEBUG_FMU130_CPP 00343 myPC_debug.printf("BLE - Vehiculo en Grua - No se notifica\r\n"); 00344 #endif 00345 break; 00346 00347 case AVLID_JAMMING: // Jamming 00348 #ifdef DEBUG_FMU130_CPP 00349 myPC_debug.printf("BLE - Deteccion de Jamming - No se notifica\r\n"); 00350 #endif 00351 break; 00352 00353 case AVLID_IDLE: // Ralentí 00354 if (avl_fmu130_status == 1) { 00355 if (estado_actual_ignicion) { 00356 jq8400_addQueue (VOICE_IDLE_TIME_WARNING); 00357 if (functionality_idle_shutdown) { 00358 tick_idle_shutdown.attach(&activate_idle_shutdown, (wait_idle_shutdown + 6.0)); // 6.0 = Duración de audio de ralentí 00359 #ifdef DEBUG_FMU130_CPP 00360 myPC_debug.printf("Apagar por ralenti en %.1f seg.\r\n", wait_idle_shutdown); 00361 #endif 00362 } 00363 if (functionality_idle_reminder) { 00364 tick_idle_reminder.attach(&activate_idle_reminder,(wait_idle_reminder + 0.0)); 00365 #ifdef DEBUG_FMU130_CPP 00366 myPC_debug.printf("Recordatorio por ralenti en %.1f seg.\r\n", wait_idle_reminder); 00367 #endif 00368 } 00369 } else { 00370 #ifdef DEBUG_FMU130_CPP 00371 myPC_debug.printf("BLE - Ignicion OFF no se notifica\r\n"); 00372 #endif 00373 } 00374 } else if (avl_fmu130_status == 0) { 00375 tick_idle_shutdown.detach(); 00376 tick_idle_reminder.detach(); 00377 } 00378 break; 00379 00380 case AVLID_HARSH_BEHAVIOUR: // Hábitos de manejo 00381 if (avl_fmu130_status == 1){ 00382 jq8400_addQueue (VOICE_HARSH_ACCELERATION); 00383 } else if (avl_fmu130_status == 2) { 00384 jq8400_addQueue (VOICE_HARSH_BREAKING); 00385 } else if (avl_fmu130_status == 3) { 00386 jq8400_addQueue (VOICE_SHARP_CORNERING); 00387 } 00388 break; 00389 00390 case AVLID_WARNING_SPEED: // Pre alerta de Exceso de velocidad 00391 if (rg9_raining) { 00392 if (functionality_rainSensor_silentMode) { 00393 #ifdef DEBUG_FMU130_CPP 00394 myPC_debug.printf("BLE - Modo Silencioso Activado - No se notifica\r\n"); 00395 #endif 00396 } else { 00397 jq8400_addQueue (VOICE_WARNING_OVERSPEED_WET); 00398 } 00399 } else { 00400 jq8400_addQueue (VOICE_WARNING_OVERSPEED); 00401 } 00402 break; 00403 00404 case AVLID_CRASH: // Colisión 00405 jq8400_addQueue (VOICE_CRASH_DETECTION); 00406 break; 00407 00408 default: 00409 // ID no identificado 00410 break; 00411 } 00412 00413 } else { 00414 // Trama invalida 00415 } 00416 break; 00417 00418 00419 case TRAMA_SERVIDOR: 00420 #ifdef DEBUG_FMU130_CPP 00421 myPC_debug.printf("BLE - Comando Servidor\r\n"); 00422 myPC_debug.printf("RAW DATA:\r\n%s\r\n\r\n", fmu130_payload); 00423 #endif 00424 if (verify_finger_payload (fmu130_payload)) { 00425 /* DESHABILITADA LA FUNCIÓN DE SLEEP EN EL LECTOR 00426 if (flag_fingerprint_Sleep) { 00427 fingerprint.WakeUp(); 00428 flag_fingerprint_Sleep = false; 00429 //myPC_debug.printf("BLE - GT521Fx@WakeUp\r\n"); 00430 } 00431 */ 00432 trama_con_huella = parse_finger_payload (fmu130_payload, fingerprint_cmd, &fingerprint_id, fingerprint_hex); 00433 if (trama_con_huella) { 00434 fingerprint_HEX2CHAR (fingerprint_hex, fingerprint_asc); 00435 #ifdef DEBUG_FMU130_CPP 00436 myPC_debug.printf("BLE - Huella HEX:\r\n%s\r\n", fingerprint_hex); 00437 #endif 00438 } 00439 bluetooth_cmd_id = identify_server_cmd (fingerprint_cmd); 00440 00441 switch (bluetooth_cmd_id) { 00442 /** ******************************** 00443 * COMANDOS DE NOTIFICACION DE GEOCERCAS 00444 * ******************************** */ 00445 case CMD_GEO_WARNING_GETIN: 00446 #ifdef DEBUG_FMU130_CPP 00447 myPC_debug.printf("BLE - Notificacion de Entrada a Geocerca Controlada\r\n"); 00448 #endif 00449 // 00450 if (functionality_geo_warning) { 00451 id_geozone = fingerprint_id; 00452 jq8400_addQueue (id_geozone); 00453 sprintf(fmu_buffer, "%s%d", TCA_ID_GEO_WARNING_GETIN, id_geozone); 00454 tx_fmu130_message (fmu_buffer, &avl_uart); 00455 #ifdef DEBUG_FMU130_CPP 00456 myPC_debug.printf("%s\r\n", fmu_buffer); 00457 #endif 00458 } else { 00459 #ifdef DEBUG_FMU130_CPP 00460 myPC_debug.printf("BLE - Funcion deshabilitada. No se notifica Entrada de Geocerca\r\n"); 00461 #endif 00462 } 00463 break; 00464 00465 case CMD_GEO_WARNING_GETOUT: 00466 #ifdef DEBUG_FMU130_CPP 00467 myPC_debug.printf("BLE - Notificacion de Salida de Geocerca Controlada\r\n"); 00468 #endif 00469 if (functionality_geo_warning) { 00470 id_geozone = fingerprint_id; 00471 jq8400_addQueue (id_geozone); 00472 sprintf(fmu_buffer, "%s%d", TCA_ID_GEO_WARNING_GETOUT, id_geozone); 00473 tx_fmu130_message (fmu_buffer, &avl_uart); 00474 #ifdef DEBUG_FMU130_CPP 00475 myPC_debug.printf("%s\r\n", fmu_buffer); 00476 #endif 00477 } else { 00478 #ifdef DEBUG_FMU130_CPP 00479 myPC_debug.printf("BLE - Funcion deshabilitada. No se notifica Salida de Geocerca\r\n"); 00480 #endif 00481 } 00482 break; 00483 00484 case CMD_GEO_WARNING_EVENT: 00485 #ifdef DEBUG_FMU130_CPP 00486 00487 #endif 00488 //myPC_debug.printf("BLE - Notificacion de Evento en Geocerca Controlada\r\n"); 00489 if (functionality_geo_warning) { 00490 id_geozone = fingerprint_id; 00491 jq8400_addQueue (id_geozone); 00492 sprintf(fmu_buffer, "%s%d", TCA_ID_GEO_WARNING_EVENT, id_geozone); 00493 #ifdef DEBUG_FMU130_CPP 00494 00495 #endif 00496 //myPC_debug.printf("%s\r\n", fmu_buffer); 00497 tx_fmu130_message (fmu_buffer, &avl_uart); 00498 00499 } else { 00500 #ifdef DEBUG_FMU130_CPP 00501 00502 #endif 00503 //myPC_debug.printf("BLE - Funcion deshabilitada. No se notifica Evento de Geocerca\r\n"); 00504 } 00505 break; 00506 00507 00508 00509 /** ******************************** 00510 * COMANDOS DE LECTOR DE HUELLA 00511 * ******************************** */ 00512 case CMD_FINGER_ADD: 00513 out3_gt521fx = out4_gt521fx = finterprint_flag_working = true; 00514 wait_us(500000); 00515 #ifdef DEBUG_FMU130_CPP 00516 myPC_debug.printf("BLE - OUT3:TRUE\r\n"); 00517 #endif 00518 fingerprint_flag_poweroff = false; 00519 #if FMU_FP_READER_GT521 == 1 00520 FP_Open(); 00521 resultado = FP_SetTemplate(fingerprint_id, fingerprint_asc); 00522 FP_Close(); 00523 #else 00524 #endif 00525 wait_us(1000000); 00526 if (resultado == 0) { 00527 sprintf(fmu_buffer, "%s%d", TCA_ID_FP_SERVER_ADD, fingerprint_id); 00528 tx_fmu130_message (fmu_buffer, &avl_uart); 00529 #ifdef DEBUG_FMU130_CPP 00530 myPC_debug.printf("BLE - Huella agregada exitosamente\r\n"); 00531 myPC_debug.printf("%s\r\n", fmu_buffer); 00532 #endif 00533 } else { 00534 sprintf(fmu_buffer, "%s%d", TCA_ID_FP_SERVER_ADD, resultado); 00535 tx_fmu130_message (fmu_buffer, &avl_uart); 00536 #ifdef DEBUG_FMU130_CPP 00537 myPC_debug.printf("BLE - Error al agregar huella\r\n"); 00538 myPC_debug.printf("%s\r\n", fmu_buffer); 00539 #endif 00540 } 00541 fingerprint_flag_poweroff = true; 00542 #ifdef DEBUG_FMU130_CPP 00543 myPC_debug.printf("BLE - Pendiente apagar FP GT521Fx...\r\n"); 00544 #endif 00545 break; 00546 00547 case CMD_FINGER_DELETE: 00548 out3_gt521fx = out4_gt521fx = finterprint_flag_working = true; 00549 wait_us(500000); 00550 #ifdef DEBUG_FMU130_CPP 00551 myPC_debug.printf("BLE - OUT3:TRUE\r\n"); 00552 #endif 00553 fingerprint_flag_poweroff = false; 00554 #if FMU_FP_READER_GT521 == 1 00555 FP_Open(); 00556 #else 00557 #endif 00558 if (fingerprint_id == 3000) { 00559 #if FMU_FP_READER_GT521 == 1 00560 resultado = FP_DeleteAll(); 00561 #else 00562 #endif 00563 } else { 00564 #if FMU_FP_READER_GT521 == 1 00565 resultado = FP_DeleteID(fingerprint_id); 00566 #else 00567 #endif 00568 } 00569 if (resultado >= 0) { 00570 sprintf(fmu_buffer, "%s%d", TCA_ID_FP_SERVER_DEL, fingerprint_id); 00571 tx_fmu130_message (fmu_buffer, &avl_uart); 00572 #ifdef DEBUG_FMU130_CPP 00573 myPC_debug.printf("BLE - Huella eliminada exitosamente\r\n"); 00574 myPC_debug.printf("%s\r\n", fmu_buffer); 00575 #endif 00576 } else { 00577 sprintf(fmu_buffer, "%s%d", TCA_ID_FP_SERVER_DEL, resultado); 00578 tx_fmu130_message (fmu_buffer, &avl_uart); 00579 #ifdef DEBUG_FMU130_CPP 00580 myPC_debug.printf("BLE - Error al eliminar huella\r\n"); 00581 myPC_debug.printf("%s\r\n", fmu_buffer); 00582 #endif 00583 } 00584 #if FMU_FP_READER_GT521 == 1 00585 FP_Close(); 00586 #else 00587 #endif 00588 wait_us(1000000); 00589 fingerprint_flag_poweroff = true; 00590 #ifdef DEBUG_FMU130_CPP 00591 myPC_debug.printf("BLE - Pendiente apagar FP GT521Fx...\r\n"); 00592 #endif 00593 break; 00594 00595 case CMD_FINGER_ENABLE: 00596 jq8400_addQueue (VOICE_functionality_fingerprint_reader); 00597 functionality_fingerprint_reader = true; 00598 fingerprint_remotly_disable = false; 00599 if (external_eeprom) { 00600 ep.write(eprom_AddressArray[EE_Address_FINGERPRINT], ((uint16_t) true)); 00601 ep.write(eprom_AddressArray[EE_Address_FINGERPRINT_RE], ((uint16_t) false)); 00602 } else { 00603 EE_WriteVariable(VirtAddVarTab[AP_FINGERPRINT], ((uint16_t) true)); 00604 EE_WriteVariable(VirtAddVarTab[AP_FINGERPRINT_RE], ((uint16_t) false)); 00605 } 00606 sprintf(fmu_buffer, "%s1", TCA_ID_FP_WORKING_STATUS); 00607 tx_fmu130_message (fmu_buffer, &avl_uart); 00608 #if FMU_FP_READER_GT521 == 1 00609 FP_Flush(); 00610 #else 00611 #endif 00612 #ifdef DEBUG_FMU130_CPP 00613 myPC_debug.printf("BLE - Lector Huella Habilitado\r\n"); 00614 myPC_debug.printf("%s\r\n", fmu_buffer); 00615 #endif 00616 break; 00617 00618 case CMD_FINGER_DISABLE: 00619 jq8400_addQueue (VOICE_FINGERPRINT_DISABLE); 00620 tx_fmu130_command(FMU_ENGINE_UNLOCK, &avl_uart); 00621 out1_fingerprint = 1; 00622 wait_us(1000000); 00623 out1_fingerprint = 0; 00624 functionality_fingerprint_reader = false; 00625 fingerprint_remotly_disable = true; 00626 if (external_eeprom) { 00627 ep.write(eprom_AddressArray[EE_Address_FINGERPRINT], ((uint16_t) false)); 00628 ep.write(eprom_AddressArray[EE_Address_FINGERPRINT_RE], ((uint16_t) true)); 00629 } else { 00630 EE_WriteVariable(VirtAddVarTab[AP_FINGERPRINT], ((uint16_t) false)); 00631 EE_WriteVariable(VirtAddVarTab[AP_FINGERPRINT_RE], ((uint16_t) true)); 00632 } 00633 sprintf(fmu_buffer, "%s0", TCA_ID_FP_WORKING_STATUS); 00634 tx_fmu130_message (fmu_buffer, &avl_uart); 00635 #ifdef DEBUG_FMU130_CPP 00636 myPC_debug.printf("BLE - Lector Huella Deshabilitado\r\n"); 00637 myPC_debug.printf("%s\r\n", fmu_buffer); 00638 #endif 00639 break; 00640 00641 case CMD_FINGERPRINT_QUERY: 00642 sprintf(fmu_buffer, "%s%d", TCA_ID_Q_FINGERPRINT_STATUS, functionality_fingerprint_reader); 00643 tx_fmu130_message (fmu_buffer, &avl_uart); 00644 #ifdef DEBUG_FMU130_CPP 00645 myPC_debug.printf("BLE - Consulta Estatus del Lector Biometrico\r\n"); 00646 myPC_debug.printf("BLE - Lector Biometrico: %d\r\n", functionality_fingerprint_reader); 00647 myPC_debug.printf("%s\r\n", fmu_buffer); 00648 #endif 00649 break; 00650 00651 case CMD_FINGER_ENROLL_CNT: 00652 out3_gt521fx = out4_gt521fx = finterprint_flag_working = true; 00653 wait_us(500000); 00654 #ifdef DEBUG_FMU130_CPP 00655 myPC_debug.printf("BLE - OUT3:TRUE\r\n"); 00656 #endif 00657 fingerprint_flag_poweroff = false; 00658 #if FMU_FP_READER_GT521 == 1 00659 FP_Open(); 00660 resultado = FP_GetEnrollCount(); 00661 FP_Close(); 00662 #else 00663 #endif 00664 wait_us(1000000); 00665 sprintf(fmu_buffer, "%s%d", TCA_ID_FP_ENROLL_CNT, resultado); 00666 tx_fmu130_message (fmu_buffer, &avl_uart); 00667 fingerprint_flag_poweroff = true; 00668 #ifdef DEBUG_FMU130_CPP 00669 myPC_debug.printf("%s\r\n", fmu_buffer); 00670 myPC_debug.printf("BLE - Pendiente apagar FP GT521Fx...\r\n"); 00671 #endif 00672 break; 00673 00674 case CMD_CHECK_ENROLLED_ID: 00675 out3_gt521fx = out4_gt521fx = finterprint_flag_working= true; 00676 fingerprint_flag_poweroff = false; 00677 consultar_ID_FP = fingerprint_id; 00678 wait_us(500000); 00679 #ifdef DEBUG_FMU130_CPP 00680 myPC_debug.printf("BLE - OUT3:TRUE\r\n"); 00681 myPC_debug.printf("BLE - Consulta de Posicion de Memoria - Lector de Huellas\r\n"); 00682 #endif 00683 #if FMU_FP_READER_GT521 == 1 00684 FP_Open(); 00685 enrolado = FP_CheckEnrolled(consultar_ID_FP); 00686 FP_Close(); 00687 #else 00688 #endif 00689 wait_us(1000000); 00690 sprintf(fmu_buffer, "%s%d", TCA_ID_CHECK_ENROLLED_ID, enrolado); 00691 tx_fmu130_message (fmu_buffer, &avl_uart); 00692 fingerprint_flag_poweroff = true; 00693 #ifdef DEBUG_FMU130_CPP 00694 myPC_debug.printf("BLE - Posicion de huella %d: %d\r\n", consultar_ID_FP, enrolado); 00695 myPC_debug.printf("%s\r\n", fmu_buffer); 00696 myPC_debug.printf("BLE - Pendiente apagar FP GT521Fx...\r\n"); 00697 #endif 00698 break; 00699 00700 case CMD_FP_OVERRIDE_ENABLE: 00701 fingerprint_override = true; 00702 if (external_eeprom) { 00703 ep.write(eprom_AddressArray[EE_Address_OVERRIDE_FP], ((uint16_t) true)); 00704 } else { 00705 EE_WriteVariable(VirtAddVarTab[AP_OVERRIDE_FP], ((uint16_t) true)); 00706 } 00707 sprintf(fmu_buffer, "%s", TCA_ID_FP_OVERRIDE_ENABLE); 00708 tx_fmu130_message (fmu_buffer, &avl_uart); 00709 #ifdef DEBUG_FMU130_CPP 00710 myPC_debug.printf("BLE - Habilitar Anulacion de Lector de Huella\r\n"); 00711 myPC_debug.printf("%s\r\n", fmu_buffer); 00712 #endif 00713 break; 00714 00715 case CMD_FP_OVERRIDE_DISABLE: 00716 fingerprint_override = false; 00717 if (external_eeprom) { 00718 ep.write(eprom_AddressArray[EE_Address_OVERRIDE_FP], ((uint16_t) false)); 00719 } else { 00720 EE_WriteVariable(VirtAddVarTab[AP_OVERRIDE_FP], ((uint16_t) false)); 00721 } 00722 sprintf(fmu_buffer, "%s", TCA_ID_FP_OVERRIDE_DISABLE); 00723 tx_fmu130_message (fmu_buffer, &avl_uart); 00724 #ifdef DEBUG_FMU130_CPP 00725 myPC_debug.printf("BLE - Deshabilitar Anulacion de Lector de Huella\r\n"); 00726 myPC_debug.printf("%s\r\n", fmu_buffer); 00727 #endif 00728 break; 00729 00730 case CMD_FP_OVERRIDE_COUNT: 00731 if (external_eeprom) { 00732 ep.write(eprom_AddressArray[EE_Address_OVERRIDE_LIMIT], ((uint16_t) fingerprint_id)); 00733 } else { 00734 EE_WriteVariable(VirtAddVarTab[AP_OVERRIDE_QT], ((uint16_t) fingerprint_id)); 00735 } 00736 fp_override_limit = fingerprint_id; 00737 sprintf(fmu_buffer, "%s%d,%d", TCA_ID_Q_FP_OVERRIDE, fingerprint_override, fp_override_limit); 00738 tx_fmu130_message (fmu_buffer, &avl_uart); 00739 #ifdef DEBUG_FMU130_CPP 00740 myPC_debug.printf("BLE - Cambio Muestras para Anulacion de Lector de Huella\n"); 00741 myPC_debug.printf("BLE - Nuevo valor de Huellas no Autorizadas: %d seg\r\n", fingerprint_id); 00742 myPC_debug.printf("%s\r\n", fmu_buffer); 00743 #endif 00744 break; 00745 00746 case CMD_FP_OVERRIDE_QUERY: 00747 sprintf(fmu_buffer, "%s%d,%d", TCA_ID_Q_FP_OVERRIDE, fingerprint_override, fp_override_limit); 00748 tx_fmu130_message (fmu_buffer, &avl_uart); 00749 #ifdef DEBUG_FMU130_CPP 00750 myPC_debug.printf("BLE - Consulta por Anulacion de Lector de Huella\r\n"); 00751 myPC_debug.printf("BLE - Anulacion: %s\r\n", fingerprint_override?"TRUE":"FALSE"); 00752 myPC_debug.printf("BLE - Cantidad de No Autorizados: %d\r\n", fp_override_limit); 00753 myPC_debug.printf("%s\r\n", fmu_buffer); 00754 #endif 00755 break; 00756 00757 00758 /** ******************************** 00759 * COMANDOS DE PARLANTE 00760 * ******************************** */ 00761 case CMD_SET_VOLUME: 00762 temp_JQ8400_Volume = fingerprint_id; 00763 if (external_eeprom) { 00764 ep.write(eprom_AddressArray[EE_Address_VOLUME], ((uint16_t) temp_JQ8400_Volume)); 00765 } else { 00766 EE_WriteVariable(VirtAddVarTab[AP_VOLUME], ((uint16_t) temp_JQ8400_Volume)); 00767 } 00768 jq8400_setVol (&temp_JQ8400_Volume, &voice_uart); 00769 sprintf(fmu_buffer, "%s%d", TCA_ID_VOLUME_SET, fingerprint_id); 00770 tx_fmu130_message (fmu_buffer, &avl_uart); 00771 #ifdef DEBUG_FMU130_CPP 00772 myPC_debug.printf("BLE - Volumen %d\r\n",fingerprint_id); 00773 myPC_debug.printf("%s\r\n", fmu_buffer); 00774 #endif 00775 break; 00776 00777 case CMD_QUERY_VOLUME_LEVEL: 00778 sprintf(fmu_buffer, "%s%d", TCA_ID_Q_VOLUME_LEVEL, temp_JQ8400_Volume); 00779 tx_fmu130_message (fmu_buffer, &avl_uart); 00780 #ifdef DEBUG_FMU130_CPP 00781 myPC_debug.printf("BLE - Consulta por el Nivel de Volumen del Parlante\r\n"); 00782 myPC_debug.printf("BLE - Nivel de Volumen del Parlante: %d\r\n", temp_JQ8400_Volume); 00783 myPC_debug.printf("%s\r\n", fmu_buffer); 00784 #endif 00785 break; 00786 00787 /** ******************************** 00788 * COMANDOS DE SENSOR DE LLUVIA 00789 * ******************************** */ 00790 case CMD_RAIN_ENABLE: 00791 functionality_rain_sensor = true; 00792 if (external_eeprom) { 00793 ep.write(eprom_AddressArray[EE_Address_RAINSENSOR], ((uint16_t) true)); 00794 } else { 00795 EE_WriteVariable(VirtAddVarTab[AP_RAINSENSOR], ((uint16_t) true)); 00796 } 00797 tick_rain_sensor.detach(); 00798 sprintf(fmu_buffer, "%s%d", TCA_ID_RAIN_SENSOR_ENA, 1); 00799 tx_fmu130_message (fmu_buffer, &avl_uart); 00800 tick_rain_sensor.attach(&queryRG9, time_sample_rain); 00801 #ifdef DEBUG_FMU130_CPP 00802 myPC_debug.printf("BLE - Sensor de Lluvia Habilitado\r\n"); 00803 myPC_debug.printf("%s\r\n", fmu_buffer); 00804 #endif 00805 break; 00806 00807 case CMD_RAIN_DISABLE: 00808 functionality_rain_sensor = false; 00809 if (external_eeprom) { 00810 ep.write(eprom_AddressArray[EE_Address_RAINSENSOR], ((uint16_t) false)); 00811 } else { 00812 EE_WriteVariable(VirtAddVarTab[AP_RAINSENSOR], ((uint16_t) false)); 00813 } 00814 tick_rain_sensor.detach(); 00815 sprintf(fmu_buffer, "%s%d", TCA_ID_RAIN_SENSOR_ENA, 0); 00816 tx_fmu130_message (fmu_buffer, &avl_uart); 00817 tx_fmu130_var_command(dry_Speed_CMD, &avl_uart); 00818 #ifdef DEBUG_FMU130_CPP 00819 myPC_debug.printf("BLE - Sensor de Lluvia Deshabilitado\r\n"); 00820 myPC_debug.printf("%s\r\n", fmu_buffer); 00821 #endif 00822 break; 00823 00824 case CMD_RAIN_QUERY: 00825 sprintf(fmu_buffer, "%s%d", TCA_ID_Q_RAINSENSOR_STATUS, functionality_rain_sensor); 00826 tx_fmu130_message (fmu_buffer, &avl_uart); 00827 #ifdef DEBUG_FMU130_CPP 00828 myPC_debug.printf("BLE - Consulta Estatus del Sensor de Lluvia\r\n"); 00829 myPC_debug.printf("BLE - Sensor de Lluvia: %d\r\n", functionality_rain_sensor); 00830 myPC_debug.printf("%s\r\n", fmu_buffer); 00831 #endif 00832 break; 00833 00834 case CMD_CHANGE_RAIN_TIMER: 00835 if (external_eeprom) { 00836 ep.write(eprom_AddressArray[EE_Address_RS_SAMPLE_T], ((uint16_t) fingerprint_id)); 00837 } else { 00838 EE_WriteVariable(VirtAddVarTab[AP_RS_SAMPLE_T], ((uint16_t) fingerprint_id)); 00839 } 00840 time_sample_rain = fingerprint_id * 1.0; 00841 if (functionality_rain_sensor) { 00842 tick_rain_sensor.detach(); 00843 tick_rain_sensor.attach(&queryRG9, time_sample_rain); 00844 } 00845 sprintf(fmu_buffer, "%s%.1f", TCA_ID_Q_RAIN_SAMPLE_TIMER, time_sample_rain); 00846 tx_fmu130_message (fmu_buffer, &avl_uart); 00847 #ifdef DEBUG_FMU130_CPP 00848 myPC_debug.printf("BLE - Cambio Temp. de Muestras para Sensor de Lluvia\n"); 00849 myPC_debug.printf("BLE - Nuevo Temp. para muestreo: %d seg\r\n", fingerprint_id); 00850 myPC_debug.printf("%s\r\n", fmu_buffer); 00851 #endif 00852 break; 00853 00854 case CMD_QUERY_RAIN_TIMER: 00855 sprintf(fmu_buffer, "%s%.1f", TCA_ID_Q_RAIN_SAMPLE_TIMER, time_sample_rain); 00856 tx_fmu130_message (fmu_buffer, &avl_uart); 00857 #ifdef DEBUG_FMU130_CPP 00858 myPC_debug.printf("BLE - Consulta por Temp. de Muestras para Sensor de Lluvia\r\n"); 00859 myPC_debug.printf("BLE - Muestras en: %.1f seg\r\n", time_sample_rain); 00860 myPC_debug.printf("%s\r\n", fmu_buffer); 00861 #endif 00862 break; 00863 00864 case CMD_RAIN_SILENT_MODE_ENA: 00865 functionality_rainSensor_silentMode = true; 00866 if (external_eeprom) { 00867 ep.write(eprom_AddressArray[EE_Address_RS_SILENTMODE], ((uint16_t) true)); 00868 } else { 00869 EE_WriteVariable(VirtAddVarTab[AP_RS_SILENTMODE], ((uint16_t) true)); 00870 } 00871 sprintf(fmu_buffer, "%s", TCA_ID_RAIN_SILENT_MODE_ENA); 00872 tx_fmu130_message (fmu_buffer, &avl_uart); 00873 tx_fmu130_var_command(dry_Speed_CMD, &avl_uart); 00874 #ifdef DEBUG_FMU130_CPP 00875 myPC_debug.printf("BLE - Habilitar Modo silencioso de Sensor de Lluvia\r\n"); 00876 myPC_debug.printf("%s\r\n", fmu_buffer); 00877 #endif 00878 break; 00879 00880 00881 case CMD_RAIN_SILENT_MODE_DIS: 00882 functionality_rainSensor_silentMode = false; 00883 if (external_eeprom) { 00884 ep.write(eprom_AddressArray[EE_Address_RS_SILENTMODE], ((uint16_t) false)); 00885 } else { 00886 EE_WriteVariable(VirtAddVarTab[AP_RS_SILENTMODE], ((uint16_t) false)); 00887 } 00888 sprintf(fmu_buffer, "%s", TCA_ID_RAIN_SILENT_MODE_DIS); 00889 tx_fmu130_message (fmu_buffer, &avl_uart); 00890 #ifdef DEBUG_FMU130_CPP 00891 myPC_debug.printf("BLE - Deshabilitar Modo silencioso de Sensor de Lluvia\r\n"); 00892 myPC_debug.printf("%s\r\n", fmu_buffer); 00893 #endif 00894 break; 00895 00896 case CMD_RAIN_SILENT_MODE_Q: 00897 sprintf(fmu_buffer, "%s%d", TCA_ID_RAIN_SILENT_MODE_Q, functionality_rainSensor_silentMode); 00898 tx_fmu130_message (fmu_buffer, &avl_uart); 00899 #ifdef DEBUG_FMU130_CPP 00900 myPC_debug.printf("BLE - Consulta por Modo silencioso de Sensor de Lluvia\r\n"); 00901 myPC_debug.printf("BLE - Modo silencioso: %s\r\n", functionality_rainSensor_silentMode?"TRUE":"FALSE"); 00902 myPC_debug.printf("%s\r\n", fmu_buffer); 00903 #endif 00904 break; 00905 00906 case CMD_CHANGE_WSL: 00907 wet_Speed_Limit = fingerprint_id; 00908 if (external_eeprom) { 00909 ep.write(eprom_AddressArray[EE_Address_WET_LIMIT], ((uint16_t) wet_Speed_Limit)); 00910 } else { 00911 EE_WriteVariable(VirtAddVarTab[AP_WET_LIMIT], ((uint16_t) wet_Speed_Limit)); 00912 } 00913 sprintf(wet_Speed_CMD, "setparam 50092:%d", wet_Speed_Limit); 00914 tx_fmu130_var_command(wet_Speed_CMD, &avl_uart); 00915 #ifdef DEBUG_FMU130_CPP 00916 myPC_debug.printf("BLE - Cambio Limite velocidad Mojado\r\n"); 00917 myPC_debug.printf("BLE - Nuevo Limite: %d\r\n", wet_Speed_Limit); 00918 myPC_debug.printf("%s\r\n", fmu_buffer); 00919 #endif 00920 sprintf(fmu_buffer, "%s%d,%d,%d,%d", TCA_ID_QUERY_SPEED_LIMIT, 00921 wet_Speed_Warning, wet_Speed_Limit, dry_Speed_Warning, dry_Speed_Limit); 00922 tx_fmu130_message (fmu_buffer, &avl_uart); 00923 #ifdef DEBUG_FMU130_CPP 00924 myPC_debug.printf("%s\r\n", fmu_buffer); 00925 #endif 00926 break; 00927 00928 case CMD_CHANGE_WSW: 00929 wet_Speed_Warning = fingerprint_id; 00930 if (external_eeprom) { 00931 ep.write(eprom_AddressArray[EE_Address_WET_WARNING], ((uint16_t) wet_Speed_Warning)); 00932 } else { 00933 EE_WriteVariable(VirtAddVarTab[AP_WET_WARNING], ((uint16_t) wet_Speed_Warning)); 00934 } 00935 sprintf(wet_Speed_CMD, "setparam 11104:%d", wet_Speed_Warning); 00936 tx_fmu130_var_command(wet_Speed_CMD, &avl_uart); 00937 #ifdef DEBUG_FMU130_CPP 00938 myPC_debug.printf("BLE - Cambio Limite advertencia Mojado\r\n"); 00939 myPC_debug.printf("BLE - Nueva advertencia: %d\r\n", wet_Speed_Warning); 00940 myPC_debug.printf("%s\r\n", fmu_buffer); 00941 #endif 00942 sprintf(fmu_buffer, "%s%d,%d,%d,%d", TCA_ID_QUERY_SPEED_LIMIT, 00943 wet_Speed_Warning, wet_Speed_Limit, dry_Speed_Warning, dry_Speed_Limit); 00944 tx_fmu130_message (fmu_buffer, &avl_uart); 00945 #ifdef DEBUG_FMU130_CPP 00946 myPC_debug.printf("%s\r\n", fmu_buffer); 00947 #endif 00948 break; 00949 00950 case CMD_CHANGE_DSL: 00951 dry_Speed_Limit = fingerprint_id; 00952 if (external_eeprom) { 00953 ep.write(eprom_AddressArray[EE_Address_DRY_LIMIT], ((uint16_t) dry_Speed_Limit)); 00954 } else { 00955 EE_WriteVariable(VirtAddVarTab[AP_DRY_LIMIT], ((uint16_t) dry_Speed_Limit)); 00956 } 00957 sprintf(dry_Speed_CMD, "setparam 50092:%d", dry_Speed_Limit); 00958 tx_fmu130_var_command(dry_Speed_CMD, &avl_uart); 00959 #ifdef DEBUG_FMU130_CPP 00960 myPC_debug.printf("BLE - Cambio Limite velocidad Seco\r\n"); 00961 myPC_debug.printf("BLE - Nuevo Limite: %d\r\n", dry_Speed_Limit); 00962 myPC_debug.printf("%s\r\n", fmu_buffer); 00963 #endif 00964 sprintf(fmu_buffer, "%s%d,%d,%d,%d", TCA_ID_QUERY_SPEED_LIMIT, 00965 wet_Speed_Warning, wet_Speed_Limit, dry_Speed_Warning, dry_Speed_Limit); 00966 tx_fmu130_message (fmu_buffer, &avl_uart); 00967 #ifdef DEBUG_FMU130_CPP 00968 myPC_debug.printf("%s\r\n", fmu_buffer); 00969 #endif 00970 break; 00971 00972 case CMD_CHANGE_DSW: 00973 dry_Speed_Warning = fingerprint_id; 00974 if (external_eeprom) { 00975 ep.write(eprom_AddressArray[EE_Address_DRY_WARNING], ((uint16_t) dry_Speed_Warning)); 00976 } else { 00977 EE_WriteVariable(VirtAddVarTab[AP_DRY_WARNING], ((uint16_t) dry_Speed_Warning)); 00978 } 00979 sprintf(dry_Speed_CMD, "setparam 11104:%d", dry_Speed_Warning); 00980 tx_fmu130_var_command(dry_Speed_CMD, &avl_uart); 00981 #ifdef DEBUG_FMU130_CPP 00982 myPC_debug.printf("BLE - Cambio Limite advertencia Seco\r\n"); 00983 myPC_debug.printf("BLE - Nueva advertencia: %d\r\n", dry_Speed_Warning); 00984 myPC_debug.printf("%s\r\n", fmu_buffer); 00985 #endif 00986 sprintf(fmu_buffer, "%s%d,%d,%d,%d", TCA_ID_QUERY_SPEED_LIMIT, 00987 wet_Speed_Warning, wet_Speed_Limit, dry_Speed_Warning, dry_Speed_Limit); 00988 tx_fmu130_message (fmu_buffer, &avl_uart); 00989 #ifdef DEBUG_FMU130_CPP 00990 myPC_debug.printf("%s\r\n", fmu_buffer); 00991 #endif 00992 break; 00993 00994 case CMD_QUERY_SPEED_LIMIT: 00995 sprintf(fmu_buffer, "%s%d,%d,%d,%d", TCA_ID_QUERY_SPEED_LIMIT, 00996 wet_Speed_Warning, wet_Speed_Limit, dry_Speed_Warning, dry_Speed_Limit); 00997 tx_fmu130_message (fmu_buffer, &avl_uart); 00998 #ifdef DEBUG_FMU130_CPP 00999 myPC_debug.printf("BLE - Consulta Limites Velocidad\r\n"); 01000 myPC_debug.printf("BLE - Mojado Advertencia: %d, Limite: %d\r\n", wet_Speed_Warning, wet_Speed_Limit); 01001 myPC_debug.printf("BLE - Seco Advertencia: %d, Limite: %d\r\n", dry_Speed_Warning, dry_Speed_Limit); 01002 myPC_debug.printf("%s\r\n", fmu_buffer); 01003 #endif 01004 break; 01005 01006 01007 01008 /** ******************************** 01009 * COMANDOS DE CINTURONES 01010 * ******************************** */ 01011 case CMD_SEATBELT_ENABLE: 01012 functionality_seatbelt_reading = true; 01013 if (external_eeprom) { 01014 ep.write(eprom_AddressArray[EE_Address_SEATBELT_READ], ((uint16_t) true)); 01015 } else { 01016 EE_WriteVariable(VirtAddVarTab[AP_SEATBELT_READ], ((uint16_t) true)); 01017 } 01018 sprintf(fmu_buffer, "%s%d", TCA_ID_SEATBELT_READ_ENA, 1); 01019 tx_fmu130_message (fmu_buffer, &avl_uart); 01020 #ifdef DEBUG_FMU130_CPP 01021 myPC_debug.printf("BLE - Lectura Cinturones Habilitado\r\n"); 01022 myPC_debug.printf("%s\r\n", fmu_buffer); 01023 #endif 01024 break; 01025 01026 case CMD_SEATBELT_DISABLE: 01027 functionality_seatbelt_reading = false; 01028 if (external_eeprom) { 01029 ep.write(eprom_AddressArray[EE_Address_SEATBELT_READ], ((uint16_t) false)); 01030 } else { 01031 EE_WriteVariable(VirtAddVarTab[AP_SEATBELT_READ], ((uint16_t) false)); 01032 } 01033 sprintf(fmu_buffer, "%s%d", TCA_ID_SEATBELT_READ_ENA, 0); 01034 tx_fmu130_message (fmu_buffer, &avl_uart); 01035 #ifdef DEBUG_FMU130_CPP 01036 myPC_debug.printf("BLE - Lectura Cinturones Deshabilitado\r\n"); 01037 myPC_debug.printf("%s\r\n", fmu_buffer); 01038 #endif 01039 break; 01040 01041 case CMD_SEATBELT_QUERY: 01042 sprintf(fmu_buffer, "%s%d", TCA_ID_SEATBELT_READ_ENA, functionality_force_driver_buclke); 01043 tx_fmu130_message (fmu_buffer, &avl_uart); 01044 #ifdef DEBUG_FMU130_CPP 01045 myPC_debug.printf("BLE - Consulta Estado de Lectura de Cinturones\r\n"); 01046 myPC_debug.printf("BLE - Lectura de Cinturones: %s\r\n", functionality_force_driver_buclke?"TRUE":"FALSE"); 01047 myPC_debug.printf("%s\r\n", fmu_buffer); 01048 #endif 01049 break; 01050 01051 case CMD_FORCE_BUCLKE_ENABLE: 01052 functionality_force_driver_buclke = true; 01053 functionality_seatbelt_reading = true; 01054 if (external_eeprom) { 01055 ep.write(eprom_AddressArray[EE_Address_SEATBELT_READ], ((uint16_t) true)); 01056 ep.write(eprom_AddressArray[EE_Address_ENFORCE_SB], ((uint16_t) true)); 01057 } else { 01058 EE_WriteVariable(VirtAddVarTab[AP_SEATBELT_READ], ((uint16_t) true)); 01059 EE_WriteVariable(VirtAddVarTab[AP_ENFORCE_SB], ((uint16_t) true)); 01060 } 01061 sprintf(fmu_buffer, "%s%d", TCA_ID_FORCE_SEATBELT, 1); 01062 tx_fmu130_message (fmu_buffer, &avl_uart); 01063 #ifdef DEBUG_FMU130_CPP 01064 myPC_debug.printf("BLE - Forzar Cinturon de Piloto Habilitado\r\n"); 01065 myPC_debug.printf("%s\r\n", fmu_buffer); 01066 #endif 01067 break; 01068 01069 case CMD_FORCE_BUCLKE_DISABLE: 01070 tx_fmu130_command(FMU_ENGINE_UNLOCK, &avl_uart); 01071 out1_fingerprint = 1; 01072 wait_us(1000000); 01073 out1_fingerprint = 0; 01074 functionality_force_driver_buclke = false; 01075 if (external_eeprom) { 01076 ep.write(eprom_AddressArray[EE_Address_ENFORCE_SB], ((uint16_t) false)); 01077 } else { 01078 EE_WriteVariable(VirtAddVarTab[AP_ENFORCE_SB], ((uint16_t) false)); 01079 } 01080 sprintf(fmu_buffer, "%s%d", TCA_ID_FORCE_SEATBELT, 0); 01081 tx_fmu130_message (fmu_buffer, &avl_uart); 01082 #ifdef DEBUG_FMU130_CPP 01083 myPC_debug.printf("BLE - Forzar Cinturon de Piloto Deshabilitado\r\n"); 01084 myPC_debug.printf("%s\r\n", fmu_buffer); 01085 #endif 01086 break; 01087 01088 case CMD_QUERY_FORCE_SEATBELT: 01089 sprintf(fmu_buffer, "%s%d", TCA_ID_Q_FORCE_SEATBELT_ST, functionality_force_driver_buclke); 01090 tx_fmu130_message (fmu_buffer, &avl_uart); 01091 #ifdef DEBUG_FMU130_CPP 01092 myPC_debug.printf("BLE - Consulta Estatus para Forzar Cinturon de Piloto\r\n"); 01093 myPC_debug.printf("BLE - Forzar Cinturon de Piloto: %d\r\n", functionality_force_driver_buclke); 01094 myPC_debug.printf("%s\r\n", fmu_buffer); 01095 #endif 01096 break; 01097 01098 case CMD_SET_INPUT_NORMAL_O: // CONFIGURACIÓN DE LIVIANO y Cinturón Chino 01099 #ifdef DEBUG_FMU130_CPP 01100 myPC_debug.printf("BLE - Entradas como Normalmente Abierta\r\n"); 01101 #endif 01102 if (external_eeprom) { 01103 ep.write(eprom_AddressArray[EE_Address_PILOT_BTYPE], ((uint16_t) true)); 01104 ep.write(eprom_AddressArray[EE_Address_COPILOT_BTYPE], ((uint16_t) true)); 01105 ep.write(eprom_AddressArray[EE_Address_CREW_BTYPE], ((uint16_t) true)); 01106 } else { 01107 EE_WriteVariable(VirtAddVarTab[AP_PILOT_BTYPE], ((uint16_t) true)); 01108 EE_WriteVariable(VirtAddVarTab[AP_COPILOT_BTYPE], ((uint16_t) true)); 01109 EE_WriteVariable(VirtAddVarTab[AP_CREW_BTYPE], ((uint16_t) true)); 01110 } 01111 pilot_buckle_type = copilot_buckle_type = crew_buckle_type = true; // HONDURAS 01112 pilot_buckleUp = copilot_buckleUp = crew_buckleUp = 1; 01113 pilot_unfasten = copilot_unfasten = crew_unfasten = -1; 01114 sprintf(fmu_buffer, "%s", TCA_ID_PILOT_BUCKLE_NO); 01115 tx_fmu130_message (fmu_buffer, &avl_uart); 01116 sprintf(fmu_buffer, "%s", TCA_ID_COPILOT_BUCKLE_NO); 01117 tx_fmu130_message (fmu_buffer, &avl_uart); 01118 sprintf(fmu_buffer, "%s", TCA_ID_CREW_BUCKLE_NO); 01119 tx_fmu130_message (fmu_buffer, &avl_uart); 01120 break; 01121 01122 case CMD_SET_INPUT_NORMAL_C: // CONFIGURACIÓN DE CAMIÓN 01123 #ifdef DEBUG_FMU130_CPP 01124 myPC_debug.printf("BLE - Entradas como Normalmente Cerradas\r\n"); 01125 #endif 01126 pilot_buckle_type = copilot_buckle_type = crew_buckle_type = false; // PANAMA 01127 if (external_eeprom) { 01128 ep.write(eprom_AddressArray[EE_Address_PILOT_BTYPE], ((uint16_t) false)); 01129 ep.write(eprom_AddressArray[EE_Address_COPILOT_BTYPE], ((uint16_t) false)); 01130 ep.write(eprom_AddressArray[EE_Address_CREW_BTYPE], ((uint16_t) false)); 01131 } else { 01132 EE_WriteVariable(VirtAddVarTab[AP_PILOT_BTYPE], ((uint16_t) false)); 01133 EE_WriteVariable(VirtAddVarTab[AP_COPILOT_BTYPE], ((uint16_t) false)); 01134 EE_WriteVariable(VirtAddVarTab[AP_CREW_BTYPE], ((uint16_t) false)); 01135 } 01136 pilot_buckleUp = copilot_buckleUp = crew_buckleUp = -1; 01137 pilot_unfasten = copilot_unfasten = crew_unfasten = 1; 01138 sprintf(fmu_buffer, "%s", TCA_ID_PILOT_BUCKLE_NC); 01139 tx_fmu130_message (fmu_buffer, &avl_uart); 01140 sprintf(fmu_buffer, "%s", TCA_ID_COPILOT_BUCKLE_NC); 01141 tx_fmu130_message (fmu_buffer, &avl_uart); 01142 sprintf(fmu_buffer, "%s", TCA_ID_CREW_BUCKLE_NC); 01143 tx_fmu130_message (fmu_buffer, &avl_uart); 01144 break; 01145 01146 case CMD_QUERY_DIN_CONFIG: 01147 #ifdef DEBUG_FMU130_CPP 01148 myPC_debug.printf("BLE - Consulta por DIN Config.\r\n"); 01149 #endif 01150 01151 if (pilot_buckle_type) { 01152 sprintf(fmu_buffer, "%s", TCA_ID_PILOT_BUCKLE_NO); 01153 tx_fmu130_message (fmu_buffer, &avl_uart); 01154 #ifdef DEBUG_FMU130_CPP 01155 myPC_debug.printf("%s\r\n", "BLE - Cinturon de Piloto: NO"); 01156 #endif 01157 } else { 01158 sprintf(fmu_buffer, "%s", TCA_ID_PILOT_BUCKLE_NC); 01159 tx_fmu130_message (fmu_buffer, &avl_uart); 01160 #ifdef DEBUG_FMU130_CPP 01161 myPC_debug.printf("%s\r\n", "BLE - Cinturon de Piloto: NC"); 01162 #endif 01163 } 01164 01165 if (copilot_buckle_type) { 01166 sprintf(fmu_buffer, "%s", TCA_ID_COPILOT_BUCKLE_NO); 01167 tx_fmu130_message (fmu_buffer, &avl_uart); 01168 #ifdef DEBUG_FMU130_CPP 01169 myPC_debug.printf("%s\r\n", "BLE - Cinturon de Copiloto: NO"); 01170 #endif 01171 } else { 01172 sprintf(fmu_buffer, "%s", TCA_ID_COPILOT_BUCKLE_NC); 01173 tx_fmu130_message (fmu_buffer, &avl_uart); 01174 #ifdef DEBUG_FMU130_CPP 01175 myPC_debug.printf("%s\r\n", "BLE - Cinturon de Copiloto: NC"); 01176 #endif 01177 } 01178 01179 if (crew_buckle_type) { 01180 sprintf(fmu_buffer, "%s", TCA_ID_CREW_BUCKLE_NO); 01181 tx_fmu130_message (fmu_buffer, &avl_uart); 01182 #ifdef DEBUG_FMU130_CPP 01183 myPC_debug.printf("%s\r\n", "BLE - Cinturon de Tripulante: NO"); 01184 #endif 01185 } else { 01186 sprintf(fmu_buffer, "%s", TCA_ID_CREW_BUCKLE_NC); 01187 tx_fmu130_message (fmu_buffer, &avl_uart); 01188 #ifdef DEBUG_FMU130_CPP 01189 myPC_debug.printf("%s\r\n", "BLE - Cinturon de Tripulante: NC"); 01190 #endif 01191 } 01192 break; 01193 01194 case CMD_PILOT_BUCKLE_NO: // CONFIGURACIÓN DE LIVIANO y Cinturón Chino 01195 pilot_buckle_type = true; // HONDURAS 01196 if (external_eeprom) { 01197 ep.write(eprom_AddressArray[EE_Address_PILOT_BTYPE], ((uint16_t) true)); 01198 } else { 01199 EE_WriteVariable(VirtAddVarTab[AP_PILOT_BTYPE], ((uint16_t) true)); 01200 } 01201 pilot_buckleUp = 1; 01202 pilot_unfasten = -1; 01203 sprintf(fmu_buffer, "%s", TCA_ID_PILOT_BUCKLE_NO); 01204 tx_fmu130_message (fmu_buffer, &avl_uart); 01205 #ifdef DEBUG_FMU130_CPP 01206 myPC_debug.printf("BLE - Cambio Config. Cinturon de Piloto: NO\r\n"); 01207 myPC_debug.printf("%s\r\n", fmu_buffer); 01208 #endif 01209 break; 01210 01211 case CMD_PILOT_BUCKLE_NC: // CONFIGURACIÓN DE CAMIÓN 01212 pilot_buckle_type = false; // PANAMA 01213 if (external_eeprom) { 01214 ep.write(eprom_AddressArray[EE_Address_PILOT_BTYPE], ((uint16_t) false)); 01215 } else { 01216 EE_WriteVariable(VirtAddVarTab[AP_PILOT_BTYPE], ((uint16_t) false)); 01217 } 01218 pilot_buckleUp = -1; 01219 pilot_unfasten = 1; 01220 sprintf(fmu_buffer, "%s", TCA_ID_PILOT_BUCKLE_NC); 01221 tx_fmu130_message (fmu_buffer, &avl_uart); 01222 #ifdef DEBUG_FMU130_CPP 01223 myPC_debug.printf("BLE - Cambio Config. Cinturon de Piloto: NC\r\n"); 01224 myPC_debug.printf("%s\r\n", fmu_buffer); 01225 #endif 01226 break; 01227 01228 case CMD_QUERY_PILOT_BT: 01229 if (pilot_buckle_type) { 01230 sprintf(fmu_buffer, "%s", TCA_ID_PILOT_BUCKLE_NO); 01231 } else { 01232 sprintf(fmu_buffer, "%s", TCA_ID_PILOT_BUCKLE_NC); 01233 } 01234 tx_fmu130_message (fmu_buffer, &avl_uart); 01235 #ifdef DEBUG_FMU130_CPP 01236 myPC_debug.printf("BLE - Consulta por Config. Cinturon de Piloto\r\n"); 01237 myPC_debug.printf("BLE - Cinturon Piloto Tipo: %s\r\n", pilot_buckle_type?"N. OPEN":"N. CLOSE"); 01238 myPC_debug.printf("%s\r\n", fmu_buffer); 01239 #endif 01240 break; 01241 01242 case CMD_COPILOT_BUCKLE_NO: // CONFIGURACIÓN DE LIVIANO y Cinturón Chino 01243 copilot_buckle_type = true; // HONDURAS 01244 if (external_eeprom) { 01245 ep.write(eprom_AddressArray[EE_Address_COPILOT_BTYPE], ((uint16_t) true)); 01246 } else { 01247 EE_WriteVariable(VirtAddVarTab[AP_COPILOT_BTYPE], ((uint16_t) true)); 01248 } 01249 copilot_buckleUp = 1; 01250 copilot_unfasten = -1; 01251 sprintf(fmu_buffer, "%s", TCA_ID_COPILOT_BUCKLE_NO); 01252 tx_fmu130_message (fmu_buffer, &avl_uart); 01253 #ifdef DEBUG_FMU130_CPP 01254 myPC_debug.printf("BLE - Cambio Config. Cinturon de Copiloto: NO\r\n"); 01255 myPC_debug.printf("%s\r\n", fmu_buffer); 01256 #endif 01257 break; 01258 01259 case CMD_COPILOT_BUCKLE_NC: // CONFIGURACIÓN DE CAMIÓN 01260 copilot_buckle_type = false; // PANAMA 01261 if (external_eeprom) { 01262 ep.write(eprom_AddressArray[EE_Address_COPILOT_BTYPE], ((uint16_t) false)); 01263 } else { 01264 EE_WriteVariable(VirtAddVarTab[AP_COPILOT_BTYPE], ((uint16_t) false)); 01265 } 01266 copilot_buckleUp = -1; 01267 copilot_unfasten = 1; 01268 sprintf(fmu_buffer, "%s", TCA_ID_COPILOT_BUCKLE_NC); 01269 tx_fmu130_message (fmu_buffer, &avl_uart); 01270 #ifdef DEBUG_FMU130_CPP 01271 myPC_debug.printf("BLE - Cambio Config. Cinturon de Copiloto: NC\r\n"); 01272 myPC_debug.printf("%s\r\n", fmu_buffer); 01273 #endif 01274 break; 01275 01276 case CMD_QUERY_COPILOT_BT: 01277 if (copilot_buckle_type) { 01278 sprintf(fmu_buffer, "%s", TCA_ID_COPILOT_BUCKLE_NO); 01279 } else { 01280 sprintf(fmu_buffer, "%s", TCA_ID_COPILOT_BUCKLE_NC); 01281 } 01282 tx_fmu130_message (fmu_buffer, &avl_uart); 01283 #ifdef DEBUG_FMU130_CPP 01284 myPC_debug.printf("BLE - Consulta por Config. Cinturon de Copiloto\r\n"); 01285 myPC_debug.printf("BLE - Cinturon Copiloto Tipo: %s\r\n", copilot_buckle_type?"N. OPEN":"N. CLOSE"); 01286 myPC_debug.printf("%s\r\n", fmu_buffer); 01287 #endif 01288 break; 01289 01290 case CMD_CREW_BUCKLE_NO: // CONFIGURACIÓN DE LIVIANO y Cinturón Chino 01291 crew_buckle_type = true; // HONDURAS 01292 if (external_eeprom) { 01293 ep.write(eprom_AddressArray[EE_Address_CREW_BTYPE], ((uint16_t) true)); 01294 } else { 01295 EE_WriteVariable(VirtAddVarTab[AP_CREW_BTYPE], ((uint16_t) true)); 01296 } 01297 crew_buckleUp = 1; 01298 crew_unfasten = -1; 01299 sprintf(fmu_buffer, "%s", TCA_ID_CREW_BUCKLE_NO); 01300 tx_fmu130_message (fmu_buffer, &avl_uart); 01301 #ifdef DEBUG_FMU130_CPP 01302 myPC_debug.printf("BLE - Cambio Config. Cinturon de Tripulante: NO\r\n"); 01303 myPC_debug.printf("%s\r\n", fmu_buffer); 01304 #endif 01305 break; 01306 01307 case CMD_CREW_BUCKLE_NC: // CONFIGURACIÓN DE CAMIÓN 01308 crew_buckle_type = false; // PANAMA 01309 if (external_eeprom) { 01310 ep.write(eprom_AddressArray[EE_Address_CREW_BTYPE], ((uint16_t) false)); 01311 } else { 01312 EE_WriteVariable(VirtAddVarTab[AP_CREW_BTYPE], ((uint16_t) false)); 01313 } 01314 crew_buckleUp = -1; 01315 crew_unfasten = 1; 01316 sprintf(fmu_buffer, "%s", TCA_ID_CREW_BUCKLE_NC); 01317 tx_fmu130_message (fmu_buffer, &avl_uart); 01318 #ifdef DEBUG_FMU130_CPP 01319 myPC_debug.printf("BLE - Cambio Config. Cinturon de Tripulante: NC\r\n"); 01320 myPC_debug.printf("%s\r\n", fmu_buffer); 01321 #endif 01322 break; 01323 01324 case CMD_QUERY_CREW_BT: 01325 if (crew_buckle_type) { 01326 sprintf(fmu_buffer, "%s", TCA_ID_CREW_BUCKLE_NO); 01327 } else { 01328 sprintf(fmu_buffer, "%s", TCA_ID_CREW_BUCKLE_NC); 01329 } 01330 tx_fmu130_message (fmu_buffer, &avl_uart); 01331 #ifdef DEBUG_FMU130_CPP 01332 myPC_debug.printf("BLE - Consulta por Config. Cinturon de Tripulante\r\n"); 01333 myPC_debug.printf("BLE - Cinturon Tripulante Tipo: %s\r\n", crew_buckle_type?"N. OPEN":"N. CLOSE"); 01334 myPC_debug.printf("%s\r\n", fmu_buffer); 01335 #endif 01336 break; 01337 01338 01339 01340 /** ******************************** 01341 * COMANDOS DE APAGADO POR RALENTI 01342 * ******************************** */ 01343 case CMD_IDLE_SHUTDOWN_ENABLE: 01344 functionality_idle_shutdown = true; 01345 if (external_eeprom) { 01346 ep.write(eprom_AddressArray[EE_Address_IDLE_SHUTDOWN], ((uint16_t) true)); 01347 } else { 01348 EE_WriteVariable(VirtAddVarTab[AP_IDLE_SHUTDOWN], ((uint16_t) true)); 01349 } 01350 sprintf(fmu_buffer, "%s%d", TCA_ID_FORCE_IDLE_SHUTDOWN, 1); 01351 tx_fmu130_message (fmu_buffer, &avl_uart); 01352 #ifdef DEBUG_FMU130_CPP 01353 myPC_debug.printf("BLE - Apagado por Ralenti Habilitado\r\n"); 01354 myPC_debug.printf("%s\r\n", fmu_buffer); 01355 #endif 01356 break; 01357 01358 case CMD_IDLE_SHUTDOWN_DISABLE: 01359 functionality_idle_shutdown = false; 01360 if (external_eeprom) { 01361 ep.write(eprom_AddressArray[EE_Address_IDLE_SHUTDOWN], ((uint16_t) false)); 01362 } else { 01363 EE_WriteVariable(VirtAddVarTab[AP_IDLE_SHUTDOWN], ((uint16_t) false)); 01364 } 01365 tick_idle_shutdown.detach(); 01366 sprintf(fmu_buffer, "%s%d", TCA_ID_FORCE_IDLE_SHUTDOWN, 0); 01367 tx_fmu130_message (fmu_buffer, &avl_uart); 01368 #ifdef DEBUG_FMU130_CPP 01369 myPC_debug.printf("BLE - Apagado por Ralenti Deshabilitado\r\n"); 01370 myPC_debug.printf("%s\r\n", fmu_buffer); 01371 #endif 01372 break; 01373 01374 case CMD_IDLE_SHUTDOWN_QUERY: 01375 sprintf(fmu_buffer, "%s%d", TCA_ID_Q_IDLE_SHUTDOWN_ST, functionality_idle_shutdown); 01376 tx_fmu130_message (fmu_buffer, &avl_uart); 01377 #ifdef DEBUG_FMU130_CPP 01378 myPC_debug.printf("BLE - Consulta Estatus de Apagado por Ralenti\r\n"); 01379 myPC_debug.printf("BLE - Apagado por Ralenti: %s\r\n", functionality_idle_shutdown?"TRUE":"FALSE"); 01380 myPC_debug.printf("%s\r\n", fmu_buffer); 01381 #endif 01382 break; 01383 01384 case CMD_CHANGE_IDLE_SHUTDOWN_T: 01385 if (external_eeprom) { 01386 ep.write(eprom_AddressArray[EE_Address_IDLE_S_TIME], ((uint16_t) fingerprint_id)); 01387 } else { 01388 EE_WriteVariable(VirtAddVarTab[AP_IDLE_S_TIME], ((uint16_t) fingerprint_id)); 01389 } 01390 wait_idle_shutdown = fingerprint_id * 1.0; 01391 sprintf(fmu_buffer, "%s%.1f", TCA_ID_QUERY_IDLE_TIMER, wait_idle_shutdown); 01392 tx_fmu130_message (fmu_buffer, &avl_uart); 01393 #ifdef DEBUG_FMU130_CPP 01394 myPC_debug.printf("BLE - Cambio Temp. de Apagado Ralenti\r\n"); 01395 myPC_debug.printf("BLE - Nuevo Temp. Ralendi: %d seg\r\n", fingerprint_id); 01396 myPC_debug.printf("%s\r\n", fmu_buffer); 01397 #endif 01398 break; 01399 01400 case CMD_QUERY_IDLE_SHUTDOWN_T: 01401 sprintf(fmu_buffer, "%s%.1f", TCA_ID_QUERY_IDLE_TIMER, wait_idle_shutdown); 01402 tx_fmu130_message (fmu_buffer, &avl_uart); 01403 #ifdef DEBUG_FMU130_CPP 01404 myPC_debug.printf("BLE - Consulta Temp. de Apagado Ralenti\r\n"); 01405 myPC_debug.printf("BLE - Apagado Ralenti en %.1f seg\r\n", wait_idle_shutdown); 01406 myPC_debug.printf("%s\r\n", fmu_buffer); 01407 #endif 01408 break; 01409 01410 01411 /** ******************************** 01412 * COMANDOS DE RECORDATORIO DE RALENTI 01413 * ******************************** */ 01414 case CMD_IDLE_REMINDER_ENABLE: 01415 functionality_idle_reminder = true; 01416 if (external_eeprom) { 01417 ep.write(eprom_AddressArray[EE_Address_IDLE_REMINDER], ((uint16_t) true)); 01418 } else { 01419 EE_WriteVariable(VirtAddVarTab[AP_IDLE_REMINDER], ((uint16_t) true)); 01420 } 01421 sprintf(fmu_buffer, "%s", TCA_ID_IDLE_REMINDER_ENA); 01422 tx_fmu130_message (fmu_buffer, &avl_uart); 01423 #ifdef DEBUG_FMU130_CPP 01424 myPC_debug.printf("BLE - Recordatorio por Ralenti Habilitado\r\n"); 01425 myPC_debug.printf("%s\r\n", fmu_buffer); 01426 #endif 01427 break; 01428 01429 case CMD_IDLE_REMINDER_DISABLE: 01430 functionality_idle_reminder = false; 01431 if (external_eeprom) { 01432 ep.write(eprom_AddressArray[EE_Address_IDLE_REMINDER], ((uint16_t) false)); 01433 } else { 01434 EE_WriteVariable(VirtAddVarTab[AP_IDLE_REMINDER], ((uint16_t) false)); 01435 } 01436 sprintf(fmu_buffer, "%s", TCA_ID_IDLE_REMINDER_DIS); 01437 tx_fmu130_message (fmu_buffer, &avl_uart); 01438 tick_idle_reminder.detach(); 01439 #ifdef DEBUG_FMU130_CPP 01440 myPC_debug.printf("BLE - Recordatorio por Ralenti Deshabilitado\r\n"); 01441 myPC_debug.printf("%s\r\n", fmu_buffer); 01442 #endif 01443 break; 01444 01445 case CMD_IDLE_REMINDER_QUERY: 01446 if (functionality_idle_reminder) { 01447 sprintf(fmu_buffer, "%s", TCA_ID_IDLE_REMINDER_ENA); 01448 } else { 01449 sprintf(fmu_buffer, "%s", TCA_ID_IDLE_REMINDER_DIS); 01450 } 01451 tx_fmu130_message (fmu_buffer, &avl_uart); 01452 #ifdef DEBUG_FMU130_CPP 01453 myPC_debug.printf("BLE - Consulta Estatus de Recordatorio por Ralenti\r\n"); 01454 myPC_debug.printf("BLE - Recordatorio por Ralenti: %s\r\n", functionality_idle_reminder?"TRUE":"FALSE"); 01455 myPC_debug.printf("%s\r\n", fmu_buffer); 01456 #endif 01457 break; 01458 01459 case CMD_CHANGE_IDLE_REMINDER_T: 01460 if (external_eeprom) { 01461 ep.write(eprom_AddressArray[EE_Address_IDLE_R_TIME], ((uint16_t) fingerprint_id)); 01462 } else { 01463 EE_WriteVariable(VirtAddVarTab[AP_IDLE_R_TIME], ((uint16_t) fingerprint_id)); 01464 } 01465 wait_idle_reminder = fingerprint_id * 1.0; 01466 sprintf(fmu_buffer, "%s%.1f", TCA_ID_IDLE_REMINDER_TIME, wait_idle_reminder); 01467 tx_fmu130_message (fmu_buffer, &avl_uart); 01468 #ifdef DEBUG_FMU130_CPP 01469 myPC_debug.printf("BLE - Cambio Temp. de Recordatorio Ralenti\r\n"); 01470 myPC_debug.printf("BLE - Nuevo Recordatorio Ralendi: %d seg\r\n", fingerprint_id); 01471 myPC_debug.printf("%s\r\n", fmu_buffer); 01472 #endif 01473 break; 01474 01475 case CMD_QUERY_IDLE_REMINDER_T: 01476 sprintf(fmu_buffer, "%s%.1f", TCA_ID_IDLE_REMINDER_TIME, wait_idle_reminder); 01477 tx_fmu130_message (fmu_buffer, &avl_uart); 01478 #ifdef DEBUG_FMU130_CPP 01479 myPC_debug.printf("BLE - Consulta Temp. de Recordatorio Ralenti\r\n"); 01480 myPC_debug.printf("BLE - Recordatorio Ralenti en %.1f seg\r\n", wait_idle_reminder); 01481 myPC_debug.printf("%s\r\n", fmu_buffer); 01482 #endif 01483 break; 01484 01485 01486 /** ******************************** 01487 * COMANDOS DE TIP DE SEGURIDAD 01488 * ******************************** */ 01489 case CMD_QUERY_SAFETY_TIP_TIME: 01490 sprintf(fmu_buffer, "%s%.1f", TCA_ID_QUERY_SAFETY_TIP, time_safety_tip); 01491 tx_fmu130_message (fmu_buffer, &avl_uart); 01492 #ifdef DEBUG_FMU130_CPP 01493 myPC_debug.printf("BLE - Consulta Temp. de Tip de Seguridad\r\n"); 01494 myPC_debug.printf("BLE - Tip de Seguridad en %.1f seg\r\n", time_safety_tip); 01495 myPC_debug.printf("%s\r\n", fmu_buffer); 01496 #endif 01497 break; 01498 01499 case CHANGE_SAFETY_TIP_TIME: 01500 if (external_eeprom) { 01501 ep.write(eprom_AddressArray[EE_Address_SAFETY_TIP_T], ((uint16_t) fingerprint_id)); 01502 } else { 01503 EE_WriteVariable(VirtAddVarTab[AP_SAFETY_TIP_T], ((uint16_t) fingerprint_id)); 01504 } 01505 time_safety_tip = fingerprint_id * 1.0; 01506 sprintf(fmu_buffer, "%s%.1f", TCA_ID_QUERY_SAFETY_TIP, time_safety_tip); 01507 tx_fmu130_message (fmu_buffer, &avl_uart); 01508 #ifdef DEBUG_FMU130_CPP 01509 myPC_debug.printf("BLE - Cambio Temp. de Tip de Seguridad\r\n"); 01510 myPC_debug.printf("BLE - Nuevo Temp. para Tip de Seguridad: %d seg\r\n", fingerprint_id); 01511 myPC_debug.printf("%s\r\n", fmu_buffer); 01512 #endif 01513 break; 01514 01515 case CMD_SAFETY_TIP_ENABLE: 01516 functionality_safety_tip = true; 01517 if (external_eeprom) { 01518 ep.write(eprom_AddressArray[EE_Address_SAFETY_TIP], ((uint16_t) true)); 01519 } else { 01520 EE_WriteVariable(VirtAddVarTab[AP_SAFETY_TIP], ((uint16_t) true)); 01521 } 01522 sprintf(fmu_buffer, "%s", TCA_ID_SAFETY_TIP_ENABLE); 01523 tx_fmu130_message (fmu_buffer, &avl_uart); 01524 #ifdef DEBUG_FMU130_CPP 01525 myPC_debug.printf("BLE - Tip de Seguridad Habilitado\r\n"); 01526 myPC_debug.printf("%s\r\n", fmu_buffer); 01527 #endif 01528 break; 01529 01530 case CMD_SAFETY_TIP_DISABLE: 01531 functionality_safety_tip = false; 01532 if (external_eeprom) { 01533 ep.write(eprom_AddressArray[EE_Address_SAFETY_TIP], ((uint16_t) false)); 01534 } else { 01535 EE_WriteVariable(VirtAddVarTab[AP_SAFETY_TIP], ((uint16_t) false)); 01536 } 01537 tick_safety_tip.detach(); 01538 sprintf(fmu_buffer, "%s", TCA_ID_SAFETY_TIP_DISABLE); 01539 tx_fmu130_message (fmu_buffer, &avl_uart); 01540 #ifdef DEBUG_FMU130_CPP 01541 myPC_debug.printf("BLE - Tip de Seguridad Deshabilitado\r\n"); 01542 myPC_debug.printf("%s\r\n", fmu_buffer); 01543 #endif 01544 break; 01545 01546 /** ******************************** 01547 * COMANDOS DE INFORMACIÓN ICS5 01548 * ******************************** */ 01549 case CMD_QUERY_HARDWARE_VER: 01550 sprintf(fmu_buffer, "%s%s", TCA_ID_HARDWARE_VERSION, hardware_version); 01551 tx_fmu130_message (fmu_buffer, &avl_uart); 01552 #ifdef DEBUG_FMU130_CPP 01553 myPC_debug.printf("BLE - Consulta por Version de HW\r\n"); 01554 myPC_debug.printf("BLE - HW: %s\r\n", hardware_version); 01555 myPC_debug.printf("%s\r\n", fmu_buffer); 01556 #endif 01557 break; 01558 01559 case CMD_QUERY_FIRMWARE_VER: 01560 sprintf(fmu_buffer, "%s%s", TCA_ID_FIRMWARE_VERSION, firmware_version); 01561 tx_fmu130_message (fmu_buffer, &avl_uart); 01562 #ifdef DEBUG_FMU130_CPP 01563 myPC_debug.printf("BLE - Consulta por Version de Firmware\r\n"); 01564 myPC_debug.printf("BLE - FW: %s\r\n", firmware_version); 01565 myPC_debug.printf("%s\r\n", fmu_buffer); 01566 #endif 01567 break; 01568 01569 /** ******************************** 01570 * COMANDOS DE GEOCERCAS 01571 * ******************************** */ 01572 case CMD_GEO_WARNING_ENABLE: 01573 functionality_geo_warning = true; 01574 if (external_eeprom) { 01575 ep.write(eprom_AddressArray[EE_Address_GEOZONE], ((uint16_t) true)); 01576 } else { 01577 EE_WriteVariable(VirtAddVarTab[AP_GEOZONE], ((uint16_t) true)); 01578 } 01579 sprintf(fmu_buffer, "%s", TCA_ID_GEO_WARNING_ENABLE); 01580 tx_fmu130_message (fmu_buffer, &avl_uart); 01581 #ifdef DEBUG_FMU130_CPP 01582 myPC_debug.printf("BLE - Habilitar Notificacion de Geocercas Controladas\r\n"); 01583 myPC_debug.printf("%s\r\n", fmu_buffer); 01584 #endif 01585 break; 01586 01587 case CMD_GEO_WARNING_DISABLE: 01588 functionality_geo_warning = false; 01589 if (external_eeprom) { 01590 ep.write(eprom_AddressArray[EE_Address_GEOZONE], ((uint16_t) false)); 01591 } else { 01592 EE_WriteVariable(VirtAddVarTab[AP_GEOZONE], ((uint16_t) false)); 01593 } 01594 sprintf(fmu_buffer, "%s", TCA_ID_GEO_WARNING_DISABLE); 01595 tx_fmu130_message (fmu_buffer, &avl_uart); 01596 #ifdef DEBUG_FMU130_CPP 01597 myPC_debug.printf("BLE - Deshabilitar Notificacion de Geocercas Controladas\r\n"); 01598 myPC_debug.printf("%s\r\n", fmu_buffer); 01599 #endif 01600 break; 01601 01602 case CMD_GEO_WARNING_QUERY: 01603 #ifdef DEBUG_FMU130_CPP 01604 myPC_debug.printf("BLE - Consulta por Notificacion de Geocercas Controladas\r\n"); 01605 myPC_debug.printf("BLE - Notificacion de Geocercas: %s\r\n", functionality_geo_warning?"TRUE":"FALSE"); 01606 #endif 01607 if (functionality_geo_warning) { 01608 sprintf(fmu_buffer, "%s", TCA_ID_GEO_WARNING_QUERY_ON); 01609 tx_fmu130_message (fmu_buffer, &avl_uart); 01610 #ifdef DEBUG_FMU130_CPP 01611 myPC_debug.printf("%s\r\n", fmu_buffer); 01612 #endif 01613 } else { 01614 sprintf(fmu_buffer, "%s", TCA_ID_GEO_WARNING_QUERY_OFF); 01615 tx_fmu130_message (fmu_buffer, &avl_uart); 01616 #ifdef DEBUG_FMU130_CPP 01617 myPC_debug.printf("%s\r\n", fmu_buffer); 01618 #endif 01619 } 01620 break; 01621 01622 01623 /** ******************************** 01624 * COMANDOS DE AUTORESET BLUETOOTH 01625 * ******************************** */ 01626 case CMD_BLE_AUTORESET_ENABLE: 01627 functionality_ble_autoreset = true; 01628 if (external_eeprom) { 01629 ep.write(eprom_AddressArray[EE_Address_BLE_RESET], ((uint16_t) true)); 01630 } else { 01631 EE_WriteVariable(VirtAddVarTab[AP_BLE_RESET], ((uint16_t) true)); 01632 } 01633 tick_autoreset_ble.detach(); 01634 tick_autoreset_ble.attach(&BLE_reset, time_ble_autoreset); 01635 sprintf(fmu_buffer, "%s", TCA_ID_BLE_AUTORESET_ENA); 01636 tx_fmu130_message (fmu_buffer, &avl_uart); 01637 #ifdef DEBUG_FMU130_CPP 01638 myPC_debug.printf("BLE - Habilitar Autoreset de Bluetooth\r\n"); 01639 myPC_debug.printf("%s\r\n", fmu_buffer); 01640 #endif 01641 break; 01642 01643 case CMD_BLE_AUTORESET_DISABLE: 01644 functionality_ble_autoreset = false; 01645 if (external_eeprom) { 01646 ep.write(eprom_AddressArray[EE_Address_BLE_RESET], ((uint16_t) false)); 01647 } else { 01648 EE_WriteVariable(VirtAddVarTab[AP_BLE_RESET], ((uint16_t) false)); 01649 } 01650 tick_autoreset_ble.detach(); 01651 sprintf(fmu_buffer, "%s", TCA_ID_BLE_AUTORESET_DIS); 01652 tx_fmu130_message (fmu_buffer, &avl_uart); 01653 #ifdef DEBUG_FMU130_CPP 01654 myPC_debug.printf("BLE - Deshabilitar Autoreset de Bluetooth\r\n"); 01655 myPC_debug.printf("%s\r\n", fmu_buffer); 01656 #endif 01657 break; 01658 01659 case CMD_BLE_AUTORESET_TIME: 01660 if (external_eeprom) { 01661 ep.write(eprom_AddressArray[EE_Address_BLE_RESET_T], ((uint16_t) fingerprint_id)); 01662 } else { 01663 EE_WriteVariable(VirtAddVarTab[AB_BLE_RESET_T], ((uint16_t) fingerprint_id)); 01664 } 01665 time_ble_autoreset = fingerprint_id * 1.0; 01666 if (functionality_ble_autoreset) { 01667 tick_autoreset_ble.detach(); 01668 tick_autoreset_ble.attach(&BLE_reset, time_ble_autoreset); 01669 } 01670 #ifdef DEBUG_FMU130_CPP 01671 myPC_debug.printf("BLE - Cambio Temp. Autoreset de Bluetooth\n"); 01672 myPC_debug.printf("BLE - Nuevo Temp. para muestreo: %d seg\r\n", fingerprint_id); 01673 #endif 01674 break; 01675 01676 case CMD_BLE_AUTORESET_QUERY: 01677 #ifdef DEBUG_FMU130_CPP 01678 myPC_debug.printf("BLE - Consulta por Autoreset de Bluetooth\r\n"); 01679 myPC_debug.printf("BLE - Autoreset de Bluetooth: %s\r\n", functionality_ble_autoreset?"TRUE":"FALSE"); 01680 myPC_debug.printf("BLE - Tiempo Autoreset de Bluetooth: %.1f\r\n", time_ble_autoreset); 01681 01682 #endif 01683 if (functionality_ble_autoreset) { 01684 sprintf(fmu_buffer, "%s%.0f", TCA_ID_BLE_AUTORESET_qENA, time_ble_autoreset); 01685 tx_fmu130_message (fmu_buffer, &avl_uart); 01686 #ifdef DEBUG_FMU130_CPP 01687 myPC_debug.printf("%s\r\n", fmu_buffer); 01688 #endif 01689 } else { 01690 sprintf(fmu_buffer, "%s%.0f", TCA_ID_BLE_AUTORESET_qDIS, time_ble_autoreset); 01691 tx_fmu130_message (fmu_buffer, &avl_uart); 01692 #ifdef DEBUG_FMU130_CPP 01693 myPC_debug.printf("%s\r\n", fmu_buffer); 01694 #endif 01695 } 01696 break; 01697 01698 default: 01699 #ifdef DEBUG_FMU130_CPP 01700 myPC_debug.printf("BLE - Comando no identificado\r\n"); 01701 #endif 01702 break; 01703 } 01704 01705 } else { 01706 // Error trama incompleta. 01707 #ifdef DEBUG_FMU130_CPP 01708 myPC_debug.printf("BLE - Trama incompleta\r\n"); 01709 #endif 01710 } 01711 /* DESHABILITADA LA FUNCIÓN DE SLEEP EN EL LECTOR 01712 fingerprint.Sleep(); 01713 flag_fingerprint_Sleep = true; 01714 myPC_debug.printf("BLE - GT521Fx@Sleep\r\n"); 01715 */ 01716 break; 01717 01718 default: 01719 #ifdef DEBUG_FMU130_CPP 01720 myPC_debug.printf("BLE - Trama no identificada\r\n"); 01721 myPC_debug.printf("BLE PAYLOAD:\r\n%s\r\n", fmu130_payload); 01722 #endif 01723 break; 01724 } 01725 } else { 01726 #ifdef DEBUG_FMU130_CPP 01727 myPC_debug.printf("BLE - Sin bytes recibidos\r\n"); 01728 #endif 01729 } 01730 }
Generated on Thu Jul 28 2022 19:27:02 by 1.7.2