static void sensor_ble_oic_server_init(void) { #if MYNEWT_VAL(SENSOR_BLE) && MYNEWT_VAL(SENSOR_OIC) int rc; /* Set initial BLE device address. */ memcpy(g_dev_addr, (uint8_t[6]){0x0a, 0xfa, 0xcf, 0xac, 0xfa, 0xc0}, 6); oc_ble_coap_gatt_srv_init(); ble_hs_cfg.reset_cb = sensor_oic_on_reset; ble_hs_cfg.sync_cb = sensor_oic_on_sync; ble_hs_cfg.gatts_register_cb = gatt_svr_register_cb; /* Set the default device name. */ rc = ble_svc_gap_device_name_set("sn"); assert(rc == 0); rc = oc_main_init((oc_handler_t *)&sensor_oic_handler); assert(!rc); oc_init_platform("MyNewt", NULL, NULL); oc_add_device("/oic/d", "oic.d.sensy", "sensy", "1.0", "1.0", NULL, NULL); assert(!oc_stack_errno); #endif }
static void ocf_init_tasks(void) { int rc; rc = os_task_init(&ocf_main_task, "ocf", ocf_main_task_handler, NULL, OCF_MAIN_TASK_PRIO, OS_WAIT_FOREVER, ocf_stack, OCF_MAIN_TASK_STACK_SIZE); assert(rc == 0); /* Initialize eventq */ os_eventq_init(&ocf_main_evq); /* Set the default eventq for packages that lack a dedicated task. */ os_eventq_dflt_set(&ocf_main_evq); oc_main_init(&ocf_handler); }
/** * init_tasks * * Called by main.c after sysinit(). This function performs initializations * that are required before tasks are running. * * @return int 0 success; error otherwise. */ static void init_tasks(void) { os_stack_t *pstack; /* Initialize global test semaphore */ os_sem_init(&g_test_sem, 0); pstack = malloc(sizeof(os_stack_t)*TASK1_STACK_SIZE); assert(pstack); os_task_init(&task1, "task1", task1_handler, NULL, TASK1_PRIO, OS_WAIT_FOREVER, pstack, TASK1_STACK_SIZE); pstack = malloc(sizeof(os_stack_t)*TASK2_STACK_SIZE); assert(pstack); os_task_init(&task2, "task2", task2_handler, NULL, TASK2_PRIO, OS_WAIT_FOREVER, pstack, TASK2_STACK_SIZE); oc_main_init((oc_handler_t *)&omgr_oc_handler); }