本文整理汇总了C++中Ticker::detach方法的典型用法代码示例。如果您正苦于以下问题:C++ Ticker::detach方法的具体用法?C++ Ticker::detach怎么用?C++ Ticker::detach使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ticker
的用法示例。
在下文中一共展示了Ticker::detach方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: report_sample
/*
for reporting a sample that satisfies the reporting criteria and resetting the state machine
*/
int report_sample(sample s)
{
if(send_notification(s)){ // sends current_sample if observing is on
last_band = band(s); // limits state machine
high_step = s + LWM2M_step; // reset floating band upper limit defined by step
low_step = s - LWM2M_step; // reset floating band lower limit defined by step
pmin_timer.detach();
pmin_exceeded = false; // state machine to inhibit reporting at intervals < pmin
pmin_timer.attach(&on_pmin, LWM2M_pmin);
pmax_timer.detach();
pmax_timer.attach(&on_pmax, LWM2M_pmax);
return 1;
}
else return 0;
}
示例2: on_write
static void on_write(ble_evt_t * p_ble_evt)
{
ble_gatts_evt_write_t * p_evt_write = &p_ble_evt->evt.gatts_evt.params.write;
// Check if this the correct CCCD
if (
(p_evt_write->handle == m_conn_params_config.start_on_notify_cccd_handle)
&&
(p_evt_write->len == 2)
)
{
// Check if this is a 'start notification'
if (ble_srv_is_notification_enabled(p_evt_write->data))
{
// Do connection parameter negotiation if necessary
conn_params_negotiation();
}
else
{
#ifdef USE_APP_TIMER
uint32_t err_code;
// Stop timer if running
err_code = app_timer_stop(m_conn_params_timer_id);
if ((err_code != NRF_SUCCESS) && (m_conn_params_config.error_handler != NULL))
{
m_conn_params_config.error_handler(err_code);
}
#else /* #if !USE_APP_TIMER */
m_conn_params_timer.detach();
#endif /* #if !USE_APP_TIMER */
}
}
}
示例3: OnMacEvent
/*!
* \brief Function to be executed on MAC layer event
*/
static void OnMacEvent( LoRaMacEventFlags_t *flags, LoRaMacEventInfo_t *info )
{
if( flags->Bits.JoinAccept == 1 )
{
#if( OVER_THE_AIR_ACTIVATION != 0 )
JoinReqTimer.detach( );
#endif
IsNetworkJoined = true;
}
if( flags->Bits.Tx == 1 )
{
}
if( flags->Bits.Rx == 1 )
{
if( flags->Bits.RxData == true )
{
ProcessRxFrame( flags, info );
}
}
// Schedule a new transmission
TxDone = true;
}
示例4: pppSurfing
void pppSurfing(void const*) {
while (pppDialingSuccessFlag == 0) {
Thread::wait(500);
}
NetLED_ticker.detach();
NetLED_ticker.attach(&toggle_NetLed, 0.5); //net is connect
startRemoteUpdate();
}
示例5: ble_conn_params_stop
uint32_t ble_conn_params_stop(void)
{
#ifdef USE_APP_TIMER
return app_timer_stop(m_conn_params_timer_id);
#else /* #if !USE_APP_TIMER */
m_conn_params_timer.detach();
return NRF_SUCCESS;
#endif /* #if !USE_APP_TIMER */
}
示例6: pushUp
void pushUp(){
freq += FREQ_SIZE;
if (freq >= MAX_FREQ) freq = MAX_FREQ;
dx = 1.0/(DX_LEN * freq);
controller.detach();
controller.attach(&bldcval, dx);
DBG("freq = %d\r\n", freq);
}
示例7: debounce_handler
void debounce_handler() {
if (debounce.read_ms() >= 500) {
debounce.reset();
training_mode = !training_mode;
if (training_mode) tcontrol.attach(checkTimers, 1);
else tcontrol.detach();
led4 = !led4;
turnoffgreen();
greenlightact();
}
}
示例8: timerCallback
void timerCallback(void)
{
DEBUG("start timer callback");
sprintf(answer,"+.!");
DEBUG("writing beatpulse \"%s\" with len %d to ble\n",answer,strlen(answer));
int l = strlen(answer);
for(int i = 0; i*20 < strlen(answer); i++) {
int len = 20 < l ? 20 : l;
ble.updateCharacteristicValue(uartServicePtr->getRXCharacteristicHandle(), (uint8_t *)&answer[i*20], len);
l -= 20;
}
ticker.detach();
}
示例9: on_pmin
/*
handler for the pmin timer, called when pmin expires
if no reportable events have occurred, set the pmin expired flag
to inform the report scheduler to report immediately
If a reportable event has occured, report a new sample
*/
void on_pmin()
{
if (report_scheduled){
report_scheduled = false;
pmin_trigger = true; // diagnostic for state machine visibility
report_sample(get_sample());
}
else{
pmin_exceeded = true; // state machine
pmin_timer.detach();
}
return;
}
示例10: update_timeout_handler
static void update_timeout_handler(void * p_context)
{
UNUSED_PARAMETER(p_context);
#else /* #if !USE_APP_TIMER */
static void update_timeout_handler(void)
{
m_conn_params_timer.detach(); /* this is supposed to be a single-shot timer callback */
#endif /* #if !USE_APP_TIMER */
if (m_conn_handle != BLE_CONN_HANDLE_INVALID)
{
// Check if we have reached the maximum number of attempts
m_update_count++;
if (m_update_count <= m_conn_params_config.max_conn_params_update_count)
{
uint32_t err_code;
// Parameters are not ok, send connection parameters update request.
err_code = sd_ble_gap_conn_param_update(m_conn_handle, &m_preferred_conn_params);
if ((err_code != NRF_SUCCESS) && (m_conn_params_config.error_handler != NULL))
{
m_conn_params_config.error_handler(err_code);
}
}
else
{
m_update_count = 0;
// Negotiation failed, disconnect automatically if this has been configured
if (m_conn_params_config.disconnect_on_fail)
{
uint32_t err_code;
err_code = sd_ble_gap_disconnect(m_conn_handle, BLE_HCI_CONN_INTERVAL_UNACCEPTABLE);
if ((err_code != NRF_SUCCESS) && (m_conn_params_config.error_handler != NULL))
{
m_conn_params_config.error_handler(err_code);
}
}
// Notify the application that the procedure has failed
if (m_conn_params_config.evt_handler != NULL)
{
ble_conn_params_evt_t evt;
evt.evt_type = BLE_CONN_PARAMS_EVT_FAILED;
m_conn_params_config.evt_handler(&evt);
}
}
}
}
示例11: resetSnake
void resetSnake(LLRoot * master) {
if(master == NULL) return;
if(LLDEBUG) printf("###### GAME RESET; Setting snake back to 0,0,0 ######\r\n\r\n");
tick.detach();
freeListLL(master);
myCube.clearCube();
initializeSnake(master);
//sysClock.reset();
if(LLDEBUG) printListLL(master);
}
示例12: A25
////////////////////////////////////////////////////////////////
//Pause du jeu //
////////////////////////////////////////////////////////////////
int A25(void)
{
son.MusicOff();
scanShip.detach();
T_MS1=500;
T_MS2=500;
space.Pause();
Chrono.stop();
lcd.cls();
lcd.printf("[]***PAUSE***[]");
lcd.locate(0,1);
lcd.printf("=>Jouer Menu");
printf("Action = A25\n\r");
printf("Etat = LCDGAME\n\r");
return LCDGAME;
}
示例13: blink
void blink(void *argument) {
// read the value of 'Pattern'
status_ticker.detach();
green_led = LED_OFF;
M2MObjectInstance* inst = led_object->object_instance();
M2MResource* res = inst->resource("5853");
// Clear previous blink data
blink_args->clear();
// values in mbed Client are all buffers, and we need a vector of int's
uint8_t* buffIn = NULL;
uint32_t sizeIn;
res->get_value(buffIn, sizeIn);
// turn the buffer into a string, and initialize a vector<int> on the heap
std::string s((char*)buffIn, sizeIn);
free(buffIn);
printf("led_execute_callback pattern=%s\n", s.c_str());
// our pattern is something like 500:200:500, so parse that
std::size_t found = s.find_first_of(":");
while (found!=std::string::npos) {
blink_args->blink_pattern.push_back(atoi((const char*)s.substr(0,found).c_str()));
s = s.substr(found+1);
found=s.find_first_of(":");
if(found == std::string::npos) {
blink_args->blink_pattern.push_back(atoi((const char*)s.c_str()));
}
}
// check if POST contains payload
if (argument) {
M2MResource::M2MExecuteParameter* param = (M2MResource::M2MExecuteParameter*)argument;
String object_name = param->get_argument_object_name();
uint16_t object_instance_id = param->get_argument_object_instance_id();
String resource_name = param->get_argument_resource_name();
int payload_length = param->get_argument_value_length();
uint8_t* payload = param->get_argument_value();
printf("Resource: %s/%d/%s executed\n", object_name.c_str(), object_instance_id, resource_name.c_str());
printf("Payload: %.*s\n", payload_length, payload);
}
// do_blink is called with the vector, and starting at -1
blinky_thread.start(callback(this, &LedResource::do_blink));
}
示例14: on_disconnect
static void on_disconnect(ble_evt_t * p_ble_evt)
{
#ifdef USE_APP_TIMER
uint32_t err_code;
#endif
m_conn_handle = BLE_CONN_HANDLE_INVALID;
// Stop timer if running
m_update_count = 0; // Connection parameters updates should happen during every connection
#ifdef USE_APP_TIMER
err_code = app_timer_stop(m_conn_params_timer_id);
if ((err_code != NRF_SUCCESS) && (m_conn_params_config.error_handler != NULL))
{
m_conn_params_config.error_handler(err_code);
}
#else
m_conn_params_timer.detach();
#endif
}
示例15: main
//.........这里部分代码省略.........
#ifdef MBEDTLS_ENTROPY_HARDWARE_ALT
// Used to randomize source port
mbedtls_hardware_poll(NULL, (unsigned char *) &seed, sizeof seed, &len);
#elif defined MBEDTLS_TEST_NULL_ENTROPY
#warning "mbedTLS security feature is disabled. Connection will not be secure !! Implement proper hardware entropy for your selected hardware."
// Used to randomize source port
mbedtls_null_entropy_poll( NULL,(unsigned char *) &seed, sizeof seed, &len);
#else
#error "This hardware does not have entropy, endpoint will not register to Connector.\
You need to enable NULL ENTROPY for your application, but if this configuration change is made then no security is offered by mbed TLS.\
Add MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES and MBEDTLS_TEST_NULL_ENTROPY in mbed_app.json macros to register your endpoint."
#endif
srand(seed);
red_led = LED_OFF;
blue_led = LED_OFF;
status_ticker.attach_us(blinky, 250000);
// Keep track of the main thread
mainThread = osThreadGetId();
printf("\nStarting mbed Client example in ");
#if defined (MESH) || (MBED_CONF_LWIP_IPV6_ENABLED==true)
printf("IPv6 mode\n");
#else
printf("IPv4 mode\n");
#endif
mbed_trace_init();
NetworkInterface* network = easy_connect(true);
if(network == NULL) {
printf("\nConnection to Network Failed - exiting application...\n");
return -1;
}
// we create our button and LED resources
ButtonResource button_resource;
LedResource led_resource;
BigPayloadResource big_payload_resource;
#ifdef TARGET_K64F
// On press of SW3 button on K64F board, example application
// will call unregister API towards mbed Device Connector
//unreg_button.fall(&mbed_client,&MbedClient::test_unregister);
unreg_button.fall(&unregister);
// Observation Button (SW2) press will send update of endpoint resource values to connector
obs_button.fall(&button_clicked);
#else
// Send update of endpoint resource values to connector every 15 seconds periodically
timer.attach(&button_clicked, 15.0);
#endif
// Create endpoint interface to manage register and unregister
mbed_client.create_interface(MBED_SERVER_ADDRESS, network);
// Create Objects of varying types, see simpleclient.h for more details on implementation.
M2MSecurity* register_object = mbed_client.create_register_object(); // server object specifying connector info
M2MDevice* device_object = mbed_client.create_device_object(); // device resources object
// Create list of Objects to register
M2MObjectList object_list;
// Add objects to list
object_list.push_back(device_object);
object_list.push_back(button_resource.get_object());
object_list.push_back(led_resource.get_object());
object_list.push_back(big_payload_resource.get_object());
// Set endpoint registration object
mbed_client.set_register_object(register_object);
// Register with mbed Device Connector
mbed_client.test_register(register_object, object_list);
registered = true;
while (true) {
updates.wait(25000);
if(registered) {
if(!clicked) {
mbed_client.test_update_register();
}
}else {
break;
}
if(clicked) {
clicked = false;
button_resource.handle_button_click();
}
}
mbed_client.test_unregister();
status_ticker.detach();
}