/** * main * * The main task for the project. This function initializes the packages, * then starts serving events from default event queue. * * @return int NOTE: this function should never return! */ int main(void) { int rc; /* Initialize OS */ sysinit(); /* Initialize the BLE host. */ log_register("ble_hs", &ble_hs_log, &log_console_handler, NULL, LOG_SYSLEVEL); ble_hs_cfg.sync_cb = bleuart_on_sync; ble_hs_cfg.store_status_cb = ble_store_util_status_rr; rc = bleuart_gatt_svr_init(); assert(rc == 0); /* Set the default device name. */ rc = ble_svc_gap_device_name_set("Mynewt_BLEuart"); assert(rc == 0); while (1) { os_eventq_run(os_eventq_dflt_get()); } /* Never exit */ return 0; }
/** * This task serves as a container for the shell and newtmgr packages. These * packages enqueue timer events when they need this task to do work. */ static void task3_handler(void *arg) { while (1) { os_eventq_run(&slinky_oic_evq); } }
/** * This task serves as a container for the shell and newtmgr packages. These * packages enqueue timer events when they need this task to do work. */ static void task2_handler(void *arg) { while (1) { os_eventq_run(&spitest_evq); } }
/** * This task serves as a container for the shell and newtmgr packages. These * packages enqueue timer events when they need this task to do work. */ static void task3_handler(void *arg) { while (1) { os_eventq_run(&splitty_evq); } }
/** * main * * The main task for the project. This function initializes the packages, calls * init_tasks to initialize additional tasks (and possibly other objects), * then starts serving events from default event queue. * * @return int NOTE: this function should never return! */ int main(int argc, char **argv) { int rc; #ifdef ARCH_sim mcu_sim_parse_args(argc, argv); #endif sysinit(); cbmem_init(&cbmem, cbmem_buf, MAX_CBMEM_BUF); log_register("log", &my_log, &log_cbmem_handler, &cbmem, LOG_SYSLEVEL); stats_init(STATS_HDR(g_stats_gpio_toggle), STATS_SIZE_INIT_PARMS(g_stats_gpio_toggle, STATS_SIZE_32), STATS_NAME_INIT_PARMS(gpio_stats)); stats_register("gpio_toggle", STATS_HDR(g_stats_gpio_toggle)); conf_load(); reboot_start(hal_reset_cause()); init_tasks(); while (1) { os_eventq_run(os_eventq_dflt_get()); } /* Never exit */ return rc; }
/** * main * * The main task for the project. This function initializes the packages, * then starts serving events from default event queue. * * @return int NOTE: this function should never return! */ int main(void) { int rc; /* Initialize OS */ sysinit(); /* Initialize the blesplit log. */ log_register("blesplit", &blesplit_log, &log_console_handler, NULL, LOG_SYSLEVEL); /* Initialize the NimBLE host configuration. */ log_register("ble_hs", &ble_hs_log, &log_console_handler, NULL, LOG_SYSLEVEL); ble_hs_cfg.reset_cb = blesplit_on_reset; ble_hs_cfg.sync_cb = blesplit_on_sync; ble_hs_cfg.store_status_cb = ble_store_util_status_rr; /* Set the default device name. */ rc = ble_svc_gap_device_name_set("nimble-blesplit"); assert(rc == 0); conf_load(); /* * As the last thing, process events from default event queue. */ while (1) { os_eventq_run(os_eventq_dflt_get()); } return 0; }
static void ble_os_test_app_task_handler(void *arg) { while (1) { os_eventq_run(&ble_hs_test_util_evq); } }
static void ocf_main_task_handler(void *arg) { #if (MYNEWT_VAL(OC_CLIENT) == 1) os_callout_init(&callout, &ocf_main_evq, stop_observe, NULL); #endif while (1) { os_eventq_run(&ocf_main_evq); } oc_main_shutdown(); }
/** * main * * The main task for the project. This function initializes the packages, calls * init_tasks to initialize additional tasks (and possibly other objects), * then starts serving events from default event queue. * * @return int NOTE: this function should never return! */ int main(int argc, char **argv) { int rc; #ifdef ARCH_sim mcu_sim_parse_args(argc, argv); #endif sysinit(); rc = conf_register(&test_conf_handler); assert(rc == 0); cbmem_init(&cbmem, cbmem_buf, MAX_CBMEM_BUF); log_register("log", &my_log, &log_cbmem_handler, &cbmem, LOG_SYSLEVEL); stats_init(STATS_HDR(g_stats_gpio_toggle), STATS_SIZE_INIT_PARMS(g_stats_gpio_toggle, STATS_SIZE_32), STATS_NAME_INIT_PARMS(gpio_stats)); stats_register("gpio_toggle", STATS_HDR(g_stats_gpio_toggle)); flash_test_init(); conf_load(); log_reboot(hal_reset_cause()); init_tasks(); /* If this app is acting as the loader in a split image setup, jump into * the second stage application instead of starting the OS. */ #if MYNEWT_VAL(SPLIT_LOADER) { void *entry; rc = split_app_go(&entry, true); if(rc == 0) { hal_system_restart(entry); } } #endif /* * As the last thing, process events from default event queue. */ while (1) { os_eventq_run(os_eventq_dflt_get()); } }
/** * main * * The main task for the project. This function initializes the packages, calls * init_tasks to initialize additional tasks (and possibly other objects), * then starts serving events from default event queue. * * @return int NOTE: this function should never return! */ int main(int argc, char **argv) { int rc; #ifdef ARCH_sim mcu_sim_parse_args(argc, argv); #endif sysinit(); rc = conf_register(&test_conf_handler); assert(rc == 0); cbmem_init(&cbmem, cbmem_buf, MAX_CBMEM_BUF); log_register("log", &my_log, &log_cbmem_handler, &cbmem, LOG_SYSLEVEL); /* Initialize the OIC */ log_register("oic", &oc_log, &log_console_handler, NULL, LOG_SYSLEVEL); stats_init(STATS_HDR(g_stats_gpio_toggle), STATS_SIZE_INIT_PARMS(g_stats_gpio_toggle, STATS_SIZE_32), STATS_NAME_INIT_PARMS(gpio_stats)); stats_register("gpio_toggle", STATS_HDR(g_stats_gpio_toggle)); conf_load(); reboot_start(hal_reset_cause()); #if MYNEWT_VAL(SPLIT_LOADER) { void *entry; rc = split_app_go(&entry, true); if(rc == 0) { hal_system_start(entry); } } #endif init_tasks(); while (1) { os_eventq_run(os_eventq_dflt_get()); } /* Never returns */ return rc; }
/** * Link Layer task. * * This is the task that runs the Link Layer. * * @param arg */ void ble_ll_task(void *arg) { /* Init ble phy */ ble_phy_init(); /* Set output power to 1mW (0 dBm) */ ble_phy_txpwr_set(MYNEWT_VAL(BLE_LL_TX_PWR_DBM)); /* Tell the host that we are ready to receive packets */ ble_ll_hci_send_noop(); ble_ll_rand_start(); while (1) { os_eventq_run(&g_ble_ll_data.ll_evq); } }
/** * main * * The main task for the project. This function initializes the packages, calls * init_tasks to initialize additional tasks (and possibly other objects), * then starts serving events from default event queue. * * @return int NOTE: this function should never return! */ int main(int argc, char **argv) { int rc; #ifdef ARCH_sim mcu_sim_parse_args(argc, argv); #endif sysinit(); init_tasks(); while (1) { os_eventq_run(os_eventq_dflt_get()); } /* Never returns */ assert(0); return rc; }
/** * main * * The main task for the project. This function initializes the packages, calls * init_tasks to initialize additional tasks (and possibly other objects), * then starts serving events from default event queue. * * @return int NOTE: this function should never return! */ int main(int argc, char **argv) { #ifdef ARCH_sim mcu_sim_parse_args(argc, argv); #endif /* Initialize OS */ sysinit(); /* Initialize BLE and OIC logs */ ble_oic_log_init(); /* Load config */ conf_load(); /* Initialize tasks */ init_tasks(); /* Sensor device shell init */ sensors_dev_shell_init(); /* Initialize BLE OIC GATT Server */ sensor_ble_oic_server_init(); /* log reboot */ reboot_start(hal_reset_cause()); /* * As the last thing, process events from default event queue. */ while (1) { os_eventq_run(os_eventq_dflt_get()); } return (0); }
/** * main * * The main task for the project. This function initializes the packages, * then starts serving events from default event queue. * * @return int NOTE: this function should never return! */ int main(void) { int rc; /* Initialize OS */ sysinit(); /* Dummy device address */ #if BLETEST_CFG_ROLE == BLETEST_ROLE_ADVERTISER g_dev_addr[0] = 0x00; g_dev_addr[1] = 0x00; g_dev_addr[2] = 0x00; g_dev_addr[3] = 0x88; g_dev_addr[4] = 0x88; g_dev_addr[5] = 0x08; g_bletest_cur_peer_addr[0] = 0x00; g_bletest_cur_peer_addr[1] = 0x00; g_bletest_cur_peer_addr[2] = 0x00; g_bletest_cur_peer_addr[3] = 0x99; g_bletest_cur_peer_addr[4] = 0x99; g_bletest_cur_peer_addr[5] = 0x09; #else g_dev_addr[0] = 0x00; g_dev_addr[1] = 0x00; g_dev_addr[2] = 0x00; g_dev_addr[3] = 0x99; g_dev_addr[4] = 0x99; g_dev_addr[5] = 0x09; g_bletest_cur_peer_addr[0] = 0x00; g_bletest_cur_peer_addr[1] = 0x00; g_bletest_cur_peer_addr[2] = 0x00; g_bletest_cur_peer_addr[3] = 0x88; g_bletest_cur_peer_addr[4] = 0x88; g_bletest_cur_peer_addr[5] = 0x08; #endif log_register("ble_hs", &ble_hs_log, &log_console_handler, NULL, LOG_SYSLEVEL); /* Set the led pin as an output */ g_led_pin = LED_BLINK_PIN; hal_gpio_init_out(g_led_pin, 1); /* Initialize eventq for bletest task */ os_eventq_init(&g_bletest_evq); rc = os_task_init(&bletest_task, "bletest", bletest_task_handler, NULL, BLETEST_TASK_PRIO, OS_WAIT_FOREVER, bletest_stack, BLETEST_STACK_SIZE); assert(rc == 0); while (1) { os_eventq_run(os_eventq_dflt_get()); } /* Never returns */ /* os start should never return. If it does, this should be an error */ assert(0); return rc; }
/** * BLE test task * * @param arg */ void bletest_task_handler(void *arg) { int rc; uint64_t rand64; uint64_t event_mask; /* Set LED blink rate */ g_bletest_led_rate = OS_TICKS_PER_SEC / 20; /* Wait one second before starting test task */ os_time_delay(OS_TICKS_PER_SEC); /* Initialize the host timer */ os_callout_init(&g_bletest_timer, &g_bletest_evq, bletest_timer_cb, NULL); ble_hs_dbg_set_sync_state(BLE_HS_SYNC_STATE_GOOD); /* Send the reset command first */ rc = bletest_hci_reset_ctlr(); assert(rc == 0); #if (BLETEST_CFG_ROLE == BLETEST_ROLE_ADVERTISER) /* Initialize the advertiser */ console_printf("Starting BLE test task as advertiser\n"); #if MYNEWT_VAL(BLE_ANDROID_MULTI_ADV_SUPPORT) /* Start up all advertising instances except default one */ bletest_init_adv_instances(); /* Start advertising on instance 0 at 0 dbm */ bletest_init_advertising(0, 0); #else bletest_init_advertising(); #endif #endif #if (BLETEST_CFG_ROLE == BLETEST_ROLE_SCANNER) /* Initialize the scanner */ console_printf("Starting BLE test task as scanner\n"); bletest_init_scanner(); #endif #if (BLETEST_CFG_ROLE == BLETEST_ROLE_INITIATOR) /* Initialize the scanner */ console_printf("Starting BLE test task as initiator\n"); bletest_init_initiator(); #endif /* Read unique HW id */ rc = hal_bsp_hw_id((void *)&g_bletest_hw_id[0], sizeof(g_bletest_hw_id)); assert(rc == 16); console_printf("HW id=%04x%04x%04x%04x\n", (unsigned int)g_bletest_hw_id[0], (unsigned int)g_bletest_hw_id[1], (unsigned int)g_bletest_hw_id[2], (unsigned int)g_bletest_hw_id[3]); /* Set the event mask we want to display */ event_mask = 0x7FF; rc = bletest_hci_le_set_event_mask(event_mask); assert(rc == 0); /* Turn on all events */ event_mask = 0xffffffffffffffff; rc = bletest_hci_set_event_mask(event_mask); assert(rc == 0); /* Read device address */ rc = bletest_hci_rd_bd_addr(); assert(rc == 0); /* Read local features */ rc = bletest_hci_rd_local_feat(); assert(rc == 0); /* Read local commands */ rc = bletest_hci_rd_local_supp_cmd(); assert(rc == 0); /* Read version */ rc = bletest_hci_rd_local_version(); assert(rc == 0); /* Read supported states */ rc = bletest_hci_le_read_supp_states(); assert(rc == 0); /* Read maximum data length */ rc = bletest_hci_le_rd_max_datalen(); assert(rc == 0); #if (MYNEWT_VAL(BLE_LL_CFG_FEAT_DATA_LEN_EXT) == 1) /* Read suggested data length */ rc = bletest_hci_le_rd_sugg_datalen(); assert(rc == 0); /* write suggested default data length */ rc = bletest_hci_le_write_sugg_datalen(BLETEST_CFG_SUGG_DEF_TXOCTETS, BLETEST_CFG_SUGG_DEF_TXTIME); assert(rc == 0); /* Read suggested data length */ rc = bletest_hci_le_rd_sugg_datalen(); assert(rc == 0); /* Set data length (note: we know there is no connection; just a test) */ rc = bletest_hci_le_set_datalen(0x1234, BLETEST_CFG_SUGG_DEF_TXOCTETS, BLETEST_CFG_SUGG_DEF_TXTIME); assert(rc != 0); #endif /* Encrypt a block */ #if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION) == 1) rc = bletest_hci_le_encrypt((uint8_t *)g_ble_ll_encrypt_test_key, (uint8_t *)g_ble_ll_encrypt_test_plain_text); assert(rc == 0); #endif /* Get a random number */ rc = ble_hs_hci_util_rand(&rand64, 8); assert(rc == 0); /* Wait some time before starting */ os_time_delay(OS_TICKS_PER_SEC); /* Init state */ g_bletest_state = 0; /* Begin advertising if we are an advertiser */ #if (BLETEST_CFG_ROLE == BLETEST_ROLE_ADVERTISER) #if MYNEWT_VAL(BLE_ANDROID_MULTI_ADV_SUPPORT) rc = bletest_hci_le_set_multi_adv_enable(1, 0); assert(rc == 0); #else rc = bletest_hci_le_set_adv_enable(1); assert(rc == 0); #endif #endif bletest_timer_cb(NULL); while (1) { os_eventq_run(&g_bletest_evq); } }