merge from develop, and update to support new sysinit
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/2681044e Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/2681044e Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/2681044e Branch: refs/heads/develop Commit: 2681044e84b6446a1a354278d8f5ca69bf6d447d Parents: 6247b5a 71f7d65 Author: Sterling Hughes <[email protected]> Authored: Mon Jan 23 19:01:08 2017 -0800 Committer: Sterling Hughes <[email protected]> Committed: Mon Jan 23 19:01:08 2017 -0800 ---------------------------------------------------------------------- apps/blecent/pkg.yml | 4 +- apps/blecent/src/blecent.h | 12 +- apps/blecent/src/main.c | 63 +- apps/blecent/src/misc.c | 26 +- apps/blecent/src/peer.c | 20 +- apps/blecent/syscfg.yml | 4 + apps/blehci/pkg.yml | 2 +- apps/blehci/src/main.c | 9 +- apps/blehci/syscfg.yml | 24 + apps/bleprph/pkg.yml | 6 +- apps/bleprph/src/gatt_svr.c | 172 +- apps/bleprph/src/main.c | 64 +- apps/bleprph/syscfg.yml | 4 + apps/bleprph_oic/pkg.yml | 4 +- apps/bleprph_oic/src/gatt_svr.c | 79 +- apps/bleprph_oic/src/main.c | 57 +- apps/bleprph_oic/syscfg.yml | 5 + apps/bletest/pkg.yml | 4 +- apps/bletest/src/main.c | 47 +- apps/bletest/syscfg.yml | 6 +- apps/bletiny/pkg.yml | 7 +- apps/bletiny/src/bletiny.h | 15 +- apps/bletiny/src/cmd.c | 98 +- apps/bletiny/src/gatt_svr.c | 330 +- apps/bletiny/src/main.c | 90 +- apps/bletiny/src/misc.c | 20 +- apps/bletiny/src/parse.c | 27 +- apps/bletiny/syscfg.yml | 7 +- apps/bleuart/pkg.yml | 3 +- apps/bleuart/src/main.c | 44 +- apps/bleuart/syscfg.yml | 4 + apps/boot/syscfg.yml | 2 + apps/fat2native/pkg.yml | 2 + apps/ffs2native/pkg.yml | 2 + apps/ocf_sample/pkg.yml | 3 +- apps/ocf_sample/src/main.c | 86 +- apps/ocf_sample/syscfg.yml | 3 + apps/slinky/pkg.yml | 10 +- apps/slinky/src/main.c | 71 +- apps/slinky/syscfg.yml | 3 + apps/slinky_oic/pkg.yml | 6 +- apps/slinky_oic/src/main.c | 45 +- apps/slinky_oic/syscfg.yml | 4 + apps/spitest/pkg.yml | 4 +- apps/spitest/src/main.c | 40 +- apps/spitest/syscfg.yml | 4 + apps/splitty/pkg.yml | 15 +- apps/splitty/src/main.c | 47 +- apps/splitty/syscfg.yml | 4 + apps/testbench/pkg.yml | 57 + apps/testbench/src/testbench.c | 386 + apps/testbench/src/testbench.h | 189 + apps/testbench/src/testbench_json.c | 82 + apps/testbench/src/testbench_mempool.c | 98 + apps/testbench/src/testbench_mutex.c | 172 + apps/testbench/src/testbench_sem.c | 141 + apps/testbench/syscfg.yml | 37 + apps/timtest/pkg.yml | 4 +- apps/timtest/src/main.c | 39 +- boot/bootutil/design.txt | 191 +- boot/bootutil/include/bootutil/bootutil.h | 15 +- boot/bootutil/include/bootutil/image.h | 9 +- boot/bootutil/pkg.yml | 3 + boot/bootutil/signed_images.md | 16 +- boot/bootutil/src/bootutil_misc.c | 46 +- boot/bootutil/src/image_ec.c | 5 +- boot/bootutil/src/image_ec256.c | 179 + boot/bootutil/src/image_validate.c | 20 +- boot/bootutil/src/loader.c | 269 +- boot/bootutil/syscfg.yml | 3 + boot/bootutil/test/src/boot_test.c | 4 + boot/bootutil/test/src/boot_test.h | 1 + boot/bootutil/test/src/boot_test_utils.c | 16 + .../test/src/testcases/boot_test_invalid_hash.c | 2 +- .../src/testcases/boot_test_no_flag_has_hash.c | 2 +- .../test/src/testcases/boot_test_no_hash.c | 2 +- .../test/src/testcases/boot_test_nv_bs_11.c | 2 +- .../src/testcases/boot_test_nv_bs_11_2areas.c | 2 +- .../test/src/testcases/boot_test_nv_ns_01.c | 2 +- .../test/src/testcases/boot_test_permanent.c | 53 + .../testcases/boot_test_permanent_continue.c | 62 + .../test/src/testcases/boot_test_vb_ns_11.c | 2 +- .../test/src/testcases/boot_test_vm_ns_01.c | 2 +- .../src/testcases/boot_test_vm_ns_11_2areas.c | 2 +- .../test/src/testcases/boot_test_vm_ns_11_b.c | 2 +- boot/split/pkg.yml | 4 +- boot/split/src/split.c | 7 +- boot/split_app/pkg.yml | 25 + boot/split_app/src/split_app.c | 46 + compiler/arm-none-eabi-m0/compiler.yml | 2 +- compiler/arm-none-eabi-m4/compiler.yml | 2 +- compiler/sim/compiler.yml | 4 +- crypto/tinycrypt/LICENSE | 62 + crypto/tinycrypt/README | 82 +- crypto/tinycrypt/VERSION | 1 + crypto/tinycrypt/include/tinycrypt/aes.h | 16 +- crypto/tinycrypt/include/tinycrypt/cbc_mode.h | 8 +- crypto/tinycrypt/include/tinycrypt/ccm_mode.h | 12 +- crypto/tinycrypt/include/tinycrypt/cmac_mode.h | 20 +- crypto/tinycrypt/include/tinycrypt/constants.h | 4 + crypto/tinycrypt/include/tinycrypt/ctr_mode.h | 4 +- crypto/tinycrypt/include/tinycrypt/ctr_prng.h | 167 + crypto/tinycrypt/include/tinycrypt/ecc.h | 8 +- crypto/tinycrypt/include/tinycrypt/ecc_dh.h | 14 +- crypto/tinycrypt/include/tinycrypt/ecc_dsa.h | 8 +- crypto/tinycrypt/include/tinycrypt/hmac.h | 16 +- crypto/tinycrypt/include/tinycrypt/hmac_prng.h | 12 +- crypto/tinycrypt/include/tinycrypt/sha256.h | 12 +- crypto/tinycrypt/include/tinycrypt/utils.h | 8 +- crypto/tinycrypt/src/aes_decrypt.c | 8 +- crypto/tinycrypt/src/aes_encrypt.c | 14 +- crypto/tinycrypt/src/cbc_mode.c | 8 +- crypto/tinycrypt/src/ccm_mode.c | 30 +- crypto/tinycrypt/src/cmac_mode.c | 28 +- crypto/tinycrypt/src/ctr_mode.c | 6 +- crypto/tinycrypt/src/ctr_prng.c | 308 + crypto/tinycrypt/src/hmac.c | 24 +- crypto/tinycrypt/src/hmac_prng.c | 16 +- crypto/tinycrypt/src/sha256.c | 18 +- crypto/tinycrypt/src/utils.c | 2 +- encoding/base64/include/base64/hex.h | 2 +- encoding/base64/src/hex.c | 2 +- encoding/cborattr/include/cborattr/cborattr.h | 33 +- encoding/cborattr/src/cborattr.c | 374 +- encoding/cborattr/test/pkg.yml | 31 + encoding/cborattr/test/src/test_cborattr.c | 48 + encoding/cborattr/test/src/test_cborattr.h | 57 + .../cborattr/test/src/test_cborattr_utils.c | 35 + .../test/src/testcases/cborattr_decode1.c | 83 + .../src/testcases/cborattr_decode_bool_array.c | 101 + .../src/testcases/cborattr_decode_int_array.c | 143 + .../src/testcases/cborattr_decode_obj_array.c | 109 + .../test/src/testcases/cborattr_decode_object.c | 198 + .../testcases/cborattr_decode_object_array.c | 126 + .../src/testcases/cborattr_decode_partial.c | 47 + .../test/src/testcases/cborattr_decode_simple.c | 123 + .../testcases/cborattr_decode_string_array.c | 135 + .../testcases/cborattr_decode_unnamed_array.c | 99 + encoding/json/test/src/test_json.h | 7 +- encoding/json/test/src/test_json_utils.c | 6 +- .../tinycbor/include/tinycbor/cbor_buf_reader.h | 4 +- .../tinycbor/include/tinycbor/cbor_buf_writer.h | 12 +- .../include/tinycbor/cbor_mbuf_reader.h | 14 +- .../include/tinycbor/cbor_mbuf_writer.h | 7 +- encoding/tinycbor/src/cbor_buf_reader.c | 25 +- encoding/tinycbor/src/cbor_buf_writer.c | 16 +- encoding/tinycbor/src/cbor_mbuf_reader.c | 55 +- encoding/tinycbor/src/cbor_mbuf_writer.c | 7 +- encoding/tinycbor/src/cborencoder.c | 8 +- .../src/cborencoder_close_container_checked.c | 10 +- encoding/tinycbor/src/cborerrorstrings.c | 2 +- encoding/tinycbor/src/cborparser.c | 10 +- encoding/tinycbor/src/cborparser_dup_string.c | 2 +- encoding/tinycbor/src/cborpretty.c | 6 +- encoding/tinycbor/src/cbortojson.c | 8 +- encoding/tinycbor/src/open_memstream.c | 2 +- fs/disk/include/disk/disk.h | 56 + fs/disk/pkg.yml | 27 + fs/disk/src/disk.c | 151 + fs/fatfs/pkg.yml | 9 +- fs/fatfs/src/mynewt_glue.c | 227 +- fs/fs/include/fs/fs_if.h | 37 +- fs/fs/pkg.yml | 3 + fs/fs/src/fs_dirent.c | 30 +- fs/fs/src/fs_file.c | 180 +- fs/fs/src/fs_mkdir.c | 8 +- fs/fs/src/fs_mount.c | 59 +- fs/fs/src/fs_priv.h | 3 +- fs/nffs/pkg.yml | 9 +- fs/nffs/src/nffs.c | 19 +- fs/nffs/src/nffs_dir.c | 5 + fs/nffs/src/nffs_file.c | 4 + fs/nffs/src/nffs_misc.c | 4 +- fs/nffs/src/nffs_priv.h | 3 + fs/nffs/test/pkg.yml | 2 + hw/bsp/arduino_primo_nrf52/pkg.yml | 2 - hw/bsp/arduino_primo_nrf52/primo_debug.sh | 3 +- .../src/arch/cortex_m4/gcc_startup_nrf52.s | 10 + .../arch/cortex_m4/gcc_startup_nrf52_split.s | 12 +- hw/bsp/arduino_primo_nrf52/src/hal_bsp.c | 11 +- hw/bsp/arduino_primo_nrf52/syscfg.yml | 7 +- hw/bsp/bmd300eval/pkg.yml | 2 - .../src/arch/cortex_m4/gcc_startup_nrf52.s | 10 + .../arch/cortex_m4/gcc_startup_nrf52_split.s | 12 +- hw/bsp/bmd300eval/src/hal_bsp.c | 11 +- hw/bsp/bmd300eval/syscfg.yml | 7 +- hw/bsp/ci40/bsp.yml | 4 +- hw/bsp/ci40/pkg.yml | 6 + hw/bsp/frdm-k64f/pkg.yml | 17 +- hw/bsp/frdm-k64f/src/hal_bsp.c | 4 + hw/bsp/native/pkg.yml | 2 - hw/bsp/native/src/hal_bsp.c | 13 + hw/bsp/nrf51-arduino_101/pkg.yml | 3 - .../src/arch/cortex_m0/gcc_startup_nrf51.s | 12 +- hw/bsp/nrf51-arduino_101/src/hal_bsp.c | 13 +- hw/bsp/nrf51-arduino_101/syscfg.yml | 7 +- hw/bsp/nrf51-blenano/nrf51dk_debug.sh | 3 +- hw/bsp/nrf51-blenano/pkg.yml | 2 - .../src/arch/cortex_m0/gcc_startup_nrf51.s | 12 +- .../arch/cortex_m0/gcc_startup_nrf51_split.s | 15 +- hw/bsp/nrf51-blenano/src/hal_bsp.c | 16 +- hw/bsp/nrf51-blenano/syscfg.yml | 7 +- hw/bsp/nrf51dk-16kbram/pkg.yml | 2 - hw/bsp/nrf51dk-16kbram/split-nrf51dk-16kbram.ld | 2 +- .../src/arch/cortex_m0/gcc_startup_nrf51.s | 14 +- .../arch/cortex_m0/gcc_startup_nrf51_split.s | 14 +- hw/bsp/nrf51dk-16kbram/src/hal_bsp.c | 13 +- hw/bsp/nrf51dk-16kbram/syscfg.yml | 7 +- hw/bsp/nrf51dk/pkg.yml | 2 - .../src/arch/cortex_m0/gcc_startup_nrf51.s | 12 +- .../arch/cortex_m0/gcc_startup_nrf51_split.s | 13 +- hw/bsp/nrf51dk/src/hal_bsp.c | 14 +- hw/bsp/nrf51dk/syscfg.yml | 7 +- hw/bsp/nrf52840pdk/boot-nrf52840aa.ld | 26 + hw/bsp/nrf52840pdk/bsp.yml | 62 + hw/bsp/nrf52840pdk/include/bsp/boards.h | 19 + hw/bsp/nrf52840pdk/include/bsp/bsp.h | 53 + hw/bsp/nrf52840pdk/include/bsp/cmsis_nvic.h | 29 + hw/bsp/nrf52840pdk/nrf52840aa.ld | 26 + hw/bsp/nrf52840pdk/nrf52840pdk_debug.sh | 46 + hw/bsp/nrf52840pdk/nrf52840pdk_download.sh | 40 + hw/bsp/nrf52840pdk/nrf52840pdk_no_boot.ld | 191 + hw/bsp/nrf52840pdk/pkg.yml | 94 + hw/bsp/nrf52840pdk/split-nrf52840pdk.ld | 204 + .../src/arch/cortex_m4/gcc_startup_nrf52840.s | 322 + .../arch/cortex_m4/gcc_startup_nrf52_split.s | 161 + hw/bsp/nrf52840pdk/src/hal_bsp.c | 209 + hw/bsp/nrf52840pdk/src/sbrk.c | 59 + hw/bsp/nrf52840pdk/syscfg.yml | 104 + hw/bsp/nrf52dk/pkg.yml | 2 - .../src/arch/cortex_m4/gcc_startup_nrf52.s | 12 +- .../arch/cortex_m4/gcc_startup_nrf52_split.s | 12 +- hw/bsp/nrf52dk/src/hal_bsp.c | 19 +- hw/bsp/nrf52dk/syscfg.yml | 7 +- hw/bsp/nucleo-f401re/nucleo-f401re_debug.sh | 2 +- .../src/arch/cortex_m4/startup_STM32F40x.s | 10 + hw/bsp/nucleo-f401re/syscfg.yml | 4 - .../olimex_stm32-e407_devboard_debug.sh | 2 +- hw/bsp/olimex_stm32-e407_devboard/pkg.yml | 2 - .../src/arch/cortex_m4/startup_STM32F40x.s | 10 + hw/bsp/olimex_stm32-e407_devboard/syscfg.yml | 4 - hw/bsp/rb-nano2/pkg.yml | 2 - hw/bsp/rb-nano2/rb-nano2_debug.sh | 3 +- .../src/arch/cortex_m4/gcc_startup_nrf52.s | 10 + .../arch/cortex_m4/gcc_startup_nrf52_split.s | 12 +- hw/bsp/rb-nano2/src/hal_bsp.c | 9 +- hw/bsp/rb-nano2/syscfg.yml | 8 +- .../src/arch/cortex_m4/startup_STM32F40x.s | 10 + .../stm32f4discovery/stm32f4discovery_debug.sh | 3 +- hw/bsp/usbmkw41z/boot-mkw41z512.ld | 197 + hw/bsp/usbmkw41z/bsp.yml | 60 + hw/bsp/usbmkw41z/include/bsp/bsp.h | 47 + hw/bsp/usbmkw41z/include/bsp/cmsis_nvic.h | 42 + hw/bsp/usbmkw41z/mkw41z512.ld | 186 + hw/bsp/usbmkw41z/no-boot-mkw41z512.ld | 197 + hw/bsp/usbmkw41z/pkg.yml | 35 + .../src/arch/cortex_m0/gcc_startup_mkw41z.s | 240 + hw/bsp/usbmkw41z/src/hal_bsp.c | 88 + hw/bsp/usbmkw41z/src/sbrk.c | 59 + hw/bsp/usbmkw41z/syscfg.yml | 31 + hw/bsp/usbmkw41z/usbkw41z_debug.sh | 36 + hw/bsp/usbmkw41z/usbkw41z_download.sh | 41 + hw/drivers/flash/at45db/pkg.yml | 27 + hw/drivers/flash/at45db/src/at45db.c | 452 + hw/drivers/mmc/include/mmc/mmc.h | 23 + hw/drivers/mmc/src/mmc.c | 34 + hw/drivers/nimble/nrf51/src/ble_phy.c | 8 +- hw/drivers/nimble/nrf52/src/ble_phy.c | 8 +- hw/hal/include/hal/hal_flash.h | 2 +- hw/hal/include/hal/hal_flash_int.h | 18 +- hw/hal/include/hal/hal_system.h | 3 + hw/hal/src/hal_flash.c | 20 +- hw/mcu/native/src/hal_flash.c | 31 +- hw/mcu/native/src/hal_system.c | 23 +- hw/mcu/native/src/hal_uart.c | 2 +- hw/mcu/nordic/nrf51xxx/src/hal_flash.c | 28 +- hw/mcu/nordic/nrf51xxx/src/hal_os_tick.c | 84 +- hw/mcu/nordic/nrf51xxx/src/hal_system.c | 63 + hw/mcu/nordic/nrf51xxx/src/hal_timer.c | 239 +- hw/mcu/nordic/nrf52xxx/include/mcu/cortex_m4.h | 5 + hw/mcu/nordic/nrf52xxx/include/mcu/mcu.h | 6 +- hw/mcu/nordic/nrf52xxx/src/hal_flash.c | 30 +- hw/mcu/nordic/nrf52xxx/src/hal_gpio.c | 62 +- hw/mcu/nordic/nrf52xxx/src/hal_i2c.c | 2 - hw/mcu/nordic/nrf52xxx/src/hal_os_tick.c | 2 +- hw/mcu/nordic/nrf52xxx/src/hal_spi.c | 2 +- hw/mcu/nordic/nrf52xxx/src/hal_timer.c | 287 +- hw/mcu/nordic/nrf52xxx/src/hal_watchdog.c | 3 +- hw/mcu/nordic/nrf52xxx/src/nrf52_hw_id.c | 4 +- hw/mcu/nordic/nrf52xxx/src/system_nrf52.c | 175 +- .../components/device/nrf.h | 25 +- .../components/device/nrf51_to_nrf52840.h | 567 + .../components/device/nrf52840.h | 2417 +++ .../components/device/nrf52840_bitfields.h | 14633 +++++++++++++++++ .../components/device/nrf52840_peripherals.h | 240 + .../components/device/nrf52_to_nrf52840.h | 88 + .../components/toolchain/system_nrf52840.c | 209 + .../components/toolchain/system_nrf52840.h | 69 + hw/mcu/nxp/MK64F12/src/hal_flash.c | 28 +- hw/mcu/nxp/mkw41z/include/mcu/MKW41Z4.h | 12979 +++++++++++++++ .../nxp/mkw41z/include/mcu/MKW41Z4_features.h | 1719 ++ hw/mcu/nxp/mkw41z/include/mcu/cortex_m0.h | 41 + .../mkw41z/include/mcu/fsl_device_registers.h | 56 + hw/mcu/nxp/mkw41z/include/mcu/mcu.h | 38 + hw/mcu/nxp/mkw41z/include/mcu/mkw41z_hal.h | 46 + hw/mcu/nxp/mkw41z/include/mcu/system_MKW41Z4.h | 133 + hw/mcu/nxp/mkw41z/pkg.yml | 31 + hw/mcu/nxp/mkw41z/src/hal_gpio.c | 161 + hw/mcu/nxp/mkw41z/src/hal_os_tick.c | 104 + hw/mcu/nxp/mkw41z/src/hal_system.c | 37 + hw/mcu/nxp/mkw41z/src/hal_watchdog.c | 41 + hw/mcu/nxp/mkw41z/src/system_MKW41Z4.c | 179 + hw/mcu/stm/stm32f4xx/src/hal_flash.c | 30 +- hw/scripts/jlink.sh | 15 +- hw/scripts/openocd.sh | 2 +- hw/sensor/pkg.yml | 3 + hw/sensor/src/sensor.c | 6 - kernel/os/include/os/os.h | 3 + kernel/os/include/os/os_eventq.h | 1 - kernel/os/include/os/os_fault.h | 34 + kernel/os/pkg.yml | 4 +- kernel/os/src/arch/cortex_m0/os_fault.c | 5 +- kernel/os/src/arch/cortex_m4/os_fault.c | 5 +- kernel/os/src/arch/mips/os_fault.c | 5 +- kernel/os/src/arch/sim-mips/os_fault.c | 9 +- kernel/os/src/arch/sim/os_fault.c | 9 +- kernel/os/src/os.c | 28 + kernel/os/src/os_eventq.c | 23 +- kernel/os/src/os_heap.c | 8 +- kernel/os/src/os_mbuf.c | 29 +- kernel/os/src/os_time.c | 9 + kernel/os/syscfg.yml | 9 + kernel/os/test/src/eventq_test.c | 1 - kernel/os/test/src/mempool_test.c | 1 + kernel/os/test/src/mutex_test.c | 52 +- kernel/os/test/src/os_test.c | 37 +- kernel/os/test/src/os_test_priv.h | 4 + kernel/os/test/src/sem_test.c | 118 +- .../test/src/testcases/event_test_poll_0timo.c | 2 +- .../src/testcases/event_test_poll_single_sr.c | 3 +- .../os/test/src/testcases/event_test_poll_sr.c | 1 + .../src/testcases/event_test_poll_timeout_sr.c | 5 +- kernel/os/test/src/testcases/event_test_src.c | 3 +- kernel/os/test/src/testcases/os_callout_test.c | 7 +- .../test/src/testcases/os_callout_test_speak.c | 7 +- .../test/src/testcases/os_callout_test_stop.c | 9 +- .../os/test/src/testcases/os_mutex_test_basic.c | 7 +- .../test/src/testcases/os_mutex_test_case_1.c | 14 +- .../test/src/testcases/os_mutex_test_case_2.c | 24 +- .../os/test/src/testcases/os_sem_test_basic.c | 7 +- .../os/test/src/testcases/os_sem_test_case_1.c | 13 +- .../os/test/src/testcases/os_sem_test_case_2.c | 16 +- .../os/test/src/testcases/os_sem_test_case_3.c | 16 +- .../os/test/src/testcases/os_sem_test_case_4.c | 16 +- libc/baselibc/include/assert.h | 2 +- libc/baselibc/src/start.c | 46 + mgmt/imgmgr/include/imgmgr/imgmgr.h | 8 +- mgmt/imgmgr/pkg.yml | 4 +- mgmt/imgmgr/src/imgmgr_cli.c | 121 +- mgmt/imgmgr/src/imgmgr_state.c | 49 +- mgmt/newtmgr/nmgr_os/pkg.yml | 5 +- mgmt/newtmgr/nmgr_os/src/newtmgr_os.c | 6 + mgmt/newtmgr/nmgr_os/syscfg.yml | 23 + mgmt/newtmgr/pkg.yml | 4 +- mgmt/newtmgr/src/newtmgr.c | 8 +- mgmt/newtmgr/transport/ble/pkg.yml | 4 +- mgmt/newtmgr/transport/ble/src/newtmgr_ble.c | 18 +- mgmt/newtmgr/transport/nmgr_shell/pkg.yml | 4 +- mgmt/newtmgr/transport/nmgr_uart/pkg.yml | 4 +- mgmt/oicmgr/pkg.yml | 9 +- mgmt/oicmgr/src/oicmgr.c | 15 +- net/ip/mn_socket/test/src/mn_sock_util.c | 1 + .../mn_socket/test/src/testcases/socket_tests.c | 1 + net/ip/native_sockets/pkg.yml | 4 +- .../controller/include/controller/ble_ll_conn.h | 7 +- .../controller/include/controller/ble_ll_hci.h | 4 +- net/nimble/controller/pkg.yml | 6 +- net/nimble/controller/src/ble_ll.c | 16 +- net/nimble/controller/src/ble_ll_adv.c | 5 +- net/nimble/controller/src/ble_ll_conn.c | 122 +- net/nimble/controller/src/ble_ll_conn_priv.h | 3 - net/nimble/controller/src/ble_ll_hci.c | 16 +- net/nimble/controller/src/ble_ll_resolv.c | 19 +- net/nimble/host/include/host/ble_gap.h | 3 + net/nimble/host/include/host/ble_gatt.h | 49 +- net/nimble/host/include/host/ble_store.h | 1 + net/nimble/host/include/host/ble_uuid.h | 92 +- net/nimble/host/pkg.yml | 12 +- net/nimble/host/profiles/lls/src/ble_svc_lls.c | 4 +- net/nimble/host/pts/README.txt | 8 + net/nimble/host/pts/pts-gap.txt | 370 + net/nimble/host/pts/pts-gatt.txt | 530 + net/nimble/host/pts/pts-l2cap.txt | 223 + net/nimble/host/pts/pts-sm.txt | 149 + .../host/pts/tpg/90359-20161220-172100175.tpg | 1022 ++ .../host/pts/tpg/90359-20161220-172113981.pts | 288 + net/nimble/host/services/ans/pkg.yml | 4 +- net/nimble/host/services/ans/src/ble_svc_ans.c | 14 +- .../services/bleuart/include/bleuart/bleuart.h | 2 +- net/nimble/host/services/bleuart/pkg.yml | 4 +- net/nimble/host/services/bleuart/src/bleuart.c | 28 +- net/nimble/host/services/gap/pkg.yml | 4 +- net/nimble/host/services/gap/src/ble_svc_gap.c | 16 +- net/nimble/host/services/gatt/pkg.yml | 4 +- .../host/services/gatt/src/ble_svc_gatt.c | 4 +- net/nimble/host/services/ias/pkg.yml | 4 +- net/nimble/host/services/ias/src/ble_svc_ias.c | 4 +- net/nimble/host/services/lls/src/ble_svc_lls.c | 4 +- net/nimble/host/services/tps/pkg.yml | 4 +- net/nimble/host/services/tps/src/ble_svc_tps.c | 4 +- net/nimble/host/src/ble_att_clt.c | 19 +- net/nimble/host/src/ble_att_cmd_priv.h | 4 +- net/nimble/host/src/ble_att_priv.h | 20 +- net/nimble/host/src/ble_att_svr.c | 388 +- net/nimble/host/src/ble_gap.c | 51 +- net/nimble/host/src/ble_gattc.c | 158 +- net/nimble/host/src/ble_gatts.c | 182 +- net/nimble/host/src/ble_hs.c | 5 +- net/nimble/host/src/ble_hs_conn.c | 8 +- net/nimble/host/src/ble_hs_conn_priv.h | 3 +- net/nimble/host/src/ble_hs_hci_cmd.c | 8 +- net/nimble/host/src/ble_hs_pvcy.c | 6 +- net/nimble/host/src/ble_sm.c | 123 +- net/nimble/host/src/ble_sm_alg.c | 29 +- net/nimble/host/src/ble_sm_priv.h | 6 +- net/nimble/host/src/ble_sm_sc.c | 6 +- net/nimble/host/src/ble_uuid.c | 240 +- net/nimble/host/src/ble_uuid_priv.h | 9 +- net/nimble/host/store/ram/pkg.yml | 4 +- net/nimble/host/syscfg.yml | 4 + net/nimble/host/test/pkg.yml | 2 + net/nimble/host/test/src/ble_att_clt_test.c | 8 +- net/nimble/host/test/src/ble_att_svr_test.c | 277 +- net/nimble/host/test/src/ble_gap_test.c | 90 + net/nimble/host/test/src/ble_gatt_conn_test.c | 22 +- net/nimble/host/test/src/ble_gatt_disc_c_test.c | 150 +- net/nimble/host/test/src/ble_gatt_disc_d_test.c | 74 +- net/nimble/host/test/src/ble_gatt_disc_s_test.c | 119 +- net/nimble/host/test/src/ble_gatt_find_s_test.c | 56 +- net/nimble/host/test/src/ble_gatt_read_test.c | 23 +- net/nimble/host/test/src/ble_gatt_write_test.c | 12 +- .../host/test/src/ble_gatts_notify_test.c | 16 +- net/nimble/host/test/src/ble_gatts_read_test.c | 8 +- net/nimble/host/test/src/ble_gatts_reg_test.c | 190 +- net/nimble/host/test/src/ble_hs_test_util.c | 152 +- net/nimble/host/test/src/ble_hs_test_util.h | 10 +- net/nimble/host/test/src/ble_uuid_test.c | 93 +- net/nimble/transport/ram/pkg.yml | 4 +- net/nimble/transport/uart/pkg.yml | 4 +- net/nimble/transport/uart/src/ble_hci_uart.c | 8 + net/oic/include/oic/oc_api.h | 5 + net/oic/include/oic/oc_client_state.h | 23 +- net/oic/include/oic/oc_gatt.h | 8 +- net/oic/include/oic/oc_log.h | 20 + net/oic/include/oic/oc_rep.h | 4 +- net/oic/include/oic/oc_ri.h | 17 + net/oic/pkg.yml | 6 +- net/oic/src/api/oc_buffer.c | 47 +- net/oic/src/api/oc_buffer.h | 5 - net/oic/src/api/oc_discovery.c | 33 +- net/oic/src/api/oc_main.c | 3 - net/oic/src/api/oc_rep.c | 21 +- net/oic/src/api/oc_ri.c | 285 +- net/oic/src/api/oc_server_api.c | 11 +- net/oic/src/messaging/coap/coap.c | 278 +- net/oic/src/messaging/coap/coap.h | 132 +- net/oic/src/messaging/coap/constants.h | 2 + net/oic/src/messaging/coap/engine.c | 51 +- net/oic/src/messaging/coap/engine.h | 2 +- net/oic/src/messaging/coap/observe.c | 39 +- net/oic/src/messaging/coap/observe.h | 2 +- net/oic/src/messaging/coap/oc_coap.h | 2 +- net/oic/src/messaging/coap/separate.c | 6 +- net/oic/src/messaging/coap/separate.h | 5 +- net/oic/src/port/mynewt/adaptor.c | 25 - net/oic/src/port/mynewt/adaptor.h | 3 - net/oic/src/port/mynewt/ble_adaptor.c | 57 +- net/oic/src/port/mynewt/ip_adaptor.c | 88 +- net/oic/src/port/mynewt/log.c | 30 + net/oic/src/port/mynewt/random.c | 9 +- net/oic/src/port/oc_connectivity.h | 7 - net/oic/src/port/oc_network_events_mutex.h | 34 - net/oic/syscfg.yml | 4 + net/oic/test/pkg.yml | 34 + net/oic/test/src/test_discovery.c | 153 + net/oic/test/src/test_getset.c | 127 + net/oic/test/src/test_oic.c | 46 + net/oic/test/src/test_oic.h | 51 + net/oic/test/src/testcases/oic_tests.c | 115 + net/oic/test/syscfg.yml | 24 + sys/config/pkg.yml | 4 +- sys/config/src/config_init.c | 30 +- sys/config/test-nffs/pkg.yml | 2 + sys/console/full/pkg.yml | 4 +- sys/console/stub/include/console/prompt.h | 21 +- sys/console/stub/include/console/ticks.h | 16 +- sys/flash_map/include/flash_map/flash_map.h | 13 +- sys/flash_map/pkg.yml | 5 +- sys/flash_map/src/flash_map.c | 47 +- .../test/src/testcases/flash_map_test_case_1.c | 2 +- .../test/src/testcases/flash_map_test_case_2.c | 2 +- sys/id/pkg.yml | 4 +- sys/log/full/include/log/ignore.h | 64 + sys/log/full/include/log/log.h | 233 + sys/log/full/pkg.yml | 44 + sys/log/full/src/log.c | 236 + sys/log/full/src/log_cbmem.c | 129 + sys/log/full/src/log_console.c | 75 + sys/log/full/src/log_fcb.c | 285 + sys/log/full/src/log_nmgr.c | 516 + sys/log/full/src/log_shell.c | 101 + sys/log/full/syscfg.yml | 37 + sys/log/full/test/pkg.yml | 30 + sys/log/full/test/src/log_test.c | 109 + sys/log/full/test/src/log_test.h | 54 + .../full/test/src/testcases/log_append_fcb.c | 33 + sys/log/full/test/src/testcases/log_flush_fcb.c | 31 + sys/log/full/test/src/testcases/log_setup_fcb.c | 39 + sys/log/full/test/src/testcases/log_walk_fcb.c | 30 + sys/log/full/test/syscfg.yml | 22 + sys/log/include/log/ignore.h | 64 - sys/log/include/log/log.h | 223 - sys/log/pkg.yml | 41 - sys/log/src/log.c | 236 - sys/log/src/log_cbmem.c | 120 - sys/log/src/log_console.c | 75 - sys/log/src/log_fcb.c | 275 - sys/log/src/log_nmgr.c | 524 - sys/log/src/log_shell.c | 101 - sys/log/stub/include/log/ignore.h | 64 + sys/log/stub/include/log/log.h | 73 + sys/log/stub/pkg.yml | 29 + sys/log/stub/syscfg.yml | 27 + sys/log/syscfg.yml | 37 - sys/log/test/pkg.yml | 30 - sys/log/test/src/log_test.c | 109 - sys/log/test/src/log_test.h | 54 - sys/log/test/src/testcases/log_append_fcb.c | 33 - sys/log/test/src/testcases/log_flush_fcb.c | 30 - sys/log/test/src/testcases/log_setup_fcb.c | 39 - sys/log/test/src/testcases/log_walk_fcb.c | 29 - sys/log/test/syscfg.yml | 22 - sys/mfg/pkg.yml | 4 +- sys/reboot/pkg.yml | 6 +- sys/shell/pkg.yml | 4 +- sys/stats/full/include/stats/stats.h | 142 + sys/stats/full/pkg.yml | 37 + sys/stats/full/src/stats.c | 390 + sys/stats/full/src/stats_nmgr.c | 185 + sys/stats/full/src/stats_shell.c | 119 + sys/stats/full/syscfg.yml | 32 + sys/stats/include/stats/stats.h | 140 - sys/stats/pkg.yml | 35 - sys/stats/src/stats.c | 390 - sys/stats/src/stats_nmgr.c | 185 - sys/stats/src/stats_shell.c | 119 - sys/stats/stub/include/stats/stats.h | 83 + sys/stats/stub/pkg.yml | 29 + sys/stats/syscfg.yml | 32 - sys/sysinit/include/sysinit/sysinit.h | 22 +- sys/sysinit/pkg.yml | 2 +- sys/sysinit/src/sysinit.c | 15 + sys/sysinit/syscfg.yml | 4 - targets/unittest/pkg.yml | 2 +- targets/unittest/target.yml | 4 +- test/crash_test/pkg.yml | 4 +- test/runtest/pkg.yml | 4 +- test/testutil/include/testutil/testutil.h | 27 +- test/testutil/src/case.c | 26 +- test/testutil/src/suite.c | 1 + test/testutil/src/testutil.c | 6 +- 571 files changed, 53844 insertions(+), 7416 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/2681044e/apps/bletiny/src/gatt_svr.c ---------------------------------------------------------------------- diff --cc apps/bletiny/src/gatt_svr.c index af7b00d,936546f..08a0f6c --- a/apps/bletiny/src/gatt_svr.c +++ b/apps/bletiny/src/gatt_svr.c @@@ -441,7 -351,7 +351,7 @@@ gatt_svr_chr_access_sec_test(uint16_t c * from 128 bit vendor specific UUID. */ static uint16_t - extract_uuid16_from_pts_uuid128(const void *uuid128) -extract_uuid16_from_pts_uuid128(const ble_uuid_t *uuid) ++xtract_uuid16_from_pts_uuid128(const ble_uuid_t *uuid) { const uint8_t *u8ptr; uint16_t uuid16; @@@ -456,7 -366,7 +366,7 @@@ static in gatt_svr_access_test(uint16_t conn_handle, uint16_t attr_handle, struct ble_gatt_access_ctxt *ctxt, void *arg) --{ ++ uint16_t uuid16; int rc; http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/2681044e/apps/slinky/pkg.yml ---------------------------------------------------------------------- diff --cc apps/slinky/pkg.yml index ab87296,3159cb9..52a08ef --- a/apps/slinky/pkg.yml +++ b/apps/slinky/pkg.yml @@@ -33,6 -30,6 +30,8 @@@ pkg.deps - mgmt/newtmgr - mgmt/newtmgr/transport/nmgr_shell - kernel/os ++ - hw/sensor ++ - hw/drivers/sensors/sim - boot/bootutil - sys/shell - sys/config http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/2681044e/apps/slinky/src/main.c ---------------------------------------------------------------------- diff --cc apps/slinky/src/main.c index 9a2b3ac,956ce38..27d6177 --- a/apps/slinky/src/main.c +++ b/apps/slinky/src/main.c @@@ -255,48 -231,8 +233,43 @@@ init_tasks(void os_task_init(&task2, "task2", task2_handler, NULL, TASK2_PRIO, OS_WAIT_FOREVER, pstack, TASK2_STACK_SIZE); - - pstack = malloc(sizeof(os_stack_t)*TASK3_STACK_SIZE); - assert(pstack); - - os_task_init(&task3, "task3", task3_handler, NULL, - TASK3_PRIO, OS_WAIT_FOREVER, pstack, TASK3_STACK_SIZE); - - /* Initialize eventq and designate it as the default. Packages that need - * to schedule work items will piggyback on this eventq. Example packages - * which do this are sys/shell and mgmt/newtmgr. - */ - os_eventq_init(&slinky_evq); - os_eventq_dflt_set(&slinky_evq); } +static int - slinky_sim_accel_init(struct os_dev *dev, void *arg) ++config_sim_sensor(void) +{ ++ struct os_dev *dev; + struct sim_accel_cfg cfg; + int rc; + - rc = sim_accel_init(dev, arg); ++ dev = (struct os_dev *) os_dev_open("simaccel0", OS_TIMEOUT_NEVER, NULL); ++ assert(dev != NULL); ++ ++ rc = sim_accel_init(dev, NULL); + if (rc != 0) { ++ os_dev_close(dev); + goto err; + } + + cfg.sac_nr_samples = 10; + cfg.sac_nr_axises = 1; + /* read once per sec. API should take this value in ms. */ + cfg.sac_sample_itvl = OS_TICKS_PER_SEC; + + rc = sim_accel_config((struct sim_accel *) dev, &cfg); + if (rc != 0) { ++ os_dev_close(dev); + goto err; + } + ++ os_dev_close(dev); ++ + return (0); +err: + return (rc); +} + + /** * main * @@@ -345,17 -286,10 +323,14 @@@ main(int argc, char **argv } #endif - init_tasks(); - - sensor_pkg_init(); - - os_dev_create((struct os_dev *) &sim_accel_sensor, "simaccel0", - OS_DEV_INIT_KERNEL, OS_DEV_INIT_PRIMARY, slinky_sim_accel_init, NULL); ++ config_sim_sensor(); + - os_start(); - - /* os start should never return. If it does, this should be an error */ - assert(0); + /* + * As the last thing, process events from default event queue. + */ + while (1) { + os_eventq_run(os_eventq_dflt_get()); + } + - return rc; ++ return (0); } http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/2681044e/hw/bsp/native/src/hal_bsp.c ---------------------------------------------------------------------- diff --cc hw/bsp/native/src/hal_bsp.c index 5f14e1e,5f14e1e..8ef4b6a --- a/hw/bsp/native/src/hal_bsp.c +++ b/hw/bsp/native/src/hal_bsp.c @@@ -30,8 -30,8 +30,11 @@@ #include "uart_hal/uart_hal.h" #include "mcu/native_bsp.h" #include "mcu/mcu_hal.h" ++#include "sensor/sensor.h" ++#include "sim/sim_accel.h" static struct uart_dev os_bsp_uart0; ++struct sim_accel sim_accel_sensor; const struct hal_flash * hal_bsp_flash_dev(uint8_t id) @@@ -51,11 -51,11 +54,21 @@@ hal_bsp_power_state(int state return (0); } ++static int ++slinky_sim_accel_init(struct os_dev *dev, void *arg) ++{ ++ return (0); ++} ++ void hal_bsp_init(void) { int rc; ++ rc = os_dev_create((struct os_dev *) &sim_accel_sensor, "simaccel0", ++ OS_DEV_INIT_KERNEL, OS_DEV_INIT_PRIMARY, slinky_sim_accel_init, NULL); ++ assert(rc == 0); ++ rc = os_dev_create((struct os_dev *) &os_bsp_uart0, "uart0", OS_DEV_INIT_PRIMARY, 0, uart_hal_init, (void *) NULL); assert(rc == 0); http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/2681044e/hw/drivers/mmc/include/mmc/mmc.h ---------------------------------------------------------------------- diff --cc hw/drivers/mmc/include/mmc/mmc.h index d65363d,4b14e27..bc60dac --- a/hw/drivers/mmc/include/mmc/mmc.h +++ b/hw/drivers/mmc/include/mmc/mmc.h @@@ -21,6 -21,7 +21,10 @@@ #define __MMC_H__ #include <os/os_dev.h> ++<<<<<<< HEAD ++======= + #include <disk/disk.h> ++>>>>>>> develop #ifdef __cplusplus extern "C" { @@@ -43,6 -44,8 +47,11 @@@ #define MMC_ERASE_ERROR (-11) #define MMC_ADDR_ERROR (-12) ++<<<<<<< HEAD ++======= + extern struct disk_ops mmc_ops; + ++>>>>>>> develop /** * Initialize the MMC driver * @@@ -66,7 -69,7 +75,11 @@@ mmc_init(int spi_num, void *spi_cfg, in * @return 0 on success, non-zero on failure */ int ++<<<<<<< HEAD +mmc_read(uint8_t mmc_id, uint32_t addr, void *buf, size_t len); ++======= + mmc_read(uint8_t mmc_id, uint32_t addr, void *buf, uint32_t len); ++>>>>>>> develop /** * Write data to the MMC @@@ -79,7 -82,13 +92,17 @@@ * @return 0 on success, non-zero on failure */ int ++<<<<<<< HEAD +mmc_write(uint8_t mmc_id, uint32_t addr, const void *buf, size_t len); ++======= + mmc_write(uint8_t mmc_id, uint32_t addr, const void *buf, uint32_t len); + + /** + * TODO + */ + int + mmc_ioctl(uint8_t mmc_id, uint32_t cmd, void *arg); ++>>>>>>> develop #ifdef __cplusplus } http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/2681044e/hw/drivers/mmc/src/mmc.c ---------------------------------------------------------------------- diff --cc hw/drivers/mmc/src/mmc.c index ca89434,cae8c29..1a09f34 --- a/hw/drivers/mmc/src/mmc.c +++ b/hw/drivers/mmc/src/mmc.c @@@ -19,9 -19,8 +19,14 @@@ #include <hal/hal_spi.h> #include <hal/hal_gpio.h> ++<<<<<<< HEAD + +#include <mmc/mmc.h> + ++======= + #include <disk/disk.h> + #include <mmc/mmc.h> ++>>>>>>> develop #include <stdio.h> #define MIN(n, m) (((n) < (m)) ? (n) : (m)) @@@ -361,7 -360,7 +366,11 @@@ wait_busy(struct mmc_cfg *mmc * @return 0 on success, non-zero on failure */ int ++<<<<<<< HEAD +mmc_read(uint8_t mmc_id, uint32_t addr, void *buf, size_t len) ++======= + mmc_read(uint8_t mmc_id, uint32_t addr, void *buf, uint32_t len) ++>>>>>>> develop { uint8_t cmd; uint8_t res; @@@ -449,7 -448,7 +458,11 @@@ out * @return 0 on success, non-zero on failure */ int ++<<<<<<< HEAD +mmc_write(uint8_t mmc_id, uint32_t addr, const void *buf, size_t len) ++======= + mmc_write(uint8_t mmc_id, uint32_t addr, const void *buf, uint32_t len) ++>>>>>>> develop { uint8_t cmd; uint8_t res; @@@ -583,3 -582,21 +596,24 @@@ out hal_gpio_write(mmc->ss_pin, 1); return (rc); } ++<<<<<<< HEAD ++======= + + /* + * + */ + int + mmc_ioctl(uint8_t mmc_id, uint32_t cmd, void *arg) + { + return 0; + } + + /* + * + */ + struct disk_ops mmc_ops = { + .read = &mmc_read, + .write = &mmc_write, + .ioctl = &mmc_ioctl, + }; ++>>>>>>> develop http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/2681044e/hw/sensor/pkg.yml ---------------------------------------------------------------------- diff --cc hw/sensor/pkg.yml index decf1c9,0000000..4fe022d mode 100644,000000..100644 --- a/hw/sensor/pkg.yml +++ b/hw/sensor/pkg.yml @@@ -1,25 -1,0 +1,28 @@@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +pkg.name: hw/sensor +pkg.description: Sensor Interface +pkg.author: "Apache Mynewt <[email protected]>" +pkg.homepage: "http://mynewt.apache.org/" +pkg.keywords: + ++ ++pkg.init: ++ sensor_pkg_init: 501 http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/2681044e/hw/sensor/src/sensor.c ---------------------------------------------------------------------- diff --cc hw/sensor/src/sensor.c index ab4c413,0000000..897b7be mode 100644,000000..100644 --- a/hw/sensor/src/sensor.c +++ b/hw/sensor/src/sensor.c @@@ -1,560 -1,0 +1,554 @@@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#include <string.h> +#include <errno.h> +#include <assert.h> + +#include "os/os.h" +#include "sysinit/sysinit.h" + +#include "sensor/sensor.h" + +#include "sensor_priv.h" + +struct { + struct os_mutex mgr_lock; + + struct os_callout mgr_wakeup_callout; + struct os_eventq *mgr_eventq; + + TAILQ_HEAD(, sensor) mgr_sensor_list; +} sensor_mgr; + +int +sensor_mgr_lock(void) +{ + int rc; + + rc = os_mutex_pend(&sensor_mgr.mgr_lock, OS_TIMEOUT_NEVER); + if (rc == 0 || rc == OS_NOT_STARTED) { + return (0); + } + return (rc); +} + +void +sensor_mgr_unlock(void) +{ + (void) os_mutex_release(&sensor_mgr.mgr_lock); +} + +static void +sensor_mgr_remove(struct sensor *sensor) +{ + TAILQ_REMOVE(&sensor_mgr.mgr_sensor_list, sensor, s_next); +} + +static void +sensor_mgr_insert(struct sensor *sensor) +{ + struct sensor *cursor; + + cursor = NULL; + TAILQ_FOREACH(cursor, &sensor_mgr.mgr_sensor_list, s_next) { + if (cursor->s_next_run == OS_TIMEOUT_NEVER) { + break; + } + + if (OS_TIME_TICK_LT(sensor->s_next_run, cursor->s_next_run)) { + break; + } + } + + if (cursor) { + TAILQ_INSERT_BEFORE(cursor, sensor, s_next); + } else { + TAILQ_INSERT_TAIL(&sensor_mgr.mgr_sensor_list, sensor, s_next); + } +} + +/** + * Register the sensor with the global sensor list. This makes the sensor + * searchable by other packages, who may want to look it up by type. + * + * @param The sensor to register + * + * @return 0 on success, non-zero error code on failure. + */ +int +sensor_mgr_register(struct sensor *sensor) +{ + int rc; + + rc = sensor_mgr_lock(); + if (rc != 0) { + goto err; + } + + rc = sensor_lock(sensor); + if (rc != 0) { + goto err; + } + + sensor_mgr_insert(sensor); + + sensor_unlock(sensor); + + sensor_mgr_unlock(); + + return (0); +err: + return (rc); +} + + +static os_time_t +sensor_mgr_poll_one(struct sensor *sensor, os_time_t now) +{ + uint32_t sensor_ticks; + int rc; + + rc = sensor_lock(sensor); + if (rc != 0) { + goto err; + } + + /* Sensor read results. Every time a sensor is read, all of its + * listeners are called by default. Specify NULL as a callback, + * because we just want to run all the listeners. + */ + sensor_read(sensor, SENSOR_TYPE_ALL, NULL, NULL, OS_TIMEOUT_NEVER); + + /* Remove the sensor from the sensor list for insertion sort. */ + sensor_mgr_remove(sensor); + + /* Set next wakeup, and insertion sort the sensor back into the + * list. + */ + os_time_ms_to_ticks(sensor->s_poll_rate, &sensor_ticks); + sensor->s_next_run = now + sensor_ticks; + + /* Re-insert the sensor manager, with the new wakeup time. */ + sensor_mgr_insert(sensor); + + /* Unlock the sensor to allow other access */ + sensor_unlock(sensor); + + return (sensor->s_next_run); +err: + /* Couldn't lock it. Re-run task and spin until we get result. */ + return (0); +} + +/** + * Event that wakes up the sensor manager, this goes through the sensor + * list and polls any active sensors. + */ +static void +sensor_mgr_wakeup_event(struct os_event *ev) +{ + struct sensor *cursor; + os_time_t now; + os_time_t task_next_wakeup; + os_time_t next_wakeup; + int rc; + + now = os_time_get(); + task_next_wakeup = now + SENSOR_MGR_WAKEUP_TICKS; + + rc = sensor_mgr_lock(); + if (rc != 0) { + /* Schedule again in 1 tick, see if we can reacquire the lock */ + task_next_wakeup = now + 1; + goto done; + } + + TAILQ_FOREACH(cursor, &sensor_mgr.mgr_sensor_list, s_next) { + /* Sensors that are not periodic are inserted at the end of the sensor + * list. + */ + if (cursor->s_next_run == OS_TIMEOUT_NEVER) { + break; + } + + /* List is sorted by what runs first. If we reached the first element that + * doesn't run, break out. + */ + if (OS_TIME_TICK_LT(now, cursor->s_next_run)) { + break; + } + + /* Sensor poll one completes the poll, updates the sensor's "next run," + * and re-inserts it into the list. It returns the next wakeup time + * for this sensor. + */ + next_wakeup = sensor_mgr_poll_one(cursor, now); + + /* If the next wakeup time for this sensor is before the task's next + * scheduled wakeup, move that forward, so we can collect data from that + * sensor + */ + if (task_next_wakeup > next_wakeup) { + task_next_wakeup = next_wakeup; + } + } + +done: + os_callout_reset(&sensor_mgr.mgr_wakeup_callout, task_next_wakeup); +} + +struct os_eventq * +sensor_mgr_evq_get(void) +{ + os_eventq_ensure(&sensor_mgr.mgr_eventq, NULL); + + return (sensor_mgr.mgr_eventq); +} + +static void +sensor_mgr_init(void) +{ + memset(&sensor_mgr, 0, sizeof(sensor_mgr)); + TAILQ_INIT(&sensor_mgr.mgr_sensor_list); + + /** + * Initialize sensor polling callout and set it to fire on boot. + */ + os_callout_init(&sensor_mgr.mgr_wakeup_callout, sensor_mgr_evq_get(), + sensor_mgr_wakeup_event, NULL); + os_callout_reset(&sensor_mgr.mgr_wakeup_callout, 0); + + os_mutex_init(&sensor_mgr.mgr_lock); +} + +/** + * The sensor manager contains a list of sensors, this function returns + * the next sensor in that list, for which compare_func() returns successful + * (one). If prev_cursor is provided, the function starts at that point + * in the sensor list. + * + * @warn This function MUST be locked by sensor_mgr_lock/unlock() if the goal is + * to iterate through sensors (as opposed to just finding one.) As the + * "prev_cursor" may be resorted in the sensor list, in between calls. + * + * @param The comparison function to use against sensors in the list. + * @param The argument to provide to that comparison function + * @param The previous sensor in the sensor manager list, in case of + * iteration. If desire is to find first matching sensor, provide a + * NULL value. + * + * @return A pointer to the first sensor found from prev_cursor, or + * NULL, if none found. + * + */ +struct sensor * +sensor_mgr_find_next(sensor_mgr_compare_func_t compare_func, void *arg, + struct sensor *prev_cursor) +{ + struct sensor *cursor; + int rc; + + cursor = NULL; + + /* Couldn't acquire lock of sensor list, exit */ + rc = sensor_mgr_lock(); + if (rc != 0) { + goto done; + } + + cursor = prev_cursor; + if (cursor == NULL) { + cursor = TAILQ_FIRST(&sensor_mgr.mgr_sensor_list); + } else { + cursor = TAILQ_NEXT(prev_cursor, s_next); + } + + while (cursor != NULL) { + if (compare_func(cursor, arg)) { + break; + } + cursor = TAILQ_NEXT(cursor, s_next); + } + + sensor_mgr_unlock(); + +done: + return (cursor); +} + + + +static int +sensor_mgr_match_bytype(struct sensor *sensor, void *arg) +{ + sensor_type_t *type; + + type = (sensor_type_t *) arg; + + /* s_types is a bitmask that contains the supported sensor types for this + * sensor, and type is the bitmask we're searching for. Compare the two, + * and if there is a match, return true (1). + */ + if ((*type & sensor->s_types) != 0) { + return (1); + } else { + return (0); + } +} + +/** + * Find the "next" sensor available for a given sensor type. + * + * If the sensor parameter, is present find the next entry from that + * parameter. Otherwise, find the first matching sensor. + * + * @param The type of sensor to search for + * @param The cursor to search from, or NULL to start from the beginning. + * + * @return A pointer to the sensor object matching that sensor type, or NULL if + * none found. + */ +struct sensor * +sensor_mgr_find_next_bytype(sensor_type_t type, struct sensor *prev_cursor) +{ + return (sensor_mgr_find_next(sensor_mgr_match_bytype, (void *) &type, + prev_cursor)); +} + +static int +sensor_mgr_match_bydevname(struct sensor *sensor, void *arg) +{ + char *devname; + + devname = (char *) arg; + + if (!strcmp(sensor->s_dev->od_name, devname)) { + return (1); + } + + return (0); +} + + +/** + * Search teh sensor list, and find the next sensor that correspondes + * to a given device name. + * + * @param The device name to search for + * @param The previous sensor found with this device name + * + * @return 0 on success, non-zero error code on failure + */ +struct sensor * +sensor_mgr_find_next_bydevname(char *devname, struct sensor *prev_cursor) +{ + return (sensor_mgr_find_next(sensor_mgr_match_bydevname, devname, + prev_cursor)); +} + +/** + * Initialize the sensor package, called through SYSINIT. Note, this function + * will assert if called directly, and _NOT_ through the sysinit package. + */ +void +sensor_pkg_init(void) +{ - /* Call directly until sysinit has the right hooks for us */ - #if 0 - /* Ensure this is only called by sysinit */ - SYSINIT_ASSERT_ACTIVE(); - #endif - + sensor_mgr_init(); + +#if MYNEWT_VAL(SENSOR_CLI) + sensor_shell_register(); +#endif +} + + +/** + * Lock access to the sensor specified by sensor. Blocks until lock acquired. + * + * @param The sensor to lock + * + * @return 0 on success, non-zero on failure. + */ +int +sensor_lock(struct sensor *sensor) +{ + int rc; + + rc = os_mutex_pend(&sensor->s_lock, OS_TIMEOUT_NEVER); + if (rc == 0 || rc == OS_NOT_STARTED) { + return (0); + } + return (rc); +} + +/** + * Unlock access to the sensor specified by sensor. Blocks until lock acquired. + * + * @param The sensor to unlock access to. + */ +void +sensor_unlock(struct sensor *sensor) +{ + os_mutex_release(&sensor->s_lock); +} + + +/** + * Initialize a sensor + * + * @param The sensor to initialize + * @param The device to associate with this sensor. + * + * @return 0 on success, non-zero error code on failure. + */ +int +sensor_init(struct sensor *sensor, struct os_dev *dev) +{ + int rc; + + memset(sensor, 0, sizeof(*sensor)); + + rc = os_mutex_init(&sensor->s_lock); + if (rc != 0) { + goto err; + } + sensor->s_dev = dev; + + return (0); +err: + return (rc); +} + + +/** + * Register a sensor listener. This allows a calling application to receive + * callbacks for data from a given sensor object. + * + * For more information on the type of callbacks available, see the documentation + * for the sensor listener structure. + * + * @param The sensor to register a listener on + * @param The listener to register onto the sensor + * + * @return 0 on success, non-zero error code on failure. + */ +int +sensor_register_listener(struct sensor *sensor, + struct sensor_listener *listener) +{ + int rc; + + rc = sensor_lock(sensor); + if (rc != 0) { + goto err; + } + + SLIST_INSERT_HEAD(&sensor->s_listener_list, listener, sl_next); + + sensor_unlock(sensor); + + return (0); +err: + return (rc); +} + +int +sensor_unregister_listener(struct sensor *sensor, + struct sensor_listener *listener) +{ + int rc; + + rc = sensor_lock(sensor); + if (rc != 0) { + goto err; + } + + /* Remove this entry from the list */ + SLIST_REMOVE(&sensor->s_listener_list, listener, sensor_listener, + sl_next); + + sensor_unlock(sensor); + + return (0); +err: + return (rc); +} + + +struct sensor_read_ctx { + sensor_data_func_t user_func; + void *user_arg; +}; + +static int +sensor_read_data_func(struct sensor *sensor, void *arg, void *data) +{ + struct sensor_listener *listener; + struct sensor_read_ctx *ctx; + + /* Notify all listeners first */ + SLIST_FOREACH(listener, &sensor->s_listener_list, sl_next) { + listener->sl_func(sensor, listener->sl_arg, data); + } + + /* Call data function */ + ctx = (struct sensor_read_ctx *) arg; + if (ctx->user_func != NULL) { + return (ctx->user_func(sensor, ctx->user_arg, data)); + } else { + return (0); + } +} + +/** + * Read the data for sensor type "type," from the sensor, "sensor" and + * return the result into the "value" parameter. + * + * @param The senssor to read data from + * @param The type of sensor data to read from the sensor + * @param The callback to call for data returned from that sensor + * @param The argument to pass to this callback. + * @param Timeout before aborting sensor read + * + * @return 0 on success, non-zero on failure. + */ +int +sensor_read(struct sensor *sensor, sensor_type_t type, + sensor_data_func_t data_func, void *arg, uint32_t timeout) +{ + struct sensor_read_ctx src; + int rc; + + rc = sensor_lock(sensor); + if (rc != 0) { + goto done; + } + + src.user_func = data_func; + src.user_arg = arg; + + rc = sensor->s_funcs->sd_read(sensor, type, sensor_read_data_func, &src, + timeout); + + sensor_unlock(sensor); + +done: + return (rc); +} + http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/2681044e/net/oic/include/oic/oc_ri.h ---------------------------------------------------------------------- diff --cc net/oic/include/oic/oc_ri.h index e58af0b,d2f0f2e..5a81c52 --- a/net/oic/include/oic/oc_ri.h +++ b/net/oic/include/oic/oc_ri.h @@@ -97,13 -97,13 +97,23 @@@ typedef enum typedef struct oc_resource oc_resource_t; ++<<<<<<< HEAD +typedef struct { + oc_endpoint_t *origin; + oc_resource_t *resource; + const char *query; + int query_len; + oc_response_t *response; + void *packet; ++======= + typedef struct oc_request { + oc_endpoint_t *origin; + oc_resource_t *resource; + const char *query; + int query_len; + oc_response_t *response; + struct coap_packet_rx *packet; ++>>>>>>> develop } oc_request_t; typedef void (*oc_request_handler_t)(oc_request_t *, oc_interface_mask_t); @@@ -150,9 -150,10 +160,16 @@@ int oc_ri_get_query_value(const char *q oc_interface_mask_t oc_ri_get_interface_mask(char *iface, int if_len); typedef struct coap_packet coap_packet_t; ++<<<<<<< HEAD +bool oc_ri_invoke_coap_entity_handler(coap_packet_t *request, + coap_packet_t *response, + int32_t *offset, oc_endpoint_t *endpoint); ++======= + struct coap_packet_rx; + bool oc_ri_invoke_coap_entity_handler(struct coap_packet_rx *request, + coap_packet_t *response, int32_t *offset, + oc_endpoint_t *endpoint); ++>>>>>>> develop #ifdef __cplusplus } http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/2681044e/net/oic/src/api/oc_buffer.c ---------------------------------------------------------------------- diff --cc net/oic/src/api/oc_buffer.c index 1df8b8d,9857eaf..5a0af49 --- a/net/oic/src/api/oc_buffer.c +++ b/net/oic/src/api/oc_buffer.c @@@ -32,9 -32,6 +32,12 @@@ #include "port/mynewt/adaptor.h" ++<<<<<<< HEAD +static struct os_mempool oc_buffers; +static uint8_t oc_buffer_area[OS_MEMPOOL_BYTES(1, sizeof(oc_message_t))]; + ++======= ++>>>>>>> develop static struct os_mqueue oc_inq; static struct os_mqueue oc_outq; @@@ -70,28 -50,6 +56,31 @@@ oc_allocate_mbuf(struct oc_endpoint *oe } void ++<<<<<<< HEAD +oc_message_add_ref(oc_message_t *message) +{ + if (message) { + message->ref_count++; + } +} + +void +oc_message_unref(oc_message_t *message) +{ + if (message) { + assert(message->ref_count > 0); + message->ref_count--; + if (message->ref_count == 0) { + os_memblock_put(&oc_buffers, message); + OC_LOG_DEBUG("buffer: freed oc_message; free: %d\n", + oc_buffers.mp_num_free); + } + } +} + +void ++======= ++>>>>>>> develop oc_recv_message(struct os_mbuf *m) { int rc; @@@ -155,43 -112,25 +143,55 @@@ oc_buffer_rx(struct os_event *ev #endif while ((m = os_mqueue_get(&oc_inq)) != NULL) { - msg = oc_allocate_message(); - if (!msg) { - goto free_msg; - } OC_LOG_DEBUG("oc_buffer_rx: "); OC_LOG_ENDPOINT(LOG_LEVEL_DEBUG, OC_MBUF_ENDPOINT(m)); ++<<<<<<< HEAD + + if (OS_MBUF_PKTHDR(m)->omp_len > MAX_PAYLOAD_SIZE) { + STATS_INC(coap_stats, itoobig); + goto free_msg; + } + if (os_mbuf_copydata(m, 0, OS_MBUF_PKTHDR(m)->omp_len, msg->data)) { + STATS_INC(coap_stats, imem); + goto free_msg; + } + memcpy(&msg->endpoint, OC_MBUF_ENDPOINT(m), sizeof(msg->endpoint)); + msg->length = OS_MBUF_PKTHDR(m)->omp_len; + os_mbuf_free_chain(m); + m = NULL; ++======= ++>>>>>>> develop #ifdef OC_SECURITY + /* + * XXX make sure first byte is within first mbuf + */ b = m->om_data[0]; if (b > 19 && b < 64) { OC_LOG_DEBUG("oc_buffer_rx: encrypted request\n"); oc_process_post(&oc_dtls_handler, oc_events[UDP_TO_DTLS_EVENT], m); } else { ++<<<<<<< HEAD + coap_receive(msg); + } +#else + coap_receive(msg); +#endif +free_msg: + if (msg) { + oc_message_unref(msg); ++======= + coap_receive(m); + } + #else + coap_receive(&m); + #endif + if (m) { + os_mbuf_free_chain(m); ++>>>>>>> develop + } + if (m) { + os_mbuf_free_chain(m); } } } @@@ -199,8 -138,6 +199,11 @@@ void oc_buffer_init(void) { ++<<<<<<< HEAD + os_mempool_init(&oc_buffers, 1, sizeof(oc_message_t), oc_buffer_area, + "oc_bufs"); ++======= ++>>>>>>> develop os_mqueue_init(&oc_inq, oc_buffer_rx, NULL); os_mqueue_init(&oc_outq, oc_buffer_tx, NULL); } http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/2681044e/net/oic/src/api/oc_discovery.c ---------------------------------------------------------------------- diff --cc net/oic/src/api/oc_discovery.c index 6427056,066764c..3c74ac8 --- a/net/oic/src/api/oc_discovery.c +++ b/net/oic/src/api/oc_discovery.c @@@ -136,6 -136,6 +136,7 @@@ oc_core_discovery_handler(oc_request_t rt_len = oc_ri_get_query_value(req->query, req->query_len, "rt", &rt); oc_uuid_to_str(oc_core_get_device_id(0), uuid, sizeof(uuid)); ++<<<<<<< HEAD switch (interface) { case OC_IF_LL: { @@@ -157,6 -157,6 +158,29 @@@ int response_length = oc_rep_finalize(); ++======= ++ ++ switch (interface) { ++ case OC_IF_LL: { ++ oc_rep_start_links_array(); ++ matches = process_device_object(oc_rep_array(links), uuid, rt, rt_len); ++ oc_rep_end_links_array(); ++ } break; ++ case OC_IF_BASELINE: { ++ oc_rep_start_root_object(); ++ oc_process_baseline_interface(req->resource); ++ oc_rep_set_array(root, links); ++ matches = process_device_object(oc_rep_array(links), uuid, rt, rt_len); ++ oc_rep_close_array(root, links); ++ oc_rep_end_root_object(); ++ } break; ++ default: ++ break; ++ } ++ ++ int response_length = oc_rep_finalize(); ++ ++>>>>>>> develop if (matches && response_length > 0) { req->response->response_buffer->response_length = response_length; req->response->response_buffer->code = oc_status_code(OC_STATUS_OK); http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/2681044e/net/oic/src/api/oc_rep.c ---------------------------------------------------------------------- diff --cc net/oic/src/api/oc_rep.c index 2e70582,c7022d8..1337f2e --- a/net/oic/src/api/oc_rep.c +++ b/net/oic/src/api/oc_rep.c @@@ -23,7 -23,7 +23,11 @@@ #include "port/oc_assert.h" #include "api/oc_priv.h" #include <tinycbor/cbor_mbuf_writer.h> ++<<<<<<< HEAD +#include <tinycbor/cbor_buf_reader.h> ++======= + #include <tinycbor/cbor_mbuf_reader.h> ++>>>>>>> develop #ifdef OC_CLIENT static struct os_mempool oc_rep_objects; @@@ -31,11 -31,10 +35,18 @@@ static uint8_t oc_rep_objects_area[OS_M sizeof(oc_rep_t))]; #endif ++<<<<<<< HEAD +static const CborEncoder g_empty; +static struct os_mbuf *g_outm; +CborEncoder g_encoder, root_map, links_array; +CborError g_err; +struct CborMbufWriter g_buf_writer; ++======= + static struct os_mbuf *g_outm; + CborEncoder g_encoder, root_map, links_array; + CborError g_err; + struct cbor_mbuf_writer g_buf_writer; ++>>>>>>> develop void oc_rep_new(struct os_mbuf *m) http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/2681044e/net/oic/src/api/oc_ri.c ---------------------------------------------------------------------- diff --cc net/oic/src/api/oc_ri.c index 2f0faea,d6180a6..2266a9b --- a/net/oic/src/api/oc_ri.c +++ b/net/oic/src/api/oc_ri.c @@@ -357,7 -347,7 +347,11 @@@ does_interface_support_method(oc_resour } bool ++<<<<<<< HEAD +oc_ri_invoke_coap_entity_handler(coap_packet_t *request, ++======= + oc_ri_invoke_coap_entity_handler(struct coap_packet_rx *request, ++>>>>>>> develop coap_packet_t *response, int32_t *offset, oc_endpoint_t *endpoint) { http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/2681044e/net/oic/src/api/oc_server_api.c ---------------------------------------------------------------------- diff --cc net/oic/src/api/oc_server_api.c index f697f5c,61acdcd..94a5e93 --- a/net/oic/src/api/oc_server_api.c +++ b/net/oic/src/api/oc_server_api.c @@@ -216,7 -216,7 +216,11 @@@ oc_interate_query(oc_request_t *request return 1; } ++<<<<<<< HEAD +#if 0 /* XXXX fix this */ ++======= + #if MYNEWT_VAL(OC_SEPARATE_RESPONSES) ++>>>>>>> develop void oc_indicate_separate_response(oc_request_t *request, oc_separate_response_t *response) http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/2681044e/net/oic/src/messaging/coap/observe.c ---------------------------------------------------------------------- diff --cc net/oic/src/messaging/coap/observe.c index 7bc8537,234b2da..499cdb5 --- a/net/oic/src/messaging/coap/observe.c +++ b/net/oic/src/messaging/coap/observe.c @@@ -293,11 -297,13 +297,16 @@@ coap_notify_observers(oc_resource_t *re coap_clear_transaction(transaction); } } + #if MYNEWT_VAL(OC_SEPARATE_RESPONSES) } + #endif + } + if (m) { + os_mbuf_free_chain(m); } + if (m) { + os_mbuf_free_chain(m); + } return num_observers; } /*---------------------------------------------------------------------------*/ http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/2681044e/net/oic/src/port/mynewt/ble_adaptor.c ---------------------------------------------------------------------- diff --cc net/oic/src/port/mynewt/ble_adaptor.c index 8ede614,85eb1f5..6a2ed74 --- a/net/oic/src/port/mynewt/ble_adaptor.c +++ b/net/oic/src/port/mynewt/ble_adaptor.c @@@ -176,6 -177,7 +177,10 @@@ oc_ble_reass(struct os_mbuf *om1, uint1 coap_tcp_msg_size(hdr, sizeof(hdr)) > pkt2->omp_len) { STAILQ_INSERT_TAIL(&oc_ble_reass_q, pkt2, omp_next); } else { ++<<<<<<< HEAD ++======= + STATS_INC(oc_ble_stats, iframe); ++>>>>>>> develop oc_recv_message(om2); } } @@@ -283,9 -285,9 +288,15 @@@ oc_ble_frag(struct os_mbuf *m, uint16_ STAILQ_NEXT(pkt, omp_next) = NULL; return 0; } ++<<<<<<< HEAD + off = pkt->omp_len % mtu; + + while (off > mtu) { ++======= + + off = pkt->omp_len - (pkt->omp_len % mtu); + while (off >= mtu) { ++>>>>>>> develop n = os_msys_get_pkthdr(mtu, 0); if (!n) { goto err; @@@ -337,7 -338,11 +347,15 @@@ oc_send_buffer_gatt(struct os_mbuf *m STATS_INCN(oc_ble_stats, obytes, OS_MBUF_PKTLEN(m)); mtu = ble_att_mtu(conn_handle); ++<<<<<<< HEAD + assert(mtu > 4); ++======= + if (mtu < 4) { + oc_ble_coap_conn_del(conn_handle); + os_mbuf_free_chain(m); + return; + } ++>>>>>>> develop mtu -= 3; /* # of bytes for ATT notification base */ if (oc_ble_frag(m, mtu)) {
