static void service_switch_onoff(uint8_t* data, uint16_t length, const service_characteristic_t* characteristic) { if (length > 0 && data[0] != switch_state) { switch_state = !!data[0]; nrf_gpio_pin_write(LED, !switch_state); #if !defined(NRF52) service_notify(characteristic); #endif } }
int main(int argc, char **argv) { int idx; early_init(); options(&argc, &argv); init_everything(); create_everything(); fill_initial_rtpe_cfg(&initial_rtpe_config); ilog(LOG_INFO, "Startup complete, version %s", RTPENGINE_VERSION); thread_create_detach(sighandler, NULL); thread_create_detach_prio(poller_timer_loop, rtpe_poller, rtpe_config.idle_scheduling, rtpe_config.idle_priority); thread_create_detach_prio(load_thread, NULL, rtpe_config.idle_scheduling, rtpe_config.idle_priority); if (!is_addr_unspecified(&rtpe_config.redis_ep.address)) thread_create_detach(redis_notify_loop, NULL); if (!is_addr_unspecified(&rtpe_config.graphite_ep.address)) thread_create_detach(graphite_loop, NULL); thread_create_detach(ice_thread_run, NULL); if (rtpe_config.num_threads < 1) { #ifdef _SC_NPROCESSORS_ONLN rtpe_config.num_threads = sysconf( _SC_NPROCESSORS_ONLN ) + 3; #endif if (rtpe_config.num_threads <= 1) rtpe_config.num_threads = 4; } service_notify("READY=1\n"); for (idx = 0; idx < rtpe_config.num_threads; ++idx) thread_create_detach_prio(poller_loop, rtpe_poller, rtpe_config.scheduling, rtpe_config.priority); if (rtpe_config.media_num_threads < 0) rtpe_config.media_num_threads = rtpe_config.num_threads; for (idx = 0; idx < rtpe_config.media_num_threads; ++idx) { #ifdef WITH_TRANSCODING thread_create_detach_prio(media_player_loop, NULL, rtpe_config.scheduling, rtpe_config.priority); #endif thread_create_detach_prio(send_timer_loop, NULL, rtpe_config.scheduling, rtpe_config.priority); } while (!rtpe_shutdown) { usleep(100000); threads_join_all(0); } service_notify("STOPPING=1\n"); if (!is_addr_unspecified(&rtpe_config.redis_ep.address)) { redis_notify_event_base_action(EVENT_BASE_LOOPBREAK); redis_notify_event_base_action(EVENT_BASE_FREE); } threads_join_all(1); ilog(LOG_INFO, "Version %s shutting down", RTPENGINE_VERSION); return 0; }