static void app_init(void) { oc_init_platform("Mynewt", NULL, NULL); #if (MYNEWT_VAL(OC_CLIENT) == 1) oc_add_device("/oic/d", "oic.d.light", "MynewtClient", "1.0", "1.0", set_device_custom_property, NULL); #endif #if (MYNEWT_VAL(OC_SERVER) == 1) oc_add_device("/oic/d", "oic.d.light", "MynewtServer", "1.0", "1.0", NULL, NULL); #endif }
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 }