static void ledConnTimerExpiry(timer_id id) { if(g_weight_hw_data.led_off_conn_tid == id) { /* The application starts LED on timer for LED_ON_CONN_PERIOD after the * expiry of LED off timer in connected state. */ TimerDelete(g_weight_hw_data.led_off_conn_tid); g_weight_hw_data.led_off_conn_tid=TIMER_INVALID; PioSet(LED_PIO, TRUE); g_weight_hw_data.led_on_conn_tid = TimerCreate(LED_ON_CONN_PERIOD,TRUE, ledConnTimerExpiry); } else if(g_weight_hw_data.led_on_conn_tid == id) { /* The application starts LED off timer for LED_OFF_CONN_PERIOD after * the expiry of LED on timer in connected state. */ TimerDelete(g_weight_hw_data.led_on_conn_tid); g_weight_hw_data.led_on_conn_tid=TIMER_INVALID; PioSet(LED_PIO,FALSE); g_weight_hw_data.led_off_conn_tid = TimerCreate(LED_OFF_CONN_PERIOD, TRUE, ledConnTimerExpiry); } }
static void ledAdTimerExpiry(timer_id id) { if(g_weight_hw_data.led_off_ad_tid == id) { /* The application starts LED on timer for LED_ON_AD_PERIOD after the * expiry of LED off timer in advertising state. */ TimerDelete(g_weight_hw_data.led_off_ad_tid); g_weight_hw_data.led_off_ad_tid=TIMER_INVALID; PioSet(LED_PIO, TRUE); g_weight_hw_data.led_on_ad_tid = TimerCreate(LED_ON_AD_PERIOD,TRUE, ledAdTimerExpiry); } else if(g_weight_hw_data.led_on_ad_tid == id) { /* The application starts LED off timer for LED_OFF_AD_PERIOD after the * expiry of LED on timer in advertising state. */ TimerDelete(g_weight_hw_data.led_on_ad_tid); g_weight_hw_data.led_on_ad_tid=TIMER_INVALID; PioSet(LED_PIO,FALSE); g_weight_hw_data.led_off_ad_tid = TimerCreate(LED_OFF_AD_PERIOD,TRUE, ledAdTimerExpiry); } }
extern void HandlePIOChangedEvent(uint32 pio_changed) { if(pio_changed & PIO_BIT_MASK(BUTTON_PIO)) { /* PIO changed */ uint32 pios = PioGets(); if(!(pios & PIO_BIT_MASK(BUTTON_PIO))) { /* This is for the case when pio changed event has come for button * press. */ /* Delete any button press timer if already running */ TimerDelete(g_app_hw_data.button_press_tid); g_app_hw_data.button_press_tid = TIMER_INVALID; /* Create a button press timer */ g_app_hw_data.button_press_tid = TimerCreate(LONG_BUTTON_PRESS_TIMER, TRUE, handleShortOrLongButtonPressTimerExpiry); /* Initialize the short (or) long button pressed flag with FALSE.*/ g_app_hw_data.long_or_short_button_pressed = FALSE; } else { /* This is for the case when pio changed event comes for * the button release */ if(g_app_hw_data.button_press_tid != TIMER_INVALID) { /* Button press timer is running.This means that either * 1.timer EXTRA_LONG_BUTTON_PRESS_TIMER has not expired yet * OR * 2.Timer EXTRA_LONG_BUTTON_PRESS_TIMER has expired but a 2nd * timer of length (EXTRA_LONG_BUTTON_PRESS_TIMER - * LONG_BUTTON_PRESS_TIMER) which we start on 1st timer * expiry, is still running. */ /* case when timer LONG_BUTTON_PRESS_TIMER is still running */ if(g_app_hw_data.long_or_short_button_pressed == FALSE) { HandleShortButtonPress(); } /* Delete the already running button press timer */ TimerDelete(g_app_hw_data.button_press_tid); g_app_hw_data.button_press_tid = TIMER_INVALID; g_app_hw_data.long_or_short_button_pressed = FALSE; } } } }
CNifPDPContextTNif::~CNifPDPContextTNif() { // Delete the Timer. TimerDelete(); Cancel(); iSblpParams.ResetAndDestroy(); };
/*----------------------------------------------------------------------------* * NAME * AppHwDataInit * * DESCRIPTION * This function initializes the application hardware data * * RETURNS * Nothing. * *----------------------------------------------------------------------------*/ extern void AppHwDataInit(void) { /* Clear the button press timer id. */ TimerDelete(g_app_hw_data.button_press_tid); g_app_hw_data.button_press_tid = TIMER_INVALID; SetIndication(app_ind_stop); }
extern void HandlePIOChangedEvent(pio_changed_data *pio_data) { if(pio_data->pio_cause & BUTTON_PIO_MASK) { /* PIO changed */ uint32 pios = PioGets(); if(!(pios & BUTTON_PIO_MASK)) { /* This event comes when a button is pressed */ /* Start a timer for EXTRA_LONG_BUTTON_PRESS_TIMER seconds. * If timer expires before we receive a button release event then * it was a long press and if we receive a button release PIO * changed event, it means it was a short press. */ TimerDelete(g_weight_hw_data.button_press_tid); g_weight_hw_data.button_press_tid = TIMER_INVALID; g_weight_hw_data.button_press_tid = TimerCreate( EXTRA_LONG_BUTTON_PRESS_TIMER, TRUE, HandleExtraLongButtonPress); } else { if(g_weight_hw_data.button_press_tid != TIMER_INVALID) { /* Timer was already running. This means it was a short button * press. */ TimerDelete(g_weight_hw_data.button_press_tid); g_weight_hw_data.button_press_tid = TIMER_INVALID; AppHandleShortButtonPress(); } } } }
/*----------------------------------------------------------------------------* * NAME * HandlePIOChangedEvent * * DESCRIPTION * This function handles the PIO Changed event. * * PARAMETERS * pio_data [in] State of the PIOs when the event occurred * * RETURNS * Nothing *----------------------------------------------------------------------------*/ extern void HandlePIOChangedEvent(pio_changed_data *pio_data) { if(pio_data->pio_cause & BUTTON_PIO_MASK) { /* PIO changed */ uint32 pios = PioGets(); if(!(pios & BUTTON_PIO_MASK)) { /* This event is triggered when a button is pressed. */ /* Start a timer for EXTRA_LONG_BUTTON_PRESS_TIMER seconds. If the * timer expires before the button is released an extra long button * press is detected. If the button is released before the timer * expires a short button press is detected. */ TimerDelete(g_app_hw_data.button_press_tid); g_app_hw_data.button_press_tid = TimerCreate(EXTRA_LONG_BUTTON_PRESS_TIMER, TRUE, handleExtraLongButtonPress); } else { /* This event comes when a button is released. */ if(g_app_hw_data.button_press_tid != TIMER_INVALID) { /* Timer was already running. This means it was a short button * press. */ TimerDelete(g_app_hw_data.button_press_tid); g_app_hw_data.button_press_tid = TIMER_INVALID; /* Indicate short button press using short beep */ SoundBuzzer(buzzer_beep_short); HandleShortButtonPress(); } } } }
/*----------------------------------------------------------------------------* * NAME * BuzzerResetData * * DESCRIPTION * This function resets the buzzer data. It is intended to be called when * the data needs to be reset to a clean state, for example, whenever a * device connects or disconnects. * * PARAMETERS * None * * RETURNS * Nothing *----------------------------------------------------------------------------*/ extern void BuzzerResetData(void) { /* Delete buzzer timer if running */ if (g_buzz_data.buzzer_tid != TIMER_INVALID) { TimerDelete(g_buzz_data.buzzer_tid); g_buzz_data.buzzer_tid = TIMER_INVALID; } /* The remaining values in the data structure are reset by SoundBuzzer */ }
extern void WeightHwDataInit(void) { /* Delete button press timer */ TimerDelete(g_weight_hw_data.button_press_tid); g_weight_hw_data.button_press_tid = TIMER_INVALID; #ifdef ENABLE_LEDBLINK /* Delete LED timers for advertising state */ TimerDelete(g_weight_hw_data.led_on_ad_tid); g_weight_hw_data.led_on_ad_tid = TIMER_INVALID; TimerDelete(g_weight_hw_data.led_off_ad_tid); g_weight_hw_data.led_off_ad_tid = TIMER_INVALID; /* Delete LED timers for advertising state */ TimerDelete(g_weight_hw_data.led_on_conn_tid); g_weight_hw_data.led_on_conn_tid = TIMER_INVALID; TimerDelete(g_weight_hw_data.led_off_conn_tid); g_weight_hw_data.led_off_conn_tid = TIMER_INVALID; #endif /* ENABLE_LEDBLINK */ }
/*----------------------------------------------------------------------------* * NAME * HwDataReset * * DESCRIPTION * This function resets the hardware data. It is intended to be called when * the data needs to be reset to a clean state, for example, whenever a * device connects or disconnects. * * PARAMETERS * None * * RETURNS * Nothing *----------------------------------------------------------------------------*/ extern void HwDataReset(void) { /* Delete button press timer */ if (g_app_hw_data.button_press_tid != TIMER_INVALID) { TimerDelete(g_app_hw_data.button_press_tid); g_app_hw_data.button_press_tid = TIMER_INVALID; } /* Reset buzzer data */ BuzzerResetData(); }
CPppChap::~CPppChap() /** Destructor. @internalComponent */ { if (iPppLcp != 0) { iChallengePacket.Free(); TimerDelete(); } }
extern void GattStartAdverts(bool fast_connection) { /* Variable 'connect_flags' needs to be updated to have peer address type * if Directed advertisements are supported as peer address type will * only be used in that case. We don't support directed advertisements for * this application. */ #ifdef USE_STATIC_RANDOM_ADDRESS uint16 connect_flags = L2CAP_CONNECTION_SLAVE_UNDIRECTED | L2CAP_OWN_ADDR_TYPE_RANDOM; #else uint16 connect_flags = L2CAP_CONNECTION_SLAVE_UNDIRECTED | L2CAP_OWN_ADDR_TYPE_PUBLIC; #endif /* USE_STATIC_RANDOM_ADDRESS */ /* Set UCID to INVALID_UCID */ g_hr_data.st_ucid = GATT_INVALID_UCID; /* Set advertisement parameters */ gattSetAdvertParams(fast_connection); /* If white list is enabled, set the controller's advertising filter policy * to "process scan and connection requests only from devices in the White * List" */ if((g_hr_data.enable_white_list == TRUE) && (!GattIsAddressResolvableRandom(&(g_hr_data.bonded_bd_addr)))) { #ifdef USE_STATIC_RANDOM_ADDRESS connect_flags = L2CAP_CONNECTION_SLAVE_WHITELIST | L2CAP_OWN_ADDR_TYPE_RANDOM; #else connect_flags = L2CAP_CONNECTION_SLAVE_WHITELIST | L2CAP_OWN_ADDR_TYPE_PUBLIC; #endif /* USE_STATIC_RANDOM_ADDRESS */ } /* Start GATT connection in Slave role */ GattConnectReq(NULL, connect_flags); /* Start advertisement timer */ if(g_hr_data.advert_timer_value) { TimerDelete(g_hr_data.app_tid); /* Start advertisement timer */ g_hr_data.app_tid = TimerCreate(g_hr_data.advert_timer_value, TRUE, gattAdvertTimerHandler); } }
extern void SetIndication(app_indication state) { #ifdef ENABLE_LEDBLINK if(state == stop_ind) { /* Stop LED glowing */ PioSet(LED_PIO, FALSE); /* Delete LED timers */ TimerDelete(g_weight_hw_data.led_on_ad_tid); g_weight_hw_data.led_on_ad_tid = TIMER_INVALID; TimerDelete(g_weight_hw_data.led_off_ad_tid); g_weight_hw_data.led_off_ad_tid = TIMER_INVALID; TimerDelete(g_weight_hw_data.led_on_conn_tid); g_weight_hw_data.led_on_conn_tid = TIMER_INVALID; TimerDelete(g_weight_hw_data.led_off_conn_tid); g_weight_hw_data.led_off_conn_tid = TIMER_INVALID; } else { if(state == advertising_ind) { /* Create a timer for LED_ON_AD_PERIOD for advertising state */ PioSet(LED_PIO, TRUE); g_weight_hw_data.led_on_ad_tid = TimerCreate(LED_ON_AD_PERIOD,TRUE, ledAdTimerExpiry); } else if(state == connected_ind) { /* Create a timer for LED_ON_CONN_PERIOD for connected state */ PioSet(LED_PIO, TRUE); g_weight_hw_data.led_on_conn_tid = TimerCreate(LED_ON_CONN_PERIOD, TRUE, ledConnTimerExpiry); } } #endif /* ENABLE_LEDBLINK */ }
extern void GattHandleAccessInd(GATT_ACCESS_IND_T *p_ind) { if(p_ind->flags == (ATT_ACCESS_WRITE | ATT_ACCESS_PERMISSION | ATT_ACCESS_WRITE_COMPLETE)) { bool old_hid_notify_status; old_hid_notify_status = AppCheckNotificationStatus(); handleAccessWrite(p_ind); #ifdef PENDING_REPORT_WAIT if(g_kbd_data.pending_report_tid != TIMER_INVALID) { /* Delete the pending timer */ TimerDelete(g_kbd_data.pending_report_tid); g_kbd_data.pending_report_tid = TIMER_INVALID; /* Recreate the timer */ g_kbd_data.pending_report_tid = TimerCreate(PENDING_REPORT_WAIT_TIMEOUT, TRUE, HandlePendingReportsTimerExpiry); } #else /* PENDING_REPORT_WAIT */ /* If notifications are just enabled and Key press is pending/buffered * notify all buffered key presses to the remote host */ bool new_hid_notify_status; new_hid_notify_status = AppCheckNotificationStatus(); if(!old_hid_notify_status && new_hid_notify_status && g_kbd_data.data_pending && g_kbd_data.encrypt_enabled && !g_kbd_data.data_tx_in_progress && !g_kbd_data.waiting_for_fw_buffer) { /* Scanning already on-going, send key-press data stored in queue */ SendKeyStrokesFromQueue(); } #endif } else if(p_ind->flags == (ATT_ACCESS_READ | ATT_ACCESS_PERMISSION)) { handleAccessRead(p_ind); } }
extern void acquireData(timer_id tid) { uint8 channelsActive = count(g_eeg_serv_data.channel_map); TimerDelete(g_eeg_serv_data.acq_tmr); g_eeg_serv_data.acq_tmr = TimerCreate((uint32) (1000000/g_eeg_serv_data.acquisition_rate), TRUE, acquireData); meas_report[3] = channelsActive; uint8 i = 0; for(i = 0; i < channelsActive; i++) { } }
/*----------------------------------------------------------------------------* * NAME * GattTriggerFastAdverts * * DESCRIPTION * This function is used to trigger fast advertisements * * RETURNS * Nothing * *---------------------------------------------------------------------------*/ extern void GattTriggerFastAdverts(void) { CSR_MESH_USER_ADV_PARAMS_T adv_params; /* Reset existing advertising data */ CsrMeshStoreUserAdvData(0, NULL, ad_src_advertise); CsrMeshStoreUserAdvData(0, NULL, ad_src_scan_rsp); #ifdef USE_STATIC_RANDOM_ADDRESS /* Restore the Random Address of the Bluetooth Device */ MemCopy(&adv_params.bd_addr.addr, &g_lightapp_data.random_bd_addr, sizeof(BD_ADDR_T)); adv_params.bd_addr.type = L2CA_RANDOM_ADDR_TYPE; #else adv_params.bd_addr.type = L2CA_PUBLIC_ADDR_TYPE; #endif /* USE_STATIC_RANDOM_ADDRESS */ /* Set GAP peripheral params */ adv_params.role = gap_role_peripheral; adv_params.bond = gap_mode_bond_no; adv_params.connect_mode = gap_mode_connect_undirected; adv_params.discover_mode = gap_mode_discover_general; adv_params.security_mode = gap_mode_security_unauthenticate; g_lightapp_data.gatt_data.advert_timer_value = ADVERT_INTERVAL + appRandomDelay(); /* If GATT bearer is enabled send connectable advert */ if(g_lightapp_data.bearer_data.bearerEnabled & BLE_GATT_SERVER_BEARER_MASK) { /* Set advertisement parameters */ gattSetAdvertParams(TRUE); /* Send a connectable advertisement */ CsrMeshSendUserAdvert(&adv_params); /* Restart the advertising timer */ TimerDelete(g_lightapp_data.gatt_data.app_tid); g_lightapp_data.gatt_data.app_tid = TimerCreate( g_lightapp_data.gatt_data.advert_timer_value, TRUE, gattAdvertTimerHandler); } }
/*----------------------------------------------------------------------------* * NAME * SoundBuzzer * * DESCRIPTION * Function for sounding beeps. * * RETURNS * Nothing. * *----------------------------------------------------------------------------*/ extern void SoundBuzzer(buzzer_beep_type beep_type) { #ifdef ENABLE_BUZZER uint32 beep_timer = SHORT_BEEP_TIMER_VALUE; PioEnablePWM(BUZZER_PWM_INDEX_0, FALSE); TimerDelete(g_app_hw_data.buzzer_tid); g_app_hw_data.buzzer_tid = TIMER_INVALID; g_app_hw_data.beep_count = 0; /* Store the beep type in some global variable. It will used on timer expiry * to check the type of beeps being sounded. */ g_app_hw_data.beep_type = beep_type; switch(g_app_hw_data.beep_type) { case beep_off: { /* Don't do anything */ } break; case beep_short: /* FALLTHROUGH */ case beep_twice: /* Two short beeps will be sounded */ /* FALLTHROUGH */ case beep_thrice: /* Three short beeps will be sounded */ { /* One short beep will be sounded */ beep_timer = SHORT_BEEP_TIMER_VALUE; } break; case beep_long: { /* One long beep will be sounded */ beep_timer = LONG_BEEP_TIMER_VALUE; } break; break; default: { /* No such beep type defined */ ReportPanic(app_panic_unexpected_beep_type); /* Though break statement will not be executed after panic but this * has been kept to avoid any confusion for default case. */ } break; } if(g_app_hw_data.beep_type != beep_off) { /* Initialize beep count to zero */ g_app_hw_data.beep_count = 0; /* Enable buzzer */ PioEnablePWM(BUZZER_PWM_INDEX_0, TRUE); TimerDelete(g_app_hw_data.buzzer_tid); g_app_hw_data.buzzer_tid = TimerCreate(beep_timer, TRUE, appBuzzerTimerHandler); } #endif /* ENABLE_BUZZER */ }
/*----------------------------------------------------------------------------* * NAME * processRxData * * DESCRIPTION * This function peeks the data from the queue and sends it to the remote * device. * * RETURNS * Nothing * *----------------------------------------------------------------------------*/ extern void processRxData(void) { uint8 data[SERIAL_RX_DATA_LENGTH]; /* Data to be sent */ uint16 size_val; /* Length of the data to be sent */ /* Length of data available in the queue */ uint16 length = BQGetDataSize(SEND_QUEUE_ID); /* Proceed only if byte queue is not empty */ if(length > 0) { /* Make sure that the maximum data length is not exceeded */ size_val = length > SERIAL_RX_DATA_LENGTH ? SERIAL_RX_DATA_LENGTH : length; if(length < SERIAL_RX_DATA_LENGTH) { /* Length of the data is less than serial data length. */ if(g_is_current_baud_rate_high) { if (g_partial_buffer_timer_tid == TIMER_INVALID) { /* Create partial buffer timer */ g_partial_buffer_timer_tid = TimerCreate( PARTIAL_BUFFER_WAIT_TIME_HIGH, TRUE, sendPartialBuffer); } } else { if (g_partial_buffer_timer_tid == TIMER_INVALID) { /* Create partial buffer timer */ g_partial_buffer_timer_tid = TimerCreate( PARTIAL_BUFFER_WAIT_TIME_LOW, TRUE, sendPartialBuffer); } } } else { if (g_partial_buffer_timer_tid != TIMER_INVALID) { /* Kill the partial buffer timer. */ TimerDelete(g_partial_buffer_timer_tid); g_partial_buffer_timer_tid = TIMER_INVALID; } if (BQPeekBytes(data, size_val,SEND_QUEUE_ID) > 0) { /* Make a note of the data length which is being sent. */ length_data_peeked = size_val; if(ExecuteWriteCommandOnSerialDataTransferCharacteristic( GetConnectionIdentifier(), data, size_val) != gatt_status_busy) { /* Pop the data out from the send queue */ BQPopBytes(data, size_val,SEND_QUEUE_ID); /* Reset the peeked variable */ length_data_peeked = 0; } else { /* Transmission failed. Just reset the peeked variable */ length_data_peeked = 0; /* Configure for Radio Tx Event */ ConfigureRadioTxEvent(); } } } } }
CSimpleIfLink::~CSimpleIfLink() { TimerDelete(); }
extern void HeartRateHandleAccessWrite(GATT_ACCESS_IND_T *p_ind) { uint8 *p_value = p_ind->value; gatt_client_config client_config; sys_status rc = sys_status_success; switch(p_ind->handle) { /* Heart Rate measurement characteristic client configuration is being * written */ case HANDLE_EEG_MEASUREMENT_C_CFG: { client_config = BufReadUint16(&p_value); /* Client Configuration is bit field value so ideally bitwise * comparison should be used but since the application supports only * notifications, direct comparison is being used. */ if((client_config == gatt_client_config_notification) || (client_config == gatt_client_config_none)) { /* Store the new client configuration */ g_eeg_serv_data.hr_meas_client_config = client_config; /* Write Heart Rate Measurement Client configuration to NVM if * the device is bonded. */ if(AppIsDeviceBonded()) { Nvm_Write((uint16*)&client_config, sizeof(client_config), g_eeg_serv_data.nvm_offset + HR_NVM_HR_MEAS_CLIENT_CONFIG_OFFSET); } /* Start sending the HR measurement notifications if they are * not being sent currently. */ StartSendingHRMeasurements(); } else { /* INDICATION or RESERVED */ /* Return Error as only Notifications are supported */ rc = gatt_status_desc_improper_config; } break; } /* EEG channels Control point is being written */ case HANDLE_EEG_CHANNELS: { /* Extract the written value */ g_eeg_serv_data.channel_map = BufReadUint16(&p_value); DebugWriteString("\n\rChannel map updated"); break; } case HANDLE_EEG_ACQUISITION_RATE: { g_eeg_serv_data.acquisition_rate = BufReadUint16(&p_value); TimerDelete(g_eeg_serv_data.acq_tmr); g_eeg_serv_data.acq_tmr = TimerCreate((uint32) (1000000/g_eeg_serv_data.acquisition_rate), TRUE, acquireData); DebugWriteString("\n\rAcq Rate changed"); break; } default: { /* Write is not permitted on any other characteristic/attribute */ rc = gatt_status_write_not_permitted; break; } } /* Send ACCESS RESPONSE */ GattAccessRsp(p_ind->cid, p_ind->handle, rc, 0, NULL); }
extern void AppHwDataInit(void) { /* Clear the button press timer id. */ TimerDelete(g_app_hw_data.button_press_tid); g_app_hw_data.button_press_tid = TIMER_INVALID; }
extern void GattStartAdverts(bool fast_connection, gap_mode_connect connect_mode) { uint16 connect_flags = L2CAP_CONNECTION_SLAVE_UNDIRECTED | L2CAP_OWN_ADDR_TYPE_PUBLIC; /* Set UCID to INVALID_UCID */ g_btcar_data.st_ucid = GATT_INVALID_UCID; /* Set advertisement parameters */ gattSetAdvertParams(fast_connection, connect_mode); if(g_btcar_data.bonded && !IsAddressResolvableRandom(&g_btcar_data.bonded_bd_addr) && !IsAddressNonResolvableRandom(&g_btcar_data.bonded_bd_addr)) { if(connect_mode == gap_mode_connect_directed) { connect_flags = L2CAP_CONNECTION_SLAVE_DIRECTED | L2CAP_OWN_ADDR_TYPE_PUBLIC | L2CAP_PEER_ADDR_TYPE_PUBLIC; } else { /* When the device is bonded, set the advertising filter policy to * "process scan and connection requests only from devices in white * list" */ connect_flags = L2CAP_CONNECTION_SLAVE_WHITELIST | L2CAP_OWN_ADDR_TYPE_PUBLIC; } } #ifdef __GAP_PRIVACY_SUPPORT__ /*Check if privacy enabled */ if(IsGapPeripheralPrivacyEnabled()) { if(connect_mode == gap_mode_connect_directed) { /* Set advAddress to reconnection address. */ GapSetRandomAddress(GapGetReconnectionAddress()); connect_flags = L2CAP_CONNECTION_SLAVE_DIRECTED | L2CAP_OWN_ADDR_TYPE_RANDOM | L2CAP_PEER_ADDR_TYPE_RANDOM; } else { /* Generate Resolvable random address and use it as advAddress. */ SMPrivacyRegenerateAddress(NULL); if(g_btcar_data.bonded_bd_addr.type == L2CA_RANDOM_ADDR_TYPE) { /* Change to random address */ connect_flags = L2CAP_CONNECTION_SLAVE_UNDIRECTED | L2CAP_OWN_ADDR_TYPE_RANDOM | L2CAP_PEER_ADDR_TYPE_RANDOM; } else { /* Change to random address */ connect_flags = L2CAP_CONNECTION_SLAVE_UNDIRECTED | L2CAP_OWN_ADDR_TYPE_RANDOM | L2CAP_PEER_ADDR_TYPE_PUBLIC; } } } #endif /* __GAP_PRIVACY_SUPPORT__ */ /* Start GATT connection in Slave role */ GattConnectReq(NULL, connect_flags); /* Start advertisement timer */ if(g_btcar_data.advert_timer_value) { TimerDelete(g_btcar_data.app_tid); /* Start advertisement timer */ g_btcar_data.app_tid = TimerCreate(g_btcar_data.advert_timer_value, TRUE, gattAdvertTimerHandler); } }
/*----------------------------------------------------------------------------* * NAME * SoundBuzzer * * DESCRIPTION * This function is called to trigger beeps of different types, enumerated * by 'buzzer_beep_type'. * * PARAMETERS * beep_type [in] Type of beep required * * RETURNS * Nothing *----------------------------------------------------------------------------*/ extern void SoundBuzzer(buzzer_beep_type beep_type) { /* Duration of beep */ uint32 beep_timer = SHORT_BEEP_TIMER_VALUE; /* Disable the buzzer and stop the buzzer timer. */ PioEnablePWM(BUZZER_PWM_INDEX_0, FALSE); if (g_buzz_data.buzzer_tid != TIMER_INVALID) { TimerDelete(g_buzz_data.buzzer_tid); g_buzz_data.buzzer_tid = TIMER_INVALID; } /* Reset the beeper state */ g_buzz_data.beep_count = 0; /* Store the beep type. It will be used on timer expiry to check the type of * beep being sounded. */ g_buzz_data.beep_type = beep_type; switch(g_buzz_data.beep_type) { case buzzer_beep_off: { /* Don't do anything */ } break; case buzzer_beep_short: /* One short beep will be sounded */ /* FALLTHROUGH */ case buzzer_beep_twice: /* Two short beeps will be sounded */ /* FALLTHROUGH */ case buzzer_beep_thrice: /* Three short beeps will be sounded */ { beep_timer = SHORT_BEEP_TIMER_VALUE; } break; case buzzer_beep_long: { /* One long beep will be sounded */ beep_timer = LONG_BEEP_TIMER_VALUE; } break; default: { /* No such beep type defined */ ReportPanic(app_panic_unexpected_beep_type); } break; } if(g_buzz_data.beep_type != buzzer_beep_off) { /* Enable buzzer */ PioEnablePWM(BUZZER_PWM_INDEX_0, TRUE); /* Start the buzzer timer */ g_buzz_data.buzzer_tid = TimerCreate(beep_timer, TRUE, appBuzzerTimerHandler); } }
int main(int argc,char *argv[]) { int i,Result; //MessageNumber; HWND Window; HMSG Message; ULONG Param1,Param2; char *opt; GetProfileString( ProfileName,InitSection, VectLibPathEntry,VectLibPath, "c:\\ezp\\fonts\\;c:\\;d:\\;e:\\;d:\\bttf;e:\\bttf;f:\\bttf;g:\\bttf"); GetProfileString( ProfileName,InitSection, TrueTypeLibPathEntry,TrueTypeLibPath, "c:\\ezp\\fonts\\;d:\\cttf;e:\\cttf;f:\\cttf;g:\\cttf;d:\ttf;e:\\ttf;f:\\ttf;g:\\ttf"); for (i=1;i<argc;i++) { opt = argv[i]; if (*opt == '-'|| *opt == '/') { opt ++; switch (toupper(*opt)) { case '6': if(!strcmp(opt,"640")) ScreenMode=MODE640X480X16; break; case '8': if(!strcmp(opt,"800")) ScreenMode=MODE800X600X16; break; case '1': if(!strcmp(opt,"1024")) ScreenMode=MODE1024X768X16; break; case 'E': fEditor=TRUE; break; case 'D': default:break; } // switch } else if (*opt == '%') { opt ++; if(*opt=='%') Result=60000; } else MakeName(opt); } /*-- argc > 1 ---*/ InitDot13LIB(); i=Result; if ((Result=SystemConstruct())<OpOK) { SystemDestruct(); Error(Result); } Result=i; FileSetMeterCM(); WaitMessageEmpty(); // run all init, ByHance /*------------- // test_speed(); printf("size of Box = %d\n",sizeof(Boxs)); printf("size of Pages = %d\n",sizeof(Pages)); printf("size of window= %d\n",sizeof(Windows)); printf("size of fillp = %d\n",sizeof(FILLP)); printf("size of fillp = %d\n",sizeof(FILLP)); getch(); goto game_over; -----------------*/ if(!fEditor) { // get printer type from file <EZP.INI> char str[80]; GetProfileString( ProfileName,InitSection, PrinterEntry,str, "HPϵÁм¤¹â´òÓ¡»ú(A4 300DPI)"); i=0; while(PrinterName[i]) { if( strcmp(str,PrinterName[i])==0 ) break; i++; } if(PrinterName[i]==NULL) i=0; CurrentPrinter=i; MessageInsert(1,MENUCOMMAND,MENU_VIEWTOOLS,0L); MessageInsert(1,MENUCOMMAND,MENU_CLIBRATION,0L); strcpy(DefaultFileName,"*.EZP;*.FRA;*.TXT;*.*"); WaitMessageEmpty(); // run all init, ByHance } else { strcpy(DefaultFileName,"*.TXT"); GlobalBoxTool=IDX_INPUTBOX; DEFAULTTYPESTYLE.CharSize=DEFAULTTYPESTYLE.CharHSize= FormattingTextStyle.CharSize=FormattingTextStyle.CharHSize=160; // 16*16 DEFAULTTYPESTYLE.ParagraphAlign= FormattingTextStyle.ParagraphAlign=ALIGNLEFT; DEFAULTTYPESTYLE.VParagraphAlign= FormattingTextStyle.VParagraphAlign=ALIGNUPDOWN; } if(fAutoLoad) MessageInsert(1,MENUCOMMAND,MENU_OPEN,0L); else //if(fEditor) MessageInsert(1,MENUCOMMAND,MENU_NEW,0L); { MessageInsert(1,MENUCOMMAND,MENU_NEW,0L); //By zjh 96.10.17 for auto load fNewA4=TRUE; } // #define OLD_VERSION #ifdef OLD_VERSION DrawIconImage(); // for debug #endif /*----------------- for test ----- WaitMessageEmpty(); for(i=0;i<200;i++) { //RedrawUserField(); //WaitMessageEmpty(); TextBoxRedrawPart(GlobalBoxHeadHandle,0,30000,0,FALSE); } goto game_over; -----------------*/ GlobalTimer=TimerInsert(1,1); // in main window, 18.2/second while(1) { if(Result==60000) { if(0==strcmp(&argv[1][2],"Han&Zhou")) { static unsigned char REDTEK_Company[32]={ '±'+3,'±'+2, '¾'+1,'©'+0, 'À'-1, 'í'-2, 'µ'-3, 'Â'-4, 'É'-5, 'Ì'-6, 'Ó'-7, 'Ã'-8, '¼'-9, '¼'-10, 'Ê'-11,'õ'-12, 'Ó'-13,'Ð'-14, 'Ï'-15,'Þ'-16, '¹'-17,'«'-18, 'Ë'-19,'¾'-20, '°'-21,'æ'-22, 'È'-23,'¨'-24, 'Ë'-25,'ù'-26, 'Ó'-27,'Ð'-28 }; Result=0; while(PageDialog[Result].ItemProcedure!=PageInitialBoxProcedure) Result++; PageDialog[Result].ItemUserData=1; // pageInitBox=TRUE; //UserMenuCommand(1,MENUCOMMAND,MENU_NEW,0L); MenuHotKeyToMessage(1,ALT_F); // ByHance MenuDefaultProc(1,KEYDOWN,'N',0); // in UserMenu.C //MessageCreatbyKeyboard(ENTER,0); *(short *)0x41a=0x1e; *(short *)0x41c=0x20; *(short *)0x41e=0x1c0d; WaitMessageEmpty(); for(Result=0;Result<32;Result++) REDTEK_Company[Result]+=(Result-3)&0xff; MessageCreatbyKeyString(REDTEK_Company,32); } } else KeyToMessage(); if ((Result=MessageGet(&Window,&Message,&Param1,&Param2))<OpOK) break; if (Result<MAXMESSAGES) { if ((Result=MessageGo(Window,Message,Param1,Param2))==SYSTEMQUIT) break; } else MessageGo(1,SYSTEMIDLE,Param1,Param2); // main window idle } TimerDelete(GlobalTimer); //game_over: #ifdef WELCOME_DISPLAY MessageNumber=Result; if ((Result=SystemDestruct())<OpOK) { SystemDealError(Result); } SystemDealError(MessageNumber); #else SystemDestruct(); #endif //printf("OK.\n"); return(0); }