Beispiel #1
0
int preinit_rep() {
    int mutex_ret;

    mutex_ret = pthread_mutex_init(&globmutex, NULL);
    if (mutex_ret != 0) {
        pax_log(LOG_ERR, "pthread_mutex_init: glob_mutex %s\n", strerror(errno));
        exit(EX_OSERR);
    }

    atexit(close_db);
    atexit(close_log);
    atexit(pax_log_close);
    atexit(close_net);
    node_init(IP_CONF, &node);
    paxos_init();
    proxy_stop();
    return 0;
}
Beispiel #2
0
static void button_event_handler(uint32_t button_number)
{
    //__LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "Button %u pressed\n", button_number);
    switch (button_number)
    {
        /* Pressing SW1 on the Development Kit will result in LED state to toggle and trigger
        the STATUS message to inform client about the state change. This is a demonstration of
        state change publication due to local event. */
        case 0:
        {
            //__LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "User action \n");
            hal_led_pin_set(ONOFF_SERVER_0_LED, !hal_led_pin_get(ONOFF_SERVER_0_LED));
            app_onoff_status_publish(&m_onoff_server_0);
            break;
        }

        /* Initiate node reset */
        case 3:
        {
            /* Clear all the states to reset the node. */
            if (mesh_stack_is_device_provisioned())
            {
#if MESH_FEATURE_GATT_PROXY_ENABLED
                (void) proxy_stop();
#endif
                mesh_stack_config_clear();
                node_reset();
            }
            else
            {
                //__LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "The device is unprovisioned. Resetting has no effect.\n");
            }
            break;
        }

        default:
            break;
    }
}