diff --git a/build/make/Engine.mk b/build/make/Engine.mk index d7fcb5bbf..953570f89 100644 --- a/build/make/Engine.mk +++ b/build/make/Engine.mk @@ -13,6 +13,7 @@ INCLUDES := $(INCLUDES) \ -I$(INCDIR) \ -I$(INCDIR)/brainflow/utils \ -I$(INCDIR)/brainflow/board_controller \ + -I$(INCDIR)/brainflow/third_party/json \ -I../../src \ -I../../priv/src \ -I$(SRCDIR) \ diff --git a/deps/README.md b/deps/README.md index 0051a53aa..471ff0d55 100644 --- a/deps/README.md +++ b/deps/README.md @@ -8,7 +8,7 @@ Open-Source Third Party Software included in this repository. | Name | Version | Link | Remarks | |---------------------|----------|-------------------------------------------------------|-----------------------------------------| -| brainflow | 4.0.1 | https://github.com/brainflow-dev/brainflow | Brainflow | +| brainflow | 5.7.0 | https://github.com/brainflow-dev/brainflow | Brainflow | | double-conversion | 3.1.5 | https://github.com/google/double-conversion | Binary-Decimal Conversion | | dspfilters | ?.?.? | | | | easing | ?.?.? | http://robertpenner.com/easing/ | Easing Functions | diff --git a/deps/build/make/brainflow-boardcontroller.mk b/deps/build/make/brainflow-boardcontroller.mk index ec4348cb6..68c8fb335 100644 --- a/deps/build/make/brainflow-boardcontroller.mk +++ b/deps/build/make/brainflow-boardcontroller.mk @@ -13,26 +13,37 @@ INCLUDES := $(INCLUDES) \ -I$(INCDIR)/json \ -I$(INCDIR)/unicorn \ -I$(INCDIR)/brainflow/board_controller \ + -I$(INCDIR)/brainflow/board_controller/ant_neuro \ + -I$(INCDIR)/brainflow/board_controller/emotibit \ + -I$(INCDIR)/brainflow/board_controller/enophone \ -I$(INCDIR)/brainflow/board_controller/freeeeg32 \ -I$(INCDIR)/brainflow/board_controller/gtec \ - -I$(INCDIR)/brainflow/board_controller/ironbci \ -I$(INCDIR)/brainflow/board_controller/mit \ + -I$(INCDIR)/brainflow/board_controller/mentalab \ + -I$(INCDIR)/brainflow/board_controller/muse \ -I$(INCDIR)/brainflow/board_controller/neuromd \ -I$(INCDIR)/brainflow/board_controller/neurosity \ -I$(INCDIR)/brainflow/board_controller/openbci \ -I$(INCDIR)/brainflow/board_controller/oymotion \ -I$(INCDIR)/brainflow/ganglion-bglib \ -I$(INCDIR)/brainflow/gforcesdkcxx-wrapper \ - -I$(INCDIR)/brainflow/utils + -I$(INCDIR)/brainflow/utils \ + -I$(INCDIR)/brainflow/utils/bluetooth \ + -I$(INCDIR)/brainflow/third_party/ CXXFLAGS := $(CXXFLAGS) -std=c++14 LINKFLAGS := $(LINKFLAGS) LINKPATH := $(LINKPATH) LINKLIBS := $(LINKLIBS) -OBJS = freeeeg32/freeeeg32.o \ +OBJS = ant_neuro/ant_neuro.o \ + emotibit/emotibit.o \ + enophone/enophone.o \ + freeeeg32/freeeeg32.o \ gtec/unicorn_board.o \ - ironbci/ironbci.o \ - mit/fascia.o \ + mentalab/explore.o \ + muse/muse.o \ + muse/muse_bled.o \ neuromd/brainbit.o \ + neuromd/brainbit_bled.o \ neuromd/callibri.o \ neuromd/callibri_ecg.o \ neuromd/callibri_eeg.o \ @@ -44,15 +55,21 @@ OBJS = freeeeg32/freeeeg32.o \ openbci/cyton_daisy_wifi.o \ openbci/cyton_wifi.o \ openbci/galea.o \ + openbci/galea_serial.o \ openbci/ganglion.o \ + openbci/ganglion_native.o \ openbci/ganglion_wifi.o \ openbci/openbci_serial_board.o \ openbci/openbci_wifi_shield_board.o \ + oymotion/gforce_dual.o \ oymotion/gforce_pro.o \ - board.o \ + ble_lib_board.o \ board_controller.o \ board_info_getter.o \ + board.o \ brainflow_boards.o \ + bt_lib_board.o \ + dyn_lib_board.o \ file_streamer.o \ multicast_streamer.o \ playback_file_board.o \ diff --git a/deps/build/make/brainflow-datahandler.mk b/deps/build/make/brainflow-datahandler.mk index 4c7ddc7b7..ee90998ba 100644 --- a/deps/build/make/brainflow-datahandler.mk +++ b/deps/build/make/brainflow-datahandler.mk @@ -12,7 +12,8 @@ INCLUDES := $(INCLUDES) \ -I$(INCDIR)/fft \ -I$(INCDIR)/wavelib \ -I$(INCDIR)/brainflow/data_handler \ - -I$(INCDIR)/brainflow/utils + -I$(INCDIR)/brainflow/utils \ + -I$(INCDIR)/brainflow/third_party/kissfft CXXFLAGS := $(CXXFLAGS) -std=c++14 LINKFLAGS := $(LINKFLAGS) LINKPATH := $(LINKPATH) diff --git a/deps/build/make/brainflow-ml.mk b/deps/build/make/brainflow-ml.mk index 82657bce1..618393302 100644 --- a/deps/build/make/brainflow-ml.mk +++ b/deps/build/make/brainflow-ml.mk @@ -12,19 +12,17 @@ INCLUDES := $(INCLUDES) \ -I$(INCDIR)/libsvm \ -I$(INCDIR)/json \ -I$(INCDIR)/brainflow/ml \ + -I$(INCDIR)/brainflow/ml/onnx \ + -I$(INCDIR)/brainflow/third_party/onnxruntime/build/native/include \ -I$(INCDIR)/brainflow/utils CXXFLAGS := $(CXXFLAGS) -std=c++14 LINKFLAGS := $(LINKFLAGS) LINKPATH := $(LINKPATH) LINKLIBS := $(LINKLIBS) -OBJS = generated/focus_dataset.o \ - generated/lda_model.o \ - generated/regression_model.o \ +OBJS = generated/mindfulness_model.o \ base_classifier.o \ - concentration_knn_classifier.o \ - concentration_lda_classifier.o \ - concentration_regression_classifier.o \ - concentration_svm_classifier.o \ + dyn_lib_classifier.o \ + mindfulness_classifier.o \ ml_module.o ifeq ($(TARGET_ARCH),x86) diff --git a/deps/build/make/brainflow.mk b/deps/build/make/brainflow.mk index c128b8968..546cb042e 100644 --- a/deps/build/make/brainflow.mk +++ b/deps/build/make/brainflow.mk @@ -24,19 +24,20 @@ OBJS = cpp-package/board_shim.o \ cpp-package/data_filter.o \ cpp-package/ml_model.o \ utils/broadcast_client.o \ + utils/broadcast_server.o \ utils/data_buffer.o \ utils/libftdi_serial.o \ utils/multicast_client.o \ utils/multicast_server.o \ - utils/os_serial.o \ utils/os_serial_ioctl.o \ + utils/os_serial.o \ utils/serial.o \ utils/socket_client_tcp.o \ utils/socket_client_udp.o \ utils/socket_server_tcp.o \ utils/socket_server_udp.o \ utils/timestamp.o - + ifeq ($(TARGET_ARCH),x86) DEFINES := $(DEFINES) endif diff --git a/deps/build/make/obj/android-arm-debug/brainflow-boardcontroller/ant_neuro/.gitignore b/deps/build/make/obj/android-arm-debug/brainflow-boardcontroller/ant_neuro/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/android-arm-debug/brainflow-boardcontroller/emotibit/.gitignore b/deps/build/make/obj/android-arm-debug/brainflow-boardcontroller/emotibit/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/android-arm-debug/brainflow-boardcontroller/enophone/.gitignore b/deps/build/make/obj/android-arm-debug/brainflow-boardcontroller/enophone/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/android-arm-debug/brainflow-boardcontroller/mentalab/.gitignore b/deps/build/make/obj/android-arm-debug/brainflow-boardcontroller/mentalab/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/android-arm-debug/brainflow-boardcontroller/meuromd/.gitignore b/deps/build/make/obj/android-arm-debug/brainflow-boardcontroller/meuromd/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/android-arm-debug/brainflow-boardcontroller/muse/.gitignore b/deps/build/make/obj/android-arm-debug/brainflow-boardcontroller/muse/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/android-arm-debug/brainflow-boardcontroller/neurosity/meurosity/.gitignore b/deps/build/make/obj/android-arm-debug/brainflow-boardcontroller/neurosity/meurosity/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/android-arm-release/brainflow-boardcontroller/ant_neuro/.gitignore b/deps/build/make/obj/android-arm-release/brainflow-boardcontroller/ant_neuro/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/android-arm-release/brainflow-boardcontroller/emotibit/.gitignore b/deps/build/make/obj/android-arm-release/brainflow-boardcontroller/emotibit/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/android-arm-release/brainflow-boardcontroller/enophone/.gitignore b/deps/build/make/obj/android-arm-release/brainflow-boardcontroller/enophone/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/android-arm-release/brainflow-boardcontroller/mentalab/.gitignore b/deps/build/make/obj/android-arm-release/brainflow-boardcontroller/mentalab/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/android-arm-release/brainflow-boardcontroller/meuromd/.gitignore b/deps/build/make/obj/android-arm-release/brainflow-boardcontroller/meuromd/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/android-arm-release/brainflow-boardcontroller/muse/.gitignore b/deps/build/make/obj/android-arm-release/brainflow-boardcontroller/muse/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/android-arm-release/brainflow-boardcontroller/neurosity/meurosity/.gitignore b/deps/build/make/obj/android-arm-release/brainflow-boardcontroller/neurosity/meurosity/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/android-arm64-debug/brainflow-boardcontroller/ant_neuro/.gitignore b/deps/build/make/obj/android-arm64-debug/brainflow-boardcontroller/ant_neuro/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/android-arm64-debug/brainflow-boardcontroller/emotibit/.gitignore b/deps/build/make/obj/android-arm64-debug/brainflow-boardcontroller/emotibit/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/android-arm64-debug/brainflow-boardcontroller/enophone/.gitignore b/deps/build/make/obj/android-arm64-debug/brainflow-boardcontroller/enophone/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/android-arm64-debug/brainflow-boardcontroller/mentalab/.gitignore b/deps/build/make/obj/android-arm64-debug/brainflow-boardcontroller/mentalab/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/android-arm64-debug/brainflow-boardcontroller/meuromd/.gitignore b/deps/build/make/obj/android-arm64-debug/brainflow-boardcontroller/meuromd/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/android-arm64-debug/brainflow-boardcontroller/muse/.gitignore b/deps/build/make/obj/android-arm64-debug/brainflow-boardcontroller/muse/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/android-arm64-debug/brainflow-boardcontroller/neurosity/meurosity/.gitignore b/deps/build/make/obj/android-arm64-debug/brainflow-boardcontroller/neurosity/meurosity/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/android-arm64-release/brainflow-boardcontroller/ant_neuro/.gitignore b/deps/build/make/obj/android-arm64-release/brainflow-boardcontroller/ant_neuro/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/android-arm64-release/brainflow-boardcontroller/emotibit/.gitignore b/deps/build/make/obj/android-arm64-release/brainflow-boardcontroller/emotibit/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/android-arm64-release/brainflow-boardcontroller/enophone/.gitignore b/deps/build/make/obj/android-arm64-release/brainflow-boardcontroller/enophone/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/android-arm64-release/brainflow-boardcontroller/mentalab/.gitignore b/deps/build/make/obj/android-arm64-release/brainflow-boardcontroller/mentalab/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/android-arm64-release/brainflow-boardcontroller/meuromd/.gitignore b/deps/build/make/obj/android-arm64-release/brainflow-boardcontroller/meuromd/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/android-arm64-release/brainflow-boardcontroller/muse/.gitignore b/deps/build/make/obj/android-arm64-release/brainflow-boardcontroller/muse/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/android-arm64-release/brainflow-boardcontroller/neurosity/meurosity/.gitignore b/deps/build/make/obj/android-arm64-release/brainflow-boardcontroller/neurosity/meurosity/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/android-x64-debug/brainflow-boardcontroller/ant_neuro/.gitignore b/deps/build/make/obj/android-x64-debug/brainflow-boardcontroller/ant_neuro/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/android-x64-debug/brainflow-boardcontroller/emotibit/.gitignore b/deps/build/make/obj/android-x64-debug/brainflow-boardcontroller/emotibit/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/android-x64-debug/brainflow-boardcontroller/enophone/.gitignore b/deps/build/make/obj/android-x64-debug/brainflow-boardcontroller/enophone/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/android-x64-debug/brainflow-boardcontroller/mentalab/.gitignore b/deps/build/make/obj/android-x64-debug/brainflow-boardcontroller/mentalab/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/android-x64-debug/brainflow-boardcontroller/meuromd/.gitignore b/deps/build/make/obj/android-x64-debug/brainflow-boardcontroller/meuromd/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/android-x64-debug/brainflow-boardcontroller/muse/.gitignore b/deps/build/make/obj/android-x64-debug/brainflow-boardcontroller/muse/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/android-x64-debug/brainflow-boardcontroller/neurosity/meurosity/.gitignore b/deps/build/make/obj/android-x64-debug/brainflow-boardcontroller/neurosity/meurosity/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/android-x64-release/brainflow-boardcontroller/ant_neuro/.gitignore b/deps/build/make/obj/android-x64-release/brainflow-boardcontroller/ant_neuro/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/android-x64-release/brainflow-boardcontroller/emotibit/.gitignore b/deps/build/make/obj/android-x64-release/brainflow-boardcontroller/emotibit/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/android-x64-release/brainflow-boardcontroller/enophone/.gitignore b/deps/build/make/obj/android-x64-release/brainflow-boardcontroller/enophone/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/android-x64-release/brainflow-boardcontroller/mentalab/.gitignore b/deps/build/make/obj/android-x64-release/brainflow-boardcontroller/mentalab/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/android-x64-release/brainflow-boardcontroller/meuromd/.gitignore b/deps/build/make/obj/android-x64-release/brainflow-boardcontroller/meuromd/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/android-x64-release/brainflow-boardcontroller/muse/.gitignore b/deps/build/make/obj/android-x64-release/brainflow-boardcontroller/muse/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/android-x64-release/brainflow-boardcontroller/neurosity/meurosity/.gitignore b/deps/build/make/obj/android-x64-release/brainflow-boardcontroller/neurosity/meurosity/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/android-x86-debug/brainflow-boardcontroller/ant_neuro/.gitignore b/deps/build/make/obj/android-x86-debug/brainflow-boardcontroller/ant_neuro/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/android-x86-debug/brainflow-boardcontroller/emotibit/.gitignore b/deps/build/make/obj/android-x86-debug/brainflow-boardcontroller/emotibit/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/android-x86-debug/brainflow-boardcontroller/enophone/.gitignore b/deps/build/make/obj/android-x86-debug/brainflow-boardcontroller/enophone/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/android-x86-debug/brainflow-boardcontroller/mentalab/.gitignore b/deps/build/make/obj/android-x86-debug/brainflow-boardcontroller/mentalab/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/android-x86-debug/brainflow-boardcontroller/meuromd/.gitignore b/deps/build/make/obj/android-x86-debug/brainflow-boardcontroller/meuromd/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/android-x86-debug/brainflow-boardcontroller/muse/.gitignore b/deps/build/make/obj/android-x86-debug/brainflow-boardcontroller/muse/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/android-x86-debug/brainflow-boardcontroller/neurosity/meurosity/.gitignore b/deps/build/make/obj/android-x86-debug/brainflow-boardcontroller/neurosity/meurosity/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/android-x86-release/brainflow-boardcontroller/ant_neuro/.gitignore b/deps/build/make/obj/android-x86-release/brainflow-boardcontroller/ant_neuro/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/android-x86-release/brainflow-boardcontroller/emotibit/.gitignore b/deps/build/make/obj/android-x86-release/brainflow-boardcontroller/emotibit/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/android-x86-release/brainflow-boardcontroller/enophone/.gitignore b/deps/build/make/obj/android-x86-release/brainflow-boardcontroller/enophone/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/android-x86-release/brainflow-boardcontroller/mentalab/.gitignore b/deps/build/make/obj/android-x86-release/brainflow-boardcontroller/mentalab/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/android-x86-release/brainflow-boardcontroller/meuromd/.gitignore b/deps/build/make/obj/android-x86-release/brainflow-boardcontroller/meuromd/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/android-x86-release/brainflow-boardcontroller/muse/.gitignore b/deps/build/make/obj/android-x86-release/brainflow-boardcontroller/muse/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/android-x86-release/brainflow-boardcontroller/neurosity/meurosity/.gitignore b/deps/build/make/obj/android-x86-release/brainflow-boardcontroller/neurosity/meurosity/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/ios-arm64-debug/brainflow-boardcontroller/ant_neuro/.gitignore b/deps/build/make/obj/ios-arm64-debug/brainflow-boardcontroller/ant_neuro/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/ios-arm64-debug/brainflow-boardcontroller/emotibit/.gitignore b/deps/build/make/obj/ios-arm64-debug/brainflow-boardcontroller/emotibit/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/ios-arm64-debug/brainflow-boardcontroller/enophone/.gitignore b/deps/build/make/obj/ios-arm64-debug/brainflow-boardcontroller/enophone/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/ios-arm64-debug/brainflow-boardcontroller/mentalab/.gitignore b/deps/build/make/obj/ios-arm64-debug/brainflow-boardcontroller/mentalab/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/ios-arm64-debug/brainflow-boardcontroller/meuromd/.gitignore b/deps/build/make/obj/ios-arm64-debug/brainflow-boardcontroller/meuromd/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/ios-arm64-debug/brainflow-boardcontroller/muse/.gitignore b/deps/build/make/obj/ios-arm64-debug/brainflow-boardcontroller/muse/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/ios-arm64-debug/brainflow-boardcontroller/neurosity/meurosity/.gitignore b/deps/build/make/obj/ios-arm64-debug/brainflow-boardcontroller/neurosity/meurosity/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/ios-arm64-release/brainflow-boardcontroller/ant_neuro/.gitignore b/deps/build/make/obj/ios-arm64-release/brainflow-boardcontroller/ant_neuro/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/ios-arm64-release/brainflow-boardcontroller/emotibit/.gitignore b/deps/build/make/obj/ios-arm64-release/brainflow-boardcontroller/emotibit/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/ios-arm64-release/brainflow-boardcontroller/enophone/.gitignore b/deps/build/make/obj/ios-arm64-release/brainflow-boardcontroller/enophone/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/ios-arm64-release/brainflow-boardcontroller/mentalab/.gitignore b/deps/build/make/obj/ios-arm64-release/brainflow-boardcontroller/mentalab/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/ios-arm64-release/brainflow-boardcontroller/meuromd/.gitignore b/deps/build/make/obj/ios-arm64-release/brainflow-boardcontroller/meuromd/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/ios-arm64-release/brainflow-boardcontroller/muse/.gitignore b/deps/build/make/obj/ios-arm64-release/brainflow-boardcontroller/muse/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/ios-arm64-release/brainflow-boardcontroller/neurosity/meurosity/.gitignore b/deps/build/make/obj/ios-arm64-release/brainflow-boardcontroller/neurosity/meurosity/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/ios-x64-debug/brainflow-boardcontroller/ant_neuro/.gitignore b/deps/build/make/obj/ios-x64-debug/brainflow-boardcontroller/ant_neuro/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/ios-x64-debug/brainflow-boardcontroller/emotibit/.gitignore b/deps/build/make/obj/ios-x64-debug/brainflow-boardcontroller/emotibit/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/ios-x64-debug/brainflow-boardcontroller/enophone/.gitignore b/deps/build/make/obj/ios-x64-debug/brainflow-boardcontroller/enophone/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/ios-x64-debug/brainflow-boardcontroller/mentalab/.gitignore b/deps/build/make/obj/ios-x64-debug/brainflow-boardcontroller/mentalab/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/ios-x64-debug/brainflow-boardcontroller/meuromd/.gitignore b/deps/build/make/obj/ios-x64-debug/brainflow-boardcontroller/meuromd/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/ios-x64-debug/brainflow-boardcontroller/muse/.gitignore b/deps/build/make/obj/ios-x64-debug/brainflow-boardcontroller/muse/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/ios-x64-debug/brainflow-boardcontroller/neurosity/meurosity/.gitignore b/deps/build/make/obj/ios-x64-debug/brainflow-boardcontroller/neurosity/meurosity/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/ios-x64-release/brainflow-boardcontroller/ant_neuro/.gitignore b/deps/build/make/obj/ios-x64-release/brainflow-boardcontroller/ant_neuro/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/ios-x64-release/brainflow-boardcontroller/emotibit/.gitignore b/deps/build/make/obj/ios-x64-release/brainflow-boardcontroller/emotibit/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/ios-x64-release/brainflow-boardcontroller/enophone/.gitignore b/deps/build/make/obj/ios-x64-release/brainflow-boardcontroller/enophone/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/ios-x64-release/brainflow-boardcontroller/mentalab/.gitignore b/deps/build/make/obj/ios-x64-release/brainflow-boardcontroller/mentalab/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/ios-x64-release/brainflow-boardcontroller/meuromd/.gitignore b/deps/build/make/obj/ios-x64-release/brainflow-boardcontroller/meuromd/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/ios-x64-release/brainflow-boardcontroller/muse/.gitignore b/deps/build/make/obj/ios-x64-release/brainflow-boardcontroller/muse/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/ios-x64-release/brainflow-boardcontroller/neurosity/meurosity/.gitignore b/deps/build/make/obj/ios-x64-release/brainflow-boardcontroller/neurosity/meurosity/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/linux-arm-debug/brainflow-boardcontroller/ant_neuro/.gitignore b/deps/build/make/obj/linux-arm-debug/brainflow-boardcontroller/ant_neuro/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/linux-arm-debug/brainflow-boardcontroller/emotibit/.gitignore b/deps/build/make/obj/linux-arm-debug/brainflow-boardcontroller/emotibit/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/linux-arm-debug/brainflow-boardcontroller/enophone/.gitignore b/deps/build/make/obj/linux-arm-debug/brainflow-boardcontroller/enophone/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/linux-arm-debug/brainflow-boardcontroller/mentalab/.gitignore b/deps/build/make/obj/linux-arm-debug/brainflow-boardcontroller/mentalab/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/linux-arm-debug/brainflow-boardcontroller/meuromd/.gitignore b/deps/build/make/obj/linux-arm-debug/brainflow-boardcontroller/meuromd/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/linux-arm-debug/brainflow-boardcontroller/muse/.gitignore b/deps/build/make/obj/linux-arm-debug/brainflow-boardcontroller/muse/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/linux-arm-debug/brainflow-boardcontroller/neurosity/meurosity/.gitignore b/deps/build/make/obj/linux-arm-debug/brainflow-boardcontroller/neurosity/meurosity/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/linux-arm-release/brainflow-boardcontroller/ant_neuro/.gitignore b/deps/build/make/obj/linux-arm-release/brainflow-boardcontroller/ant_neuro/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/linux-arm-release/brainflow-boardcontroller/emotibit/.gitignore b/deps/build/make/obj/linux-arm-release/brainflow-boardcontroller/emotibit/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/linux-arm-release/brainflow-boardcontroller/enophone/.gitignore b/deps/build/make/obj/linux-arm-release/brainflow-boardcontroller/enophone/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/linux-arm-release/brainflow-boardcontroller/mentalab/.gitignore b/deps/build/make/obj/linux-arm-release/brainflow-boardcontroller/mentalab/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/linux-arm-release/brainflow-boardcontroller/meuromd/.gitignore b/deps/build/make/obj/linux-arm-release/brainflow-boardcontroller/meuromd/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/linux-arm-release/brainflow-boardcontroller/muse/.gitignore b/deps/build/make/obj/linux-arm-release/brainflow-boardcontroller/muse/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/linux-arm-release/brainflow-boardcontroller/neurosity/meurosity/.gitignore b/deps/build/make/obj/linux-arm-release/brainflow-boardcontroller/neurosity/meurosity/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/linux-arm64-debug/brainflow-boardcontroller/ant_neuro/.gitignore b/deps/build/make/obj/linux-arm64-debug/brainflow-boardcontroller/ant_neuro/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/linux-arm64-debug/brainflow-boardcontroller/emotibit/.gitignore b/deps/build/make/obj/linux-arm64-debug/brainflow-boardcontroller/emotibit/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/linux-arm64-debug/brainflow-boardcontroller/enophone/.gitignore b/deps/build/make/obj/linux-arm64-debug/brainflow-boardcontroller/enophone/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/linux-arm64-debug/brainflow-boardcontroller/mentalab/.gitignore b/deps/build/make/obj/linux-arm64-debug/brainflow-boardcontroller/mentalab/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/linux-arm64-debug/brainflow-boardcontroller/meuromd/.gitignore b/deps/build/make/obj/linux-arm64-debug/brainflow-boardcontroller/meuromd/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/linux-arm64-debug/brainflow-boardcontroller/muse/.gitignore b/deps/build/make/obj/linux-arm64-debug/brainflow-boardcontroller/muse/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/linux-arm64-debug/brainflow-boardcontroller/neurosity/meurosity/.gitignore b/deps/build/make/obj/linux-arm64-debug/brainflow-boardcontroller/neurosity/meurosity/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/linux-arm64-release/brainflow-boardcontroller/ant_neuro/.gitignore b/deps/build/make/obj/linux-arm64-release/brainflow-boardcontroller/ant_neuro/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/linux-arm64-release/brainflow-boardcontroller/emotibit/.gitignore b/deps/build/make/obj/linux-arm64-release/brainflow-boardcontroller/emotibit/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/linux-arm64-release/brainflow-boardcontroller/enophone/.gitignore b/deps/build/make/obj/linux-arm64-release/brainflow-boardcontroller/enophone/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/linux-arm64-release/brainflow-boardcontroller/mentalab/.gitignore b/deps/build/make/obj/linux-arm64-release/brainflow-boardcontroller/mentalab/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/linux-arm64-release/brainflow-boardcontroller/meuromd/.gitignore b/deps/build/make/obj/linux-arm64-release/brainflow-boardcontroller/meuromd/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/linux-arm64-release/brainflow-boardcontroller/muse/.gitignore b/deps/build/make/obj/linux-arm64-release/brainflow-boardcontroller/muse/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/linux-arm64-release/brainflow-boardcontroller/neurosity/meurosity/.gitignore b/deps/build/make/obj/linux-arm64-release/brainflow-boardcontroller/neurosity/meurosity/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/linux-x64-debug/brainflow-boardcontroller/ant_neuro/.gitignore b/deps/build/make/obj/linux-x64-debug/brainflow-boardcontroller/ant_neuro/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/linux-x64-debug/brainflow-boardcontroller/emotibit/.gitignore b/deps/build/make/obj/linux-x64-debug/brainflow-boardcontroller/emotibit/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/linux-x64-debug/brainflow-boardcontroller/enophone/.gitignore b/deps/build/make/obj/linux-x64-debug/brainflow-boardcontroller/enophone/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/linux-x64-debug/brainflow-boardcontroller/mentalab/.gitignore b/deps/build/make/obj/linux-x64-debug/brainflow-boardcontroller/mentalab/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/linux-x64-debug/brainflow-boardcontroller/meuromd/.gitignore b/deps/build/make/obj/linux-x64-debug/brainflow-boardcontroller/meuromd/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/linux-x64-debug/brainflow-boardcontroller/muse/.gitignore b/deps/build/make/obj/linux-x64-debug/brainflow-boardcontroller/muse/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/linux-x64-debug/brainflow-boardcontroller/neurosity/meurosity/.gitignore b/deps/build/make/obj/linux-x64-debug/brainflow-boardcontroller/neurosity/meurosity/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/linux-x64-release/brainflow-boardcontroller/ant_neuro/.gitignore b/deps/build/make/obj/linux-x64-release/brainflow-boardcontroller/ant_neuro/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/linux-x64-release/brainflow-boardcontroller/emotibit/.gitignore b/deps/build/make/obj/linux-x64-release/brainflow-boardcontroller/emotibit/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/linux-x64-release/brainflow-boardcontroller/enophone/.gitignore b/deps/build/make/obj/linux-x64-release/brainflow-boardcontroller/enophone/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/linux-x64-release/brainflow-boardcontroller/mentalab/.gitignore b/deps/build/make/obj/linux-x64-release/brainflow-boardcontroller/mentalab/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/linux-x64-release/brainflow-boardcontroller/meuromd/.gitignore b/deps/build/make/obj/linux-x64-release/brainflow-boardcontroller/meuromd/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/linux-x64-release/brainflow-boardcontroller/muse/.gitignore b/deps/build/make/obj/linux-x64-release/brainflow-boardcontroller/muse/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/linux-x64-release/brainflow-boardcontroller/neurosity/meurosity/.gitignore b/deps/build/make/obj/linux-x64-release/brainflow-boardcontroller/neurosity/meurosity/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/linux-x86-debug/brainflow-boardcontroller/ant_neuro/.gitignore b/deps/build/make/obj/linux-x86-debug/brainflow-boardcontroller/ant_neuro/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/linux-x86-debug/brainflow-boardcontroller/emotibit/.gitignore b/deps/build/make/obj/linux-x86-debug/brainflow-boardcontroller/emotibit/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/linux-x86-debug/brainflow-boardcontroller/enophone/.gitignore b/deps/build/make/obj/linux-x86-debug/brainflow-boardcontroller/enophone/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/linux-x86-debug/brainflow-boardcontroller/mentalab/.gitignore b/deps/build/make/obj/linux-x86-debug/brainflow-boardcontroller/mentalab/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/linux-x86-debug/brainflow-boardcontroller/meuromd/.gitignore b/deps/build/make/obj/linux-x86-debug/brainflow-boardcontroller/meuromd/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/linux-x86-debug/brainflow-boardcontroller/muse/.gitignore b/deps/build/make/obj/linux-x86-debug/brainflow-boardcontroller/muse/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/linux-x86-debug/brainflow-boardcontroller/neurosity/meurosity/.gitignore b/deps/build/make/obj/linux-x86-debug/brainflow-boardcontroller/neurosity/meurosity/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/linux-x86-release/brainflow-boardcontroller/ant_neuro/.gitignore b/deps/build/make/obj/linux-x86-release/brainflow-boardcontroller/ant_neuro/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/linux-x86-release/brainflow-boardcontroller/emotibit/.gitignore b/deps/build/make/obj/linux-x86-release/brainflow-boardcontroller/emotibit/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/linux-x86-release/brainflow-boardcontroller/enophone/.gitignore b/deps/build/make/obj/linux-x86-release/brainflow-boardcontroller/enophone/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/linux-x86-release/brainflow-boardcontroller/mentalab/.gitignore b/deps/build/make/obj/linux-x86-release/brainflow-boardcontroller/mentalab/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/linux-x86-release/brainflow-boardcontroller/meuromd/.gitignore b/deps/build/make/obj/linux-x86-release/brainflow-boardcontroller/meuromd/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/linux-x86-release/brainflow-boardcontroller/muse/.gitignore b/deps/build/make/obj/linux-x86-release/brainflow-boardcontroller/muse/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/linux-x86-release/brainflow-boardcontroller/neurosity/meurosity/.gitignore b/deps/build/make/obj/linux-x86-release/brainflow-boardcontroller/neurosity/meurosity/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/osx-arm64-debug/brainflow-boardcontroller/ant_neuro/.gitignore b/deps/build/make/obj/osx-arm64-debug/brainflow-boardcontroller/ant_neuro/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/osx-arm64-debug/brainflow-boardcontroller/emotibit/.gitignore b/deps/build/make/obj/osx-arm64-debug/brainflow-boardcontroller/emotibit/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/osx-arm64-debug/brainflow-boardcontroller/enophone/.gitignore b/deps/build/make/obj/osx-arm64-debug/brainflow-boardcontroller/enophone/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/osx-arm64-debug/brainflow-boardcontroller/mentalab/.gitignore b/deps/build/make/obj/osx-arm64-debug/brainflow-boardcontroller/mentalab/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/osx-arm64-debug/brainflow-boardcontroller/meuromd/.gitignore b/deps/build/make/obj/osx-arm64-debug/brainflow-boardcontroller/meuromd/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/osx-arm64-debug/brainflow-boardcontroller/muse/.gitignore b/deps/build/make/obj/osx-arm64-debug/brainflow-boardcontroller/muse/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/osx-arm64-debug/brainflow-boardcontroller/neurosity/meurosity/.gitignore b/deps/build/make/obj/osx-arm64-debug/brainflow-boardcontroller/neurosity/meurosity/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/osx-arm64-release/brainflow-boardcontroller/ant_neuro/.gitignore b/deps/build/make/obj/osx-arm64-release/brainflow-boardcontroller/ant_neuro/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/osx-arm64-release/brainflow-boardcontroller/emotibit/.gitignore b/deps/build/make/obj/osx-arm64-release/brainflow-boardcontroller/emotibit/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/osx-arm64-release/brainflow-boardcontroller/enophone/.gitignore b/deps/build/make/obj/osx-arm64-release/brainflow-boardcontroller/enophone/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/osx-arm64-release/brainflow-boardcontroller/mentalab/.gitignore b/deps/build/make/obj/osx-arm64-release/brainflow-boardcontroller/mentalab/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/osx-arm64-release/brainflow-boardcontroller/meuromd/.gitignore b/deps/build/make/obj/osx-arm64-release/brainflow-boardcontroller/meuromd/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/osx-arm64-release/brainflow-boardcontroller/muse/.gitignore b/deps/build/make/obj/osx-arm64-release/brainflow-boardcontroller/muse/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/osx-arm64-release/brainflow-boardcontroller/neurosity/meurosity/.gitignore b/deps/build/make/obj/osx-arm64-release/brainflow-boardcontroller/neurosity/meurosity/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/osx-x64-debug/brainflow-boardcontroller/ant_neuro/.gitignore b/deps/build/make/obj/osx-x64-debug/brainflow-boardcontroller/ant_neuro/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/osx-x64-debug/brainflow-boardcontroller/emotibit/.gitignore b/deps/build/make/obj/osx-x64-debug/brainflow-boardcontroller/emotibit/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/osx-x64-debug/brainflow-boardcontroller/enophone/.gitignore b/deps/build/make/obj/osx-x64-debug/brainflow-boardcontroller/enophone/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/osx-x64-debug/brainflow-boardcontroller/mentalab/.gitignore b/deps/build/make/obj/osx-x64-debug/brainflow-boardcontroller/mentalab/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/osx-x64-debug/brainflow-boardcontroller/meuromd/.gitignore b/deps/build/make/obj/osx-x64-debug/brainflow-boardcontroller/meuromd/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/osx-x64-debug/brainflow-boardcontroller/muse/.gitignore b/deps/build/make/obj/osx-x64-debug/brainflow-boardcontroller/muse/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/osx-x64-debug/brainflow-boardcontroller/neurosity/meurosity/.gitignore b/deps/build/make/obj/osx-x64-debug/brainflow-boardcontroller/neurosity/meurosity/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/osx-x64-release/brainflow-boardcontroller/ant_neuro/.gitignore b/deps/build/make/obj/osx-x64-release/brainflow-boardcontroller/ant_neuro/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/osx-x64-release/brainflow-boardcontroller/emotibit/.gitignore b/deps/build/make/obj/osx-x64-release/brainflow-boardcontroller/emotibit/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/osx-x64-release/brainflow-boardcontroller/enophone/.gitignore b/deps/build/make/obj/osx-x64-release/brainflow-boardcontroller/enophone/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/osx-x64-release/brainflow-boardcontroller/mentalab/.gitignore b/deps/build/make/obj/osx-x64-release/brainflow-boardcontroller/mentalab/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/osx-x64-release/brainflow-boardcontroller/meuromd/.gitignore b/deps/build/make/obj/osx-x64-release/brainflow-boardcontroller/meuromd/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/osx-x64-release/brainflow-boardcontroller/muse/.gitignore b/deps/build/make/obj/osx-x64-release/brainflow-boardcontroller/muse/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/osx-x64-release/brainflow-boardcontroller/neurosity/meurosity/.gitignore b/deps/build/make/obj/osx-x64-release/brainflow-boardcontroller/neurosity/meurosity/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/win-arm-debug/brainflow-boardcontroller/ant_neuro/.gitignore b/deps/build/make/obj/win-arm-debug/brainflow-boardcontroller/ant_neuro/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/win-arm-debug/brainflow-boardcontroller/emotibit/.gitignore b/deps/build/make/obj/win-arm-debug/brainflow-boardcontroller/emotibit/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/win-arm-debug/brainflow-boardcontroller/enophone/.gitignore b/deps/build/make/obj/win-arm-debug/brainflow-boardcontroller/enophone/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/win-arm-debug/brainflow-boardcontroller/mentalab/.gitignore b/deps/build/make/obj/win-arm-debug/brainflow-boardcontroller/mentalab/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/win-arm-debug/brainflow-boardcontroller/meuromd/.gitignore b/deps/build/make/obj/win-arm-debug/brainflow-boardcontroller/meuromd/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/win-arm-debug/brainflow-boardcontroller/muse/.gitignore b/deps/build/make/obj/win-arm-debug/brainflow-boardcontroller/muse/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/win-arm-debug/brainflow-boardcontroller/neurosity/meurosity/.gitignore b/deps/build/make/obj/win-arm-debug/brainflow-boardcontroller/neurosity/meurosity/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/win-arm-release/brainflow-boardcontroller/ant_neuro/.gitignore b/deps/build/make/obj/win-arm-release/brainflow-boardcontroller/ant_neuro/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/win-arm-release/brainflow-boardcontroller/emotibit/.gitignore b/deps/build/make/obj/win-arm-release/brainflow-boardcontroller/emotibit/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/win-arm-release/brainflow-boardcontroller/enophone/.gitignore b/deps/build/make/obj/win-arm-release/brainflow-boardcontroller/enophone/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/win-arm-release/brainflow-boardcontroller/mentalab/.gitignore b/deps/build/make/obj/win-arm-release/brainflow-boardcontroller/mentalab/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/win-arm-release/brainflow-boardcontroller/meuromd/.gitignore b/deps/build/make/obj/win-arm-release/brainflow-boardcontroller/meuromd/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/win-arm-release/brainflow-boardcontroller/muse/.gitignore b/deps/build/make/obj/win-arm-release/brainflow-boardcontroller/muse/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/win-arm-release/brainflow-boardcontroller/neurosity/meurosity/.gitignore b/deps/build/make/obj/win-arm-release/brainflow-boardcontroller/neurosity/meurosity/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/win-arm64-debug/brainflow-boardcontroller/ant_neuro/.gitignore b/deps/build/make/obj/win-arm64-debug/brainflow-boardcontroller/ant_neuro/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/win-arm64-debug/brainflow-boardcontroller/emotibit/.gitignore b/deps/build/make/obj/win-arm64-debug/brainflow-boardcontroller/emotibit/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/win-arm64-debug/brainflow-boardcontroller/enophone/.gitignore b/deps/build/make/obj/win-arm64-debug/brainflow-boardcontroller/enophone/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/win-arm64-debug/brainflow-boardcontroller/mentalab/.gitignore b/deps/build/make/obj/win-arm64-debug/brainflow-boardcontroller/mentalab/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/win-arm64-debug/brainflow-boardcontroller/meuromd/.gitignore b/deps/build/make/obj/win-arm64-debug/brainflow-boardcontroller/meuromd/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/win-arm64-debug/brainflow-boardcontroller/muse/.gitignore b/deps/build/make/obj/win-arm64-debug/brainflow-boardcontroller/muse/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/win-arm64-debug/brainflow-boardcontroller/neurosity/meurosity/.gitignore b/deps/build/make/obj/win-arm64-debug/brainflow-boardcontroller/neurosity/meurosity/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/win-arm64-release/brainflow-boardcontroller/ant_neuro/.gitignore b/deps/build/make/obj/win-arm64-release/brainflow-boardcontroller/ant_neuro/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/win-arm64-release/brainflow-boardcontroller/emotibit/.gitignore b/deps/build/make/obj/win-arm64-release/brainflow-boardcontroller/emotibit/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/win-arm64-release/brainflow-boardcontroller/enophone/.gitignore b/deps/build/make/obj/win-arm64-release/brainflow-boardcontroller/enophone/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/win-arm64-release/brainflow-boardcontroller/mentalab/.gitignore b/deps/build/make/obj/win-arm64-release/brainflow-boardcontroller/mentalab/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/win-arm64-release/brainflow-boardcontroller/meuromd/.gitignore b/deps/build/make/obj/win-arm64-release/brainflow-boardcontroller/meuromd/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/win-arm64-release/brainflow-boardcontroller/muse/.gitignore b/deps/build/make/obj/win-arm64-release/brainflow-boardcontroller/muse/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/win-arm64-release/brainflow-boardcontroller/neurosity/meurosity/.gitignore b/deps/build/make/obj/win-arm64-release/brainflow-boardcontroller/neurosity/meurosity/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/win-x64-debug/brainflow-boardcontroller/ant_neuro/.gitignore b/deps/build/make/obj/win-x64-debug/brainflow-boardcontroller/ant_neuro/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/win-x64-debug/brainflow-boardcontroller/emotibit/.gitignore b/deps/build/make/obj/win-x64-debug/brainflow-boardcontroller/emotibit/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/win-x64-debug/brainflow-boardcontroller/enophone/.gitignore b/deps/build/make/obj/win-x64-debug/brainflow-boardcontroller/enophone/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/win-x64-debug/brainflow-boardcontroller/mentalab/.gitignore b/deps/build/make/obj/win-x64-debug/brainflow-boardcontroller/mentalab/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/win-x64-debug/brainflow-boardcontroller/meuromd/.gitignore b/deps/build/make/obj/win-x64-debug/brainflow-boardcontroller/meuromd/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/win-x64-debug/brainflow-boardcontroller/muse/.gitignore b/deps/build/make/obj/win-x64-debug/brainflow-boardcontroller/muse/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/win-x64-debug/brainflow-boardcontroller/neurosity/meurosity/.gitignore b/deps/build/make/obj/win-x64-debug/brainflow-boardcontroller/neurosity/meurosity/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/win-x64-release/brainflow-boardcontroller/ant_neuro/.gitignore b/deps/build/make/obj/win-x64-release/brainflow-boardcontroller/ant_neuro/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/win-x64-release/brainflow-boardcontroller/emotibit/.gitignore b/deps/build/make/obj/win-x64-release/brainflow-boardcontroller/emotibit/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/win-x64-release/brainflow-boardcontroller/enophone/.gitignore b/deps/build/make/obj/win-x64-release/brainflow-boardcontroller/enophone/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/win-x64-release/brainflow-boardcontroller/mentalab/.gitignore b/deps/build/make/obj/win-x64-release/brainflow-boardcontroller/mentalab/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/win-x64-release/brainflow-boardcontroller/meuromd/.gitignore b/deps/build/make/obj/win-x64-release/brainflow-boardcontroller/meuromd/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/win-x64-release/brainflow-boardcontroller/muse/.gitignore b/deps/build/make/obj/win-x64-release/brainflow-boardcontroller/muse/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/win-x64-release/brainflow-boardcontroller/neurosity/meurosity/.gitignore b/deps/build/make/obj/win-x64-release/brainflow-boardcontroller/neurosity/meurosity/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/win-x86-debug/brainflow-boardcontroller/ant_neuro/.gitignore b/deps/build/make/obj/win-x86-debug/brainflow-boardcontroller/ant_neuro/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/win-x86-debug/brainflow-boardcontroller/emotibit/.gitignore b/deps/build/make/obj/win-x86-debug/brainflow-boardcontroller/emotibit/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/win-x86-debug/brainflow-boardcontroller/enophone/.gitignore b/deps/build/make/obj/win-x86-debug/brainflow-boardcontroller/enophone/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/win-x86-debug/brainflow-boardcontroller/mentalab/.gitignore b/deps/build/make/obj/win-x86-debug/brainflow-boardcontroller/mentalab/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/win-x86-debug/brainflow-boardcontroller/meuromd/.gitignore b/deps/build/make/obj/win-x86-debug/brainflow-boardcontroller/meuromd/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/win-x86-debug/brainflow-boardcontroller/muse/.gitignore b/deps/build/make/obj/win-x86-debug/brainflow-boardcontroller/muse/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/win-x86-debug/brainflow-boardcontroller/neurosity/meurosity/.gitignore b/deps/build/make/obj/win-x86-debug/brainflow-boardcontroller/neurosity/meurosity/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/win-x86-release/brainflow-boardcontroller/ant_neuro/.gitignore b/deps/build/make/obj/win-x86-release/brainflow-boardcontroller/ant_neuro/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/win-x86-release/brainflow-boardcontroller/emotibit/.gitignore b/deps/build/make/obj/win-x86-release/brainflow-boardcontroller/emotibit/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/win-x86-release/brainflow-boardcontroller/enophone/.gitignore b/deps/build/make/obj/win-x86-release/brainflow-boardcontroller/enophone/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/win-x86-release/brainflow-boardcontroller/mentalab/.gitignore b/deps/build/make/obj/win-x86-release/brainflow-boardcontroller/mentalab/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/win-x86-release/brainflow-boardcontroller/meuromd/.gitignore b/deps/build/make/obj/win-x86-release/brainflow-boardcontroller/meuromd/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/win-x86-release/brainflow-boardcontroller/muse/.gitignore b/deps/build/make/obj/win-x86-release/brainflow-boardcontroller/muse/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/build/make/obj/win-x86-release/brainflow-boardcontroller/neurosity/meurosity/.gitignore b/deps/build/make/obj/win-x86-release/brainflow-boardcontroller/neurosity/meurosity/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/deps/include/brainflow/board_controller/ant_neuro/ant_neuro.h b/deps/include/brainflow/board_controller/ant_neuro/ant_neuro.h new file mode 100644 index 000000000..854ab6948 --- /dev/null +++ b/deps/include/brainflow/board_controller/ant_neuro/ant_neuro.h @@ -0,0 +1,43 @@ +#pragma once + +#include +#include + +#include "board.h" + +#if defined __linux__ || defined _WIN32 +// required to dont link ant neuro sdk +#define EEGO_SDK_BIND_DYNAMIC + +#include +#include +#endif + + +class AntNeuroBoard : public Board +{ + +#if defined __linux__ || defined _WIN32 +private: + volatile bool keep_alive; + bool initialized; + std::thread streaming_thread; + std::string ant_neuro_lib_path; + eemagine::sdk::amplifier *amp; + eemagine::sdk::stream *stream; + int sampling_rate; + + void read_thread (); +#endif + + +public: + AntNeuroBoard (int board_id, struct BrainFlowInputParams params); + ~AntNeuroBoard (); + + int prepare_session (); + int start_stream (int buffer_size, const char *streamer_params); + int stop_stream (); + int release_session (); + int config_board (std::string config, std::string &response); +}; diff --git a/deps/include/brainflow/board_controller/ble_lib_board.h b/deps/include/brainflow/board_controller/ble_lib_board.h new file mode 100644 index 000000000..32cf196ad --- /dev/null +++ b/deps/include/brainflow/board_controller/ble_lib_board.h @@ -0,0 +1,67 @@ +#pragma once + +#include + +#include "board.h" +#include "board_controller.h" +#include "runtime_dll_loader.h" +#include "simpleble_c/types.h" + + +class BLELibBoard : public Board +{ + +private: + static DLLLoader *dll_loader; + static std::mutex mutex; + +protected: + static bool init_dll_loader (); + // common + void simpleble_free (void *handle); + // adapter + size_t simpleble_adapter_get_count (void); + bool simpleble_adapter_is_bluetooth_enabled (void); + simpleble_adapter_t simpleble_adapter_get_handle (size_t index); + void simpleble_adapter_release_handle (simpleble_adapter_t handle); + simpleble_err_t simpleble_adapter_scan_for (simpleble_adapter_t handle, int timeout_ms); + simpleble_err_t simpleble_adapter_scan_start (simpleble_adapter_t handle); + simpleble_err_t simpleble_adapter_scan_stop (simpleble_adapter_t handle); + simpleble_err_t simpleble_adapter_set_callback_on_scan_start ( + simpleble_adapter_t handle, void (*) (simpleble_adapter_t, void *), void *); + simpleble_err_t simpleble_adapter_set_callback_on_scan_stop ( + simpleble_adapter_t handle, void (*) (simpleble_adapter_t, void *), void *); + simpleble_err_t simpleble_adapter_set_callback_on_scan_updated (simpleble_adapter_t handle, + void (*) (simpleble_adapter_t, simpleble_peripheral_t, void *), void *); + simpleble_err_t simpleble_adapter_set_callback_on_scan_found (simpleble_adapter_t handle, + void (*) (simpleble_adapter_t, simpleble_peripheral_t, void *), void *); + // peripheral + char *simpleble_peripheral_address (simpleble_peripheral_t handle); + char *simpleble_peripheral_identifier (simpleble_peripheral_t handle); + void simpleble_peripheral_release_handle (simpleble_peripheral_t handle); + simpleble_err_t simpleble_peripheral_connect (simpleble_peripheral_t handle); + simpleble_err_t simpleble_peripheral_disconnect (simpleble_peripheral_t handle); + size_t simpleble_peripheral_services_count (simpleble_peripheral_t handle); + simpleble_err_t simpleble_peripheral_services_get ( + simpleble_peripheral_t handle, size_t index, simpleble_service_t *services); + simpleble_err_t simpleble_peripheral_write_request (simpleble_peripheral_t handle, + simpleble_uuid_t service, simpleble_uuid_t characteristic, uint8_t *data, + size_t data_length); + simpleble_err_t simpleble_peripheral_write_command (simpleble_peripheral_t handle, + simpleble_uuid_t service, simpleble_uuid_t characteristic, uint8_t *data, + size_t data_length); + simpleble_err_t simpleble_peripheral_notify (simpleble_peripheral_t handle, + simpleble_uuid_t service, simpleble_uuid_t characteristic, + void (*) (simpleble_uuid_t, simpleble_uuid_t, uint8_t *, size_t, void *), void *); + simpleble_err_t simpleble_peripheral_unsubscribe ( + simpleble_peripheral_t handle, simpleble_uuid_t service, simpleble_uuid_t characteristic); + size_t simpleble_peripheral_manufacturer_data_count (simpleble_peripheral_t handle); + simpleble_err_t simpleble_peripheral_manufacturer_data_get (simpleble_peripheral_t handle, + size_t index, simpleble_manufacturer_data_t *manufacturer_data); + simpleble_err_t simpleble_peripheral_is_connected ( + simpleble_peripheral_t handle, bool *connected); + +public: + BLELibBoard (int board_id, struct BrainFlowInputParams params); + virtual ~BLELibBoard (); +}; diff --git a/deps/include/brainflow/board_controller/board.h b/deps/include/brainflow/board_controller/board.h index a684aa6a1..f3fb4a498 100644 --- a/deps/include/brainflow/board_controller/board.h +++ b/deps/include/brainflow/board_controller/board.h @@ -3,6 +3,7 @@ #include #include #include +#include #include #include "board_controller.h" @@ -24,7 +25,7 @@ class Board static std::shared_ptr board_logger; static JNIEnv *java_jnienv; // nullptr unless on java static int set_log_level (int log_level); - static int set_log_file (char *log_file); + static int set_log_file (const char *log_file); virtual ~Board () { @@ -36,21 +37,30 @@ class Board Board (int board_id, struct BrainFlowInputParams params) { skip_logs = false; - db = NULL; - streamer = NULL; this->board_id = board_id; this->params = params; + try + { + board_descr = boards_struct.brainflow_boards_json["boards"][std::to_string (board_id)]; + } + catch (json::exception &e) + { + safe_logger (spdlog::level::err, e.what ()); + } } virtual int prepare_session () = 0; - virtual int start_stream (int buffer_size, char *streamer_params) = 0; + virtual int start_stream (int buffer_size, const char *streamer_params) = 0; virtual int stop_stream () = 0; virtual int release_session () = 0; virtual int config_board (std::string config, std::string &response) = 0; - int get_current_board_data (int num_samples, double *data_buf, int *returned_samples); - int get_board_data_count (int *result); - int get_board_data (int data_count, double *data_buf); - int insert_marker (double value); + int get_current_board_data ( + int num_samples, int preset, double *data_buf, int *returned_samples); + int get_board_data_count (int preset, int *result); + int get_board_data (int data_count, int preset, double *data_buf); + int insert_marker (double value, int preset); + int add_streamer (const char *streamer_params, int preset); + int delete_streamer (const char *streamer_params, int preset); // Board::board_logger should not be called from destructors, to ensure that there are safe log // methods Board::board_logger still available but should be used only outside destructors @@ -81,21 +91,24 @@ class Board } protected: - DataBuffer *db; + std::map dbs; + std::map> streamers; bool skip_logs; int board_id; struct BrainFlowInputParams params; - Streamer *streamer; json board_descr; SpinLock lock; - std::deque marker_queue; + std::map> marker_queues; - int prepare_for_acquisition (int buffer_size, char *streamer_params); + int prepare_for_acquisition (int buffer_size, const char *streamer_params); void free_packages (); - void push_package (double *package); + void push_package (double *package, int preset = (int)BrainFlowPresets::DEFAULT_PRESET); + std::string preset_to_string (int preset); + int preset_to_int (std::string preset); + int parse_streamer_params (const char *streamer_params, std::string &streamer_type, + std::string &streamer_dest, std::string &streamer_mods); private: - int prepare_streamer (char *streamer_params); // reshapes data from DataBuffer format where all channels are mixed to linear buffer - void reshape_data (int data_count, const double *buf, double *output_buf); + void reshape_data (int data_count, int preset, const double *buf, double *output_buf); }; diff --git a/deps/include/brainflow/board_controller/board_controller.h b/deps/include/brainflow/board_controller/board_controller.h index abc614b27..0ebcec79b 100644 --- a/deps/include/brainflow/board_controller/board_controller.h +++ b/deps/include/brainflow/board_controller/board_controller.h @@ -7,39 +7,44 @@ extern "C" { #endif - // I dont use const char * because I am not sure that all - // languages support passing const char * instead char * - // data acquisition methods SHARED_EXPORT int CALLING_CONVENTION prepare_session ( - int board_id, char *json_brainflow_input_params); - SHARED_EXPORT int CALLING_CONVENTION start_stream ( - int buffer_size, char *streamer_params, int board_id, char *json_brainflow_input_params); + int board_id, const char *json_brainflow_input_params); + SHARED_EXPORT int CALLING_CONVENTION start_stream (int buffer_size, const char *streamer_params, + int board_id, const char *json_brainflow_input_params); SHARED_EXPORT int CALLING_CONVENTION stop_stream ( - int board_id, char *json_brainflow_input_params); + int board_id, const char *json_brainflow_input_params); SHARED_EXPORT int CALLING_CONVENTION release_session ( - int board_id, char *json_brainflow_input_params); - SHARED_EXPORT int get_current_board_data (int num_samples, double *data_buf, - int *returned_samples, int board_id, char *json_brainflow_input_params); + int board_id, const char *json_brainflow_input_params); + SHARED_EXPORT int get_current_board_data (int num_samples, int preset, double *data_buf, + int *returned_samples, int board_id, const char *json_brainflow_input_params); SHARED_EXPORT int CALLING_CONVENTION get_board_data_count ( - int *result, int board_id, char *json_brainflow_input_params); - SHARED_EXPORT int CALLING_CONVENTION get_board_data ( - int data_count, double *data_buf, int board_id, char *json_brainflow_input_params); - SHARED_EXPORT int CALLING_CONVENTION config_board (char *config, char *response, - int *response_len, int board_id, char *json_brainflow_input_params); + int preset, int *result, int board_id, const char *json_brainflow_input_params); + SHARED_EXPORT int CALLING_CONVENTION get_board_data (int data_count, int preset, + double *data_buf, int board_id, const char *json_brainflow_input_params); + SHARED_EXPORT int CALLING_CONVENTION config_board (const char *config, char *response, + int *response_len, int board_id, const char *json_brainflow_input_params); SHARED_EXPORT int CALLING_CONVENTION is_prepared ( - int *prepared, int board_id, char *json_brainflow_input_params); + int *prepared, int board_id, const char *json_brainflow_input_params); SHARED_EXPORT int CALLING_CONVENTION insert_marker ( - double marker_value, int board_id, char *json_brainflow_input_params); + double marker_value, int preset, int board_id, const char *json_brainflow_input_params); + SHARED_EXPORT int CALLING_CONVENTION add_streamer ( + const char *streamer, int preset, int board_id, const char *json_brainflow_input_params); + SHARED_EXPORT int CALLING_CONVENTION delete_streamer ( + const char *streamer, int preset, int board_id, const char *json_brainflow_input_params); + SHARED_EXPORT int CALLING_CONVENTION release_all_sessions (); // logging methods - SHARED_EXPORT int CALLING_CONVENTION set_log_level (int log_level); - SHARED_EXPORT int CALLING_CONVENTION set_log_file (char *log_file); - SHARED_EXPORT int CALLING_CONVENTION log_message (int log_level, char *message); + SHARED_EXPORT int CALLING_CONVENTION set_log_level_board_controller (int log_level); + SHARED_EXPORT int CALLING_CONVENTION set_log_file_board_controller (const char *log_file); + SHARED_EXPORT int CALLING_CONVENTION log_message_board_controller ( + int log_level, char *message); // platform types and methods typedef const struct JNINativeInterface *JNIEnv; // A handle to use Java's JNI SHARED_EXPORT int CALLING_CONVENTION java_set_jnienv (JNIEnv *java_jnienv); + SHARED_EXPORT int CALLING_CONVENTION get_version_board_controller ( + char *version, int *num_chars, int max_chars); #ifdef __cplusplus } diff --git a/deps/include/brainflow/board_controller/board_info_getter.h b/deps/include/brainflow/board_controller/board_info_getter.h index fd5ae9bcd..53a423e51 100644 --- a/deps/include/brainflow/board_controller/board_info_getter.h +++ b/deps/include/brainflow/board_controller/board_info_getter.h @@ -7,42 +7,52 @@ extern "C" { #endif // data and board desc methods - SHARED_EXPORT int CALLING_CONVENTION get_sampling_rate (int board_id, int *sampling_rate); + SHARED_EXPORT int CALLING_CONVENTION get_board_descr ( + int board_id, int preset, char *board_descr, int *len); + SHARED_EXPORT int CALLING_CONVENTION get_sampling_rate ( + int board_id, int preset, int *sampling_rate); SHARED_EXPORT int CALLING_CONVENTION get_package_num_channel ( - int board_id, int *package_num_channel); + int board_id, int preset, int *package_num_channel); SHARED_EXPORT int CALLING_CONVENTION get_timestamp_channel ( - int board_id, int *timestamp_channel); - SHARED_EXPORT int CALLING_CONVENTION get_marker_channel (int board_id, int *marker_channel); - SHARED_EXPORT int CALLING_CONVENTION get_battery_channel (int board_id, int *battery_channel); - SHARED_EXPORT int CALLING_CONVENTION get_num_rows (int board_id, int *num_rows); - SHARED_EXPORT int CALLING_CONVENTION get_eeg_names (int board_id, char *eeg_names, int *len); + int board_id, int preset, int *timestamp_channel); + SHARED_EXPORT int CALLING_CONVENTION get_marker_channel ( + int board_id, int preset, int *marker_channel); + SHARED_EXPORT int CALLING_CONVENTION get_battery_channel ( + int board_id, int preset, int *battery_channel); + SHARED_EXPORT int CALLING_CONVENTION get_num_rows (int board_id, int preset, int *num_rows); + SHARED_EXPORT int CALLING_CONVENTION get_eeg_names ( + int board_id, int preset, char *eeg_names, int *len); SHARED_EXPORT int CALLING_CONVENTION get_exg_channels ( - int board_id, int *exg_channels, int *len); + int board_id, int preset, int *exg_channels, int *len); SHARED_EXPORT int CALLING_CONVENTION get_eeg_channels ( - int board_id, int *eeg_channels, int *len); + int board_id, int preset, int *eeg_channels, int *len); SHARED_EXPORT int CALLING_CONVENTION get_emg_channels ( - int board_id, int *emg_channels, int *len); + int board_id, int preset, int *emg_channels, int *len); SHARED_EXPORT int CALLING_CONVENTION get_ecg_channels ( - int board_id, int *ecg_channels, int *len); + int board_id, int preset, int *ecg_channels, int *len); SHARED_EXPORT int CALLING_CONVENTION get_eog_channels ( - int board_id, int *eog_channels, int *len); + int board_id, int preset, int *eog_channels, int *len); SHARED_EXPORT int CALLING_CONVENTION get_ppg_channels ( - int board_id, int *ppg_channels, int *len); + int board_id, int preset, int *ppg_channels, int *len); SHARED_EXPORT int CALLING_CONVENTION get_eda_channels ( - int board_id, int *eda_channels, int *len); + int board_id, int preset, int *eda_channels, int *len); SHARED_EXPORT int CALLING_CONVENTION get_accel_channels ( - int board_id, int *accel_channels, int *len); + int board_id, int preset, int *accel_channels, int *len); SHARED_EXPORT int CALLING_CONVENTION get_analog_channels ( - int board_id, int *analog_channels, int *len); + int board_id, int preset, int *analog_channels, int *len); SHARED_EXPORT int CALLING_CONVENTION get_gyro_channels ( - int board_id, int *gyro_channels, int *len); + int board_id, int preset, int *gyro_channels, int *len); SHARED_EXPORT int CALLING_CONVENTION get_other_channels ( - int board_id, int *other_channels, int *len); + int board_id, int preset, int *other_channels, int *len); SHARED_EXPORT int CALLING_CONVENTION get_temperature_channels ( - int board_id, int *temperature_channels, int *len); + int board_id, int preset, int *temperature_channels, int *len); SHARED_EXPORT int CALLING_CONVENTION get_resistance_channels ( - int board_id, int *resistance_channels, int *len); - SHARED_EXPORT int CALLING_CONVENTION get_device_name (int board_id, char *name, int *len); + int board_id, int preset, int *resistance_channels, int *len); + SHARED_EXPORT int CALLING_CONVENTION get_magnetometer_channels ( + int board_id, int preset, int *magnetometer_channels, int *len); + SHARED_EXPORT int CALLING_CONVENTION get_device_name ( + int board_id, int preset, char *name, int *len); + SHARED_EXPORT int CALLING_CONVENTION get_board_presets (int board_id, int *presets, int *len); #ifdef __cplusplus } diff --git a/deps/include/brainflow/board_controller/brainflow_boards.h b/deps/include/brainflow/board_controller/brainflow_boards.h index 2fa3a0f3d..90c886553 100644 --- a/deps/include/brainflow/board_controller/brainflow_boards.h +++ b/deps/include/brainflow/board_controller/brainflow_boards.h @@ -4,4 +4,10 @@ using json = nlohmann::json; -extern json brainflow_boards_json; +struct BrainFlowBoards +{ + json brainflow_boards_json; + BrainFlowBoards (); +}; + +extern BrainFlowBoards boards_struct; diff --git a/deps/include/brainflow/board_controller/brainflow_input_params.h b/deps/include/brainflow/board_controller/brainflow_input_params.h index 1b52b95e3..b3143f09d 100644 --- a/deps/include/brainflow/board_controller/brainflow_input_params.h +++ b/deps/include/brainflow/board_controller/brainflow_input_params.h @@ -3,12 +3,7 @@ #include #include -enum class IpProtocolType -{ - NONE = 0, - UDP = 1, - TCP = 2 -}; +#include "brainflow_constants.h" // we pass this structure from user API as a json string struct BrainFlowInputParams @@ -16,33 +11,50 @@ struct BrainFlowInputParams std::string serial_port; std::string mac_address; std::string ip_address; + std::string ip_address_aux; + std::string ip_address_anc; int ip_port; + int ip_port_aux; + int ip_port_anc; int ip_protocol; std::string other_info; int timeout; std::string serial_number; std::string file; + std::string file_aux; + std::string file_anc; + int master_board; BrainFlowInputParams () { serial_port = ""; mac_address = ""; ip_address = ""; + ip_address_aux = ""; + ip_address_anc = ""; ip_port = 0; - ip_protocol = (int)IpProtocolType::NONE; + ip_port_aux = 0; + ip_port_anc = 0; + ip_protocol = 0; other_info = ""; timeout = 0; serial_number = ""; file = ""; + file_aux = ""; + file_anc = ""; + master_board = (int)BoardIds::NO_BOARD; } // default copy constructor and assignment operator are ok, need less operator to use in map bool operator< (const struct BrainFlowInputParams &other) const { - return std::tie (serial_port, mac_address, ip_address, ip_port, ip_protocol, other_info, - timeout, serial_number, file) < - std::tie (other.serial_port, other.mac_address, other.ip_address, other.ip_port, - other.ip_protocol, other.other_info, timeout, serial_number, file); + return std::tie (serial_port, mac_address, ip_address, ip_address_aux, ip_address_anc, + ip_port, ip_port_aux, ip_port_anc, ip_protocol, other_info, timeout, + serial_number, file, file_aux, file_anc, master_board) < + std::tie (other.serial_port, other.mac_address, other.ip_address, other.ip_address_aux, + other.ip_address_anc, other.ip_port, other.ip_port_aux, other.ip_port_anc, + other.ip_protocol, other.other_info, other.timeout, other.serial_number, other.file, + other.file_aux, other.file_anc, other.master_board); } bool operator> (const struct BrainFlowInputParams &other) const diff --git a/deps/include/brainflow/board_controller/bt_lib_board.h b/deps/include/brainflow/board_controller/bt_lib_board.h new file mode 100644 index 000000000..b992555f1 --- /dev/null +++ b/deps/include/brainflow/board_controller/bt_lib_board.h @@ -0,0 +1,32 @@ +#pragma once + +#include + +#include "board.h" +#include "board_controller.h" +#include "runtime_dll_loader.h" + + +class BTLibBoard : public Board +{ + +protected: + bool initialized; + DLLLoader *dll_loader; + + int bluetooth_open_device (); + int bluetooth_get_data (char *data, int len); + int bluetooth_write_data (const char *data, int len); + int bluetooth_close_device (); + int find_bt_addr (const char *name_selector); + + virtual std::string get_name_selector () = 0; + +public: + BTLibBoard (int board_id, struct BrainFlowInputParams params); + virtual ~BTLibBoard (); + + virtual int prepare_session (); + virtual int release_session (); + virtual int config_board (std::string config, std::string &response); +}; diff --git a/deps/include/brainflow/board_controller/dyn_lib_board.h b/deps/include/brainflow/board_controller/dyn_lib_board.h new file mode 100644 index 000000000..cf35354e0 --- /dev/null +++ b/deps/include/brainflow/board_controller/dyn_lib_board.h @@ -0,0 +1,55 @@ +#pragma once + +#include +#include +#include +#include +#include +#include + +#ifdef _WIN32 +#include +#else +#include +#endif + +#include "board.h" +#include "board_controller.h" +#include "runtime_dll_loader.h" + + +class DynLibBoard : public Board +{ + +protected: + volatile bool keep_alive; + bool initialized; + bool is_streaming; + std::thread streaming_thread; + std::mutex m; + std::condition_variable cv; + volatile int state; + DLLLoader *dll_loader; + + virtual int call_init (); + virtual int call_open (); + virtual int call_close (); + virtual int call_start (); + virtual int call_stop (); + virtual int call_release (); + virtual int call_config (char *config); + + virtual void read_thread (); + virtual std::string get_lib_name () = 0; + + +public: + DynLibBoard (int board_id, struct BrainFlowInputParams params); + virtual ~DynLibBoard (); + + int prepare_session () override; + int start_stream (int buffer_size, const char *streamer_params) override; + int stop_stream () override; + int release_session () override; + int config_board (std::string config, std::string &response) override; +}; diff --git a/deps/include/brainflow/board_controller/emotibit/emotibit.h b/deps/include/brainflow/board_controller/emotibit/emotibit.h new file mode 100644 index 000000000..e639e822a --- /dev/null +++ b/deps/include/brainflow/board_controller/emotibit/emotibit.h @@ -0,0 +1,66 @@ +#pragma once + +#include +#include +#include + +#include "board.h" +#include "board_controller.h" + +#include "broadcast_server.h" +#include "socket_client_udp.h" +#include "socket_server_tcp.h" + + +class Emotibit : public Board +{ + +private: + volatile bool keep_alive; + volatile bool initialized; + + std::string ip_address; + std::thread streaming_thread; + std::thread connection_thread; + SocketClientUDP *data_socket; + SocketServerTCP *control_socket; + BroadCastServer *advertise_socket_server; + std::mutex m; + std::condition_variable cv; + int control_port; + int data_port; + + void read_thread (); + void ping_thread (); + + std::string create_package (const std::string &type_tag, uint16_t packet_number, + const std::string &data, uint16_t data_length, uint8_t protocol_version = 1, + uint8_t data_reliability = 100); + std::string create_package (const std::string &type_tag, uint16_t packet_number, + std::vector data, uint8_t protocol_version = 1, + uint8_t data_reliability = 100); + std::string create_header (const std::string &type_tag, uint32_t timestamp, + uint16_t packet_number, uint16_t data_length, uint8_t protocol_version = 1, + uint8_t data_reliability = 100); + std::vector split_string (const std::string &package, char delim); + bool get_header ( + const std::string &package_string, int *package_num, int *data_len, std::string &type_tag); + std::vector get_payload (const std::string &package_string, int data_len); + + int create_adv_connection (); + int create_data_connection (); + int create_control_connection (); + int send_connect_msg (); + int send_control_msg (const char *msg); + int wait_for_connection (); + +public: + Emotibit (struct BrainFlowInputParams params); + ~Emotibit (); + + int prepare_session (); + int start_stream (int buffer_size, const char *streamer_params); + int stop_stream (); + int release_session (); + int config_board (std::string config, std::string &response); +}; \ No newline at end of file diff --git a/deps/include/brainflow/board_controller/emotibit/emotibit_defines.h b/deps/include/brainflow/board_controller/emotibit/emotibit_defines.h new file mode 100644 index 000000000..8404fc0fa --- /dev/null +++ b/deps/include/brainflow/board_controller/emotibit/emotibit_defines.h @@ -0,0 +1,79 @@ +#pragma once + +#define EDA "EA\0" +#define EDL "EL\0" +#define EDR "ER\0" +#define PPG_INFRARED "PI\0" +#define PPG_RED "PR\0" +#define PPG_GREEN "PG\0" +#define SPO2 "O2\0" +#define TEMPERATURE_0 "T0\0" +#define TEMPERATURE_1 "T1\0" +#define THERMOPILE "TH\0" +#define HUMIDITY_0 "H0\0" +#define ACCELEROMETER_X "AX\0" +#define ACCELEROMETER_Y "AY\0" +#define ACCELEROMETER_Z "AZ\0" +#define GYROSCOPE_X "GX\0" +#define GYROSCOPE_Y "GY\0" +#define GYROSCOPE_Z "GZ\0" +#define MAGNETOMETER_X "MX\0" +#define MAGNETOMETER_Y "MY\0" +#define MAGNETOMETER_Z "MZ\0" +#define BATTERY_VOLTAGE "BV\0" +#define BATTERY_PERCENT "B%\0" +#define BUTTON_PRESS_SHORT "BS\0" +#define BUTTON_PRESS_LONG "BL\0" +#define DATA_CLIPPING "DC\0" +#define DATA_OVERFLOW "DO\0" +#define SD_CARD_PERCENT "SD\0" +#define RESET "RS\0" // still necessary? +#define EMOTIBIT_DEBUG "DB\0" +#define ACK "AK\0" +#define REQUEST_DATA "RD\0" +#define TIMESTAMP_EMOTIBIT "TE\0" +#define TIMESTAMP_LOCAL "TL\0" +#define TIMESTAMP_UTC "TU\0" +#define TIMESTAMP_CROSS_TIME "TX\0" +#define EMOTIBIT_MODE "EM\0" +#define EMOTIBIT_INFO "EI\0" +#define HEART_RATE "HR\0" +#define INTER_BEAT_INTERVAL "BI\0" +#define SKIN_CONDUCTANCE_RESPONSE_AMPLITUDE "SA\0" +#define SKIN_CONDUCTANCE_RESPONSE_FREQ "SF\0" +#define SKIN_CONDUCTANCE_RESPONSE_RISE_TIME "SR\0" +// Computer data TypeTags (sent over reliable channel e.g. Control) +#define GPS_LATLNG "GL\0" +#define GPS_SPEED "GS\0" +#define GPS_BEARING "GB\0" +#define GPS_ALTITUDE "GA\0" +#define USER_NOTE "UN\0" +#define LSL_MARKER "LM\0" +// Control TypeTags +#define RECORD_BEGIN "RB\0" +#define RECORD_END "RE\0" +#define MODE_NORMAL_POWER "MN\0" // Stops sending data timestamping should be accurate +#define MODE_LOW_POWER "ML\0" // Stops sending data timestamping should be accurate +#define MODE_MAX_LOW_POWER "MM\0" // Stops sending data timestamping accuracy drops +#define MODE_WIRELESS_OFF "MO\0" // Stops sending data timestamping should be accurate +#define MODE_HIBERNATE "MH\0" // Full shutdown of all operation +#define EMOTIBIT_DISCONNECT "ED\0" +#define SERIAL_DATA_ON "S+\0" +#define SERIAL_DATA_OFF "S-\0" +// Advertising TypeTags +#define PING "PN\0" +#define PONG "PO\0" +#define HELLO_EMOTIBIT "HE\0" +#define HELLO_HOST "HH\0" +#define EMOTIBIT_CONNECT "EC\0" + +#define CONTROL_PORT "CP\0" +#define DATA_PORT "DP\0" +#define RECORDING_STATUS "RS\0" +#define POWER_STATUS "PS\0" + +#define PACKET_DELIMITER_CSV '\n' +#define PAYLOAD_DELIMITER ',' + +#define HEADER_LENGTH 6 +#define WIFI_ADVERTISING_PORT 3131 \ No newline at end of file diff --git a/deps/include/brainflow/board_controller/enophone/enophone.h b/deps/include/brainflow/board_controller/enophone/enophone.h new file mode 100644 index 000000000..c9eb3fca7 --- /dev/null +++ b/deps/include/brainflow/board_controller/enophone/enophone.h @@ -0,0 +1,33 @@ +#pragma once + +#include +#include +#include + +#include "bt_lib_board.h" + + +class Enophone : public BTLibBoard +{ + +protected: + volatile bool keep_alive; + bool is_streaming; + std::thread streaming_thread; + std::mutex m; + std::condition_variable cv; + volatile int state; + + void read_thread (); + std::string get_name_selector (); + +public: + Enophone (struct BrainFlowInputParams params); + ~Enophone (); + + int prepare_session (); + int start_stream (int buffer_size, const char *streamer_params); + int stop_stream (); + int release_session (); + int config_board (std::string config, std::string &response); +}; diff --git a/deps/include/brainflow/board_controller/freeeeg32/freeeeg32.h b/deps/include/brainflow/board_controller/freeeeg32/freeeeg32.h index 450a4b658..56110339b 100644 --- a/deps/include/brainflow/board_controller/freeeeg32/freeeeg32.h +++ b/deps/include/brainflow/board_controller/freeeeg32/freeeeg32.h @@ -26,7 +26,7 @@ class FreeEEG32 : public Board ~FreeEEG32 (); int prepare_session (); - int start_stream (int buffer_size, char *streamer_params); + int start_stream (int buffer_size, const char *streamer_params); int stop_stream (); int release_session (); int config_board (std::string config, std::string &response); @@ -34,5 +34,5 @@ class FreeEEG32 : public Board static constexpr int start_byte = 0xA0; static constexpr int end_byte = 0xC0; static constexpr double ads_gain = 8.0; - static constexpr double ads_vref = 4.5; + static constexpr double ads_vref = 2.5; }; diff --git a/deps/include/brainflow/board_controller/gtec/unicorn_board.h b/deps/include/brainflow/board_controller/gtec/unicorn_board.h index 671bb19cf..6c293e990 100644 --- a/deps/include/brainflow/board_controller/gtec/unicorn_board.h +++ b/deps/include/brainflow/board_controller/gtec/unicorn_board.h @@ -39,7 +39,7 @@ class UnicornBoard : public Board ~UnicornBoard (); int prepare_session (); - int start_stream (int buffer_size, char *streamer_params); + int start_stream (int buffer_size, const char *streamer_params); int stop_stream (); int release_session (); int config_board (std::string config, std::string &response); diff --git a/deps/include/brainflow/board_controller/ironbci/ironbci.h b/deps/include/brainflow/board_controller/ironbci/ironbci.h deleted file mode 100644 index e40e90aef..000000000 --- a/deps/include/brainflow/board_controller/ironbci/ironbci.h +++ /dev/null @@ -1,40 +0,0 @@ -#pragma once - -#include -#include - -#include "board.h" -#include "board_controller.h" -#include "math.h" -#include "serial.h" - - -class IronBCI : public Board -{ - -protected: - volatile bool keep_alive; - bool initialized; - std::thread streaming_thread; - - Serial *serial; - - void read_thread (); - int send_to_board (const char *msg); - -public: - IronBCI (struct BrainFlowInputParams params); - ~IronBCI (); - - int prepare_session (); - int start_stream (int buffer_size, char *streamer_params); - int stop_stream (); - int release_session (); - int config_board (std::string config, std::string &response); - - static constexpr int ads_gain = 8; - static constexpr int start_byte = 0xA0; // package start byte - static constexpr int stop_byte = 0xC0; // package stop byte - static const std::string start_command; // command which starts streaming - static const std::string stop_command; // command which stops streaming -}; diff --git a/deps/include/brainflow/board_controller/mentalab/explore.h b/deps/include/brainflow/board_controller/mentalab/explore.h new file mode 100644 index 000000000..f12cb44bf --- /dev/null +++ b/deps/include/brainflow/board_controller/mentalab/explore.h @@ -0,0 +1,58 @@ +#pragma once + +#include +#include +#include +#include + +#include "bt_lib_board.h" + + +#pragma pack(push, 1) +struct ExploreHeader +{ + unsigned char pid; + unsigned char counter; + uint16_t payload_size; + uint32_t timestamp; + + ExploreHeader () + { + pid = 0; + payload_size = 0; + counter = 0; + timestamp = 0; + } +}; +#pragma pack(pop) + +class Explore : public BTLibBoard +{ + +protected: + volatile bool keep_alive; + volatile int state; + std::thread streaming_thread; + std::mutex m; + std::condition_variable cv; + double last_eeg_timestamp; + + void read_thread (); + std::string get_name_selector (); + void parse_eeg_data (const ExploreHeader *header, double *package, unsigned char *payload, + double vref, int n_packages); + void parse_orientation_data ( + const ExploreHeader *header, double *package, unsigned char *payload); + void parse_env_data (const ExploreHeader *header, double *package, unsigned char *payload); + double get_battery_percentage (double battery); + +public: + Explore (int board_id, struct BrainFlowInputParams params); + ~Explore (); + + int prepare_session (); + int config_board (std::string config, std::string &response); + int start_stream (int buffer_size, const char *streamer_params); + int stop_stream (); + int release_session (); +}; diff --git a/deps/include/brainflow/board_controller/mit/fascia.h b/deps/include/brainflow/board_controller/mit/fascia.h deleted file mode 100644 index 2b6104c8e..000000000 --- a/deps/include/brainflow/board_controller/mit/fascia.h +++ /dev/null @@ -1,46 +0,0 @@ -#pragma once - -#include -#include -#include -#include - -#include "board.h" -#include "board_controller.h" -#include "socket_server_udp.h" - - -class Fascia : public Board -{ - -private: - const double accel_scale = 0.002 / (pow (2, 4)); - - volatile bool keep_alive; - bool initialized; - bool is_streaming; - std::thread streaming_thread; - SocketServerUDP *socket; - - // mutex and cond variable to wait in the main thread for the first received package (this check - // is optional) - std::mutex m; - std::condition_variable cv; - volatile int state; - - void read_thread (); - -public: - Fascia (struct BrainFlowInputParams params); - ~Fascia (); - - int prepare_session (); - int start_stream (int buffer_size, char *streamer_params); - int stop_stream (); - int release_session (); - int config_board (std::string config, std::string &response); - - static constexpr int package_size = 68; - static constexpr int num_packages = 20; - static constexpr int transaction_size = Fascia::package_size * Fascia::num_packages; -}; diff --git a/deps/include/brainflow/board_controller/multicast_streamer.h b/deps/include/brainflow/board_controller/multicast_streamer.h index c8730edea..8893f39d6 100644 --- a/deps/include/brainflow/board_controller/multicast_streamer.h +++ b/deps/include/brainflow/board_controller/multicast_streamer.h @@ -1,7 +1,9 @@ #pragma once -#include "multicast_server.h" +#include +#include "data_buffer.h" +#include "multicast_server.h" #include "streamer.h" @@ -19,4 +21,9 @@ class MultiCastStreamer : public Streamer char ip[128]; int port; MultiCastServer *server; + DataBuffer *db; + volatile bool is_streaming; + std::thread streaming_thread; + + void thread_worker (); }; diff --git a/deps/include/brainflow/board_controller/muse/muse.h b/deps/include/brainflow/board_controller/muse/muse.h new file mode 100644 index 000000000..d5687c9ca --- /dev/null +++ b/deps/include/brainflow/board_controller/muse/muse.h @@ -0,0 +1,55 @@ +#pragma once + +#include "ble_lib_board.h" +#include +#include +#include +#include + + +class Muse : public BLELibBoard +{ + +protected: + volatile simpleble_adapter_t muse_adapter; + volatile simpleble_peripheral_t muse_peripheral; + bool initialized; + bool is_streaming; + std::mutex m; + std::mutex callback_lock; + std::condition_variable cv; + std::vector> notified_characteristics; + std::pair control_characteristics; + std::vector> current_default_buf; + std::vector> current_aux_buf; + std::vector> current_anc_buf; + std::vector new_eeg_data; + std::vector new_ppg_data; + double last_fifth_chan_timestamp; // used to determine 4 or 5 channels used + double last_ppg_timestamp; // used for timestamp correction + double last_eeg_timestamp; // used for timestamp correction + double last_aux_timestamp; // used for timestamp correction + +public: + Muse (int board_id, struct BrainFlowInputParams params); + ~Muse (); + + int prepare_session (); + int start_stream (int buffer_size, const char *streamer_params); + int stop_stream (); + int release_session (); + int config_board (std::string config, std::string &response); + int config_board (std::string config); + + void adapter_on_scan_found (simpleble_adapter_t adapter, simpleble_peripheral_t peripheral); + void peripheral_on_eeg (simpleble_uuid_t service, simpleble_uuid_t characteristic, + uint8_t *data, size_t size, size_t channel_num); + void peripheral_on_ppg (simpleble_uuid_t service, simpleble_uuid_t characteristic, + uint8_t *data, size_t size, size_t ppg_num); + void peripheral_on_accel ( + simpleble_uuid_t service, simpleble_uuid_t characteristic, uint8_t *data, size_t size); + void peripheral_on_gyro ( + simpleble_uuid_t service, simpleble_uuid_t characteristic, uint8_t *data, size_t size); + void peripheral_on_status ( + simpleble_uuid_t service, simpleble_uuid_t characteristic, uint8_t *data, size_t size); +}; diff --git a/deps/include/brainflow/board_controller/muse/muse_bglib/build.cmake b/deps/include/brainflow/board_controller/muse/muse_bglib/build.cmake new file mode 100644 index 000000000..f44d3baa6 --- /dev/null +++ b/deps/include/brainflow/board_controller/muse/muse_bglib/build.cmake @@ -0,0 +1,79 @@ +if (CMAKE_SIZEOF_VOID_P EQUAL 8) + SET (MUSE_BLED_LIB "MuseLib") + if (APPLE) + SET (MUSE_BLED_LIB_NAME "libMuseLib.dylib") + elseif (UNIX) + SET (MUSE_BLED_LIB_NAME "libMuseLib.so") + else () + SET (MUSE_BLED_LIB_NAME "MuseLib.dll") + endif (APPLE) +else (CMAKE_SIZEOF_VOID_P EQUAL 8) + MESSAGE ("32 bits compiler detected") + SET (PLATFORM_ACH "X86") + if (APPLE) + SET (MUSE_BLED_LIB "MuseLib") + SET (MUSE_BLED_LIB_NAME "libMuseLib.dylib") + elseif (UNIX) + SET (MUSE_BLED_LIB "MuseLib") + SET (MUSE_BLED_LIB_NAME "libMuseLib.so") + else () + SET (MUSE_BLED_LIB "MuseLib32") + SET (MUSE_BLED_LIB_NAME "MuseLib32.dll") + endif (APPLE) +endif (CMAKE_SIZEOF_VOID_P EQUAL 8) + +SET (MUSE_BLED_SOURCE_LIB + ${CMAKE_CURRENT_LIST_DIR}/callbacks.cpp + ${CMAKE_CURRENT_LIST_DIR}/cmd_def.cpp + ${CMAKE_CURRENT_LIST_DIR}/muse_bglib_helper.cpp + ${CMAKE_CURRENT_LIST_DIR}/main.cpp + ${CMAKE_CURRENT_LIST_DIR}/stubs.cpp + ${CMAKE_CURRENT_LIST_DIR}/uart.cpp + ${CMAKE_HOME_DIRECTORY}/src/utils/timestamp.cpp + ${CMAKE_HOME_DIRECTORY}/src/utils/data_buffer.cpp +) + +add_library (${MUSE_BLED_LIB} SHARED ${MUSE_BLED_SOURCE_LIB}) +target_include_directories (${MUSE_BLED_LIB} PUBLIC + $ + $ + $ + $ + $ +) +set_property (TARGET ${MUSE_BLED_LIB} PROPERTY POSITION_INDEPENDENT_CODE ON) + +set_target_properties (${MUSE_BLED_LIB} + PROPERTIES + ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_HOME_DIRECTORY}/compiled + LIBRARY_OUTPUT_DIRECTORY ${CMAKE_HOME_DIRECTORY}/compiled + RUNTIME_OUTPUT_DIRECTORY ${CMAKE_HOME_DIRECTORY}/compiled +) + +if (MSVC) + add_custom_command (TARGET ${MUSE_BLED_LIB} POST_BUILD + COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_HOME_DIRECTORY}/compiled/$/${MUSE_BLED_LIB_NAME}" "${CMAKE_HOME_DIRECTORY}/python_package/brainflow/lib/${MUSE_BLED_LIB_NAME}" + COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_HOME_DIRECTORY}/compiled/$/${MUSE_BLED_LIB_NAME}" "${CMAKE_HOME_DIRECTORY}/java_package/brainflow/src/main/resources/${MUSE_BLED_LIB_NAME}" + COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_HOME_DIRECTORY}/compiled/$/${MUSE_BLED_LIB_NAME}" "${CMAKE_HOME_DIRECTORY}/csharp_package/brainflow/brainflow/lib/${MUSE_BLED_LIB_NAME}" + COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_HOME_DIRECTORY}/compiled/$/${MUSE_BLED_LIB_NAME}" "${CMAKE_HOME_DIRECTORY}/matlab_package/brainflow/lib/${MUSE_BLED_LIB_NAME}" + COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_HOME_DIRECTORY}/compiled/$/${MUSE_BLED_LIB_NAME}" "${CMAKE_HOME_DIRECTORY}/julia_package/brainflow/lib/${MUSE_BLED_LIB_NAME}" + ) +endif (MSVC) +if (UNIX AND NOT ANDROID) + add_custom_command (TARGET ${MUSE_BLED_LIB} POST_BUILD + COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_HOME_DIRECTORY}/compiled/${MUSE_BLED_LIB_NAME}" "${CMAKE_HOME_DIRECTORY}/python_package/brainflow/lib/${MUSE_BLED_LIB_NAME}" + COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_HOME_DIRECTORY}/compiled/${MUSE_BLED_LIB_NAME}" "${CMAKE_HOME_DIRECTORY}/julia_package/brainflow/lib/${MUSE_BLED_LIB_NAME}" + COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_HOME_DIRECTORY}/compiled/${MUSE_BLED_LIB_NAME}" "${CMAKE_HOME_DIRECTORY}/java_package/brainflow/src/main/resources/${MUSE_BLED_LIB_NAME}" + COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_HOME_DIRECTORY}/compiled/${MUSE_BLED_LIB_NAME}" "${CMAKE_HOME_DIRECTORY}/csharp_package/brainflow/brainflow/${MUSE_BLED_LIB_NAME}" + COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_HOME_DIRECTORY}/compiled/${MUSE_BLED_LIB_NAME}" "${CMAKE_HOME_DIRECTORY}/matlab_package/brainflow/lib/${MUSE_BLED_LIB_NAME}" + ) +endif (UNIX AND NOT ANDROID) + +install ( + TARGETS ${MUSE_BLED_LIB} + EXPORT ${TARGETS_EXPORT_NAME} + RUNTIME DESTINATION lib + LIBRARY DESTINATION lib + INCLUDES DESTINATION inc + ARCHIVE DESTINATION lib +) \ No newline at end of file diff --git a/deps/include/brainflow/board_controller/muse/muse_bglib/callbacks.cpp b/deps/include/brainflow/board_controller/muse/muse_bglib/callbacks.cpp new file mode 100644 index 000000000..b1a6a2834 --- /dev/null +++ b/deps/include/brainflow/board_controller/muse/muse_bglib/callbacks.cpp @@ -0,0 +1,67 @@ +#include +#include + +#include "cmd_def.h" +#include "muse_bglib_helper.h" + +extern MuseBGLibHelper *helper; + + +void ble_evt_connection_status (const struct ble_msg_connection_status_evt_t *msg) +{ + if (helper != NULL) + { + helper->ble_evt_connection_status (msg); + } +} + +void ble_evt_connection_disconnected (const struct ble_msg_connection_disconnected_evt_t *msg) +{ + if (helper != NULL) + { + helper->ble_evt_connection_disconnected (msg); + } +} + +void ble_evt_attclient_group_found (const struct ble_msg_attclient_group_found_evt_t *msg) +{ + if (helper != NULL) + { + helper->ble_evt_attclient_group_found (msg); + } +} + +void ble_evt_attclient_procedure_completed ( + const struct ble_msg_attclient_procedure_completed_evt_t *msg) +{ + + if (helper != NULL) + { + helper->ble_evt_attclient_procedure_completed (msg); + } +} + +void ble_evt_attclient_find_information_found ( + const struct ble_msg_attclient_find_information_found_evt_t *msg) +{ + if (helper != NULL) + { + helper->ble_evt_attclient_find_information_found (msg); + } +} + +void ble_evt_attclient_attribute_value (const struct ble_msg_attclient_attribute_value_evt_t *msg) +{ + if (helper != NULL) + { + helper->ble_evt_attclient_attribute_value (msg); + } +} + +void ble_evt_gap_scan_response (const struct ble_msg_gap_scan_response_evt_t *msg) +{ + if (helper != NULL) + { + helper->ble_evt_gap_scan_response (msg); + } +} \ No newline at end of file diff --git a/deps/include/brainflow/board_controller/muse/muse_bglib/cmd_def.cpp b/deps/include/brainflow/board_controller/muse/muse_bglib/cmd_def.cpp new file mode 100644 index 000000000..2ed452879 --- /dev/null +++ b/deps/include/brainflow/board_controller/muse/muse_bglib/cmd_def.cpp @@ -0,0 +1,613 @@ + +/***************************************************************************** + * + * + * !!!!!!!! THIS IS AUTOGENERATED FILE, DO NOT EDIT !!!!!!!! + * + * + ****************************************************************************/ + + +// clang-format off +#include + +#include "cmd_def.h" + +#pragma warning(disable:4244) + + +void (*bglib_output)(uint8 len1,uint8* data1,uint16 len2,uint8* data2)=0; +static const struct ble_msg apis[]={ + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x1,ble_cls_system,ble_cmd_system_reset_id}, 0x2,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x0,ble_cls_system,ble_cmd_system_hello_id}, 0x0,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x0,ble_cls_system,ble_cmd_system_address_get_id}, 0x0,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x3,ble_cls_system,ble_cmd_system_reg_write_id}, 0x24,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x2,ble_cls_system,ble_cmd_system_reg_read_id}, 0x4,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x0,ble_cls_system,ble_cmd_system_get_counters_id}, 0x0,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x0,ble_cls_system,ble_cmd_system_get_connections_id}, 0x0,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x5,ble_cls_system,ble_cmd_system_read_memory_id}, 0x26,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x0,ble_cls_system,ble_cmd_system_get_info_id}, 0x0,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x2,ble_cls_system,ble_cmd_system_endpoint_tx_id}, 0x82,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x7,ble_cls_system,ble_cmd_system_whitelist_append_id}, 0x2a,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x7,ble_cls_system,ble_cmd_system_whitelist_remove_id}, 0x2a,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x0,ble_cls_system,ble_cmd_system_whitelist_clear_id}, 0x0,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x2,ble_cls_system,ble_cmd_system_endpoint_rx_id}, 0x22,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x3,ble_cls_system,ble_cmd_system_endpoint_set_watermarks_id}, 0x222,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x1,ble_cls_system,ble_cmd_system_aes_setkey_id}, 0x8,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x1,ble_cls_system,ble_cmd_system_aes_encrypt_id}, 0x8,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x1,ble_cls_system,ble_cmd_system_aes_decrypt_id}, 0x8,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x0,ble_cls_flash,ble_cmd_flash_ps_defrag_id}, 0x0,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x0,ble_cls_flash,ble_cmd_flash_ps_dump_id}, 0x0,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x0,ble_cls_flash,ble_cmd_flash_ps_erase_all_id}, 0x0,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x3,ble_cls_flash,ble_cmd_flash_ps_save_id}, 0x84,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x2,ble_cls_flash,ble_cmd_flash_ps_load_id}, 0x4,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x2,ble_cls_flash,ble_cmd_flash_ps_erase_id}, 0x4,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x1,ble_cls_flash,ble_cmd_flash_erase_page_id}, 0x2,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x5,ble_cls_flash,ble_cmd_flash_write_data_id}, 0x86,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x5,ble_cls_flash,ble_cmd_flash_read_data_id}, 0x26,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x4,ble_cls_attributes,ble_cmd_attributes_write_id}, 0x824,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x4,ble_cls_attributes,ble_cmd_attributes_read_id}, 0x44,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x2,ble_cls_attributes,ble_cmd_attributes_read_type_id}, 0x4,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x3,ble_cls_attributes,ble_cmd_attributes_user_read_response_id}, 0x822,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x2,ble_cls_attributes,ble_cmd_attributes_user_write_response_id}, 0x22,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x4,ble_cls_attributes,ble_cmd_attributes_send_id}, 0x842,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x1,ble_cls_connection,ble_cmd_connection_disconnect_id}, 0x2,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x1,ble_cls_connection,ble_cmd_connection_get_rssi_id}, 0x2,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x9,ble_cls_connection,ble_cmd_connection_update_id}, 0x44442,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x1,ble_cls_connection,ble_cmd_connection_version_update_id}, 0x2,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x1,ble_cls_connection,ble_cmd_connection_channel_map_get_id}, 0x2,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x2,ble_cls_connection,ble_cmd_connection_channel_map_set_id}, 0x82,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x1,ble_cls_connection,ble_cmd_connection_features_get_id}, 0x2,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x1,ble_cls_connection,ble_cmd_connection_get_status_id}, 0x2,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x2,ble_cls_connection,ble_cmd_connection_raw_tx_id}, 0x82,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x8,ble_cls_attclient,ble_cmd_attclient_find_by_type_value_id}, 0x84442,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x6,ble_cls_attclient,ble_cmd_attclient_read_by_group_type_id}, 0x8442,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x6,ble_cls_attclient,ble_cmd_attclient_read_by_type_id}, 0x8442,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x5,ble_cls_attclient,ble_cmd_attclient_find_information_id}, 0x442,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x3,ble_cls_attclient,ble_cmd_attclient_read_by_handle_id}, 0x42,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x4,ble_cls_attclient,ble_cmd_attclient_attribute_write_id}, 0x842,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x4,ble_cls_attclient,ble_cmd_attclient_write_command_id}, 0x842,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x1,ble_cls_attclient,ble_cmd_attclient_indicate_confirm_id}, 0x2,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x3,ble_cls_attclient,ble_cmd_attclient_read_long_id}, 0x42,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x6,ble_cls_attclient,ble_cmd_attclient_prepare_write_id}, 0x8442,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x2,ble_cls_attclient,ble_cmd_attclient_execute_write_id}, 0x22,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x2,ble_cls_attclient,ble_cmd_attclient_read_multiple_id}, 0x82,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x2,ble_cls_sm,ble_cmd_sm_encrypt_start_id}, 0x22,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x1,ble_cls_sm,ble_cmd_sm_set_bondable_mode_id}, 0x2,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x1,ble_cls_sm,ble_cmd_sm_delete_bonding_id}, 0x2,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x3,ble_cls_sm,ble_cmd_sm_set_parameters_id}, 0x222,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x5,ble_cls_sm,ble_cmd_sm_passkey_entry_id}, 0x62,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x0,ble_cls_sm,ble_cmd_sm_get_bonds_id}, 0x0,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x1,ble_cls_sm,ble_cmd_sm_set_oob_data_id}, 0x8,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x0,ble_cls_sm,ble_cmd_sm_whitelist_bonds_id}, 0x0,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x2,ble_cls_gap,ble_cmd_gap_set_privacy_flags_id}, 0x22,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x2,ble_cls_gap,ble_cmd_gap_set_mode_id}, 0x22,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x1,ble_cls_gap,ble_cmd_gap_discover_id}, 0x2,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0xf,ble_cls_gap,ble_cmd_gap_connect_direct_id}, 0x44442a,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x0,ble_cls_gap,ble_cmd_gap_end_procedure_id}, 0x0,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x8,ble_cls_gap,ble_cmd_gap_connect_selective_id}, 0x4444,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x3,ble_cls_gap,ble_cmd_gap_set_filtering_id}, 0x222,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x5,ble_cls_gap,ble_cmd_gap_set_scan_parameters_id}, 0x244,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x5,ble_cls_gap,ble_cmd_gap_set_adv_parameters_id}, 0x244,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x2,ble_cls_gap,ble_cmd_gap_set_adv_data_id}, 0x82,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x7,ble_cls_gap,ble_cmd_gap_set_directed_connectable_mode_id}, 0x2a,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x3,ble_cls_hardware,ble_cmd_hardware_io_port_config_irq_id}, 0x222,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x6,ble_cls_hardware,ble_cmd_hardware_set_soft_timer_id}, 0x226,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x3,ble_cls_hardware,ble_cmd_hardware_adc_read_id}, 0x222,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x2,ble_cls_hardware,ble_cmd_hardware_io_port_config_direction_id}, 0x22,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x2,ble_cls_hardware,ble_cmd_hardware_io_port_config_function_id}, 0x22,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x3,ble_cls_hardware,ble_cmd_hardware_io_port_config_pull_id}, 0x222,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x3,ble_cls_hardware,ble_cmd_hardware_io_port_write_id}, 0x222,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x2,ble_cls_hardware,ble_cmd_hardware_io_port_read_id}, 0x22,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x6,ble_cls_hardware,ble_cmd_hardware_spi_config_id}, 0x222222,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x2,ble_cls_hardware,ble_cmd_hardware_spi_transfer_id}, 0x82,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x3,ble_cls_hardware,ble_cmd_hardware_i2c_read_id}, 0x222,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x3,ble_cls_hardware,ble_cmd_hardware_i2c_write_id}, 0x822,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x1,ble_cls_hardware,ble_cmd_hardware_set_txpower_id}, 0x2,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x5,ble_cls_hardware,ble_cmd_hardware_timer_comparator_id}, 0x4222,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x2,ble_cls_hardware,ble_cmd_hardware_io_port_irq_enable_id}, 0x22,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x2,ble_cls_hardware,ble_cmd_hardware_io_port_irq_direction_id}, 0x22,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x1,ble_cls_hardware,ble_cmd_hardware_analog_comparator_enable_id}, 0x2,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x0,ble_cls_hardware,ble_cmd_hardware_analog_comparator_read_id}, 0x0,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x1,ble_cls_hardware,ble_cmd_hardware_analog_comparator_config_irq_id}, 0x2,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x1,ble_cls_hardware,ble_cmd_hardware_set_rxgain_id}, 0x2,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x1,ble_cls_hardware,ble_cmd_hardware_usb_enable_id}, 0x2,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x3,ble_cls_test,ble_cmd_test_phy_tx_id}, 0x222,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x1,ble_cls_test,ble_cmd_test_phy_rx_id}, 0x2,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x0,ble_cls_test,ble_cmd_test_phy_end_id}, 0x0,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x0,ble_cls_test,ble_cmd_test_phy_reset_id}, 0x0,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x0,ble_cls_test,ble_cmd_test_get_channel_map_id}, 0x0,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x1,ble_cls_test,ble_cmd_test_debug_id}, 0x8,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x1,ble_cls_test,ble_cmd_test_channel_mode_id}, 0x2,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x1,ble_cls_dfu,ble_cmd_dfu_reset_id}, 0x2,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x4,ble_cls_dfu,ble_cmd_dfu_flash_set_address_id}, 0x6,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x1,ble_cls_dfu,ble_cmd_dfu_flash_upload_id}, 0x8,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_cmd|0x0,0x0,ble_cls_dfu,ble_cmd_dfu_flash_upload_finish_id}, 0x0,(ble_cmd_handler)ble_default}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x0,ble_cls_system,ble_cmd_system_reset_id}, 0x0, (ble_cmd_handler)ble_rsp_system_reset}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x0,ble_cls_system,ble_cmd_system_hello_id}, 0x0, (ble_cmd_handler)ble_rsp_system_hello}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x6,ble_cls_system,ble_cmd_system_address_get_id}, 0xa, (ble_cmd_handler)ble_rsp_system_address_get}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x2,ble_cls_system,ble_cmd_system_reg_write_id}, 0x4, (ble_cmd_handler)ble_rsp_system_reg_write}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x3,ble_cls_system,ble_cmd_system_reg_read_id}, 0x24, (ble_cmd_handler)ble_rsp_system_reg_read}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x5,ble_cls_system,ble_cmd_system_get_counters_id}, 0x22222, (ble_cmd_handler)ble_rsp_system_get_counters}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x1,ble_cls_system,ble_cmd_system_get_connections_id}, 0x2, (ble_cmd_handler)ble_rsp_system_get_connections}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x5,ble_cls_system,ble_cmd_system_read_memory_id}, 0x86, (ble_cmd_handler)ble_rsp_system_read_memory}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0xc,ble_cls_system,ble_cmd_system_get_info_id}, 0x2244444, (ble_cmd_handler)ble_rsp_system_get_info}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x2,ble_cls_system,ble_cmd_system_endpoint_tx_id}, 0x4, (ble_cmd_handler)ble_rsp_system_endpoint_tx}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x2,ble_cls_system,ble_cmd_system_whitelist_append_id}, 0x4, (ble_cmd_handler)ble_rsp_system_whitelist_append}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x2,ble_cls_system,ble_cmd_system_whitelist_remove_id}, 0x4, (ble_cmd_handler)ble_rsp_system_whitelist_remove}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x0,ble_cls_system,ble_cmd_system_whitelist_clear_id}, 0x0, (ble_cmd_handler)ble_rsp_system_whitelist_clear}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x3,ble_cls_system,ble_cmd_system_endpoint_rx_id}, 0x84, (ble_cmd_handler)ble_rsp_system_endpoint_rx}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x2,ble_cls_system,ble_cmd_system_endpoint_set_watermarks_id}, 0x4, (ble_cmd_handler)ble_rsp_system_endpoint_set_watermarks}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x0,ble_cls_system,ble_cmd_system_aes_setkey_id}, 0x0, (ble_cmd_handler)ble_rsp_system_aes_setkey}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x1,ble_cls_system,ble_cmd_system_aes_encrypt_id}, 0x8, (ble_cmd_handler)ble_rsp_system_aes_encrypt}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x1,ble_cls_system,ble_cmd_system_aes_decrypt_id}, 0x8, (ble_cmd_handler)ble_rsp_system_aes_decrypt}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x0,ble_cls_flash,ble_cmd_flash_ps_defrag_id}, 0x0, (ble_cmd_handler)ble_rsp_flash_ps_defrag}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x0,ble_cls_flash,ble_cmd_flash_ps_dump_id}, 0x0, (ble_cmd_handler)ble_rsp_flash_ps_dump}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x0,ble_cls_flash,ble_cmd_flash_ps_erase_all_id}, 0x0, (ble_cmd_handler)ble_rsp_flash_ps_erase_all}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x2,ble_cls_flash,ble_cmd_flash_ps_save_id}, 0x4, (ble_cmd_handler)ble_rsp_flash_ps_save}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x3,ble_cls_flash,ble_cmd_flash_ps_load_id}, 0x84, (ble_cmd_handler)ble_rsp_flash_ps_load}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x0,ble_cls_flash,ble_cmd_flash_ps_erase_id}, 0x0, (ble_cmd_handler)ble_rsp_flash_ps_erase}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x2,ble_cls_flash,ble_cmd_flash_erase_page_id}, 0x4, (ble_cmd_handler)ble_rsp_flash_erase_page}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x2,ble_cls_flash,ble_cmd_flash_write_data_id}, 0x4, (ble_cmd_handler)ble_rsp_flash_write_data}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x1,ble_cls_flash,ble_cmd_flash_read_data_id}, 0x8, (ble_cmd_handler)ble_rsp_flash_read_data}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x2,ble_cls_attributes,ble_cmd_attributes_write_id}, 0x4, (ble_cmd_handler)ble_rsp_attributes_write}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x7,ble_cls_attributes,ble_cmd_attributes_read_id}, 0x8444, (ble_cmd_handler)ble_rsp_attributes_read}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x5,ble_cls_attributes,ble_cmd_attributes_read_type_id}, 0x844, (ble_cmd_handler)ble_rsp_attributes_read_type}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x0,ble_cls_attributes,ble_cmd_attributes_user_read_response_id}, 0x0, (ble_cmd_handler)ble_rsp_attributes_user_read_response}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x0,ble_cls_attributes,ble_cmd_attributes_user_write_response_id}, 0x0, (ble_cmd_handler)ble_rsp_attributes_user_write_response}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x2,ble_cls_attributes,ble_cmd_attributes_send_id}, 0x4, (ble_cmd_handler)ble_rsp_attributes_send}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x3,ble_cls_connection,ble_cmd_connection_disconnect_id}, 0x42, (ble_cmd_handler)ble_rsp_connection_disconnect}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x2,ble_cls_connection,ble_cmd_connection_get_rssi_id}, 0x32, (ble_cmd_handler)ble_rsp_connection_get_rssi}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x3,ble_cls_connection,ble_cmd_connection_update_id}, 0x42, (ble_cmd_handler)ble_rsp_connection_update}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x3,ble_cls_connection,ble_cmd_connection_version_update_id}, 0x42, (ble_cmd_handler)ble_rsp_connection_version_update}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x2,ble_cls_connection,ble_cmd_connection_channel_map_get_id}, 0x82, (ble_cmd_handler)ble_rsp_connection_channel_map_get}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x3,ble_cls_connection,ble_cmd_connection_channel_map_set_id}, 0x42, (ble_cmd_handler)ble_rsp_connection_channel_map_set}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x3,ble_cls_connection,ble_cmd_connection_features_get_id}, 0x42, (ble_cmd_handler)ble_rsp_connection_features_get}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x1,ble_cls_connection,ble_cmd_connection_get_status_id}, 0x2, (ble_cmd_handler)ble_rsp_connection_get_status}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x1,ble_cls_connection,ble_cmd_connection_raw_tx_id}, 0x2, (ble_cmd_handler)ble_rsp_connection_raw_tx}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x3,ble_cls_attclient,ble_cmd_attclient_find_by_type_value_id}, 0x42, (ble_cmd_handler)ble_rsp_attclient_find_by_type_value}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x3,ble_cls_attclient,ble_cmd_attclient_read_by_group_type_id}, 0x42, (ble_cmd_handler)ble_rsp_attclient_read_by_group_type}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x3,ble_cls_attclient,ble_cmd_attclient_read_by_type_id}, 0x42, (ble_cmd_handler)ble_rsp_attclient_read_by_type}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x3,ble_cls_attclient,ble_cmd_attclient_find_information_id}, 0x42, (ble_cmd_handler)ble_rsp_attclient_find_information}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x3,ble_cls_attclient,ble_cmd_attclient_read_by_handle_id}, 0x42, (ble_cmd_handler)ble_rsp_attclient_read_by_handle}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x3,ble_cls_attclient,ble_cmd_attclient_attribute_write_id}, 0x42, (ble_cmd_handler)ble_rsp_attclient_attribute_write}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x3,ble_cls_attclient,ble_cmd_attclient_write_command_id}, 0x42, (ble_cmd_handler)ble_rsp_attclient_write_command}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x2,ble_cls_attclient,ble_cmd_attclient_indicate_confirm_id}, 0x4, (ble_cmd_handler)ble_rsp_attclient_indicate_confirm}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x3,ble_cls_attclient,ble_cmd_attclient_read_long_id}, 0x42, (ble_cmd_handler)ble_rsp_attclient_read_long}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x3,ble_cls_attclient,ble_cmd_attclient_prepare_write_id}, 0x42, (ble_cmd_handler)ble_rsp_attclient_prepare_write}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x3,ble_cls_attclient,ble_cmd_attclient_execute_write_id}, 0x42, (ble_cmd_handler)ble_rsp_attclient_execute_write}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x3,ble_cls_attclient,ble_cmd_attclient_read_multiple_id}, 0x42, (ble_cmd_handler)ble_rsp_attclient_read_multiple}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x3,ble_cls_sm,ble_cmd_sm_encrypt_start_id}, 0x42, (ble_cmd_handler)ble_rsp_sm_encrypt_start}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x0,ble_cls_sm,ble_cmd_sm_set_bondable_mode_id}, 0x0, (ble_cmd_handler)ble_rsp_sm_set_bondable_mode}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x2,ble_cls_sm,ble_cmd_sm_delete_bonding_id}, 0x4, (ble_cmd_handler)ble_rsp_sm_delete_bonding}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x0,ble_cls_sm,ble_cmd_sm_set_parameters_id}, 0x0, (ble_cmd_handler)ble_rsp_sm_set_parameters}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x2,ble_cls_sm,ble_cmd_sm_passkey_entry_id}, 0x4, (ble_cmd_handler)ble_rsp_sm_passkey_entry}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x1,ble_cls_sm,ble_cmd_sm_get_bonds_id}, 0x2, (ble_cmd_handler)ble_rsp_sm_get_bonds}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x0,ble_cls_sm,ble_cmd_sm_set_oob_data_id}, 0x0, (ble_cmd_handler)ble_rsp_sm_set_oob_data}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x3,ble_cls_sm,ble_cmd_sm_whitelist_bonds_id}, 0x24, (ble_cmd_handler)ble_rsp_sm_whitelist_bonds}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x0,ble_cls_gap,ble_cmd_gap_set_privacy_flags_id}, 0x0, (ble_cmd_handler)ble_rsp_gap_set_privacy_flags}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x2,ble_cls_gap,ble_cmd_gap_set_mode_id}, 0x4, (ble_cmd_handler)ble_rsp_gap_set_mode}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x2,ble_cls_gap,ble_cmd_gap_discover_id}, 0x4, (ble_cmd_handler)ble_rsp_gap_discover}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x3,ble_cls_gap,ble_cmd_gap_connect_direct_id}, 0x24, (ble_cmd_handler)ble_rsp_gap_connect_direct}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x2,ble_cls_gap,ble_cmd_gap_end_procedure_id}, 0x4, (ble_cmd_handler)ble_rsp_gap_end_procedure}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x3,ble_cls_gap,ble_cmd_gap_connect_selective_id}, 0x24, (ble_cmd_handler)ble_rsp_gap_connect_selective}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x2,ble_cls_gap,ble_cmd_gap_set_filtering_id}, 0x4, (ble_cmd_handler)ble_rsp_gap_set_filtering}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x2,ble_cls_gap,ble_cmd_gap_set_scan_parameters_id}, 0x4, (ble_cmd_handler)ble_rsp_gap_set_scan_parameters}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x2,ble_cls_gap,ble_cmd_gap_set_adv_parameters_id}, 0x4, (ble_cmd_handler)ble_rsp_gap_set_adv_parameters}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x2,ble_cls_gap,ble_cmd_gap_set_adv_data_id}, 0x4, (ble_cmd_handler)ble_rsp_gap_set_adv_data}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x2,ble_cls_gap,ble_cmd_gap_set_directed_connectable_mode_id}, 0x4, (ble_cmd_handler)ble_rsp_gap_set_directed_connectable_mode}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x2,ble_cls_hardware,ble_cmd_hardware_io_port_config_irq_id}, 0x4, (ble_cmd_handler)ble_rsp_hardware_io_port_config_irq}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x2,ble_cls_hardware,ble_cmd_hardware_set_soft_timer_id}, 0x4, (ble_cmd_handler)ble_rsp_hardware_set_soft_timer}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x2,ble_cls_hardware,ble_cmd_hardware_adc_read_id}, 0x4, (ble_cmd_handler)ble_rsp_hardware_adc_read}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x2,ble_cls_hardware,ble_cmd_hardware_io_port_config_direction_id}, 0x4, (ble_cmd_handler)ble_rsp_hardware_io_port_config_direction}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x2,ble_cls_hardware,ble_cmd_hardware_io_port_config_function_id}, 0x4, (ble_cmd_handler)ble_rsp_hardware_io_port_config_function}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x2,ble_cls_hardware,ble_cmd_hardware_io_port_config_pull_id}, 0x4, (ble_cmd_handler)ble_rsp_hardware_io_port_config_pull}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x2,ble_cls_hardware,ble_cmd_hardware_io_port_write_id}, 0x4, (ble_cmd_handler)ble_rsp_hardware_io_port_write}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x4,ble_cls_hardware,ble_cmd_hardware_io_port_read_id}, 0x224, (ble_cmd_handler)ble_rsp_hardware_io_port_read}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x2,ble_cls_hardware,ble_cmd_hardware_spi_config_id}, 0x4, (ble_cmd_handler)ble_rsp_hardware_spi_config}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x4,ble_cls_hardware,ble_cmd_hardware_spi_transfer_id}, 0x824, (ble_cmd_handler)ble_rsp_hardware_spi_transfer}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x3,ble_cls_hardware,ble_cmd_hardware_i2c_read_id}, 0x84, (ble_cmd_handler)ble_rsp_hardware_i2c_read}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x1,ble_cls_hardware,ble_cmd_hardware_i2c_write_id}, 0x2, (ble_cmd_handler)ble_rsp_hardware_i2c_write}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x0,ble_cls_hardware,ble_cmd_hardware_set_txpower_id}, 0x0, (ble_cmd_handler)ble_rsp_hardware_set_txpower}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x2,ble_cls_hardware,ble_cmd_hardware_timer_comparator_id}, 0x4, (ble_cmd_handler)ble_rsp_hardware_timer_comparator}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x2,ble_cls_hardware,ble_cmd_hardware_io_port_irq_enable_id}, 0x4, (ble_cmd_handler)ble_rsp_hardware_io_port_irq_enable}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x2,ble_cls_hardware,ble_cmd_hardware_io_port_irq_direction_id}, 0x4, (ble_cmd_handler)ble_rsp_hardware_io_port_irq_direction}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x0,ble_cls_hardware,ble_cmd_hardware_analog_comparator_enable_id}, 0x0, (ble_cmd_handler)ble_rsp_hardware_analog_comparator_enable}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x3,ble_cls_hardware,ble_cmd_hardware_analog_comparator_read_id}, 0x24, (ble_cmd_handler)ble_rsp_hardware_analog_comparator_read}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x2,ble_cls_hardware,ble_cmd_hardware_analog_comparator_config_irq_id}, 0x4, (ble_cmd_handler)ble_rsp_hardware_analog_comparator_config_irq}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x0,ble_cls_hardware,ble_cmd_hardware_set_rxgain_id}, 0x0, (ble_cmd_handler)ble_rsp_hardware_set_rxgain}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x2,ble_cls_hardware,ble_cmd_hardware_usb_enable_id}, 0x4, (ble_cmd_handler)ble_rsp_hardware_usb_enable}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x0,ble_cls_test,ble_cmd_test_phy_tx_id}, 0x0, (ble_cmd_handler)ble_rsp_test_phy_tx}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x0,ble_cls_test,ble_cmd_test_phy_rx_id}, 0x0, (ble_cmd_handler)ble_rsp_test_phy_rx}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x2,ble_cls_test,ble_cmd_test_phy_end_id}, 0x4, (ble_cmd_handler)ble_rsp_test_phy_end}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x0,ble_cls_test,ble_cmd_test_phy_reset_id}, 0x0, (ble_cmd_handler)ble_rsp_test_phy_reset}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x1,ble_cls_test,ble_cmd_test_get_channel_map_id}, 0x8, (ble_cmd_handler)ble_rsp_test_get_channel_map}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x1,ble_cls_test,ble_cmd_test_debug_id}, 0x8, (ble_cmd_handler)ble_rsp_test_debug}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x0,ble_cls_test,ble_cmd_test_channel_mode_id}, 0x0, (ble_cmd_handler)ble_rsp_test_channel_mode}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x0,ble_cls_dfu,ble_cmd_dfu_reset_id}, 0x0, (ble_cmd_handler)ble_rsp_dfu_reset}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x2,ble_cls_dfu,ble_cmd_dfu_flash_set_address_id}, 0x4, (ble_cmd_handler)ble_rsp_dfu_flash_set_address}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x2,ble_cls_dfu,ble_cmd_dfu_flash_upload_id}, 0x4, (ble_cmd_handler)ble_rsp_dfu_flash_upload}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_rsp|0x0,0x2,ble_cls_dfu,ble_cmd_dfu_flash_upload_finish_id}, 0x4, (ble_cmd_handler)ble_rsp_dfu_flash_upload_finish}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_evt|0x0,0xc,ble_cls_system,ble_evt_system_boot_id}, 0x2244444, (ble_cmd_handler)ble_evt_system_boot}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_evt|0x0,0x1,ble_cls_system,ble_evt_system_debug_id}, 0x8, (ble_cmd_handler)ble_evt_system_debug}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_evt|0x0,0x2,ble_cls_system,ble_evt_system_endpoint_watermark_rx_id}, 0x22, (ble_cmd_handler)ble_evt_system_endpoint_watermark_rx}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_evt|0x0,0x2,ble_cls_system,ble_evt_system_endpoint_watermark_tx_id}, 0x22, (ble_cmd_handler)ble_evt_system_endpoint_watermark_tx}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_evt|0x0,0x4,ble_cls_system,ble_evt_system_script_failure_id}, 0x44, (ble_cmd_handler)ble_evt_system_script_failure}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_evt|0x0,0x0,ble_cls_system,ble_evt_system_no_license_key_id}, 0x0, (ble_cmd_handler)ble_evt_system_no_license_key}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_evt|0x0,0x2,ble_cls_system,ble_evt_system_protocol_error_id}, 0x4, (ble_cmd_handler)ble_evt_system_protocol_error}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_evt|0x0,0x3,ble_cls_flash,ble_evt_flash_ps_key_id}, 0x84, (ble_cmd_handler)ble_evt_flash_ps_key}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_evt|0x0,0x7,ble_cls_attributes,ble_evt_attributes_value_id}, 0x84422, (ble_cmd_handler)ble_evt_attributes_value}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_evt|0x0,0x6,ble_cls_attributes,ble_evt_attributes_user_read_request_id}, 0x2442, (ble_cmd_handler)ble_evt_attributes_user_read_request}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_evt|0x0,0x3,ble_cls_attributes,ble_evt_attributes_status_id}, 0x24, (ble_cmd_handler)ble_evt_attributes_status}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_evt|0x0,0x10,ble_cls_connection,ble_evt_connection_status_id}, 0x24442a22, (ble_cmd_handler)ble_evt_connection_status}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_evt|0x0,0x6,ble_cls_connection,ble_evt_connection_version_ind_id}, 0x4422, (ble_cmd_handler)ble_evt_connection_version_ind}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_evt|0x0,0x2,ble_cls_connection,ble_evt_connection_feature_ind_id}, 0x82, (ble_cmd_handler)ble_evt_connection_feature_ind}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_evt|0x0,0x2,ble_cls_connection,ble_evt_connection_raw_rx_id}, 0x82, (ble_cmd_handler)ble_evt_connection_raw_rx}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_evt|0x0,0x3,ble_cls_connection,ble_evt_connection_disconnected_id}, 0x42, (ble_cmd_handler)ble_evt_connection_disconnected}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_evt|0x0,0x3,ble_cls_attclient,ble_evt_attclient_indicated_id}, 0x42, (ble_cmd_handler)ble_evt_attclient_indicated}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_evt|0x0,0x5,ble_cls_attclient,ble_evt_attclient_procedure_completed_id}, 0x442, (ble_cmd_handler)ble_evt_attclient_procedure_completed}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_evt|0x0,0x6,ble_cls_attclient,ble_evt_attclient_group_found_id}, 0x8442, (ble_cmd_handler)ble_evt_attclient_group_found}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_evt|0x0,0x7,ble_cls_attclient,ble_evt_attclient_attribute_found_id}, 0x82442, (ble_cmd_handler)ble_evt_attclient_attribute_found}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_evt|0x0,0x4,ble_cls_attclient,ble_evt_attclient_find_information_found_id}, 0x842, (ble_cmd_handler)ble_evt_attclient_find_information_found}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_evt|0x0,0x5,ble_cls_attclient,ble_evt_attclient_attribute_value_id}, 0x8242, (ble_cmd_handler)ble_evt_attclient_attribute_value}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_evt|0x0,0x2,ble_cls_attclient,ble_evt_attclient_read_multiple_response_id}, 0x82, (ble_cmd_handler)ble_evt_attclient_read_multiple_response}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_evt|0x0,0x3,ble_cls_sm,ble_evt_sm_smp_data_id}, 0x822, (ble_cmd_handler)ble_evt_sm_smp_data}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_evt|0x0,0x3,ble_cls_sm,ble_evt_sm_bonding_fail_id}, 0x42, (ble_cmd_handler)ble_evt_sm_bonding_fail}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_evt|0x0,0x5,ble_cls_sm,ble_evt_sm_passkey_display_id}, 0x62, (ble_cmd_handler)ble_evt_sm_passkey_display}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_evt|0x0,0x1,ble_cls_sm,ble_evt_sm_passkey_request_id}, 0x2, (ble_cmd_handler)ble_evt_sm_passkey_request}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_evt|0x0,0x4,ble_cls_sm,ble_evt_sm_bond_status_id}, 0x2222, (ble_cmd_handler)ble_evt_sm_bond_status}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_evt|0x0,0xb,ble_cls_gap,ble_evt_gap_scan_response_id}, 0x822a23, (ble_cmd_handler)ble_evt_gap_scan_response}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_evt|0x0,0x2,ble_cls_gap,ble_evt_gap_mode_changed_id}, 0x22, (ble_cmd_handler)ble_evt_gap_mode_changed}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_evt|0x0,0x7,ble_cls_hardware,ble_evt_hardware_io_port_status_id}, 0x2226, (ble_cmd_handler)ble_evt_hardware_io_port_status}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_evt|0x0,0x1,ble_cls_hardware,ble_evt_hardware_soft_timer_id}, 0x2, (ble_cmd_handler)ble_evt_hardware_soft_timer}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_evt|0x0,0x3,ble_cls_hardware,ble_evt_hardware_adc_result_id}, 0x52, (ble_cmd_handler)ble_evt_hardware_adc_result}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_evt|0x0,0x5,ble_cls_hardware,ble_evt_hardware_analog_comparator_status_id}, 0x26, (ble_cmd_handler)ble_evt_hardware_analog_comparator_status}, + {{(uint8)ble_dev_type_ble|(uint8)ble_msg_type_evt|0x0,0x4,ble_cls_dfu,ble_evt_dfu_boot_id}, 0x6, (ble_cmd_handler)ble_evt_dfu_boot}, + {{0,0,0,0}, 0, 0}}; +const struct ble_msg * ble_get_msg(uint8 idx) +{ + return &apis[idx]; +} +const struct ble_msg * ble_find_msg_hdr(struct ble_header hdr) +{ + const struct ble_msg *msg=apis; + + while(msg->handler) + { + if(((msg->hdr.type_hilen&0xF8)==(hdr.type_hilen&0xF8))&& + (msg->hdr.cls==hdr.cls)&& + (msg->hdr.command==hdr.command))return msg; + msg++; + } + return 0; +} + +const struct ble_msg * ble_get_msg_hdr(struct ble_header hdr) +{ + if((hdr.type_hilen&0x80)==ble_msg_type_evt) + { + if(hdr.cls>=(sizeof(ble_class_evt_handlers)/sizeof(struct ble_class_handler_t))) + return NULL; + if(hdr.command>=ble_class_evt_handlers[hdr.cls].maxhandlers) + return NULL; + return ble_class_evt_handlers[hdr.cls].msgs[hdr.command]; + }else + if((hdr.type_hilen&0x80)==ble_msg_type_rsp) + { + if(hdr.cls>=(sizeof(ble_class_rsp_handlers)/sizeof(struct ble_class_handler_t))) + return NULL; + if(hdr.command>=ble_class_rsp_handlers[hdr.cls].maxhandlers) + return NULL; + return ble_class_rsp_handlers[hdr.cls].msgs[hdr.command]; + } + return ble_find_msg_hdr(hdr); +} +void ble_send_message(uint8 msgid,...) + { + uint32 i; + uint32 u32; + uint16 u16; + uint8 u8; + + struct ble_cmd_packet packet; + uint8 *b=(uint8 *)&packet.payload; + + uint8 *hw; + uint8 *data_ptr=0; + uint16 data_len=0; + va_list va; + va_start(va,msgid); + + i=apis[msgid].params; + packet.header=apis[msgid].hdr; + while(i) + { + + switch(i&0xF) + { + + case 7:/*int32*/ + case 6:/*uint32*/ + u32=va_arg(va,uint32); + *b++=u32&0xff;u32>>=8; + *b++=u32&0xff;u32>>=8; + *b++=u32&0xff;u32>>=8; + *b++=u32&0xff; + break; + case 5:/*int16*/ + case 4:/*uint16*/ + u16=va_arg(va,unsigned); + *b++=u16&0xff;u16>>=8; + *b++=u16&0xff; + break; + case 3:/*int8*/ + case 2:/*uint8*/ + u8=va_arg(va,int); + *b++=u8&0xff; + break; + + case 9:/*string*/ + case 8:/*uint8 array*/ + data_len=va_arg(va,int); + *b++=data_len; + + u16=data_len+packet.header.lolen; + packet.header.lolen=u16&0xff; + packet.header.type_hilen|=u16>>8; + + data_ptr=va_arg(va,uint8*); + break; + case 10:/*hwaddr*/ + hw=va_arg(va,uint8*); + + *b++=*hw++; + *b++=*hw++; + *b++=*hw++; + *b++=*hw++; + *b++=*hw++; + *b++=*hw++; + + break; + case 11:/*uint16 array*/ + data_len=va_arg(va,int); + *b++=data_len&0xff; + *b++=data_len>>8; + + u16=data_len+packet.header.lolen; + packet.header.lolen=u16&0xff; + packet.header.type_hilen|=u16>>8; + + data_ptr=va_arg(va,uint8*); + break; + } + i=i>>4; + } + va_end(va); + if(bglib_output)bglib_output(sizeof(struct ble_header)+apis[msgid].hdr.lolen,(uint8*)&packet,data_len,(uint8*)data_ptr); +} + +static const struct ble_msg* const ble_class_system_rsp_handlers[]= +{ + &apis[ble_rsp_system_reset_idx], + &apis[ble_rsp_system_hello_idx], + &apis[ble_rsp_system_address_get_idx], + &apis[ble_rsp_system_reg_write_idx], + &apis[ble_rsp_system_reg_read_idx], + &apis[ble_rsp_system_get_counters_idx], + &apis[ble_rsp_system_get_connections_idx], + &apis[ble_rsp_system_read_memory_idx], + &apis[ble_rsp_system_get_info_idx], + &apis[ble_rsp_system_endpoint_tx_idx], + &apis[ble_rsp_system_whitelist_append_idx], + &apis[ble_rsp_system_whitelist_remove_idx], + &apis[ble_rsp_system_whitelist_clear_idx], + &apis[ble_rsp_system_endpoint_rx_idx], + &apis[ble_rsp_system_endpoint_set_watermarks_idx], + &apis[ble_rsp_system_aes_setkey_idx], + &apis[ble_rsp_system_aes_encrypt_idx], + &apis[ble_rsp_system_aes_decrypt_idx], +}; +static const struct ble_msg* const ble_class_system_evt_handlers[]= +{ + &apis[ble_evt_system_boot_idx], + &apis[ble_evt_system_debug_idx], + &apis[ble_evt_system_endpoint_watermark_rx_idx], + &apis[ble_evt_system_endpoint_watermark_tx_idx], + &apis[ble_evt_system_script_failure_idx], + &apis[ble_evt_system_no_license_key_idx], + &apis[ble_evt_system_protocol_error_idx], +}; +static const struct ble_msg* const ble_class_flash_rsp_handlers[]= +{ + &apis[ble_rsp_flash_ps_defrag_idx], + &apis[ble_rsp_flash_ps_dump_idx], + &apis[ble_rsp_flash_ps_erase_all_idx], + &apis[ble_rsp_flash_ps_save_idx], + &apis[ble_rsp_flash_ps_load_idx], + &apis[ble_rsp_flash_ps_erase_idx], + &apis[ble_rsp_flash_erase_page_idx], + &apis[ble_rsp_flash_write_data_idx], + &apis[ble_rsp_flash_read_data_idx], +}; +static const struct ble_msg* const ble_class_flash_evt_handlers[]= +{ + &apis[ble_evt_flash_ps_key_idx], +}; +static const struct ble_msg* const ble_class_attributes_rsp_handlers[]= +{ + &apis[ble_rsp_attributes_write_idx], + &apis[ble_rsp_attributes_read_idx], + &apis[ble_rsp_attributes_read_type_idx], + &apis[ble_rsp_attributes_user_read_response_idx], + &apis[ble_rsp_attributes_user_write_response_idx], + &apis[ble_rsp_attributes_send_idx], +}; +static const struct ble_msg* const ble_class_attributes_evt_handlers[]= +{ + &apis[ble_evt_attributes_value_idx], + &apis[ble_evt_attributes_user_read_request_idx], + &apis[ble_evt_attributes_status_idx], +}; +static const struct ble_msg* const ble_class_connection_rsp_handlers[]= +{ + &apis[ble_rsp_connection_disconnect_idx], + &apis[ble_rsp_connection_get_rssi_idx], + &apis[ble_rsp_connection_update_idx], + &apis[ble_rsp_connection_version_update_idx], + &apis[ble_rsp_connection_channel_map_get_idx], + &apis[ble_rsp_connection_channel_map_set_idx], + &apis[ble_rsp_connection_features_get_idx], + &apis[ble_rsp_connection_get_status_idx], + &apis[ble_rsp_connection_raw_tx_idx], +}; +static const struct ble_msg* const ble_class_connection_evt_handlers[]= +{ + &apis[ble_evt_connection_status_idx], + &apis[ble_evt_connection_version_ind_idx], + &apis[ble_evt_connection_feature_ind_idx], + &apis[ble_evt_connection_raw_rx_idx], + &apis[ble_evt_connection_disconnected_idx], +}; +static const struct ble_msg* const ble_class_attclient_rsp_handlers[]= +{ + &apis[ble_rsp_attclient_find_by_type_value_idx], + &apis[ble_rsp_attclient_read_by_group_type_idx], + &apis[ble_rsp_attclient_read_by_type_idx], + &apis[ble_rsp_attclient_find_information_idx], + &apis[ble_rsp_attclient_read_by_handle_idx], + &apis[ble_rsp_attclient_attribute_write_idx], + &apis[ble_rsp_attclient_write_command_idx], + &apis[ble_rsp_attclient_indicate_confirm_idx], + &apis[ble_rsp_attclient_read_long_idx], + &apis[ble_rsp_attclient_prepare_write_idx], + &apis[ble_rsp_attclient_execute_write_idx], + &apis[ble_rsp_attclient_read_multiple_idx], +}; +static const struct ble_msg* const ble_class_attclient_evt_handlers[]= +{ + &apis[ble_evt_attclient_indicated_idx], + &apis[ble_evt_attclient_procedure_completed_idx], + &apis[ble_evt_attclient_group_found_idx], + &apis[ble_evt_attclient_attribute_found_idx], + &apis[ble_evt_attclient_find_information_found_idx], + &apis[ble_evt_attclient_attribute_value_idx], + &apis[ble_evt_attclient_read_multiple_response_idx], +}; +static const struct ble_msg* const ble_class_sm_rsp_handlers[]= +{ + &apis[ble_rsp_sm_encrypt_start_idx], + &apis[ble_rsp_sm_set_bondable_mode_idx], + &apis[ble_rsp_sm_delete_bonding_idx], + &apis[ble_rsp_sm_set_parameters_idx], + &apis[ble_rsp_sm_passkey_entry_idx], + &apis[ble_rsp_sm_get_bonds_idx], + &apis[ble_rsp_sm_set_oob_data_idx], + &apis[ble_rsp_sm_whitelist_bonds_idx], +}; +static const struct ble_msg* const ble_class_sm_evt_handlers[]= +{ + &apis[ble_evt_sm_smp_data_idx], + &apis[ble_evt_sm_bonding_fail_idx], + &apis[ble_evt_sm_passkey_display_idx], + &apis[ble_evt_sm_passkey_request_idx], + &apis[ble_evt_sm_bond_status_idx], +}; +static const struct ble_msg* const ble_class_gap_rsp_handlers[]= +{ + &apis[ble_rsp_gap_set_privacy_flags_idx], + &apis[ble_rsp_gap_set_mode_idx], + &apis[ble_rsp_gap_discover_idx], + &apis[ble_rsp_gap_connect_direct_idx], + &apis[ble_rsp_gap_end_procedure_idx], + &apis[ble_rsp_gap_connect_selective_idx], + &apis[ble_rsp_gap_set_filtering_idx], + &apis[ble_rsp_gap_set_scan_parameters_idx], + &apis[ble_rsp_gap_set_adv_parameters_idx], + &apis[ble_rsp_gap_set_adv_data_idx], + &apis[ble_rsp_gap_set_directed_connectable_mode_idx], +}; +static const struct ble_msg* const ble_class_gap_evt_handlers[]= +{ + &apis[ble_evt_gap_scan_response_idx], + &apis[ble_evt_gap_mode_changed_idx], +}; +static const struct ble_msg* const ble_class_hardware_rsp_handlers[]= +{ + &apis[ble_rsp_hardware_io_port_config_irq_idx], + &apis[ble_rsp_hardware_set_soft_timer_idx], + &apis[ble_rsp_hardware_adc_read_idx], + &apis[ble_rsp_hardware_io_port_config_direction_idx], + &apis[ble_rsp_hardware_io_port_config_function_idx], + &apis[ble_rsp_hardware_io_port_config_pull_idx], + &apis[ble_rsp_hardware_io_port_write_idx], + &apis[ble_rsp_hardware_io_port_read_idx], + &apis[ble_rsp_hardware_spi_config_idx], + &apis[ble_rsp_hardware_spi_transfer_idx], + &apis[ble_rsp_hardware_i2c_read_idx], + &apis[ble_rsp_hardware_i2c_write_idx], + &apis[ble_rsp_hardware_set_txpower_idx], + &apis[ble_rsp_hardware_timer_comparator_idx], + &apis[ble_rsp_hardware_io_port_irq_enable_idx], + &apis[ble_rsp_hardware_io_port_irq_direction_idx], + &apis[ble_rsp_hardware_analog_comparator_enable_idx], + &apis[ble_rsp_hardware_analog_comparator_read_idx], + &apis[ble_rsp_hardware_analog_comparator_config_irq_idx], + &apis[ble_rsp_hardware_set_rxgain_idx], + &apis[ble_rsp_hardware_usb_enable_idx], +}; +static const struct ble_msg* const ble_class_hardware_evt_handlers[]= +{ + &apis[ble_evt_hardware_io_port_status_idx], + &apis[ble_evt_hardware_soft_timer_idx], + &apis[ble_evt_hardware_adc_result_idx], + &apis[ble_evt_hardware_analog_comparator_status_idx], +}; +static const struct ble_msg* const ble_class_test_rsp_handlers[]= +{ + &apis[ble_rsp_test_phy_tx_idx], + &apis[ble_rsp_test_phy_rx_idx], + &apis[ble_rsp_test_phy_end_idx], + &apis[ble_rsp_test_phy_reset_idx], + &apis[ble_rsp_test_get_channel_map_idx], + &apis[ble_rsp_test_debug_idx], + &apis[ble_rsp_test_channel_mode_idx], +}; +static const struct ble_msg* const ble_class_dfu_rsp_handlers[]= +{ + &apis[ble_rsp_dfu_reset_idx], + &apis[ble_rsp_dfu_flash_set_address_idx], + &apis[ble_rsp_dfu_flash_upload_idx], + &apis[ble_rsp_dfu_flash_upload_finish_idx], +}; +static const struct ble_msg* const ble_class_dfu_evt_handlers[]= +{ + &apis[ble_evt_dfu_boot_idx], +}; +const struct ble_class_handler_t ble_class_rsp_handlers[ble_cls_last]= +{ + {ble_class_system_rsp_handlers,18}, + {ble_class_flash_rsp_handlers,9}, + {ble_class_attributes_rsp_handlers,6}, + {ble_class_connection_rsp_handlers,9}, + {ble_class_attclient_rsp_handlers,12}, + {ble_class_sm_rsp_handlers,8}, + {ble_class_gap_rsp_handlers,11}, + {ble_class_hardware_rsp_handlers,21}, + {ble_class_test_rsp_handlers,7}, + {ble_class_dfu_rsp_handlers,4}, +}; +const struct ble_class_handler_t ble_class_evt_handlers[ble_cls_last]= +{ + {ble_class_system_evt_handlers,7}, + {ble_class_flash_evt_handlers,1}, + {ble_class_attributes_evt_handlers,3}, + {ble_class_connection_evt_handlers,5}, + {ble_class_attclient_evt_handlers,7}, + {ble_class_sm_evt_handlers,5}, + {ble_class_gap_evt_handlers,2}, + {ble_class_hardware_evt_handlers,4}, + {NULL,0}, + {ble_class_dfu_evt_handlers,1}, +}; + +// clang-format on diff --git a/deps/include/brainflow/board_controller/muse/muse_bglib/inc/apitypes.h b/deps/include/brainflow/board_controller/muse/muse_bglib/inc/apitypes.h new file mode 100644 index 000000000..1747bb7b3 --- /dev/null +++ b/deps/include/brainflow/board_controller/muse/muse_bglib/inc/apitypes.h @@ -0,0 +1,45 @@ + +#ifndef APITYPES_H_ +#define APITYPES_H_ + +#ifdef __GNUC__ + +#define PACKSTRUCT(decl) decl __attribute__ ((__packed__)) +#define ALIGNED __attribute__ ((aligned (0x4))) + +#else // msvc + +#define PACKSTRUCT(decl) __pragma (pack (push, 1)) decl __pragma (pack (pop)) +#define ALIGNED + +#pragma warning(disable : 4200) + +#endif + +typedef unsigned char uint8; +typedef unsigned short uint16; +typedef signed short int16; +typedef unsigned long uint32; +typedef signed char int8; + +typedef struct bd_addr_t +{ + uint8 addr[6]; + +} bd_addr; + +typedef bd_addr hwaddr; +typedef struct +{ + uint8 len; + uint8 data[]; +} uint8array; + +typedef struct +{ + uint8 len; + int8 data[]; +} string; + + +#endif diff --git a/deps/include/brainflow/board_controller/muse/muse_bglib/inc/cmd_def.h b/deps/include/brainflow/board_controller/muse/muse_bglib/inc/cmd_def.h new file mode 100644 index 000000000..994518d36 --- /dev/null +++ b/deps/include/brainflow/board_controller/muse/muse_bglib/inc/cmd_def.h @@ -0,0 +1,2791 @@ +#ifndef cmd_def_h +#define cmd_def_h + +/***************************************************************************** + * + * + * !!!!!!!! THIS IS AUTOGENERATED FILE, DO NOT EDIT !!!!!!!! + * + * + ****************************************************************************/ + +#include +/***************************************************************************** + * + * Support for compilers other than GCC and MSVC: + * + * To support specific compiler add compiler's structure packing directives to following macro: + * PACKSTRUCT( decl ) + * + * BGLIB uses PACKSTRUCT macro to add packing information for structures: + * PACKSTRUCT(struct wifi_msg_dfu_reset_cmd_t + * { + * uint8 dfu; + * }); + * + * + ****************************************************************************/ + +/*lint -save --e{528,572,778,845,835,849}*/ +#include "apitypes.h" +#ifdef __cplusplus +extern "C" +{ +#endif + +/* Compability */ +#ifndef PACKSTRUCT +#ifdef PACKED +#define PACKSTRUCT(a) a PACKED +#else +/*Default packed configuration*/ +#ifdef __GNUC__ +#ifdef _WIN32 +#define PACKSTRUCT(decl) decl __attribute__ ((__packed__, gcc_struct)) +#else +#define PACKSTRUCT(decl) decl __attribute__ ((__packed__)) +#endif +#define ALIGNED __attribute__ ((aligned (0x4))) + +#else // msvc + +#define PACKSTRUCT(decl) __pragma (pack (push, 1)) decl __pragma (pack (pop)) +#define ALIGNED + +#endif +#endif +#endif + struct ble_cmd_packet; + typedef void (*ble_cmd_handler) (const void *); + struct ble_header + { + uint8 type_hilen; + uint8 lolen; + uint8 cls; + uint8 command; + }; + + + struct ble_msg + { + struct ble_header hdr; + uint32 params; + ble_cmd_handler handler; + }; + + const struct ble_msg *ble_find_msg_hdr (struct ble_header hdr); + const struct ble_msg *ble_get_msg (uint8 idx); + const struct ble_msg *ble_get_msg_hdr (struct ble_header hdr); + extern void (*bglib_output) (uint8 len1, uint8 *data1, uint16 len2, uint8 *data2); + void ble_send_message (uint8 msgid, ...); + + enum system_endpoints + { + system_endpoint_api = 0, + system_endpoint_test = 1, + system_endpoint_script = 2, + system_endpoint_usb = 3, + system_endpoint_uart0 = 4, + system_endpoint_uart1 = 5, + system_endpoints_max = 6 + }; + + enum attributes_attribute_change_reason + { + attributes_attribute_change_reason_write_request = 0, + attributes_attribute_change_reason_write_command = 1, + attributes_attribute_change_reason_write_request_user = 2, + attributes_attribute_change_reason_max = 3 + }; + + enum attributes_attribute_status_flag + { + attributes_attribute_status_flag_notify = 1, + attributes_attribute_status_flag_indicate = 2, + attributes_attribute_status_flag_max = 3 + }; + + enum connection_connstatus + { + connection_connected = 1, + connection_encrypted = 2, + connection_completed = 4, + connection_parameters_change = 8, + connection_connstatus_max = 9 + }; + + enum attclient_attribute_value_types + { + attclient_attribute_value_type_read = 0, + attclient_attribute_value_type_notify = 1, + attclient_attribute_value_type_indicate = 2, + attclient_attribute_value_type_read_by_type = 3, + attclient_attribute_value_type_read_blob = 4, + attclient_attribute_value_type_indicate_rsp_req = 5, + attclient_attribute_value_types_max = 6 + }; + + enum sm_bonding_key + { + sm_bonding_key_ltk = 0x01, + sm_bonding_key_addr_public = 0x02, + sm_bonding_key_addr_static = 0x04, + sm_bonding_key_irk = 0x08, + sm_bonding_key_edivrand = 0x10, + sm_bonding_key_csrk = 0x20, + sm_bonding_key_masterid = 0x40, + sm_bonding_key_max = 65 + }; + + enum sm_io_capability + { + sm_io_capability_displayonly = 0, + sm_io_capability_displayyesno = 1, + sm_io_capability_keyboardonly = 2, + sm_io_capability_noinputnooutput = 3, + sm_io_capability_keyboarddisplay = 4, + sm_io_capability_max = 5 + }; + +#define GAP_SCAN_HEADER_ADV_IND 0 +#define GAP_SCAN_HEADER_ADV_DIRECT_IND 1 +#define GAP_SCAN_HEADER_ADV_NONCONN_IND 2 +#define GAP_SCAN_HEADER_SCAN_REQ 3 +#define GAP_SCAN_HEADER_SCAN_RSP 4 +#define GAP_SCAN_HEADER_CONNECT_REQ 5 +#define GAP_SCAN_HEADER_ADV_DISCOVER_IND 6 + +#define GAP_AD_FLAG_LIMITED_DISCOVERABLE 0x01 +#define GAP_AD_FLAG_GENERAL_DISCOVERABLE 0x02 +#define GAP_AD_FLAG_BREDR_NOT_SUPPORTED 0x04 +#define GAP_AD_FLAG_SIMULTANEOUS_LEBREDR_CTRL 0x10 +#define GAP_AD_FLAG_SIMULTANEOUS_LEBREDR_HOST 0x20 +#define GAP_AD_FLAG_MASK 0x1f + + enum gap_address_type + { + gap_address_type_public = 0, + gap_address_type_random = 1, + gap_address_type_max = 2 + }; + + enum gap_discoverable_mode + { + gap_non_discoverable = 0, + gap_limited_discoverable = 1, + gap_general_discoverable = 2, + gap_broadcast = 3, + gap_user_data = 4, + gap_discoverable_mode_max = 5 + }; + + enum gap_connectable_mode + { + gap_non_connectable = 0, + gap_directed_connectable = 1, + gap_undirected_connectable = 2, + gap_scannable_non_connectable = 3, + gap_connectable_mode_max = 4 + }; + + enum gap_discover_mode + { + gap_discover_limited = 0, + gap_discover_generic = 1, + gap_discover_observation = 2, + gap_discover_mode_max = 3 + }; + + enum gap_ad_types + { + gap_ad_type_none = 0, + gap_ad_type_flags = 1, + gap_ad_type_services_16bit_more = 2, + gap_ad_type_services_16bit_all = 3, + gap_ad_type_services_32bit_more = 4, + gap_ad_type_services_32bit_all = 5, + gap_ad_type_services_128bit_more = 6, + gap_ad_type_services_128bit_all = 7, + gap_ad_type_localname_short = 8, + gap_ad_type_localname_complete = 9, + gap_ad_type_txpower = 10, + gap_ad_types_max = 11 + }; + + enum gap_advertising_policy + { + gap_adv_policy_all = 0, + gap_adv_policy_whitelist_scan = 1, + gap_adv_policy_whitelist_connect = 2, + gap_adv_policy_whitelist_all = 3, + gap_advertising_policy_max = 4 + }; + + enum gap_scan_policy + { + gap_scan_policy_all = 0, + gap_scan_policy_whitelist = 1, + gap_scan_policy_max = 2 + }; + + + enum ble_parameter_types + { + ble_msg_parameter_uint8 = 2, + ble_msg_parameter_int8 = 3, + ble_msg_parameter_uint16 = 4, + ble_msg_parameter_int16 = 5, + ble_msg_parameter_uint32 = 6, + ble_msg_parameter_int32 = 7, + ble_msg_parameter_uint8array = 8, + ble_msg_parameter_string = 9, + ble_msg_parameter_hwaddr = 10, + ble_msg_parameter_uint16array = 11 + }; + + enum ble_msg_types + { + ble_msg_type_cmd = 0x00, + ble_msg_type_rsp = 0x00, + ble_msg_type_evt = 0x80 + }; + enum ble_dev_types + { + ble_dev_type_ble = 0x00, + ble_dev_type_wifi = 0x08, + ble_dev_type_iwrap = 0x10, + ble_dev_type_dumo = 0x20, + ble_dev_type_test = 0x20 + }; + + enum ble_classes + { + ble_cls_system, + ble_cls_flash, + ble_cls_attributes, + ble_cls_connection, + ble_cls_attclient, + ble_cls_sm, + ble_cls_gap, + ble_cls_hardware, + ble_cls_test, + ble_cls_dfu, + ble_cls_last + }; + enum ble_command_ids + { + ble_cmd_system_reset_id = 0, + ble_cmd_system_hello_id = 1, + ble_cmd_system_address_get_id = 2, + ble_cmd_system_reg_write_id = 3, + ble_cmd_system_reg_read_id = 4, + ble_cmd_system_get_counters_id = 5, + ble_cmd_system_get_connections_id = 6, + ble_cmd_system_read_memory_id = 7, + ble_cmd_system_get_info_id = 8, + ble_cmd_system_endpoint_tx_id = 9, + ble_cmd_system_whitelist_append_id = 10, + ble_cmd_system_whitelist_remove_id = 11, + ble_cmd_system_whitelist_clear_id = 12, + ble_cmd_system_endpoint_rx_id = 13, + ble_cmd_system_endpoint_set_watermarks_id = 14, + ble_cmd_system_aes_setkey_id = 15, + ble_cmd_system_aes_encrypt_id = 16, + ble_cmd_system_aes_decrypt_id = 17, + ble_cmd_flash_ps_defrag_id = 0, + ble_cmd_flash_ps_dump_id = 1, + ble_cmd_flash_ps_erase_all_id = 2, + ble_cmd_flash_ps_save_id = 3, + ble_cmd_flash_ps_load_id = 4, + ble_cmd_flash_ps_erase_id = 5, + ble_cmd_flash_erase_page_id = 6, + ble_cmd_flash_write_data_id = 7, + ble_cmd_flash_read_data_id = 8, + ble_cmd_attributes_write_id = 0, + ble_cmd_attributes_read_id = 1, + ble_cmd_attributes_read_type_id = 2, + ble_cmd_attributes_user_read_response_id = 3, + ble_cmd_attributes_user_write_response_id = 4, + ble_cmd_attributes_send_id = 5, + ble_cmd_connection_disconnect_id = 0, + ble_cmd_connection_get_rssi_id = 1, + ble_cmd_connection_update_id = 2, + ble_cmd_connection_version_update_id = 3, + ble_cmd_connection_channel_map_get_id = 4, + ble_cmd_connection_channel_map_set_id = 5, + ble_cmd_connection_features_get_id = 6, + ble_cmd_connection_get_status_id = 7, + ble_cmd_connection_raw_tx_id = 8, + ble_cmd_attclient_find_by_type_value_id = 0, + ble_cmd_attclient_read_by_group_type_id = 1, + ble_cmd_attclient_read_by_type_id = 2, + ble_cmd_attclient_find_information_id = 3, + ble_cmd_attclient_read_by_handle_id = 4, + ble_cmd_attclient_attribute_write_id = 5, + ble_cmd_attclient_write_command_id = 6, + ble_cmd_attclient_indicate_confirm_id = 7, + ble_cmd_attclient_read_long_id = 8, + ble_cmd_attclient_prepare_write_id = 9, + ble_cmd_attclient_execute_write_id = 10, + ble_cmd_attclient_read_multiple_id = 11, + ble_cmd_sm_encrypt_start_id = 0, + ble_cmd_sm_set_bondable_mode_id = 1, + ble_cmd_sm_delete_bonding_id = 2, + ble_cmd_sm_set_parameters_id = 3, + ble_cmd_sm_passkey_entry_id = 4, + ble_cmd_sm_get_bonds_id = 5, + ble_cmd_sm_set_oob_data_id = 6, + ble_cmd_sm_whitelist_bonds_id = 7, + ble_cmd_gap_set_privacy_flags_id = 0, + ble_cmd_gap_set_mode_id = 1, + ble_cmd_gap_discover_id = 2, + ble_cmd_gap_connect_direct_id = 3, + ble_cmd_gap_end_procedure_id = 4, + ble_cmd_gap_connect_selective_id = 5, + ble_cmd_gap_set_filtering_id = 6, + ble_cmd_gap_set_scan_parameters_id = 7, + ble_cmd_gap_set_adv_parameters_id = 8, + ble_cmd_gap_set_adv_data_id = 9, + ble_cmd_gap_set_directed_connectable_mode_id = 10, + ble_cmd_hardware_io_port_config_irq_id = 0, + ble_cmd_hardware_set_soft_timer_id = 1, + ble_cmd_hardware_adc_read_id = 2, + ble_cmd_hardware_io_port_config_direction_id = 3, + ble_cmd_hardware_io_port_config_function_id = 4, + ble_cmd_hardware_io_port_config_pull_id = 5, + ble_cmd_hardware_io_port_write_id = 6, + ble_cmd_hardware_io_port_read_id = 7, + ble_cmd_hardware_spi_config_id = 8, + ble_cmd_hardware_spi_transfer_id = 9, + ble_cmd_hardware_i2c_read_id = 10, + ble_cmd_hardware_i2c_write_id = 11, + ble_cmd_hardware_set_txpower_id = 12, + ble_cmd_hardware_timer_comparator_id = 13, + ble_cmd_hardware_io_port_irq_enable_id = 14, + ble_cmd_hardware_io_port_irq_direction_id = 15, + ble_cmd_hardware_analog_comparator_enable_id = 16, + ble_cmd_hardware_analog_comparator_read_id = 17, + ble_cmd_hardware_analog_comparator_config_irq_id = 18, + ble_cmd_hardware_set_rxgain_id = 19, + ble_cmd_hardware_usb_enable_id = 20, + ble_cmd_test_phy_tx_id = 0, + ble_cmd_test_phy_rx_id = 1, + ble_cmd_test_phy_end_id = 2, + ble_cmd_test_phy_reset_id = 3, + ble_cmd_test_get_channel_map_id = 4, + ble_cmd_test_debug_id = 5, + ble_cmd_test_channel_mode_id = 6, + ble_cmd_dfu_reset_id = 0, + ble_cmd_dfu_flash_set_address_id = 1, + ble_cmd_dfu_flash_upload_id = 2, + ble_cmd_dfu_flash_upload_finish_id = 3 + }; + enum ble_response_ids + { + ble_rsp_system_reset_id = 0, + ble_rsp_system_hello_id = 1, + ble_rsp_system_address_get_id = 2, + ble_rsp_system_reg_write_id = 3, + ble_rsp_system_reg_read_id = 4, + ble_rsp_system_get_counters_id = 5, + ble_rsp_system_get_connections_id = 6, + ble_rsp_system_read_memory_id = 7, + ble_rsp_system_get_info_id = 8, + ble_rsp_system_endpoint_tx_id = 9, + ble_rsp_system_whitelist_append_id = 10, + ble_rsp_system_whitelist_remove_id = 11, + ble_rsp_system_whitelist_clear_id = 12, + ble_rsp_system_endpoint_rx_id = 13, + ble_rsp_system_endpoint_set_watermarks_id = 14, + ble_rsp_system_aes_setkey_id = 15, + ble_rsp_system_aes_encrypt_id = 16, + ble_rsp_system_aes_decrypt_id = 17, + ble_rsp_flash_ps_defrag_id = 0, + ble_rsp_flash_ps_dump_id = 1, + ble_rsp_flash_ps_erase_all_id = 2, + ble_rsp_flash_ps_save_id = 3, + ble_rsp_flash_ps_load_id = 4, + ble_rsp_flash_ps_erase_id = 5, + ble_rsp_flash_erase_page_id = 6, + ble_rsp_flash_write_data_id = 7, + ble_rsp_flash_read_data_id = 8, + ble_rsp_attributes_write_id = 0, + ble_rsp_attributes_read_id = 1, + ble_rsp_attributes_read_type_id = 2, + ble_rsp_attributes_user_read_response_id = 3, + ble_rsp_attributes_user_write_response_id = 4, + ble_rsp_attributes_send_id = 5, + ble_rsp_connection_disconnect_id = 0, + ble_rsp_connection_get_rssi_id = 1, + ble_rsp_connection_update_id = 2, + ble_rsp_connection_version_update_id = 3, + ble_rsp_connection_channel_map_get_id = 4, + ble_rsp_connection_channel_map_set_id = 5, + ble_rsp_connection_features_get_id = 6, + ble_rsp_connection_get_status_id = 7, + ble_rsp_connection_raw_tx_id = 8, + ble_rsp_attclient_find_by_type_value_id = 0, + ble_rsp_attclient_read_by_group_type_id = 1, + ble_rsp_attclient_read_by_type_id = 2, + ble_rsp_attclient_find_information_id = 3, + ble_rsp_attclient_read_by_handle_id = 4, + ble_rsp_attclient_attribute_write_id = 5, + ble_rsp_attclient_write_command_id = 6, + ble_rsp_attclient_indicate_confirm_id = 7, + ble_rsp_attclient_read_long_id = 8, + ble_rsp_attclient_prepare_write_id = 9, + ble_rsp_attclient_execute_write_id = 10, + ble_rsp_attclient_read_multiple_id = 11, + ble_rsp_sm_encrypt_start_id = 0, + ble_rsp_sm_set_bondable_mode_id = 1, + ble_rsp_sm_delete_bonding_id = 2, + ble_rsp_sm_set_parameters_id = 3, + ble_rsp_sm_passkey_entry_id = 4, + ble_rsp_sm_get_bonds_id = 5, + ble_rsp_sm_set_oob_data_id = 6, + ble_rsp_sm_whitelist_bonds_id = 7, + ble_rsp_gap_set_privacy_flags_id = 0, + ble_rsp_gap_set_mode_id = 1, + ble_rsp_gap_discover_id = 2, + ble_rsp_gap_connect_direct_id = 3, + ble_rsp_gap_end_procedure_id = 4, + ble_rsp_gap_connect_selective_id = 5, + ble_rsp_gap_set_filtering_id = 6, + ble_rsp_gap_set_scan_parameters_id = 7, + ble_rsp_gap_set_adv_parameters_id = 8, + ble_rsp_gap_set_adv_data_id = 9, + ble_rsp_gap_set_directed_connectable_mode_id = 10, + ble_rsp_hardware_io_port_config_irq_id = 0, + ble_rsp_hardware_set_soft_timer_id = 1, + ble_rsp_hardware_adc_read_id = 2, + ble_rsp_hardware_io_port_config_direction_id = 3, + ble_rsp_hardware_io_port_config_function_id = 4, + ble_rsp_hardware_io_port_config_pull_id = 5, + ble_rsp_hardware_io_port_write_id = 6, + ble_rsp_hardware_io_port_read_id = 7, + ble_rsp_hardware_spi_config_id = 8, + ble_rsp_hardware_spi_transfer_id = 9, + ble_rsp_hardware_i2c_read_id = 10, + ble_rsp_hardware_i2c_write_id = 11, + ble_rsp_hardware_set_txpower_id = 12, + ble_rsp_hardware_timer_comparator_id = 13, + ble_rsp_hardware_io_port_irq_enable_id = 14, + ble_rsp_hardware_io_port_irq_direction_id = 15, + ble_rsp_hardware_analog_comparator_enable_id = 16, + ble_rsp_hardware_analog_comparator_read_id = 17, + ble_rsp_hardware_analog_comparator_config_irq_id = 18, + ble_rsp_hardware_set_rxgain_id = 19, + ble_rsp_hardware_usb_enable_id = 20, + ble_rsp_test_phy_tx_id = 0, + ble_rsp_test_phy_rx_id = 1, + ble_rsp_test_phy_end_id = 2, + ble_rsp_test_phy_reset_id = 3, + ble_rsp_test_get_channel_map_id = 4, + ble_rsp_test_debug_id = 5, + ble_rsp_test_channel_mode_id = 6, + ble_rsp_dfu_reset_id = 0, + ble_rsp_dfu_flash_set_address_id = 1, + ble_rsp_dfu_flash_upload_id = 2, + ble_rsp_dfu_flash_upload_finish_id = 3 + }; + enum ble_event_ids + { + ble_evt_system_boot_id = 0, + ble_evt_system_debug_id = 1, + ble_evt_system_endpoint_watermark_rx_id = 2, + ble_evt_system_endpoint_watermark_tx_id = 3, + ble_evt_system_script_failure_id = 4, + ble_evt_system_no_license_key_id = 5, + ble_evt_system_protocol_error_id = 6, + ble_evt_flash_ps_key_id = 0, + ble_evt_attributes_value_id = 0, + ble_evt_attributes_user_read_request_id = 1, + ble_evt_attributes_status_id = 2, + ble_evt_connection_status_id = 0, + ble_evt_connection_version_ind_id = 1, + ble_evt_connection_feature_ind_id = 2, + ble_evt_connection_raw_rx_id = 3, + ble_evt_connection_disconnected_id = 4, + ble_evt_attclient_indicated_id = 0, + ble_evt_attclient_procedure_completed_id = 1, + ble_evt_attclient_group_found_id = 2, + ble_evt_attclient_attribute_found_id = 3, + ble_evt_attclient_find_information_found_id = 4, + ble_evt_attclient_attribute_value_id = 5, + ble_evt_attclient_read_multiple_response_id = 6, + ble_evt_sm_smp_data_id = 0, + ble_evt_sm_bonding_fail_id = 1, + ble_evt_sm_passkey_display_id = 2, + ble_evt_sm_passkey_request_id = 3, + ble_evt_sm_bond_status_id = 4, + ble_evt_gap_scan_response_id = 0, + ble_evt_gap_mode_changed_id = 1, + ble_evt_hardware_io_port_status_id = 0, + ble_evt_hardware_soft_timer_id = 1, + ble_evt_hardware_adc_result_id = 2, + ble_evt_hardware_analog_comparator_status_id = 3, + ble_evt_dfu_boot_id = 0 + }; + enum ble_msg_idx + { + ble_cmd_system_reset_idx = 0, + ble_cmd_system_hello_idx = 1, + ble_cmd_system_address_get_idx = 2, + ble_cmd_system_reg_write_idx = 3, + ble_cmd_system_reg_read_idx = 4, + ble_cmd_system_get_counters_idx = 5, + ble_cmd_system_get_connections_idx = 6, + ble_cmd_system_read_memory_idx = 7, + ble_cmd_system_get_info_idx = 8, + ble_cmd_system_endpoint_tx_idx = 9, + ble_cmd_system_whitelist_append_idx = 10, + ble_cmd_system_whitelist_remove_idx = 11, + ble_cmd_system_whitelist_clear_idx = 12, + ble_cmd_system_endpoint_rx_idx = 13, + ble_cmd_system_endpoint_set_watermarks_idx = 14, + ble_cmd_system_aes_setkey_idx = 15, + ble_cmd_system_aes_encrypt_idx = 16, + ble_cmd_system_aes_decrypt_idx = 17, + ble_cmd_flash_ps_defrag_idx = 18, + ble_cmd_flash_ps_dump_idx = 19, + ble_cmd_flash_ps_erase_all_idx = 20, + ble_cmd_flash_ps_save_idx = 21, + ble_cmd_flash_ps_load_idx = 22, + ble_cmd_flash_ps_erase_idx = 23, + ble_cmd_flash_erase_page_idx = 24, + ble_cmd_flash_write_data_idx = 25, + ble_cmd_flash_read_data_idx = 26, + ble_cmd_attributes_write_idx = 27, + ble_cmd_attributes_read_idx = 28, + ble_cmd_attributes_read_type_idx = 29, + ble_cmd_attributes_user_read_response_idx = 30, + ble_cmd_attributes_user_write_response_idx = 31, + ble_cmd_attributes_send_idx = 32, + ble_cmd_connection_disconnect_idx = 33, + ble_cmd_connection_get_rssi_idx = 34, + ble_cmd_connection_update_idx = 35, + ble_cmd_connection_version_update_idx = 36, + ble_cmd_connection_channel_map_get_idx = 37, + ble_cmd_connection_channel_map_set_idx = 38, + ble_cmd_connection_features_get_idx = 39, + ble_cmd_connection_get_status_idx = 40, + ble_cmd_connection_raw_tx_idx = 41, + ble_cmd_attclient_find_by_type_value_idx = 42, + ble_cmd_attclient_read_by_group_type_idx = 43, + ble_cmd_attclient_read_by_type_idx = 44, + ble_cmd_attclient_find_information_idx = 45, + ble_cmd_attclient_read_by_handle_idx = 46, + ble_cmd_attclient_attribute_write_idx = 47, + ble_cmd_attclient_write_command_idx = 48, + ble_cmd_attclient_indicate_confirm_idx = 49, + ble_cmd_attclient_read_long_idx = 50, + ble_cmd_attclient_prepare_write_idx = 51, + ble_cmd_attclient_execute_write_idx = 52, + ble_cmd_attclient_read_multiple_idx = 53, + ble_cmd_sm_encrypt_start_idx = 54, + ble_cmd_sm_set_bondable_mode_idx = 55, + ble_cmd_sm_delete_bonding_idx = 56, + ble_cmd_sm_set_parameters_idx = 57, + ble_cmd_sm_passkey_entry_idx = 58, + ble_cmd_sm_get_bonds_idx = 59, + ble_cmd_sm_set_oob_data_idx = 60, + ble_cmd_sm_whitelist_bonds_idx = 61, + ble_cmd_gap_set_privacy_flags_idx = 62, + ble_cmd_gap_set_mode_idx = 63, + ble_cmd_gap_discover_idx = 64, + ble_cmd_gap_connect_direct_idx = 65, + ble_cmd_gap_end_procedure_idx = 66, + ble_cmd_gap_connect_selective_idx = 67, + ble_cmd_gap_set_filtering_idx = 68, + ble_cmd_gap_set_scan_parameters_idx = 69, + ble_cmd_gap_set_adv_parameters_idx = 70, + ble_cmd_gap_set_adv_data_idx = 71, + ble_cmd_gap_set_directed_connectable_mode_idx = 72, + ble_cmd_hardware_io_port_config_irq_idx = 73, + ble_cmd_hardware_set_soft_timer_idx = 74, + ble_cmd_hardware_adc_read_idx = 75, + ble_cmd_hardware_io_port_config_direction_idx = 76, + ble_cmd_hardware_io_port_config_function_idx = 77, + ble_cmd_hardware_io_port_config_pull_idx = 78, + ble_cmd_hardware_io_port_write_idx = 79, + ble_cmd_hardware_io_port_read_idx = 80, + ble_cmd_hardware_spi_config_idx = 81, + ble_cmd_hardware_spi_transfer_idx = 82, + ble_cmd_hardware_i2c_read_idx = 83, + ble_cmd_hardware_i2c_write_idx = 84, + ble_cmd_hardware_set_txpower_idx = 85, + ble_cmd_hardware_timer_comparator_idx = 86, + ble_cmd_hardware_io_port_irq_enable_idx = 87, + ble_cmd_hardware_io_port_irq_direction_idx = 88, + ble_cmd_hardware_analog_comparator_enable_idx = 89, + ble_cmd_hardware_analog_comparator_read_idx = 90, + ble_cmd_hardware_analog_comparator_config_irq_idx = 91, + ble_cmd_hardware_set_rxgain_idx = 92, + ble_cmd_hardware_usb_enable_idx = 93, + ble_cmd_test_phy_tx_idx = 94, + ble_cmd_test_phy_rx_idx = 95, + ble_cmd_test_phy_end_idx = 96, + ble_cmd_test_phy_reset_idx = 97, + ble_cmd_test_get_channel_map_idx = 98, + ble_cmd_test_debug_idx = 99, + ble_cmd_test_channel_mode_idx = 100, + ble_cmd_dfu_reset_idx = 101, + ble_cmd_dfu_flash_set_address_idx = 102, + ble_cmd_dfu_flash_upload_idx = 103, + ble_cmd_dfu_flash_upload_finish_idx = 104, + ble_rsp_system_reset_idx = 105, + ble_rsp_system_hello_idx = 106, + ble_rsp_system_address_get_idx = 107, + ble_rsp_system_reg_write_idx = 108, + ble_rsp_system_reg_read_idx = 109, + ble_rsp_system_get_counters_idx = 110, + ble_rsp_system_get_connections_idx = 111, + ble_rsp_system_read_memory_idx = 112, + ble_rsp_system_get_info_idx = 113, + ble_rsp_system_endpoint_tx_idx = 114, + ble_rsp_system_whitelist_append_idx = 115, + ble_rsp_system_whitelist_remove_idx = 116, + ble_rsp_system_whitelist_clear_idx = 117, + ble_rsp_system_endpoint_rx_idx = 118, + ble_rsp_system_endpoint_set_watermarks_idx = 119, + ble_rsp_system_aes_setkey_idx = 120, + ble_rsp_system_aes_encrypt_idx = 121, + ble_rsp_system_aes_decrypt_idx = 122, + ble_rsp_flash_ps_defrag_idx = 123, + ble_rsp_flash_ps_dump_idx = 124, + ble_rsp_flash_ps_erase_all_idx = 125, + ble_rsp_flash_ps_save_idx = 126, + ble_rsp_flash_ps_load_idx = 127, + ble_rsp_flash_ps_erase_idx = 128, + ble_rsp_flash_erase_page_idx = 129, + ble_rsp_flash_write_data_idx = 130, + ble_rsp_flash_read_data_idx = 131, + ble_rsp_attributes_write_idx = 132, + ble_rsp_attributes_read_idx = 133, + ble_rsp_attributes_read_type_idx = 134, + ble_rsp_attributes_user_read_response_idx = 135, + ble_rsp_attributes_user_write_response_idx = 136, + ble_rsp_attributes_send_idx = 137, + ble_rsp_connection_disconnect_idx = 138, + ble_rsp_connection_get_rssi_idx = 139, + ble_rsp_connection_update_idx = 140, + ble_rsp_connection_version_update_idx = 141, + ble_rsp_connection_channel_map_get_idx = 142, + ble_rsp_connection_channel_map_set_idx = 143, + ble_rsp_connection_features_get_idx = 144, + ble_rsp_connection_get_status_idx = 145, + ble_rsp_connection_raw_tx_idx = 146, + ble_rsp_attclient_find_by_type_value_idx = 147, + ble_rsp_attclient_read_by_group_type_idx = 148, + ble_rsp_attclient_read_by_type_idx = 149, + ble_rsp_attclient_find_information_idx = 150, + ble_rsp_attclient_read_by_handle_idx = 151, + ble_rsp_attclient_attribute_write_idx = 152, + ble_rsp_attclient_write_command_idx = 153, + ble_rsp_attclient_indicate_confirm_idx = 154, + ble_rsp_attclient_read_long_idx = 155, + ble_rsp_attclient_prepare_write_idx = 156, + ble_rsp_attclient_execute_write_idx = 157, + ble_rsp_attclient_read_multiple_idx = 158, + ble_rsp_sm_encrypt_start_idx = 159, + ble_rsp_sm_set_bondable_mode_idx = 160, + ble_rsp_sm_delete_bonding_idx = 161, + ble_rsp_sm_set_parameters_idx = 162, + ble_rsp_sm_passkey_entry_idx = 163, + ble_rsp_sm_get_bonds_idx = 164, + ble_rsp_sm_set_oob_data_idx = 165, + ble_rsp_sm_whitelist_bonds_idx = 166, + ble_rsp_gap_set_privacy_flags_idx = 167, + ble_rsp_gap_set_mode_idx = 168, + ble_rsp_gap_discover_idx = 169, + ble_rsp_gap_connect_direct_idx = 170, + ble_rsp_gap_end_procedure_idx = 171, + ble_rsp_gap_connect_selective_idx = 172, + ble_rsp_gap_set_filtering_idx = 173, + ble_rsp_gap_set_scan_parameters_idx = 174, + ble_rsp_gap_set_adv_parameters_idx = 175, + ble_rsp_gap_set_adv_data_idx = 176, + ble_rsp_gap_set_directed_connectable_mode_idx = 177, + ble_rsp_hardware_io_port_config_irq_idx = 178, + ble_rsp_hardware_set_soft_timer_idx = 179, + ble_rsp_hardware_adc_read_idx = 180, + ble_rsp_hardware_io_port_config_direction_idx = 181, + ble_rsp_hardware_io_port_config_function_idx = 182, + ble_rsp_hardware_io_port_config_pull_idx = 183, + ble_rsp_hardware_io_port_write_idx = 184, + ble_rsp_hardware_io_port_read_idx = 185, + ble_rsp_hardware_spi_config_idx = 186, + ble_rsp_hardware_spi_transfer_idx = 187, + ble_rsp_hardware_i2c_read_idx = 188, + ble_rsp_hardware_i2c_write_idx = 189, + ble_rsp_hardware_set_txpower_idx = 190, + ble_rsp_hardware_timer_comparator_idx = 191, + ble_rsp_hardware_io_port_irq_enable_idx = 192, + ble_rsp_hardware_io_port_irq_direction_idx = 193, + ble_rsp_hardware_analog_comparator_enable_idx = 194, + ble_rsp_hardware_analog_comparator_read_idx = 195, + ble_rsp_hardware_analog_comparator_config_irq_idx = 196, + ble_rsp_hardware_set_rxgain_idx = 197, + ble_rsp_hardware_usb_enable_idx = 198, + ble_rsp_test_phy_tx_idx = 199, + ble_rsp_test_phy_rx_idx = 200, + ble_rsp_test_phy_end_idx = 201, + ble_rsp_test_phy_reset_idx = 202, + ble_rsp_test_get_channel_map_idx = 203, + ble_rsp_test_debug_idx = 204, + ble_rsp_test_channel_mode_idx = 205, + ble_rsp_dfu_reset_idx = 206, + ble_rsp_dfu_flash_set_address_idx = 207, + ble_rsp_dfu_flash_upload_idx = 208, + ble_rsp_dfu_flash_upload_finish_idx = 209, + ble_evt_system_boot_idx = 210, + ble_evt_system_debug_idx = 211, + ble_evt_system_endpoint_watermark_rx_idx = 212, + ble_evt_system_endpoint_watermark_tx_idx = 213, + ble_evt_system_script_failure_idx = 214, + ble_evt_system_no_license_key_idx = 215, + ble_evt_system_protocol_error_idx = 216, + ble_evt_flash_ps_key_idx = 217, + ble_evt_attributes_value_idx = 218, + ble_evt_attributes_user_read_request_idx = 219, + ble_evt_attributes_status_idx = 220, + ble_evt_connection_status_idx = 221, + ble_evt_connection_version_ind_idx = 222, + ble_evt_connection_feature_ind_idx = 223, + ble_evt_connection_raw_rx_idx = 224, + ble_evt_connection_disconnected_idx = 225, + ble_evt_attclient_indicated_idx = 226, + ble_evt_attclient_procedure_completed_idx = 227, + ble_evt_attclient_group_found_idx = 228, + ble_evt_attclient_attribute_found_idx = 229, + ble_evt_attclient_find_information_found_idx = 230, + ble_evt_attclient_attribute_value_idx = 231, + ble_evt_attclient_read_multiple_response_idx = 232, + ble_evt_sm_smp_data_idx = 233, + ble_evt_sm_bonding_fail_idx = 234, + ble_evt_sm_passkey_display_idx = 235, + ble_evt_sm_passkey_request_idx = 236, + ble_evt_sm_bond_status_idx = 237, + ble_evt_gap_scan_response_idx = 238, + ble_evt_gap_mode_changed_idx = 239, + ble_evt_hardware_io_port_status_idx = 240, + ble_evt_hardware_soft_timer_idx = 241, + ble_evt_hardware_adc_result_idx = 242, + ble_evt_hardware_analog_comparator_status_idx = 243, + ble_evt_dfu_boot_idx = 244 + }; +#ifndef BG_ERRORCODES +#define BG_ERRORCODES + enum ble_error_spaces + { + ble_errspc_bt = 512, + ble_errspc_att = 1024, + ble_errspc_bg = 256, + ble_errspc_smp = 768, + }; + typedef enum ble_error + { + ble_err_bt_error_success = ble_errspc_bt + 0, // Command completed succesfully + ble_err_bt_bt_error_authentication_failure = ble_errspc_bt + + 5, // Pairing or authentication failed due to incorrect results in the pairing or + // authentication procedure. This could be due to an incorrect PIN or Link Key + ble_err_bt_pin_or_key_missing = + ble_errspc_bt + 6, // Pairing failed because of missing PIN, or authentication failed + // because of missing Key + ble_err_bt_bt_error_memory_capacity_exceeded = + ble_errspc_bt + 7, // Controller is out of memory. + ble_err_bt_connection_timeout = ble_errspc_bt + 8, // Link supervision timeout has expired. + ble_err_bt_connection_limit_exceeded = + ble_errspc_bt + 9, // Controller is at limit of connections it can support. + ble_err_bt_bt_error_command_disallowed = + ble_errspc_bt + 12, // Command requested cannot be executed because the Controller is in + // a state where it cannot process this command at this time. + ble_err_bt_bt_error_invalid_command_parameters = + ble_errspc_bt + 18, // Command contained invalid parameters. + ble_err_bt_bt_error_remote_user_terminated = + ble_errspc_bt + 19, // User on the remote device terminated the connection. + ble_err_bt_bt_error_connection_terminated_by_local_host = + ble_errspc_bt + 22, // Local device terminated the connection. + ble_err_bt_bt_error_ll_response_timeout = + ble_errspc_bt + 34, // Connection terminated due to link-layer procedure timeout. + ble_err_bt_bt_error_ll_instant_passed = + ble_errspc_bt + 40, // Received link-layer control packet where instant was in the past. + ble_err_bt_bt_error_controller_busy = + ble_errspc_bt + 58, // Operation was rejected because the controller is busy and unable + // to process the request. + ble_err_bt_bt_error_unacceptable_connection_interval = + ble_errspc_bt + 59, // Remote evice terminated the connection because of an unacceptable + // connection interval. + ble_err_bt_bt_error_directed_advertising_timeout = ble_errspc_bt + + 60, // Directed advertising completed without a connection being created. + ble_err_bt_bt_error_connection_terminated_due_to_mic_failure = + ble_errspc_bt + 61, // Connection was terminated because the Message Integrity Check + // (MIC) failed on a received packet. + ble_err_bt_bt_error_connection_failed_to_be_established = ble_errspc_bt + + 62, // LL initiated a connection but the connection has failed to be established. + // Controller did not receive any packets from remote end. + ble_err_att_invalid_handle = + ble_errspc_att + 1, // The attribute handle given was not valid on this server + ble_err_att_read_not_permitted = ble_errspc_att + 2, // The attribute cannot be read + ble_err_att_write_not_permitted = ble_errspc_att + 3, // The attribute cannot be written + ble_err_att_invalid_pdu = ble_errspc_att + 4, // The attribute PDU was invalid + ble_err_att_insufficient_authentication = ble_errspc_att + + 5, // The attribute requires authentication before it can be read or written. + ble_err_att_request_not_supported = ble_errspc_att + + 6, // Attribute Server does not support the request received from the client. + ble_err_att_invalid_offset = + ble_errspc_att + 7, // Offset specified was past the end of the attribute + ble_err_att_insufficient_authorization = ble_errspc_att + + 8, // The attribute requires authorization before it can be read or written. + ble_err_att_prepare_queue_full = + ble_errspc_att + 9, // Too many prepare writes have been queueud + ble_err_att_att_not_found = + ble_errspc_att + 10, // No attribute found within the given attribute handle range. + ble_err_att_att_not_long = ble_errspc_att + + 11, // The attribute cannot be read or written using the Read Blob Request + ble_err_att_insufficient_enc_key_size = ble_errspc_att + + 12, // The Encryption Key Size used for encrypting this link is insufficient. + ble_err_att_invalid_att_length = + ble_errspc_att + 13, // The attribute value length is invalid for the operation + ble_err_att_unlikely_error = ble_errspc_att + + 14, // The attribute request that was requested has encountered an error that was + // unlikely, and therefore could not be completed as requested. + ble_err_att_insufficient_encryption = ble_errspc_att + + 15, // The attribute requires encryption before it can be read or written. + ble_err_att_unsupported_group_type = + ble_errspc_att + 16, // The attribute type is not a supported grouping attribute as + // defined by a higher layer specification. + ble_err_att_insufficient_resources = + ble_errspc_att + 17, // Insufficient Resources to complete the request + ble_err_att_application = + ble_errspc_att + 128, // Application error code defined by a higher layer specification. + ble_err_success = 0, // No error + ble_err_invalid_param = ble_errspc_bg + 128, // Command contained invalid parameter + ble_err_wrong_state = ble_errspc_bg + 129, // Device is in wrong state to receive command + ble_err_out_of_memory = ble_errspc_bg + 130, // Device has run out of memory + ble_err_not_implemented = ble_errspc_bg + 131, // Feature is not implemented + ble_err_invalid_command = ble_errspc_bg + 132, // Command was not recognized + ble_err_timeout = ble_errspc_bg + 133, // Command or Procedure failed due to timeout + ble_err_not_connected = + ble_errspc_bg + 134, // Connection handle passed is to command is not a valid handle + ble_err_flow = + ble_errspc_bg + 135, // Command would cause either underflow or overflow error + ble_err_user_attribute = + ble_errspc_bg + 136, // User attribute was accessed through API which is not supported + ble_err_invalid_license_key = ble_errspc_bg + 137, // No valid license key found + ble_err_command_too_long = ble_errspc_bg + 138, // Command maximum length exceeded + ble_err_out_of_bonds = ble_errspc_bg + + 139, // Bonding procedure can't be started because device has no space left for bond. + ble_err_smp_passkey_entry_failed = ble_errspc_smp + + 1, // The user input of passkey failed, for example, the user cancelled the operation + ble_err_smp_oob_not_available = + ble_errspc_smp + 2, // Out of Band data is not available for authentication + ble_err_smp_authentication_requirements = ble_errspc_smp + + 3, // The pairing procedure cannot be performed as authentication requirements cannot be + // met due to IO capabilities of one or both devices + ble_err_smp_confirm_value_failed = + ble_errspc_smp + 4, // The confirm value does not match the calculated compare value + ble_err_smp_pairing_not_supported = + ble_errspc_smp + 5, // Pairing is not supported by the device + ble_err_smp_encryption_key_size = + ble_errspc_smp + 6, // The resultant encryption key size is insufficient for the + // security requirements of this device + ble_err_smp_command_not_supported = + ble_errspc_smp + 7, // The SMP command received is not supported on this device + ble_err_smp_unspecified_reason = + ble_errspc_smp + 8, // Pairing failed due to an unspecified reason + ble_err_smp_repeated_attempts = ble_errspc_smp + + 9, // Pairing or authentication procedure is disallowed because too little time has + // elapsed since last pairing request or security request + ble_err_smp_invalid_parameters = + ble_errspc_smp + 10, // The Invalid Parameters error code indicates: the command length + // is invalid or a parameter is outside of the specified range. + ble_err_last + } errorcode_t; +#endif + PACKSTRUCT (struct ble_msg_system_reset_cmd_t { uint8 boot_in_dfu; }); + + PACKSTRUCT (struct ble_msg_system_address_get_rsp_t { bd_addr address; }); + + PACKSTRUCT (struct ble_msg_system_reg_write_cmd_t { + uint16 address; + uint8 value; + }); + + PACKSTRUCT (struct ble_msg_system_reg_write_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_system_reg_read_cmd_t { uint16 address; }); + + PACKSTRUCT (struct ble_msg_system_reg_read_rsp_t { + uint16 address; + uint8 value; + }); + + PACKSTRUCT (struct ble_msg_system_get_counters_rsp_t { + uint8 txok; + uint8 txretry; + uint8 rxok; + uint8 rxfail; + uint8 mbuf; + }); + + PACKSTRUCT (struct ble_msg_system_get_connections_rsp_t { uint8 maxconn; }); + + PACKSTRUCT (struct ble_msg_system_read_memory_cmd_t { + uint32 address; + uint8 length; + }); + + PACKSTRUCT (struct ble_msg_system_read_memory_rsp_t { + uint32 address; + uint8array data; + }); + + PACKSTRUCT (struct ble_msg_system_get_info_rsp_t { + uint16 major; + uint16 minor; + uint16 patch; + uint16 build; + uint16 ll_version; + uint8 protocol_version; + uint8 hw; + }); + + PACKSTRUCT (struct ble_msg_system_endpoint_tx_cmd_t { + uint8 endpoint; + uint8array data; + }); + + PACKSTRUCT (struct ble_msg_system_endpoint_tx_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_system_whitelist_append_cmd_t { + bd_addr address; + uint8 address_type; + }); + + PACKSTRUCT (struct ble_msg_system_whitelist_append_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_system_whitelist_remove_cmd_t { + bd_addr address; + uint8 address_type; + }); + + PACKSTRUCT (struct ble_msg_system_whitelist_remove_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_system_endpoint_rx_cmd_t { + uint8 endpoint; + uint8 size; + }); + + PACKSTRUCT (struct ble_msg_system_endpoint_rx_rsp_t { + uint16 result; + uint8array data; + }); + + PACKSTRUCT (struct ble_msg_system_endpoint_set_watermarks_cmd_t { + uint8 endpoint; + uint8 rx; + uint8 tx; + }); + + PACKSTRUCT (struct ble_msg_system_endpoint_set_watermarks_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_system_aes_setkey_cmd_t { uint8array key; }); + + PACKSTRUCT (struct ble_msg_system_aes_encrypt_cmd_t { uint8array data; }); + + PACKSTRUCT (struct ble_msg_system_aes_encrypt_rsp_t { uint8array data; }); + + PACKSTRUCT (struct ble_msg_system_aes_decrypt_cmd_t { uint8array data; }); + + PACKSTRUCT (struct ble_msg_system_aes_decrypt_rsp_t { uint8array data; }); + + PACKSTRUCT (struct ble_msg_system_boot_evt_t { + uint16 major; + uint16 minor; + uint16 patch; + uint16 build; + uint16 ll_version; + uint8 protocol_version; + uint8 hw; + }); + + PACKSTRUCT (struct ble_msg_system_debug_evt_t { uint8array data; }); + + PACKSTRUCT (struct ble_msg_system_endpoint_watermark_rx_evt_t { + uint8 endpoint; + uint8 data; + }); + + PACKSTRUCT (struct ble_msg_system_endpoint_watermark_tx_evt_t { + uint8 endpoint; + uint8 data; + }); + + PACKSTRUCT (struct ble_msg_system_script_failure_evt_t { + uint16 address; + uint16 reason; + }); + + PACKSTRUCT (struct ble_msg_system_protocol_error_evt_t { uint16 reason; }); + + PACKSTRUCT (struct ble_msg_flash_ps_save_cmd_t { + uint16 key; + uint8array value; + }); + + PACKSTRUCT (struct ble_msg_flash_ps_save_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_flash_ps_load_cmd_t { uint16 key; }); + + PACKSTRUCT (struct ble_msg_flash_ps_load_rsp_t { + uint16 result; + uint8array value; + }); + + PACKSTRUCT (struct ble_msg_flash_ps_erase_cmd_t { uint16 key; }); + + PACKSTRUCT (struct ble_msg_flash_erase_page_cmd_t { uint8 page; }); + + PACKSTRUCT (struct ble_msg_flash_erase_page_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_flash_write_data_cmd_t { + uint32 address; + uint8array data; + }); + + PACKSTRUCT (struct ble_msg_flash_write_data_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_flash_read_data_cmd_t { + uint32 address; + uint8 length; + }); + + PACKSTRUCT (struct ble_msg_flash_read_data_rsp_t { uint8array data; }); + + PACKSTRUCT (struct ble_msg_flash_ps_key_evt_t { + uint16 key; + uint8array value; + }); + + PACKSTRUCT (struct ble_msg_attributes_write_cmd_t { + uint16 handle; + uint8 offset; + uint8array value; + }); + + PACKSTRUCT (struct ble_msg_attributes_write_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_attributes_read_cmd_t { + uint16 handle; + uint16 offset; + }); + + PACKSTRUCT (struct ble_msg_attributes_read_rsp_t { + uint16 handle; + uint16 offset; + uint16 result; + uint8array value; + }); + + PACKSTRUCT (struct ble_msg_attributes_read_type_cmd_t { uint16 handle; }); + + PACKSTRUCT (struct ble_msg_attributes_read_type_rsp_t { + uint16 handle; + uint16 result; + uint8array value; + }); + + PACKSTRUCT (struct ble_msg_attributes_user_read_response_cmd_t { + uint8 connection; + uint8 att_error; + uint8array value; + }); + + PACKSTRUCT (struct ble_msg_attributes_user_write_response_cmd_t { + uint8 connection; + uint8 att_error; + }); + + PACKSTRUCT (struct ble_msg_attributes_send_cmd_t { + uint8 connection; + uint16 handle; + uint8array value; + }); + + PACKSTRUCT (struct ble_msg_attributes_send_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_attributes_value_evt_t { + uint8 connection; + uint8 reason; + uint16 handle; + uint16 offset; + uint8array value; + }); + + PACKSTRUCT (struct ble_msg_attributes_user_read_request_evt_t { + uint8 connection; + uint16 handle; + uint16 offset; + uint8 maxsize; + }); + + PACKSTRUCT (struct ble_msg_attributes_status_evt_t { + uint16 handle; + uint8 flags; + }); + + PACKSTRUCT (struct ble_msg_connection_disconnect_cmd_t { uint8 connection; }); + + PACKSTRUCT (struct ble_msg_connection_disconnect_rsp_t { + uint8 connection; + uint16 result; + }); + + PACKSTRUCT (struct ble_msg_connection_get_rssi_cmd_t { uint8 connection; }); + + PACKSTRUCT (struct ble_msg_connection_get_rssi_rsp_t { + uint8 connection; + int8 rssi; + }); + + PACKSTRUCT (struct ble_msg_connection_update_cmd_t { + uint8 connection; + uint16 interval_min; + uint16 interval_max; + uint16 latency; + uint16 timeout; + }); + + PACKSTRUCT (struct ble_msg_connection_update_rsp_t { + uint8 connection; + uint16 result; + }); + + PACKSTRUCT (struct ble_msg_connection_version_update_cmd_t { uint8 connection; }); + + PACKSTRUCT (struct ble_msg_connection_version_update_rsp_t { + uint8 connection; + uint16 result; + }); + + PACKSTRUCT (struct ble_msg_connection_channel_map_get_cmd_t { uint8 connection; }); + + PACKSTRUCT (struct ble_msg_connection_channel_map_get_rsp_t { + uint8 connection; + uint8array map; + }); + + PACKSTRUCT (struct ble_msg_connection_channel_map_set_cmd_t { + uint8 connection; + uint8array map; + }); + + PACKSTRUCT (struct ble_msg_connection_channel_map_set_rsp_t { + uint8 connection; + uint16 result; + }); + + PACKSTRUCT (struct ble_msg_connection_features_get_cmd_t { uint8 connection; }); + + PACKSTRUCT (struct ble_msg_connection_features_get_rsp_t { + uint8 connection; + uint16 result; + }); + + PACKSTRUCT (struct ble_msg_connection_get_status_cmd_t { uint8 connection; }); + + PACKSTRUCT (struct ble_msg_connection_get_status_rsp_t { uint8 connection; }); + + PACKSTRUCT (struct ble_msg_connection_raw_tx_cmd_t { + uint8 connection; + uint8array data; + }); + + PACKSTRUCT (struct ble_msg_connection_raw_tx_rsp_t { uint8 connection; }); + + PACKSTRUCT (struct ble_msg_connection_status_evt_t { + uint8 connection; + uint8 flags; + bd_addr address; + uint8 address_type; + uint16 conn_interval; + uint16 timeout; + uint16 latency; + uint8 bonding; + }); + + PACKSTRUCT (struct ble_msg_connection_version_ind_evt_t { + uint8 connection; + uint8 vers_nr; + uint16 comp_id; + uint16 sub_vers_nr; + }); + + PACKSTRUCT (struct ble_msg_connection_feature_ind_evt_t { + uint8 connection; + uint8array features; + }); + + PACKSTRUCT (struct ble_msg_connection_raw_rx_evt_t { + uint8 connection; + uint8array data; + }); + + PACKSTRUCT (struct ble_msg_connection_disconnected_evt_t { + uint8 connection; + uint16 reason; + }); + + PACKSTRUCT (struct ble_msg_attclient_find_by_type_value_cmd_t { + uint8 connection; + uint16 start; + uint16 end; + uint16 uuid; + uint8array value; + }); + + PACKSTRUCT (struct ble_msg_attclient_find_by_type_value_rsp_t { + uint8 connection; + uint16 result; + }); + + PACKSTRUCT (struct ble_msg_attclient_read_by_group_type_cmd_t { + uint8 connection; + uint16 start; + uint16 end; + uint8array uuid; + }); + + PACKSTRUCT (struct ble_msg_attclient_read_by_group_type_rsp_t { + uint8 connection; + uint16 result; + }); + + PACKSTRUCT (struct ble_msg_attclient_read_by_type_cmd_t { + uint8 connection; + uint16 start; + uint16 end; + uint8array uuid; + }); + + PACKSTRUCT (struct ble_msg_attclient_read_by_type_rsp_t { + uint8 connection; + uint16 result; + }); + + PACKSTRUCT (struct ble_msg_attclient_find_information_cmd_t { + uint8 connection; + uint16 start; + uint16 end; + }); + + PACKSTRUCT (struct ble_msg_attclient_find_information_rsp_t { + uint8 connection; + uint16 result; + }); + + PACKSTRUCT (struct ble_msg_attclient_read_by_handle_cmd_t { + uint8 connection; + uint16 chrhandle; + }); + + PACKSTRUCT (struct ble_msg_attclient_read_by_handle_rsp_t { + uint8 connection; + uint16 result; + }); + + PACKSTRUCT (struct ble_msg_attclient_attribute_write_cmd_t { + uint8 connection; + uint16 atthandle; + uint8array data; + }); + + PACKSTRUCT (struct ble_msg_attclient_attribute_write_rsp_t { + uint8 connection; + uint16 result; + }); + + PACKSTRUCT (struct ble_msg_attclient_write_command_cmd_t { + uint8 connection; + uint16 atthandle; + uint8array data; + }); + + PACKSTRUCT (struct ble_msg_attclient_write_command_rsp_t { + uint8 connection; + uint16 result; + }); + + PACKSTRUCT (struct ble_msg_attclient_indicate_confirm_cmd_t { uint8 connection; }); + + PACKSTRUCT (struct ble_msg_attclient_indicate_confirm_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_attclient_read_long_cmd_t { + uint8 connection; + uint16 chrhandle; + }); + + PACKSTRUCT (struct ble_msg_attclient_read_long_rsp_t { + uint8 connection; + uint16 result; + }); + + PACKSTRUCT (struct ble_msg_attclient_prepare_write_cmd_t { + uint8 connection; + uint16 atthandle; + uint16 offset; + uint8array data; + }); + + PACKSTRUCT (struct ble_msg_attclient_prepare_write_rsp_t { + uint8 connection; + uint16 result; + }); + + PACKSTRUCT (struct ble_msg_attclient_execute_write_cmd_t { + uint8 connection; + uint8 commit; + }); + + PACKSTRUCT (struct ble_msg_attclient_execute_write_rsp_t { + uint8 connection; + uint16 result; + }); + + PACKSTRUCT (struct ble_msg_attclient_read_multiple_cmd_t { + uint8 connection; + uint8array handles; + }); + + PACKSTRUCT (struct ble_msg_attclient_read_multiple_rsp_t { + uint8 connection; + uint16 result; + }); + + PACKSTRUCT (struct ble_msg_attclient_indicated_evt_t { + uint8 connection; + uint16 attrhandle; + }); + + PACKSTRUCT (struct ble_msg_attclient_procedure_completed_evt_t { + uint8 connection; + uint16 result; + uint16 chrhandle; + }); + + PACKSTRUCT (struct ble_msg_attclient_group_found_evt_t { + uint8 connection; + uint16 start; + uint16 end; + uint8array uuid; + }); + + PACKSTRUCT (struct ble_msg_attclient_attribute_found_evt_t { + uint8 connection; + uint16 chrdecl; + uint16 value; + uint8 properties; + uint8array uuid; + }); + + PACKSTRUCT (struct ble_msg_attclient_find_information_found_evt_t { + uint8 connection; + uint16 chrhandle; + uint8array uuid; + }); + + PACKSTRUCT (struct ble_msg_attclient_attribute_value_evt_t { + uint8 connection; + uint16 atthandle; + uint8 type; + uint8array value; + }); + + PACKSTRUCT (struct ble_msg_attclient_read_multiple_response_evt_t { + uint8 connection; + uint8array handles; + }); + + PACKSTRUCT (struct ble_msg_sm_encrypt_start_cmd_t { + uint8 handle; + uint8 bonding; + }); + + PACKSTRUCT (struct ble_msg_sm_encrypt_start_rsp_t { + uint8 handle; + uint16 result; + }); + + PACKSTRUCT (struct ble_msg_sm_set_bondable_mode_cmd_t { uint8 bondable; }); + + PACKSTRUCT (struct ble_msg_sm_delete_bonding_cmd_t { uint8 handle; }); + + PACKSTRUCT (struct ble_msg_sm_delete_bonding_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_sm_set_parameters_cmd_t { + uint8 mitm; + uint8 min_key_size; + uint8 io_capabilities; + }); + + PACKSTRUCT (struct ble_msg_sm_passkey_entry_cmd_t { + uint8 handle; + uint32 passkey; + }); + + PACKSTRUCT (struct ble_msg_sm_passkey_entry_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_sm_get_bonds_rsp_t { uint8 bonds; }); + + PACKSTRUCT (struct ble_msg_sm_set_oob_data_cmd_t { uint8array oob; }); + + PACKSTRUCT (struct ble_msg_sm_whitelist_bonds_rsp_t { + uint16 result; + uint8 count; + }); + + PACKSTRUCT (struct ble_msg_sm_smp_data_evt_t { + uint8 handle; + uint8 packet; + uint8array data; + }); + + PACKSTRUCT (struct ble_msg_sm_bonding_fail_evt_t { + uint8 handle; + uint16 result; + }); + + PACKSTRUCT (struct ble_msg_sm_passkey_display_evt_t { + uint8 handle; + uint32 passkey; + }); + + PACKSTRUCT (struct ble_msg_sm_passkey_request_evt_t { uint8 handle; }); + + PACKSTRUCT (struct ble_msg_sm_bond_status_evt_t { + uint8 bond; + uint8 keysize; + uint8 mitm; + uint8 keys; + }); + + PACKSTRUCT (struct ble_msg_gap_set_privacy_flags_cmd_t { + uint8 peripheral_privacy; + uint8 central_privacy; + }); + + PACKSTRUCT (struct ble_msg_gap_set_mode_cmd_t { + uint8 discover; + uint8 connect; + }); + + PACKSTRUCT (struct ble_msg_gap_set_mode_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_gap_discover_cmd_t { uint8 mode; }); + + PACKSTRUCT (struct ble_msg_gap_discover_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_gap_connect_direct_cmd_t { + bd_addr address; + uint8 addr_type; + uint16 conn_interval_min; + uint16 conn_interval_max; + uint16 timeout; + uint16 latency; + }); + + PACKSTRUCT (struct ble_msg_gap_connect_direct_rsp_t { + uint16 result; + uint8 connection_handle; + }); + + PACKSTRUCT (struct ble_msg_gap_end_procedure_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_gap_connect_selective_cmd_t { + uint16 conn_interval_min; + uint16 conn_interval_max; + uint16 timeout; + uint16 latency; + }); + + PACKSTRUCT (struct ble_msg_gap_connect_selective_rsp_t { + uint16 result; + uint8 connection_handle; + }); + + PACKSTRUCT (struct ble_msg_gap_set_filtering_cmd_t { + uint8 scan_policy; + uint8 adv_policy; + uint8 scan_duplicate_filtering; + }); + + PACKSTRUCT (struct ble_msg_gap_set_filtering_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_gap_set_scan_parameters_cmd_t { + uint16 scan_interval; + uint16 scan_window; + uint8 active; + }); + + PACKSTRUCT (struct ble_msg_gap_set_scan_parameters_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_gap_set_adv_parameters_cmd_t { + uint16 adv_interval_min; + uint16 adv_interval_max; + uint8 adv_channels; + }); + + PACKSTRUCT (struct ble_msg_gap_set_adv_parameters_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_gap_set_adv_data_cmd_t { + uint8 set_scanrsp; + uint8array adv_data; + }); + + PACKSTRUCT (struct ble_msg_gap_set_adv_data_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_gap_set_directed_connectable_mode_cmd_t { + bd_addr address; + uint8 addr_type; + }); + + PACKSTRUCT (struct ble_msg_gap_set_directed_connectable_mode_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_gap_scan_response_evt_t { + int8 rssi; + uint8 packet_type; + bd_addr sender; + uint8 address_type; + uint8 bond; + uint8array data; + }); + + PACKSTRUCT (struct ble_msg_gap_mode_changed_evt_t { + uint8 discover; + uint8 connect; + }); + + PACKSTRUCT (struct ble_msg_hardware_io_port_config_irq_cmd_t { + uint8 port; + uint8 enable_bits; + uint8 falling_edge; + }); + + PACKSTRUCT (struct ble_msg_hardware_io_port_config_irq_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_hardware_set_soft_timer_cmd_t { + uint32 time; + uint8 handle; + uint8 single_shot; + }); + + PACKSTRUCT (struct ble_msg_hardware_set_soft_timer_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_hardware_adc_read_cmd_t { + uint8 input; + uint8 decimation; + uint8 reference_selection; + }); + + PACKSTRUCT (struct ble_msg_hardware_adc_read_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_hardware_io_port_config_direction_cmd_t { + uint8 port; + uint8 direction; + }); + + PACKSTRUCT (struct ble_msg_hardware_io_port_config_direction_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_hardware_io_port_config_function_cmd_t { + uint8 port; + uint8 function; + }); + + PACKSTRUCT (struct ble_msg_hardware_io_port_config_function_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_hardware_io_port_config_pull_cmd_t { + uint8 port; + uint8 tristate_mask; + uint8 pull_up; + }); + + PACKSTRUCT (struct ble_msg_hardware_io_port_config_pull_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_hardware_io_port_write_cmd_t { + uint8 port; + uint8 mask; + uint8 data; + }); + + PACKSTRUCT (struct ble_msg_hardware_io_port_write_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_hardware_io_port_read_cmd_t { + uint8 port; + uint8 mask; + }); + + PACKSTRUCT (struct ble_msg_hardware_io_port_read_rsp_t { + uint16 result; + uint8 port; + uint8 data; + }); + + PACKSTRUCT (struct ble_msg_hardware_spi_config_cmd_t { + uint8 channel; + uint8 polarity; + uint8 phase; + uint8 bit_order; + uint8 baud_e; + uint8 baud_m; + }); + + PACKSTRUCT (struct ble_msg_hardware_spi_config_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_hardware_spi_transfer_cmd_t { + uint8 channel; + uint8array data; + }); + + PACKSTRUCT (struct ble_msg_hardware_spi_transfer_rsp_t { + uint16 result; + uint8 channel; + uint8array data; + }); + + PACKSTRUCT (struct ble_msg_hardware_i2c_read_cmd_t { + uint8 address; + uint8 stop; + uint8 length; + }); + + PACKSTRUCT (struct ble_msg_hardware_i2c_read_rsp_t { + uint16 result; + uint8array data; + }); + + PACKSTRUCT (struct ble_msg_hardware_i2c_write_cmd_t { + uint8 address; + uint8 stop; + uint8array data; + }); + + PACKSTRUCT (struct ble_msg_hardware_i2c_write_rsp_t { uint8 written; }); + + PACKSTRUCT (struct ble_msg_hardware_set_txpower_cmd_t { uint8 power; }); + + PACKSTRUCT (struct ble_msg_hardware_timer_comparator_cmd_t { + uint8 timer; + uint8 channel; + uint8 mode; + uint16 comparator_value; + }); + + PACKSTRUCT (struct ble_msg_hardware_timer_comparator_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_hardware_io_port_irq_enable_cmd_t { + uint8 port; + uint8 enable_bits; + }); + + PACKSTRUCT (struct ble_msg_hardware_io_port_irq_enable_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_hardware_io_port_irq_direction_cmd_t { + uint8 port; + uint8 falling_edge; + }); + + PACKSTRUCT (struct ble_msg_hardware_io_port_irq_direction_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_hardware_analog_comparator_enable_cmd_t { uint8 enable; }); + + PACKSTRUCT (struct ble_msg_hardware_analog_comparator_read_rsp_t { + uint16 result; + uint8 output; + }); + + PACKSTRUCT (struct ble_msg_hardware_analog_comparator_config_irq_cmd_t { uint8 enabled; }); + + PACKSTRUCT (struct ble_msg_hardware_analog_comparator_config_irq_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_hardware_set_rxgain_cmd_t { uint8 gain; }); + + PACKSTRUCT (struct ble_msg_hardware_usb_enable_cmd_t { uint8 enable; }); + + PACKSTRUCT (struct ble_msg_hardware_usb_enable_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_hardware_io_port_status_evt_t { + uint32 timestamp; + uint8 port; + uint8 irq; + uint8 state; + }); + + PACKSTRUCT (struct ble_msg_hardware_soft_timer_evt_t { uint8 handle; }); + + PACKSTRUCT (struct ble_msg_hardware_adc_result_evt_t { + uint8 input; + int16 value; + }); + + PACKSTRUCT (struct ble_msg_hardware_analog_comparator_status_evt_t { + uint32 timestamp; + uint8 output; + }); + + PACKSTRUCT (struct ble_msg_test_phy_tx_cmd_t { + uint8 channel; + uint8 length; + uint8 type; + }); + + PACKSTRUCT (struct ble_msg_test_phy_rx_cmd_t { uint8 channel; }); + + PACKSTRUCT (struct ble_msg_test_phy_end_rsp_t { uint16 counter; }); + + PACKSTRUCT (struct ble_msg_test_get_channel_map_rsp_t { uint8array channel_map; }); + + PACKSTRUCT (struct ble_msg_test_debug_cmd_t { uint8array input; }); + + PACKSTRUCT (struct ble_msg_test_debug_rsp_t { uint8array output; }); + + PACKSTRUCT (struct ble_msg_test_channel_mode_cmd_t { uint8 mode; }); + + PACKSTRUCT (struct ble_msg_dfu_reset_cmd_t { uint8 dfu; }); + + PACKSTRUCT (struct ble_msg_dfu_flash_set_address_cmd_t { uint32 address; }); + + PACKSTRUCT (struct ble_msg_dfu_flash_set_address_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_dfu_flash_upload_cmd_t { uint8array data; }); + + PACKSTRUCT (struct ble_msg_dfu_flash_upload_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_dfu_flash_upload_finish_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_dfu_boot_evt_t { uint32 version; }); + + PACKSTRUCT (struct ble_cmd_packet { + struct ble_header header; + + union { + uint8 handle; + + uint8 payload; + + struct ble_msg_system_reset_cmd_t system_reset_cmd; + struct ble_msg_system_reg_write_cmd_t system_reg_write_cmd; + struct ble_msg_system_reg_read_cmd_t system_reg_read_cmd; + struct ble_msg_system_read_memory_cmd_t system_read_memory_cmd; + struct ble_msg_system_endpoint_tx_cmd_t system_endpoint_tx_cmd; + struct ble_msg_system_whitelist_append_cmd_t system_whitelist_append_cmd; + struct ble_msg_system_whitelist_remove_cmd_t system_whitelist_remove_cmd; + struct ble_msg_system_endpoint_rx_cmd_t system_endpoint_rx_cmd; + struct ble_msg_system_endpoint_set_watermarks_cmd_t system_endpoint_set_watermarks_cmd; + struct ble_msg_system_aes_setkey_cmd_t system_aes_setkey_cmd; + struct ble_msg_system_aes_encrypt_cmd_t system_aes_encrypt_cmd; + struct ble_msg_system_aes_decrypt_cmd_t system_aes_decrypt_cmd; + struct ble_msg_system_boot_evt_t system_boot_evt; + struct ble_msg_system_debug_evt_t system_debug_evt; + struct ble_msg_system_endpoint_watermark_rx_evt_t system_endpoint_watermark_rx_evt; + struct ble_msg_system_endpoint_watermark_tx_evt_t system_endpoint_watermark_tx_evt; + struct ble_msg_system_script_failure_evt_t system_script_failure_evt; + struct ble_msg_system_protocol_error_evt_t system_protocol_error_evt; + struct ble_msg_system_address_get_rsp_t system_address_get_rsp; + struct ble_msg_system_reg_write_rsp_t system_reg_write_rsp; + struct ble_msg_system_reg_read_rsp_t system_reg_read_rsp; + struct ble_msg_system_get_counters_rsp_t system_get_counters_rsp; + struct ble_msg_system_get_connections_rsp_t system_get_connections_rsp; + struct ble_msg_system_read_memory_rsp_t system_read_memory_rsp; + struct ble_msg_system_get_info_rsp_t system_get_info_rsp; + struct ble_msg_system_endpoint_tx_rsp_t system_endpoint_tx_rsp; + struct ble_msg_system_whitelist_append_rsp_t system_whitelist_append_rsp; + struct ble_msg_system_whitelist_remove_rsp_t system_whitelist_remove_rsp; + struct ble_msg_system_endpoint_rx_rsp_t system_endpoint_rx_rsp; + struct ble_msg_system_endpoint_set_watermarks_rsp_t system_endpoint_set_watermarks_rsp; + struct ble_msg_system_aes_encrypt_rsp_t system_aes_encrypt_rsp; + struct ble_msg_system_aes_decrypt_rsp_t system_aes_decrypt_rsp; + struct ble_msg_flash_ps_save_cmd_t flash_ps_save_cmd; + struct ble_msg_flash_ps_load_cmd_t flash_ps_load_cmd; + struct ble_msg_flash_ps_erase_cmd_t flash_ps_erase_cmd; + struct ble_msg_flash_erase_page_cmd_t flash_erase_page_cmd; + struct ble_msg_flash_write_data_cmd_t flash_write_data_cmd; + struct ble_msg_flash_read_data_cmd_t flash_read_data_cmd; + struct ble_msg_flash_ps_key_evt_t flash_ps_key_evt; + struct ble_msg_flash_ps_save_rsp_t flash_ps_save_rsp; + struct ble_msg_flash_ps_load_rsp_t flash_ps_load_rsp; + struct ble_msg_flash_erase_page_rsp_t flash_erase_page_rsp; + struct ble_msg_flash_write_data_rsp_t flash_write_data_rsp; + struct ble_msg_flash_read_data_rsp_t flash_read_data_rsp; + struct ble_msg_attributes_write_cmd_t attributes_write_cmd; + struct ble_msg_attributes_read_cmd_t attributes_read_cmd; + struct ble_msg_attributes_read_type_cmd_t attributes_read_type_cmd; + struct ble_msg_attributes_user_read_response_cmd_t attributes_user_read_response_cmd; + struct ble_msg_attributes_user_write_response_cmd_t attributes_user_write_response_cmd; + struct ble_msg_attributes_send_cmd_t attributes_send_cmd; + struct ble_msg_attributes_value_evt_t attributes_value_evt; + struct ble_msg_attributes_user_read_request_evt_t attributes_user_read_request_evt; + struct ble_msg_attributes_status_evt_t attributes_status_evt; + struct ble_msg_attributes_write_rsp_t attributes_write_rsp; + struct ble_msg_attributes_read_rsp_t attributes_read_rsp; + struct ble_msg_attributes_read_type_rsp_t attributes_read_type_rsp; + struct ble_msg_attributes_send_rsp_t attributes_send_rsp; + struct ble_msg_connection_disconnect_cmd_t connection_disconnect_cmd; + struct ble_msg_connection_get_rssi_cmd_t connection_get_rssi_cmd; + struct ble_msg_connection_update_cmd_t connection_update_cmd; + struct ble_msg_connection_version_update_cmd_t connection_version_update_cmd; + struct ble_msg_connection_channel_map_get_cmd_t connection_channel_map_get_cmd; + struct ble_msg_connection_channel_map_set_cmd_t connection_channel_map_set_cmd; + struct ble_msg_connection_features_get_cmd_t connection_features_get_cmd; + struct ble_msg_connection_get_status_cmd_t connection_get_status_cmd; + struct ble_msg_connection_raw_tx_cmd_t connection_raw_tx_cmd; + struct ble_msg_connection_status_evt_t connection_status_evt; + struct ble_msg_connection_version_ind_evt_t connection_version_ind_evt; + struct ble_msg_connection_feature_ind_evt_t connection_feature_ind_evt; + struct ble_msg_connection_raw_rx_evt_t connection_raw_rx_evt; + struct ble_msg_connection_disconnected_evt_t connection_disconnected_evt; + struct ble_msg_connection_disconnect_rsp_t connection_disconnect_rsp; + struct ble_msg_connection_get_rssi_rsp_t connection_get_rssi_rsp; + struct ble_msg_connection_update_rsp_t connection_update_rsp; + struct ble_msg_connection_version_update_rsp_t connection_version_update_rsp; + struct ble_msg_connection_channel_map_get_rsp_t connection_channel_map_get_rsp; + struct ble_msg_connection_channel_map_set_rsp_t connection_channel_map_set_rsp; + struct ble_msg_connection_features_get_rsp_t connection_features_get_rsp; + struct ble_msg_connection_get_status_rsp_t connection_get_status_rsp; + struct ble_msg_connection_raw_tx_rsp_t connection_raw_tx_rsp; + struct ble_msg_attclient_find_by_type_value_cmd_t attclient_find_by_type_value_cmd; + struct ble_msg_attclient_read_by_group_type_cmd_t attclient_read_by_group_type_cmd; + struct ble_msg_attclient_read_by_type_cmd_t attclient_read_by_type_cmd; + struct ble_msg_attclient_find_information_cmd_t attclient_find_information_cmd; + struct ble_msg_attclient_read_by_handle_cmd_t attclient_read_by_handle_cmd; + struct ble_msg_attclient_attribute_write_cmd_t attclient_attribute_write_cmd; + struct ble_msg_attclient_write_command_cmd_t attclient_write_command_cmd; + struct ble_msg_attclient_indicate_confirm_cmd_t attclient_indicate_confirm_cmd; + struct ble_msg_attclient_read_long_cmd_t attclient_read_long_cmd; + struct ble_msg_attclient_prepare_write_cmd_t attclient_prepare_write_cmd; + struct ble_msg_attclient_execute_write_cmd_t attclient_execute_write_cmd; + struct ble_msg_attclient_read_multiple_cmd_t attclient_read_multiple_cmd; + struct ble_msg_attclient_indicated_evt_t attclient_indicated_evt; + struct ble_msg_attclient_procedure_completed_evt_t attclient_procedure_completed_evt; + struct ble_msg_attclient_group_found_evt_t attclient_group_found_evt; + struct ble_msg_attclient_attribute_found_evt_t attclient_attribute_found_evt; + struct ble_msg_attclient_find_information_found_evt_t + attclient_find_information_found_evt; + struct ble_msg_attclient_attribute_value_evt_t attclient_attribute_value_evt; + struct ble_msg_attclient_read_multiple_response_evt_t + attclient_read_multiple_response_evt; + struct ble_msg_attclient_find_by_type_value_rsp_t attclient_find_by_type_value_rsp; + struct ble_msg_attclient_read_by_group_type_rsp_t attclient_read_by_group_type_rsp; + struct ble_msg_attclient_read_by_type_rsp_t attclient_read_by_type_rsp; + struct ble_msg_attclient_find_information_rsp_t attclient_find_information_rsp; + struct ble_msg_attclient_read_by_handle_rsp_t attclient_read_by_handle_rsp; + struct ble_msg_attclient_attribute_write_rsp_t attclient_attribute_write_rsp; + struct ble_msg_attclient_write_command_rsp_t attclient_write_command_rsp; + struct ble_msg_attclient_indicate_confirm_rsp_t attclient_indicate_confirm_rsp; + struct ble_msg_attclient_read_long_rsp_t attclient_read_long_rsp; + struct ble_msg_attclient_prepare_write_rsp_t attclient_prepare_write_rsp; + struct ble_msg_attclient_execute_write_rsp_t attclient_execute_write_rsp; + struct ble_msg_attclient_read_multiple_rsp_t attclient_read_multiple_rsp; + struct ble_msg_sm_encrypt_start_cmd_t sm_encrypt_start_cmd; + struct ble_msg_sm_set_bondable_mode_cmd_t sm_set_bondable_mode_cmd; + struct ble_msg_sm_delete_bonding_cmd_t sm_delete_bonding_cmd; + struct ble_msg_sm_set_parameters_cmd_t sm_set_parameters_cmd; + struct ble_msg_sm_passkey_entry_cmd_t sm_passkey_entry_cmd; + struct ble_msg_sm_set_oob_data_cmd_t sm_set_oob_data_cmd; + struct ble_msg_sm_smp_data_evt_t sm_smp_data_evt; + struct ble_msg_sm_bonding_fail_evt_t sm_bonding_fail_evt; + struct ble_msg_sm_passkey_display_evt_t sm_passkey_display_evt; + struct ble_msg_sm_passkey_request_evt_t sm_passkey_request_evt; + struct ble_msg_sm_bond_status_evt_t sm_bond_status_evt; + struct ble_msg_sm_encrypt_start_rsp_t sm_encrypt_start_rsp; + struct ble_msg_sm_delete_bonding_rsp_t sm_delete_bonding_rsp; + struct ble_msg_sm_passkey_entry_rsp_t sm_passkey_entry_rsp; + struct ble_msg_sm_get_bonds_rsp_t sm_get_bonds_rsp; + struct ble_msg_sm_whitelist_bonds_rsp_t sm_whitelist_bonds_rsp; + struct ble_msg_gap_set_privacy_flags_cmd_t gap_set_privacy_flags_cmd; + struct ble_msg_gap_set_mode_cmd_t gap_set_mode_cmd; + struct ble_msg_gap_discover_cmd_t gap_discover_cmd; + struct ble_msg_gap_connect_direct_cmd_t gap_connect_direct_cmd; + struct ble_msg_gap_connect_selective_cmd_t gap_connect_selective_cmd; + struct ble_msg_gap_set_filtering_cmd_t gap_set_filtering_cmd; + struct ble_msg_gap_set_scan_parameters_cmd_t gap_set_scan_parameters_cmd; + struct ble_msg_gap_set_adv_parameters_cmd_t gap_set_adv_parameters_cmd; + struct ble_msg_gap_set_adv_data_cmd_t gap_set_adv_data_cmd; + struct ble_msg_gap_set_directed_connectable_mode_cmd_t + gap_set_directed_connectable_mode_cmd; + struct ble_msg_gap_scan_response_evt_t gap_scan_response_evt; + struct ble_msg_gap_mode_changed_evt_t gap_mode_changed_evt; + struct ble_msg_gap_set_mode_rsp_t gap_set_mode_rsp; + struct ble_msg_gap_discover_rsp_t gap_discover_rsp; + struct ble_msg_gap_connect_direct_rsp_t gap_connect_direct_rsp; + struct ble_msg_gap_end_procedure_rsp_t gap_end_procedure_rsp; + struct ble_msg_gap_connect_selective_rsp_t gap_connect_selective_rsp; + struct ble_msg_gap_set_filtering_rsp_t gap_set_filtering_rsp; + struct ble_msg_gap_set_scan_parameters_rsp_t gap_set_scan_parameters_rsp; + struct ble_msg_gap_set_adv_parameters_rsp_t gap_set_adv_parameters_rsp; + struct ble_msg_gap_set_adv_data_rsp_t gap_set_adv_data_rsp; + struct ble_msg_gap_set_directed_connectable_mode_rsp_t + gap_set_directed_connectable_mode_rsp; + struct ble_msg_hardware_io_port_config_irq_cmd_t hardware_io_port_config_irq_cmd; + struct ble_msg_hardware_set_soft_timer_cmd_t hardware_set_soft_timer_cmd; + struct ble_msg_hardware_adc_read_cmd_t hardware_adc_read_cmd; + struct ble_msg_hardware_io_port_config_direction_cmd_t + hardware_io_port_config_direction_cmd; + struct ble_msg_hardware_io_port_config_function_cmd_t + hardware_io_port_config_function_cmd; + struct ble_msg_hardware_io_port_config_pull_cmd_t hardware_io_port_config_pull_cmd; + struct ble_msg_hardware_io_port_write_cmd_t hardware_io_port_write_cmd; + struct ble_msg_hardware_io_port_read_cmd_t hardware_io_port_read_cmd; + struct ble_msg_hardware_spi_config_cmd_t hardware_spi_config_cmd; + struct ble_msg_hardware_spi_transfer_cmd_t hardware_spi_transfer_cmd; + struct ble_msg_hardware_i2c_read_cmd_t hardware_i2c_read_cmd; + struct ble_msg_hardware_i2c_write_cmd_t hardware_i2c_write_cmd; + struct ble_msg_hardware_set_txpower_cmd_t hardware_set_txpower_cmd; + struct ble_msg_hardware_timer_comparator_cmd_t hardware_timer_comparator_cmd; + struct ble_msg_hardware_io_port_irq_enable_cmd_t hardware_io_port_irq_enable_cmd; + struct ble_msg_hardware_io_port_irq_direction_cmd_t hardware_io_port_irq_direction_cmd; + struct ble_msg_hardware_analog_comparator_enable_cmd_t + hardware_analog_comparator_enable_cmd; + struct ble_msg_hardware_analog_comparator_config_irq_cmd_t + hardware_analog_comparator_config_irq_cmd; + struct ble_msg_hardware_set_rxgain_cmd_t hardware_set_rxgain_cmd; + struct ble_msg_hardware_usb_enable_cmd_t hardware_usb_enable_cmd; + struct ble_msg_hardware_io_port_status_evt_t hardware_io_port_status_evt; + struct ble_msg_hardware_soft_timer_evt_t hardware_soft_timer_evt; + struct ble_msg_hardware_adc_result_evt_t hardware_adc_result_evt; + struct ble_msg_hardware_analog_comparator_status_evt_t + hardware_analog_comparator_status_evt; + struct ble_msg_hardware_io_port_config_irq_rsp_t hardware_io_port_config_irq_rsp; + struct ble_msg_hardware_set_soft_timer_rsp_t hardware_set_soft_timer_rsp; + struct ble_msg_hardware_adc_read_rsp_t hardware_adc_read_rsp; + struct ble_msg_hardware_io_port_config_direction_rsp_t + hardware_io_port_config_direction_rsp; + struct ble_msg_hardware_io_port_config_function_rsp_t + hardware_io_port_config_function_rsp; + struct ble_msg_hardware_io_port_config_pull_rsp_t hardware_io_port_config_pull_rsp; + struct ble_msg_hardware_io_port_write_rsp_t hardware_io_port_write_rsp; + struct ble_msg_hardware_io_port_read_rsp_t hardware_io_port_read_rsp; + struct ble_msg_hardware_spi_config_rsp_t hardware_spi_config_rsp; + struct ble_msg_hardware_spi_transfer_rsp_t hardware_spi_transfer_rsp; + struct ble_msg_hardware_i2c_read_rsp_t hardware_i2c_read_rsp; + struct ble_msg_hardware_i2c_write_rsp_t hardware_i2c_write_rsp; + struct ble_msg_hardware_timer_comparator_rsp_t hardware_timer_comparator_rsp; + struct ble_msg_hardware_io_port_irq_enable_rsp_t hardware_io_port_irq_enable_rsp; + struct ble_msg_hardware_io_port_irq_direction_rsp_t hardware_io_port_irq_direction_rsp; + struct ble_msg_hardware_analog_comparator_read_rsp_t + hardware_analog_comparator_read_rsp; + struct ble_msg_hardware_analog_comparator_config_irq_rsp_t + hardware_analog_comparator_config_irq_rsp; + struct ble_msg_hardware_usb_enable_rsp_t hardware_usb_enable_rsp; + struct ble_msg_test_phy_tx_cmd_t test_phy_tx_cmd; + struct ble_msg_test_phy_rx_cmd_t test_phy_rx_cmd; + struct ble_msg_test_debug_cmd_t test_debug_cmd; + struct ble_msg_test_channel_mode_cmd_t test_channel_mode_cmd; + struct ble_msg_test_phy_end_rsp_t test_phy_end_rsp; + struct ble_msg_test_get_channel_map_rsp_t test_get_channel_map_rsp; + struct ble_msg_test_debug_rsp_t test_debug_rsp; + struct ble_msg_dfu_reset_cmd_t dfu_reset_cmd; + struct ble_msg_dfu_flash_set_address_cmd_t dfu_flash_set_address_cmd; + struct ble_msg_dfu_flash_upload_cmd_t dfu_flash_upload_cmd; + struct ble_msg_dfu_boot_evt_t dfu_boot_evt; + struct ble_msg_dfu_flash_set_address_rsp_t dfu_flash_set_address_rsp; + struct ble_msg_dfu_flash_upload_rsp_t dfu_flash_upload_rsp; + struct ble_msg_dfu_flash_upload_finish_rsp_t dfu_flash_upload_finish_rsp; + }; + } ALIGNED); +/**Reset device**/ +#define ble_cmd_system_reset(boot_in_dfu) ble_send_message (ble_cmd_system_reset_idx, boot_in_dfu) +/**Hello - command for testing**/ +#define ble_cmd_system_hello() ble_send_message (ble_cmd_system_hello_idx) +/**Get device bluetooth address**/ +#define ble_cmd_system_address_get() ble_send_message (ble_cmd_system_address_get_idx) +/**write register**/ +#define ble_cmd_system_reg_write(address, value) \ + ble_send_message (ble_cmd_system_reg_write_idx, address, value) +/**read register**/ +#define ble_cmd_system_reg_read(address) ble_send_message (ble_cmd_system_reg_read_idx, address) +/**get and reset packet counters**/ +#define ble_cmd_system_get_counters() ble_send_message (ble_cmd_system_get_counters_idx) +/**Get status from all connections**/ +#define ble_cmd_system_get_connections() ble_send_message (ble_cmd_system_get_connections_idx) +/**Read Memory**/ +#define ble_cmd_system_read_memory(address, length) \ + ble_send_message (ble_cmd_system_read_memory_idx, address, length) +/**Get Device info**/ +#define ble_cmd_system_get_info() ble_send_message (ble_cmd_system_get_info_idx) +/**Send data to endpoint, error is returned if endpoint does not have enough space**/ +#define ble_cmd_system_endpoint_tx(endpoint, data_len, data_data) \ + ble_send_message (ble_cmd_system_endpoint_tx_idx, endpoint, data_len, data_data) +/**Add entry to whitelist**/ +#define ble_cmd_system_whitelist_append(address, address_type) \ + ble_send_message (ble_cmd_system_whitelist_append_idx, address, address_type) +/**Remove entry from whitelist**/ +#define ble_cmd_system_whitelist_remove(address, address_type) \ + ble_send_message (ble_cmd_system_whitelist_remove_idx, address, address_type) +/**Add entry to whitelist**/ +#define ble_cmd_system_whitelist_clear() ble_send_message (ble_cmd_system_whitelist_clear_idx) +/**Read data from endpoint, error is returned if endpoint does not have enough data.**/ +#define ble_cmd_system_endpoint_rx(endpoint, size) \ + ble_send_message (ble_cmd_system_endpoint_rx_idx, endpoint, size) +/**Set watermarks on both input and output side**/ +#define ble_cmd_system_endpoint_set_watermarks(endpoint, rx, tx) \ + ble_send_message (ble_cmd_system_endpoint_set_watermarks_idx, endpoint, rx, tx) +/**Set encryption key that will be used with aes_encrypt and aes_decrypt commands.**/ +#define ble_cmd_system_aes_setkey(key_len, key_data) \ + ble_send_message (ble_cmd_system_aes_setkey_idx, key_len, key_data) +/**Encrypt one block of data**/ +#define ble_cmd_system_aes_encrypt(data_len, data_data) \ + ble_send_message (ble_cmd_system_aes_encrypt_idx, data_len, data_data) +/**Decrypt one block of data**/ +#define ble_cmd_system_aes_decrypt(data_len, data_data) \ + ble_send_message (ble_cmd_system_aes_decrypt_idx, data_len, data_data) +/**Defragment persistent store**/ +#define ble_cmd_flash_ps_defrag() ble_send_message (ble_cmd_flash_ps_defrag_idx) +/**Dump all ps keys**/ +#define ble_cmd_flash_ps_dump() ble_send_message (ble_cmd_flash_ps_dump_idx) +/**erase all ps keys**/ +#define ble_cmd_flash_ps_erase_all() ble_send_message (ble_cmd_flash_ps_erase_all_idx) +/**save ps key**/ +#define ble_cmd_flash_ps_save(key, value_len, value_data) \ + ble_send_message (ble_cmd_flash_ps_save_idx, key, value_len, value_data) +/**load ps key**/ +#define ble_cmd_flash_ps_load(key) ble_send_message (ble_cmd_flash_ps_load_idx, key) +/**erase ps key**/ +#define ble_cmd_flash_ps_erase(key) ble_send_message (ble_cmd_flash_ps_erase_idx, key) +/**erase flash page**/ +#define ble_cmd_flash_erase_page(page) ble_send_message (ble_cmd_flash_erase_page_idx, page) +/**write data to user data area**/ +#define ble_cmd_flash_write_data(address, data_len, data_data) \ + ble_send_message (ble_cmd_flash_write_data_idx, address, data_len, data_data) +/**read data from user data area.**/ +#define ble_cmd_flash_read_data(address, length) \ + ble_send_message (ble_cmd_flash_read_data_idx, address, length) +/**Write to attribute database**/ +#define ble_cmd_attributes_write(handle, offset, value_len, value_data) \ + ble_send_message (ble_cmd_attributes_write_idx, handle, offset, value_len, value_data) +/**Read from attribute database**/ +#define ble_cmd_attributes_read(handle, offset) \ + ble_send_message (ble_cmd_attributes_read_idx, handle, offset) +/**Read attribute type from database**/ +#define ble_cmd_attributes_read_type(handle) \ + ble_send_message (ble_cmd_attributes_read_type_idx, handle) +/**Respond to user attribute read request**/ +#define ble_cmd_attributes_user_read_response(connection, att_error, value_len, value_data) \ + ble_send_message ( \ + ble_cmd_attributes_user_read_response_idx, connection, att_error, value_len, value_data) +/**Response to attribute_changed event where reason is user-attribute write.**/ +#define ble_cmd_attributes_user_write_response(connection, att_error) \ + ble_send_message (ble_cmd_attributes_user_write_response_idx, connection, att_error) +/**Send notification or indication to remote device.**/ +#define ble_cmd_attributes_send(connection, handle, value_len, value_data) \ + ble_send_message (ble_cmd_attributes_send_idx, connection, handle, value_len, value_data) +/**Disconnect connection, starts a disconnection procedure on connection**/ +#define ble_cmd_connection_disconnect(connection) \ + ble_send_message (ble_cmd_connection_disconnect_idx, connection) +/**Get Link RSSI**/ +#define ble_cmd_connection_get_rssi(connection) \ + ble_send_message (ble_cmd_connection_get_rssi_idx, connection) +/**Update connection parameters**/ +#define ble_cmd_connection_update(connection, interval_min, interval_max, latency, timeout) \ + ble_send_message ( \ + ble_cmd_connection_update_idx, connection, interval_min, interval_max, latency, timeout) +/**Request version exchange**/ +#define ble_cmd_connection_version_update(connection) \ + ble_send_message (ble_cmd_connection_version_update_idx, connection) +/**Get Current channel map**/ +#define ble_cmd_connection_channel_map_get(connection) \ + ble_send_message (ble_cmd_connection_channel_map_get_idx, connection) +/**Set Channel map**/ +#define ble_cmd_connection_channel_map_set(connection, map_len, map_data) \ + ble_send_message (ble_cmd_connection_channel_map_set_idx, connection, map_len, map_data) +/**Remote feature request**/ +#define ble_cmd_connection_features_get(connection) \ + ble_send_message (ble_cmd_connection_features_get_idx, connection) +/**Get Connection Status Parameters**/ +#define ble_cmd_connection_get_status(connection) \ + ble_send_message (ble_cmd_connection_get_status_idx, connection) +/**Raw TX**/ +#define ble_cmd_connection_raw_tx(connection, data_len, data_data) \ + ble_send_message (ble_cmd_connection_raw_tx_idx, connection, data_len, data_data) +/**Discover attributes by type and value**/ +#define ble_cmd_attclient_find_by_type_value(connection, start, end, uuid, value_len, value_data) \ + ble_send_message (ble_cmd_attclient_find_by_type_value_idx, connection, start, end, uuid, \ + value_len, value_data) +/**Discover attributes by type and value**/ +#define ble_cmd_attclient_read_by_group_type(connection, start, end, uuid_len, uuid_data) \ + ble_send_message ( \ + ble_cmd_attclient_read_by_group_type_idx, connection, start, end, uuid_len, uuid_data) +/**Read all attributes where type matches**/ +#define ble_cmd_attclient_read_by_type(connection, start, end, uuid_len, uuid_data) \ + ble_send_message ( \ + ble_cmd_attclient_read_by_type_idx, connection, start, end, uuid_len, uuid_data) +/**Discover Attribute handle and type mappings**/ +#define ble_cmd_attclient_find_information(connection, start, end) \ + ble_send_message (ble_cmd_attclient_find_information_idx, connection, start, end) +/**Read Characteristic value using handle**/ +#define ble_cmd_attclient_read_by_handle(connection, chrhandle) \ + ble_send_message (ble_cmd_attclient_read_by_handle_idx, connection, chrhandle) +/**write data to attribute**/ +#define ble_cmd_attclient_attribute_write(connection, atthandle, data_len, data_data) \ + ble_send_message ( \ + ble_cmd_attclient_attribute_write_idx, connection, atthandle, data_len, data_data) +/**write data to attribute using ATT write command**/ +#define ble_cmd_attclient_write_command(connection, atthandle, data_len, data_data) \ + ble_send_message ( \ + ble_cmd_attclient_write_command_idx, connection, atthandle, data_len, data_data) +/**Send confirmation for received indication, use only if manual indications are enabled**/ +#define ble_cmd_attclient_indicate_confirm(connection) \ + ble_send_message (ble_cmd_attclient_indicate_confirm_idx, connection) +/**Read Long Characteristic value**/ +#define ble_cmd_attclient_read_long(connection, chrhandle) \ + ble_send_message (ble_cmd_attclient_read_long_idx, connection, chrhandle) +/**Send prepare write request to remote host**/ +#define ble_cmd_attclient_prepare_write(connection, atthandle, offset, data_len, data_data) \ + ble_send_message ( \ + ble_cmd_attclient_prepare_write_idx, connection, atthandle, offset, data_len, data_data) +/**Send prepare write request to remote host**/ +#define ble_cmd_attclient_execute_write(connection, commit) \ + ble_send_message (ble_cmd_attclient_execute_write_idx, connection, commit) +/**Read multiple attributes from server**/ +#define ble_cmd_attclient_read_multiple(connection, handles_len, handles_data) \ + ble_send_message (ble_cmd_attclient_read_multiple_idx, connection, handles_len, handles_data) +/**Enable encryption on link**/ +#define ble_cmd_sm_encrypt_start(handle, bonding) \ + ble_send_message (ble_cmd_sm_encrypt_start_idx, handle, bonding) +/**Set device to bondable mode**/ +#define ble_cmd_sm_set_bondable_mode(bondable) \ + ble_send_message (ble_cmd_sm_set_bondable_mode_idx, bondable) +/**delete bonding information from ps store**/ +#define ble_cmd_sm_delete_bonding(handle) ble_send_message (ble_cmd_sm_delete_bonding_idx, handle) +/**set pairing requirements**/ +#define ble_cmd_sm_set_parameters(mitm, min_key_size, io_capabilities) \ + ble_send_message (ble_cmd_sm_set_parameters_idx, mitm, min_key_size, io_capabilities) +/**Passkey entered**/ +#define ble_cmd_sm_passkey_entry(handle, passkey) \ + ble_send_message (ble_cmd_sm_passkey_entry_idx, handle, passkey) +/**List all bonded devices**/ +#define ble_cmd_sm_get_bonds() ble_send_message (ble_cmd_sm_get_bonds_idx) +/** + Set out-of-band encryption data for device + Device does not allow any other kind of pairing except oob if oob data is set. + **/ +#define ble_cmd_sm_set_oob_data(oob_len, oob_data) \ + ble_send_message (ble_cmd_sm_set_oob_data_idx, oob_len, oob_data) +/** + Add all bonded devices with a known public or static address to + the whitelist. Previous entries in the whitelist are first + cleared. This command can't be used while advertising, scanning + or being connected. + **/ +#define ble_cmd_sm_whitelist_bonds() ble_send_message (ble_cmd_sm_whitelist_bonds_idx) +/**Set GAP central/peripheral privacy flags + **/ +#define ble_cmd_gap_set_privacy_flags(peripheral_privacy, central_privacy) \ + ble_send_message (ble_cmd_gap_set_privacy_flags_idx, peripheral_privacy, central_privacy) +/**Set discoverable and connectable mode**/ +#define ble_cmd_gap_set_mode(discover, connect) \ + ble_send_message (ble_cmd_gap_set_mode_idx, discover, connect) +/**start or stop discover procedure**/ +#define ble_cmd_gap_discover(mode) ble_send_message (ble_cmd_gap_discover_idx, mode) +/**Direct connection**/ +#define ble_cmd_gap_connect_direct( \ + address, addr_type, conn_interval_min, conn_interval_max, timeout, latency) \ + ble_send_message (ble_cmd_gap_connect_direct_idx, address, addr_type, conn_interval_min, \ + conn_interval_max, timeout, latency) +/**End current GAP procedure**/ +#define ble_cmd_gap_end_procedure() ble_send_message (ble_cmd_gap_end_procedure_idx) +/**Connect to any device on whitelist**/ +#define ble_cmd_gap_connect_selective(conn_interval_min, conn_interval_max, timeout, latency) \ + ble_send_message ( \ + ble_cmd_gap_connect_selective_idx, conn_interval_min, conn_interval_max, timeout, latency) +/**Set scan and advertising filtering parameters**/ +#define ble_cmd_gap_set_filtering(scan_policy, adv_policy, scan_duplicate_filtering) \ + ble_send_message ( \ + ble_cmd_gap_set_filtering_idx, scan_policy, adv_policy, scan_duplicate_filtering) +/**Set scan parameters**/ +#define ble_cmd_gap_set_scan_parameters(scan_interval, scan_window, active) \ + ble_send_message (ble_cmd_gap_set_scan_parameters_idx, scan_interval, scan_window, active) +/**Set advertising parameters**/ +#define ble_cmd_gap_set_adv_parameters(adv_interval_min, adv_interval_max, adv_channels) \ + ble_send_message ( \ + ble_cmd_gap_set_adv_parameters_idx, adv_interval_min, adv_interval_max, adv_channels) +/**Set advertisement or scan response data. Use broadcast mode to advertise data**/ +#define ble_cmd_gap_set_adv_data(set_scanrsp, adv_data_len, adv_data_data) \ + ble_send_message (ble_cmd_gap_set_adv_data_idx, set_scanrsp, adv_data_len, adv_data_data) +/**Sets device to Directed Connectable Mode + Uses fast advertisement procedure for 1.28s after which device enters + nonconnectable mode. If device has valid reconnection characteristic value, it is used for + connection otherwise passed address and address type are used + **/ +#define ble_cmd_gap_set_directed_connectable_mode(address, addr_type) \ + ble_send_message (ble_cmd_gap_set_directed_connectable_mode_idx, address, addr_type) +/**Configure I/O-port interrupts**/ +#define ble_cmd_hardware_io_port_config_irq(port, enable_bits, falling_edge) \ + ble_send_message (ble_cmd_hardware_io_port_config_irq_idx, port, enable_bits, falling_edge) +/**Set soft timer to send events**/ +#define ble_cmd_hardware_set_soft_timer(time, handle, single_shot) \ + ble_send_message (ble_cmd_hardware_set_soft_timer_idx, time, handle, single_shot) +/**Read A/D conversion**/ +#define ble_cmd_hardware_adc_read(input, decimation, reference_selection) \ + ble_send_message (ble_cmd_hardware_adc_read_idx, input, decimation, reference_selection) +/**Configure I/O-port direction**/ +#define ble_cmd_hardware_io_port_config_direction(port, direction) \ + ble_send_message (ble_cmd_hardware_io_port_config_direction_idx, port, direction) +/**Configure I/O-port function**/ +#define ble_cmd_hardware_io_port_config_function(port, function) \ + ble_send_message (ble_cmd_hardware_io_port_config_function_idx, port, function) +/**Configure I/O-port pull-up/pull-down**/ +#define ble_cmd_hardware_io_port_config_pull(port, tristate_mask, pull_up) \ + ble_send_message (ble_cmd_hardware_io_port_config_pull_idx, port, tristate_mask, pull_up) +/**Write I/O-port**/ +#define ble_cmd_hardware_io_port_write(port, mask, data) \ + ble_send_message (ble_cmd_hardware_io_port_write_idx, port, mask, data) +/**Read I/O-port**/ +#define ble_cmd_hardware_io_port_read(port, mask) \ + ble_send_message (ble_cmd_hardware_io_port_read_idx, port, mask) +/**Configure SPI**/ +#define ble_cmd_hardware_spi_config(channel, polarity, phase, bit_order, baud_e, baud_m) \ + ble_send_message ( \ + ble_cmd_hardware_spi_config_idx, channel, polarity, phase, bit_order, baud_e, baud_m) +/**Transfer SPI data**/ +#define ble_cmd_hardware_spi_transfer(channel, data_len, data_data) \ + ble_send_message (ble_cmd_hardware_spi_transfer_idx, channel, data_len, data_data) +/**Read data from I2C bus using bit-bang in cc2540. I2C clk is in P1.7 data in P1.6. Pull-up must be + * enabled on pins**/ +#define ble_cmd_hardware_i2c_read(address, stop, length) \ + ble_send_message (ble_cmd_hardware_i2c_read_idx, address, stop, length) +/**Write data to I2C bus using bit-bang in cc2540. I2C clk is in P1.7 data in P1.6. Pull-up must be + * enabled on pins**/ +#define ble_cmd_hardware_i2c_write(address, stop, data_len, data_data) \ + ble_send_message (ble_cmd_hardware_i2c_write_idx, address, stop, data_len, data_data) +/**Set TX Power**/ +#define ble_cmd_hardware_set_txpower(power) \ + ble_send_message (ble_cmd_hardware_set_txpower_idx, power) +/**Set comparator for timer channel**/ +#define ble_cmd_hardware_timer_comparator(timer, channel, mode, comparator_value) \ + ble_send_message (ble_cmd_hardware_timer_comparator_idx, timer, channel, mode, comparator_value) +/**Enable I/O-port interrupts**/ +#define ble_cmd_hardware_io_port_irq_enable(port, enable_bits) \ + ble_send_message (ble_cmd_hardware_io_port_irq_enable_idx, port, enable_bits) +/**Set I/O-port interrupt direction**/ +#define ble_cmd_hardware_io_port_irq_direction(port, falling_edge) \ + ble_send_message (ble_cmd_hardware_io_port_irq_direction_idx, port, falling_edge) +/**Enable or disable analog comparator**/ +#define ble_cmd_hardware_analog_comparator_enable(enable) \ + ble_send_message (ble_cmd_hardware_analog_comparator_enable_idx, enable) +/**Read analog comparator output**/ +#define ble_cmd_hardware_analog_comparator_read() \ + ble_send_message (ble_cmd_hardware_analog_comparator_read_idx) +/**Configure analog comparator interrupt**/ +#define ble_cmd_hardware_analog_comparator_config_irq(enabled) \ + ble_send_message (ble_cmd_hardware_analog_comparator_config_irq_idx, enabled) +/**Set RX Sensitivity**/ +#define ble_cmd_hardware_set_rxgain(gain) ble_send_message (ble_cmd_hardware_set_rxgain_idx, gain) +/**Enable or disable USB**/ +#define ble_cmd_hardware_usb_enable(enable) \ + ble_send_message (ble_cmd_hardware_usb_enable_idx, enable) +/**Start packet transmission, send one packet at every 625us**/ +#define ble_cmd_test_phy_tx(channel, length, type) \ + ble_send_message (ble_cmd_test_phy_tx_idx, channel, length, type) +/**Start receive test**/ +#define ble_cmd_test_phy_rx(channel) ble_send_message (ble_cmd_test_phy_rx_idx, channel) +/**End test, and report received packets**/ +#define ble_cmd_test_phy_end() ble_send_message (ble_cmd_test_phy_end_idx) +/**Reset test**/ +#define ble_cmd_test_phy_reset() ble_send_message (ble_cmd_test_phy_reset_idx) +/**Get current channel quality map**/ +#define ble_cmd_test_get_channel_map() ble_send_message (ble_cmd_test_get_channel_map_idx) +/**Debug command**/ +#define ble_cmd_test_debug(input_len, input_data) \ + ble_send_message (ble_cmd_test_debug_idx, input_len, input_data) +/**Set channel quality measurement mode**/ +#define ble_cmd_test_channel_mode(mode) ble_send_message (ble_cmd_test_channel_mode_idx, mode) +/**Reset system**/ +#define ble_cmd_dfu_reset(dfu) ble_send_message (ble_cmd_dfu_reset_idx, dfu) +/**set address for flashing**/ +#define ble_cmd_dfu_flash_set_address(address) \ + ble_send_message (ble_cmd_dfu_flash_set_address_idx, address) +/**Upload binary for flashing. Address will be updated automatically.**/ +#define ble_cmd_dfu_flash_upload(data_len, data_data) \ + ble_send_message (ble_cmd_dfu_flash_upload_idx, data_len, data_data) +/**Uploading is finished.**/ +#define ble_cmd_dfu_flash_upload_finish() ble_send_message (ble_cmd_dfu_flash_upload_finish_idx) + /**Reset device**/ + void ble_rsp_system_reset (const void *nul); + + /**Hello - command for testing**/ + void ble_rsp_system_hello (const void *nul); + + /**Get device bluetooth address**/ + void ble_rsp_system_address_get (const struct ble_msg_system_address_get_rsp_t *msg); + + /**write register**/ + void ble_rsp_system_reg_write (const struct ble_msg_system_reg_write_rsp_t *msg); + + /**read register**/ + void ble_rsp_system_reg_read (const struct ble_msg_system_reg_read_rsp_t *msg); + + /**get and reset packet counters**/ + void ble_rsp_system_get_counters (const struct ble_msg_system_get_counters_rsp_t *msg); + + /**Get status from all connections**/ + void ble_rsp_system_get_connections (const struct ble_msg_system_get_connections_rsp_t *msg); + + /**Read Memory**/ + void ble_rsp_system_read_memory (const struct ble_msg_system_read_memory_rsp_t *msg); + + /**Get Device info**/ + void ble_rsp_system_get_info (const struct ble_msg_system_get_info_rsp_t *msg); + + /**Send data to endpoint, error is returned if endpoint does not have enough space**/ + void ble_rsp_system_endpoint_tx (const struct ble_msg_system_endpoint_tx_rsp_t *msg); + + /**Add entry to whitelist**/ + void ble_rsp_system_whitelist_append (const struct ble_msg_system_whitelist_append_rsp_t *msg); + + /**Remove entry from whitelist**/ + void ble_rsp_system_whitelist_remove (const struct ble_msg_system_whitelist_remove_rsp_t *msg); + + /**Add entry to whitelist**/ + void ble_rsp_system_whitelist_clear (const void *nul); + + /**Read data from endpoint, error is returned if endpoint does not have enough data.**/ + void ble_rsp_system_endpoint_rx (const struct ble_msg_system_endpoint_rx_rsp_t *msg); + + /**Set watermarks on both input and output side**/ + void ble_rsp_system_endpoint_set_watermarks ( + const struct ble_msg_system_endpoint_set_watermarks_rsp_t *msg); + + /**Set encryption key that will be used with aes_encrypt and aes_decrypt commands.**/ + void ble_rsp_system_aes_setkey (const void *nul); + + /**Encrypt one block of data**/ + void ble_rsp_system_aes_encrypt (const struct ble_msg_system_aes_encrypt_rsp_t *msg); + + /**Decrypt one block of data**/ + void ble_rsp_system_aes_decrypt (const struct ble_msg_system_aes_decrypt_rsp_t *msg); + + /**Defragment persistent store**/ + void ble_rsp_flash_ps_defrag (const void *nul); + + /**Dump all ps keys**/ + void ble_rsp_flash_ps_dump (const void *nul); + + /**erase all ps keys**/ + void ble_rsp_flash_ps_erase_all (const void *nul); + + /**save ps key**/ + void ble_rsp_flash_ps_save (const struct ble_msg_flash_ps_save_rsp_t *msg); + + /**load ps key**/ + void ble_rsp_flash_ps_load (const struct ble_msg_flash_ps_load_rsp_t *msg); + + /**erase ps key**/ + void ble_rsp_flash_ps_erase (const void *nul); + + /**erase flash page**/ + void ble_rsp_flash_erase_page (const struct ble_msg_flash_erase_page_rsp_t *msg); + + /**write data to user data area**/ + void ble_rsp_flash_write_data (const struct ble_msg_flash_write_data_rsp_t *msg); + + /**read data from user data area.**/ + void ble_rsp_flash_read_data (const struct ble_msg_flash_read_data_rsp_t *msg); + + /**Write to attribute database**/ + void ble_rsp_attributes_write (const struct ble_msg_attributes_write_rsp_t *msg); + + /**Read from attribute database**/ + void ble_rsp_attributes_read (const struct ble_msg_attributes_read_rsp_t *msg); + + /**Read attribute type from database**/ + void ble_rsp_attributes_read_type (const struct ble_msg_attributes_read_type_rsp_t *msg); + + /**Respond to user attribute read request**/ + void ble_rsp_attributes_user_read_response (const void *nul); + + /**Response to attribute_changed event where reason is user-attribute write.**/ + void ble_rsp_attributes_user_write_response (const void *nul); + + /**Send notification or indication to remote device.**/ + void ble_rsp_attributes_send (const struct ble_msg_attributes_send_rsp_t *msg); + + /**Disconnect connection, starts a disconnection procedure on connection**/ + void ble_rsp_connection_disconnect (const struct ble_msg_connection_disconnect_rsp_t *msg); + + /**Get Link RSSI**/ + void ble_rsp_connection_get_rssi (const struct ble_msg_connection_get_rssi_rsp_t *msg); + + /**Update connection parameters**/ + void ble_rsp_connection_update (const struct ble_msg_connection_update_rsp_t *msg); + + /**Request version exchange**/ + void ble_rsp_connection_version_update ( + const struct ble_msg_connection_version_update_rsp_t *msg); + + /**Get Current channel map**/ + void ble_rsp_connection_channel_map_get ( + const struct ble_msg_connection_channel_map_get_rsp_t *msg); + + /**Set Channel map**/ + void ble_rsp_connection_channel_map_set ( + const struct ble_msg_connection_channel_map_set_rsp_t *msg); + + /**Remote feature request**/ + void ble_rsp_connection_features_get (const struct ble_msg_connection_features_get_rsp_t *msg); + + /**Get Connection Status Parameters**/ + void ble_rsp_connection_get_status (const struct ble_msg_connection_get_status_rsp_t *msg); + + /**Raw TX**/ + void ble_rsp_connection_raw_tx (const struct ble_msg_connection_raw_tx_rsp_t *msg); + + /**Discover attributes by type and value**/ + void ble_rsp_attclient_find_by_type_value ( + const struct ble_msg_attclient_find_by_type_value_rsp_t *msg); + + /**Discover attributes by type and value**/ + void ble_rsp_attclient_read_by_group_type ( + const struct ble_msg_attclient_read_by_group_type_rsp_t *msg); + + /**Read all attributes where type matches**/ + void ble_rsp_attclient_read_by_type (const struct ble_msg_attclient_read_by_type_rsp_t *msg); + + /**Discover Attribute handle and type mappings**/ + void ble_rsp_attclient_find_information ( + const struct ble_msg_attclient_find_information_rsp_t *msg); + + /**Read Characteristic value using handle**/ + void ble_rsp_attclient_read_by_handle ( + const struct ble_msg_attclient_read_by_handle_rsp_t *msg); + + /**write data to attribute**/ + void ble_rsp_attclient_attribute_write ( + const struct ble_msg_attclient_attribute_write_rsp_t *msg); + + /**write data to attribute using ATT write command**/ + void ble_rsp_attclient_write_command (const struct ble_msg_attclient_write_command_rsp_t *msg); + + /**Send confirmation for received indication, use only if manual indications are enabled**/ + void ble_rsp_attclient_indicate_confirm ( + const struct ble_msg_attclient_indicate_confirm_rsp_t *msg); + + /**Read Long Characteristic value**/ + void ble_rsp_attclient_read_long (const struct ble_msg_attclient_read_long_rsp_t *msg); + + /**Send prepare write request to remote host**/ + void ble_rsp_attclient_prepare_write (const struct ble_msg_attclient_prepare_write_rsp_t *msg); + + /**Send prepare write request to remote host**/ + void ble_rsp_attclient_execute_write (const struct ble_msg_attclient_execute_write_rsp_t *msg); + + /**Read multiple attributes from server**/ + void ble_rsp_attclient_read_multiple (const struct ble_msg_attclient_read_multiple_rsp_t *msg); + + /**Enable encryption on link**/ + void ble_rsp_sm_encrypt_start (const struct ble_msg_sm_encrypt_start_rsp_t *msg); + + /**Set device to bondable mode**/ + void ble_rsp_sm_set_bondable_mode (const void *nul); + + /**delete bonding information from ps store**/ + void ble_rsp_sm_delete_bonding (const struct ble_msg_sm_delete_bonding_rsp_t *msg); + + /**set pairing requirements**/ + void ble_rsp_sm_set_parameters (const void *nul); + + /**Passkey entered**/ + void ble_rsp_sm_passkey_entry (const struct ble_msg_sm_passkey_entry_rsp_t *msg); + + /**List all bonded devices**/ + void ble_rsp_sm_get_bonds (const struct ble_msg_sm_get_bonds_rsp_t *msg); + + /** + Set out-of-band encryption data for device + Device does not allow any other kind of pairing except oob if oob data is set. + **/ + void ble_rsp_sm_set_oob_data (const void *nul); + + /** + Add all bonded devices with a known public or static address to + the whitelist. Previous entries in the whitelist are first + cleared. This command can't be used while advertising, scanning + or being connected. + **/ + void ble_rsp_sm_whitelist_bonds (const struct ble_msg_sm_whitelist_bonds_rsp_t *msg); + + /**Set GAP central/peripheral privacy flags + **/ + void ble_rsp_gap_set_privacy_flags (const void *nul); + + /**Set discoverable and connectable mode**/ + void ble_rsp_gap_set_mode (const struct ble_msg_gap_set_mode_rsp_t *msg); + + /**start or stop discover procedure**/ + void ble_rsp_gap_discover (const struct ble_msg_gap_discover_rsp_t *msg); + + /**Direct connection**/ + void ble_rsp_gap_connect_direct (const struct ble_msg_gap_connect_direct_rsp_t *msg); + + /**End current GAP procedure**/ + void ble_rsp_gap_end_procedure (const struct ble_msg_gap_end_procedure_rsp_t *msg); + + /**Connect to any device on whitelist**/ + void ble_rsp_gap_connect_selective (const struct ble_msg_gap_connect_selective_rsp_t *msg); + + /**Set scan and advertising filtering parameters**/ + void ble_rsp_gap_set_filtering (const struct ble_msg_gap_set_filtering_rsp_t *msg); + + /**Set scan parameters**/ + void ble_rsp_gap_set_scan_parameters (const struct ble_msg_gap_set_scan_parameters_rsp_t *msg); + + /**Set advertising parameters**/ + void ble_rsp_gap_set_adv_parameters (const struct ble_msg_gap_set_adv_parameters_rsp_t *msg); + + /**Set advertisement or scan response data. Use broadcast mode to advertise data**/ + void ble_rsp_gap_set_adv_data (const struct ble_msg_gap_set_adv_data_rsp_t *msg); + + /**Sets device to Directed Connectable Mode + Uses fast advertisement procedure for 1.28s after which device enters + nonconnectable mode. If device has valid reconnection characteristic value, it is used for + connection otherwise passed address and address type are used + **/ + void ble_rsp_gap_set_directed_connectable_mode ( + const struct ble_msg_gap_set_directed_connectable_mode_rsp_t *msg); + + /**Configure I/O-port interrupts**/ + void ble_rsp_hardware_io_port_config_irq ( + const struct ble_msg_hardware_io_port_config_irq_rsp_t *msg); + + /**Set soft timer to send events**/ + void ble_rsp_hardware_set_soft_timer (const struct ble_msg_hardware_set_soft_timer_rsp_t *msg); + + /**Read A/D conversion**/ + void ble_rsp_hardware_adc_read (const struct ble_msg_hardware_adc_read_rsp_t *msg); + + /**Configure I/O-port direction**/ + void ble_rsp_hardware_io_port_config_direction ( + const struct ble_msg_hardware_io_port_config_direction_rsp_t *msg); + + /**Configure I/O-port function**/ + void ble_rsp_hardware_io_port_config_function ( + const struct ble_msg_hardware_io_port_config_function_rsp_t *msg); + + /**Configure I/O-port pull-up/pull-down**/ + void ble_rsp_hardware_io_port_config_pull ( + const struct ble_msg_hardware_io_port_config_pull_rsp_t *msg); + + /**Write I/O-port**/ + void ble_rsp_hardware_io_port_write (const struct ble_msg_hardware_io_port_write_rsp_t *msg); + + /**Read I/O-port**/ + void ble_rsp_hardware_io_port_read (const struct ble_msg_hardware_io_port_read_rsp_t *msg); + + /**Configure SPI**/ + void ble_rsp_hardware_spi_config (const struct ble_msg_hardware_spi_config_rsp_t *msg); + + /**Transfer SPI data**/ + void ble_rsp_hardware_spi_transfer (const struct ble_msg_hardware_spi_transfer_rsp_t *msg); + + /**Read data from I2C bus using bit-bang in cc2540. I2C clk is in P1.7 data in P1.6. Pull-up + * must be enabled on pins**/ + void ble_rsp_hardware_i2c_read (const struct ble_msg_hardware_i2c_read_rsp_t *msg); + + /**Write data to I2C bus using bit-bang in cc2540. I2C clk is in P1.7 data in P1.6. Pull-up must + * be enabled on pins**/ + void ble_rsp_hardware_i2c_write (const struct ble_msg_hardware_i2c_write_rsp_t *msg); + + /**Set TX Power**/ + void ble_rsp_hardware_set_txpower (const void *nul); + + /**Set comparator for timer channel**/ + void ble_rsp_hardware_timer_comparator ( + const struct ble_msg_hardware_timer_comparator_rsp_t *msg); + + /**Enable I/O-port interrupts**/ + void ble_rsp_hardware_io_port_irq_enable ( + const struct ble_msg_hardware_io_port_irq_enable_rsp_t *msg); + + /**Set I/O-port interrupt direction**/ + void ble_rsp_hardware_io_port_irq_direction ( + const struct ble_msg_hardware_io_port_irq_direction_rsp_t *msg); + + /**Enable or disable analog comparator**/ + void ble_rsp_hardware_analog_comparator_enable (const void *nul); + + /**Read analog comparator output**/ + void ble_rsp_hardware_analog_comparator_read ( + const struct ble_msg_hardware_analog_comparator_read_rsp_t *msg); + + /**Configure analog comparator interrupt**/ + void ble_rsp_hardware_analog_comparator_config_irq ( + const struct ble_msg_hardware_analog_comparator_config_irq_rsp_t *msg); + + /**Set RX Sensitivity**/ + void ble_rsp_hardware_set_rxgain (const void *nul); + + /**Enable or disable USB**/ + void ble_rsp_hardware_usb_enable (const struct ble_msg_hardware_usb_enable_rsp_t *msg); + + /**Start packet transmission, send one packet at every 625us**/ + void ble_rsp_test_phy_tx (const void *nul); + + /**Start receive test**/ + void ble_rsp_test_phy_rx (const void *nul); + + /**End test, and report received packets**/ + void ble_rsp_test_phy_end (const struct ble_msg_test_phy_end_rsp_t *msg); + + /**Reset test**/ + void ble_rsp_test_phy_reset (const void *nul); + + /**Get current channel quality map**/ + void ble_rsp_test_get_channel_map (const struct ble_msg_test_get_channel_map_rsp_t *msg); + + /**Debug command**/ + void ble_rsp_test_debug (const struct ble_msg_test_debug_rsp_t *msg); + + /**Set channel quality measurement mode**/ + void ble_rsp_test_channel_mode (const void *nul); + + /**Reset system**/ + void ble_rsp_dfu_reset (const void *nul); + + /**set address for flashing**/ + void ble_rsp_dfu_flash_set_address (const struct ble_msg_dfu_flash_set_address_rsp_t *msg); + + /**Upload binary for flashing. Address will be updated automatically.**/ + void ble_rsp_dfu_flash_upload (const struct ble_msg_dfu_flash_upload_rsp_t *msg); + + /**Uploading is finished.**/ + void ble_rsp_dfu_flash_upload_finish (const struct ble_msg_dfu_flash_upload_finish_rsp_t *msg); + + /**Device booted up, and is ready to receive commands**/ + void ble_evt_system_boot (const struct ble_msg_system_boot_evt_t *msg); + + /**Debug data output**/ + void ble_evt_system_debug (const struct ble_msg_system_debug_evt_t *msg); + + /**Endpoint receive size crossed watermark**/ + void ble_evt_system_endpoint_watermark_rx ( + const struct ble_msg_system_endpoint_watermark_rx_evt_t *msg); + + /**Endpoint transmit size crossed watermark**/ + void ble_evt_system_endpoint_watermark_tx ( + const struct ble_msg_system_endpoint_watermark_tx_evt_t *msg); + + /**Script failure detected**/ + void ble_evt_system_script_failure (const struct ble_msg_system_script_failure_evt_t *msg); + + /**No valid license key found**/ + void ble_evt_system_no_license_key (const void *nul); + + /**Protocol error in command parser**/ + void ble_evt_system_protocol_error (const struct ble_msg_system_protocol_error_evt_t *msg); + + /**Dump key result**/ + void ble_evt_flash_ps_key (const struct ble_msg_flash_ps_key_evt_t *msg); + + /**Attribute value has changed**/ + void ble_evt_attributes_value (const struct ble_msg_attributes_value_evt_t *msg); + + /**User-backed attribute data requested**/ + void ble_evt_attributes_user_read_request ( + const struct ble_msg_attributes_user_read_request_evt_t *msg); + + /**attribute status flags has changed**/ + void ble_evt_attributes_status (const struct ble_msg_attributes_status_evt_t *msg); + + /**Connection opened**/ + void ble_evt_connection_status (const struct ble_msg_connection_status_evt_t *msg); + + /**Remote version information**/ + void ble_evt_connection_version_ind (const struct ble_msg_connection_version_ind_evt_t *msg); + + /**Remote feature information**/ + void ble_evt_connection_feature_ind (const struct ble_msg_connection_feature_ind_evt_t *msg); + + /**Raw RX**/ + void ble_evt_connection_raw_rx (const struct ble_msg_connection_raw_rx_evt_t *msg); + + /**Link Disconnected**/ + void ble_evt_connection_disconnected (const struct ble_msg_connection_disconnected_evt_t *msg); + + /**Attribute indication has been acknowledged**/ + void ble_evt_attclient_indicated (const struct ble_msg_attclient_indicated_evt_t *msg); + + /**GATT procedure completed**/ + void ble_evt_attclient_procedure_completed ( + const struct ble_msg_attclient_procedure_completed_evt_t *msg); + + /**group discovery return**/ + void ble_evt_attclient_group_found (const struct ble_msg_attclient_group_found_evt_t *msg); + + /**characteristics found**/ + void ble_evt_attclient_attribute_found ( + const struct ble_msg_attclient_attribute_found_evt_t *msg); + + /**Handle type mapping found**/ + void ble_evt_attclient_find_information_found ( + const struct ble_msg_attclient_find_information_found_evt_t *msg); + + /**attribute value returned**/ + void ble_evt_attclient_attribute_value ( + const struct ble_msg_attclient_attribute_value_evt_t *msg); + + /**Response to read multiple request**/ + void ble_evt_attclient_read_multiple_response ( + const struct ble_msg_attclient_read_multiple_response_evt_t *msg); + + /**SMP data output**/ + void ble_evt_sm_smp_data (const struct ble_msg_sm_smp_data_evt_t *msg); + + /**Link bonding has failed**/ + void ble_evt_sm_bonding_fail (const struct ble_msg_sm_bonding_fail_evt_t *msg); + + /**Passkey to be entered to remote device**/ + void ble_evt_sm_passkey_display (const struct ble_msg_sm_passkey_display_evt_t *msg); + + /**Passkey Requested**/ + void ble_evt_sm_passkey_request (const struct ble_msg_sm_passkey_request_evt_t *msg); + + /**Bond status information**/ + void ble_evt_sm_bond_status (const struct ble_msg_sm_bond_status_evt_t *msg); + + /**Scan Response**/ + void ble_evt_gap_scan_response (const struct ble_msg_gap_scan_response_evt_t *msg); + + /**Not used**/ + void ble_evt_gap_mode_changed (const struct ble_msg_gap_mode_changed_evt_t *msg); + + /**I/O-port state**/ + void ble_evt_hardware_io_port_status (const struct ble_msg_hardware_io_port_status_evt_t *msg); + + /**soft timer event**/ + void ble_evt_hardware_soft_timer (const struct ble_msg_hardware_soft_timer_evt_t *msg); + + /**adc result**/ + void ble_evt_hardware_adc_result (const struct ble_msg_hardware_adc_result_evt_t *msg); + + /**This event is produced when analog comparator output changes**/ + void ble_evt_hardware_analog_comparator_status ( + const struct ble_msg_hardware_analog_comparator_status_evt_t *msg); + + /**Device booted up in dfu, and is ready to receive commands**/ + void ble_evt_dfu_boot (const struct ble_msg_dfu_boot_evt_t *msg); + + + struct ble_class_handler_t + { + const struct ble_msg *const *msgs; + uint8 maxhandlers; + }; + extern const struct ble_class_handler_t ble_class_rsp_handlers[ble_cls_last]; + extern const struct ble_class_handler_t ble_class_evt_handlers[ble_cls_last]; + + void ble_default (const void *); +#ifdef __cplusplus +} +#endif +/*lint -restore*/ +#endif diff --git a/deps/include/brainflow/board_controller/muse/muse_bglib/inc/muse_bglib_helper.h b/deps/include/brainflow/board_controller/muse/muse_bglib/inc/muse_bglib_helper.h new file mode 100644 index 000000000..5464ce9f0 --- /dev/null +++ b/deps/include/brainflow/board_controller/muse/muse_bglib/inc/muse_bglib_helper.h @@ -0,0 +1,130 @@ +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "cmd_def.h" + +#include "brainflow_constants.h" +#include "brainflow_input_params.h" +#include "data_buffer.h" +#include "json.hpp" + +using json = nlohmann::json; + +enum class DeviceState : int +{ + NONE = 0, + INIT_CALLED = 1, + INITIAL_CONNECTION = 2, + OPEN_CALLED = 3, + CONFIG_CALLED = 4, + CLOSE_CALLED = 5, + GET_DATA_CALLED = 6, + WRITE_TO_CLIENT_CHAR = 7 +}; + +class MuseBGLibHelper +{ + +protected: + int board_id; + volatile bool should_stop_stream; + std::thread read_characteristic_thread; + + volatile bd_addr connect_addr; + volatile uint8 connection; + volatile uint16 muse_handle_start; + volatile uint16 muse_handle_end; + volatile int state; + volatile bool initialized; + struct BrainFlowInputParams input_params; + std::set ccids; + uint16 control_char_handle; + std::map characteristics; + DataBuffer *db_default; + DataBuffer *db_aux; + DataBuffer *db_anc; + json board_descr; + std::vector> current_default_buf; + std::vector> current_aux_buf; + std::vector> current_anc_buf; + std::vector new_eeg_data; + std::vector new_ppg_data; + double last_fifth_chan_timestamp; // used to determine 4 or 5 channels used + double last_ppg_timestamp; // used for timestamp correction + double last_eeg_timestamp; // used for timestamp correction + double last_aux_timestamp; // used for timestamp correction + + void thread_worker (); + +public: + volatile int exit_code; + + MuseBGLibHelper (int board_id, json descr) + { + this->board_id = board_id; + exit_code = (int)BrainFlowExitCodes::SYNC_TIMEOUT_ERROR; + connection = -1; + muse_handle_start = 0; + muse_handle_end = 0; + state = (int)DeviceState::NONE; + should_stop_stream = true; + initialized = false; + control_char_handle = 0; + db_default = NULL; + db_anc = NULL; + db_aux = NULL; + board_descr = descr; + last_fifth_chan_timestamp = -1.0; + last_aux_timestamp = -1.0; + last_eeg_timestamp = -1.0; + last_ppg_timestamp = -1.0; + } + + virtual ~MuseBGLibHelper () + { + release (); + } + + MuseBGLibHelper (const MuseBGLibHelper &other) = delete; + MuseBGLibHelper &operator= (const MuseBGLibHelper &other) = delete; + + // methods from dll which will be called + virtual int initialize (struct BrainFlowInputParams params); + virtual int open_device (); + virtual int stop_stream (); + virtual int start_stream (); + virtual int close_device (); + virtual int get_data_default (void *param); + virtual int get_data_aux (void *param); + virtual int get_data_anc (void *param); + virtual int release (); + virtual int config_device (const char *config); + + // callbacks from bglib which we need + virtual void ble_evt_connection_status (const struct ble_msg_connection_status_evt_t *msg); + virtual void ble_evt_connection_disconnected ( + const struct ble_msg_connection_disconnected_evt_t *msg); + virtual void ble_evt_attclient_group_found ( + const struct ble_msg_attclient_group_found_evt_t *msg); + virtual void ble_evt_attclient_procedure_completed ( + const struct ble_msg_attclient_procedure_completed_evt_t *msg); + virtual void ble_evt_attclient_find_information_found ( + const struct ble_msg_attclient_find_information_found_evt_t *msg); + virtual void ble_evt_attclient_attribute_value ( + const struct ble_msg_attclient_attribute_value_evt_t *msg); + virtual void ble_evt_gap_scan_response (const struct ble_msg_gap_scan_response_evt_t *msg); + + // helpers + virtual int read_message (); + virtual int connect_ble_dev (); + virtual int wait_for_callback (); + virtual int reset_ble_dev (); +}; diff --git a/deps/include/brainflow/board_controller/muse/muse_bglib/inc/muse_functions.h b/deps/include/brainflow/board_controller/muse/muse_bglib/inc/muse_functions.h new file mode 100644 index 000000000..8276fe208 --- /dev/null +++ b/deps/include/brainflow/board_controller/muse/muse_bglib/inc/muse_functions.h @@ -0,0 +1,20 @@ +#include "shared_export.h" + + +#ifdef __cplusplus +extern "C" +{ +#endif + SHARED_EXPORT int CALLING_CONVENTION initialize (void *param); + SHARED_EXPORT int CALLING_CONVENTION open_device (void *param); + SHARED_EXPORT int CALLING_CONVENTION stop_stream (void *param); + SHARED_EXPORT int CALLING_CONVENTION start_stream (void *param); + SHARED_EXPORT int CALLING_CONVENTION close_device (void *param); + SHARED_EXPORT int CALLING_CONVENTION get_data_default (void *param); + SHARED_EXPORT int CALLING_CONVENTION get_data_aux (void *param); + SHARED_EXPORT int CALLING_CONVENTION get_data_anc (void *param); + SHARED_EXPORT int CALLING_CONVENTION release (void *param); + SHARED_EXPORT int CALLING_CONVENTION config_device (void *param); +#ifdef __cplusplus +} +#endif diff --git a/deps/include/brainflow/board_controller/muse/muse_bglib/inc/uart.h b/deps/include/brainflow/board_controller/muse/muse_bglib/inc/uart.h new file mode 100644 index 000000000..f2efcd150 --- /dev/null +++ b/deps/include/brainflow/board_controller/muse/muse_bglib/inc/uart.h @@ -0,0 +1,10 @@ +#ifndef UART_H +#define UART_H + +void uart_list_devices (); +int uart_find_serialport (char *name); +int uart_open (const char *port); +void uart_close (); +int uart_tx (int len, unsigned char *data); +int uart_rx (int len, unsigned char *data, int timeout_ms); +#endif // UART_H diff --git a/deps/include/brainflow/board_controller/muse/muse_bglib/main.cpp b/deps/include/brainflow/board_controller/muse/muse_bglib/main.cpp new file mode 100644 index 000000000..e094e52db --- /dev/null +++ b/deps/include/brainflow/board_controller/muse/muse_bglib/main.cpp @@ -0,0 +1,132 @@ +#include +#include + +#include "brainflow_constants.h" +#include "brainflow_input_params.h" + +#include "json.hpp" +#include "muse_bglib_helper.h" +#include "muse_functions.h" +#include "uart.h" + +using json = nlohmann::json; + + +MuseBGLibHelper *helper = NULL; + + +void output (uint8 len1, uint8 *data1, uint16 len2, uint8 *data2) +{ + if (helper != NULL) + { + if (uart_tx (len1, data1) || uart_tx (len2, data2)) + { + } + } +} + +int initialize (void *param) +{ + if (helper != NULL) + { + return (int)BrainFlowExitCodes::ANOTHER_BOARD_IS_CREATED_ERROR; + } + std::tuple *info = + (std::tuple *)param; + helper = new MuseBGLibHelper (std::get<0> (*info), std::get<2> (*info)); + int res = helper->initialize (std::get<1> (*info)); + if (res != (int)BrainFlowExitCodes::STATUS_OK) + { + delete helper; + helper = NULL; + } + else + { + bglib_output = output; + } + return res; +} + +int open_device (void *param) +{ + if (helper == NULL) + { + return (int)BrainFlowExitCodes::BOARD_NOT_CREATED_ERROR; + } + return helper->open_device (); +} + +int stop_stream (void *param) +{ + if (helper == NULL) + { + return (int)BrainFlowExitCodes::BOARD_NOT_CREATED_ERROR; + } + return helper->stop_stream (); +} + +int start_stream (void *param) +{ + if (helper == NULL) + { + return (int)BrainFlowExitCodes::BOARD_NOT_CREATED_ERROR; + } + return helper->start_stream (); +} + +int close_device (void *param) +{ + if (helper == NULL) + { + return (int)BrainFlowExitCodes::BOARD_NOT_CREATED_ERROR; + } + return helper->close_device (); +} + +int get_data_default (void *param) +{ + if (helper == NULL) + { + return (int)BrainFlowExitCodes::BOARD_NOT_CREATED_ERROR; + } + return helper->get_data_default (param); +} + +int get_data_aux (void *param) +{ + if (helper == NULL) + { + return (int)BrainFlowExitCodes::BOARD_NOT_CREATED_ERROR; + } + return helper->get_data_aux (param); +} + +int get_data_anc (void *param) +{ + if (helper == NULL) + { + return (int)BrainFlowExitCodes::BOARD_NOT_CREATED_ERROR; + } + return helper->get_data_anc (param); +} + +int release (void *param) +{ + if (helper == NULL) + { + return (int)BrainFlowExitCodes::BOARD_NOT_CREATED_ERROR; + } + int res = helper->release (); + delete helper; + helper = NULL; + return res; +} + +int config_device (void *param) +{ + if (helper == NULL) + { + return (int)BrainFlowExitCodes::BOARD_NOT_CREATED_ERROR; + } + return helper->config_device ((const char *)param); +} diff --git a/deps/include/brainflow/board_controller/muse/muse_bglib/muse_bglib_helper.cpp b/deps/include/brainflow/board_controller/muse/muse_bglib/muse_bglib_helper.cpp new file mode 100644 index 000000000..362fa1ad3 --- /dev/null +++ b/deps/include/brainflow/board_controller/muse/muse_bglib/muse_bglib_helper.cpp @@ -0,0 +1,840 @@ +#include +#include +#include + +#include "custom_cast.h" +#include "muse_bglib_helper.h" +#include "muse_constants.h" +#include "timestamp.h" +#include "uart.h" + +#ifdef _WIN32 +#include +#else +#include +#endif + + +int MuseBGLibHelper::initialize (struct BrainFlowInputParams params) +{ + if (!initialized) + { + input_params = params; + exit_code = (int)BrainFlowExitCodes::SYNC_TIMEOUT_ERROR; + int buffer_size_default = board_descr["default"]["num_rows"].get (); + int buffer_size_aux = board_descr["auxiliary"]["num_rows"].get (); + if (db_default != NULL) + { + delete db_default; + db_default = NULL; + } + db_default = new DataBuffer (buffer_size_default, 1000); + if (db_aux != NULL) + { + delete db_aux; + db_aux = NULL; + } + db_aux = new DataBuffer (buffer_size_aux, 1000); + if (board_id != (int)BoardIds::MUSE_2016_BLED_BOARD) + { + int buffer_size_anc = board_descr["ancillary"]["num_rows"].get (); + current_anc_buf.resize (6); // 6 ppg packages in single transaction + for (int i = 0; i < 6; i++) + { + current_anc_buf[i].resize (buffer_size_anc); + std::fill (current_anc_buf[i].begin (), current_anc_buf[i].end (), 0.0); + } + new_ppg_data.resize (3); // 3 ppg chars + std::fill (new_ppg_data.begin (), new_ppg_data.end (), false); + if (db_anc != NULL) + { + delete db_anc; + db_anc = NULL; + } + db_anc = new DataBuffer (buffer_size_anc, 1000); + } + current_default_buf.resize (12); // 12 eeg packages in single ble transaction + new_eeg_data.resize (5); // 5 eeg channels total + current_aux_buf.resize (3); // 3 samples in each message for gyro and accel + for (int i = 0; i < 12; i++) + { + current_default_buf[i].resize (buffer_size_default); + std::fill (current_default_buf[i].begin (), current_default_buf[i].end (), 0.0); + } + std::fill (new_eeg_data.begin (), new_eeg_data.end (), false); + for (int i = 0; i < 3; i++) + { + current_aux_buf[i].resize (buffer_size_aux); + std::fill (current_aux_buf[i].begin (), current_aux_buf[i].end (), 0.0); + } + initialized = true; + } + return (int)BrainFlowExitCodes::STATUS_OK; +} + +int MuseBGLibHelper::open_device () +{ + if (!initialized) + { + return (int)BrainFlowExitCodes::BOARD_NOT_CREATED_ERROR; + } + int res = reset_ble_dev (); + if (res == (int)BrainFlowExitCodes::STATUS_OK) + { + exit_code = (int)BrainFlowExitCodes::SYNC_TIMEOUT_ERROR; + state = (int)DeviceState::OPEN_CALLED; + ble_cmd_gap_discover (gap_discover_observation); + res = wait_for_callback (); + } + if (res == (int)BrainFlowExitCodes::STATUS_OK) + { + ble_cmd_gap_end_procedure (); + res = connect_ble_dev (); + } + if (res == (int)BrainFlowExitCodes::STATUS_OK) + { + res = config_device ("p21"); + } + + return res; +} + +int MuseBGLibHelper::stop_stream () +{ + if (!initialized) + { + return (int)BrainFlowExitCodes::BOARD_NOT_CREATED_ERROR; + } + if (!should_stop_stream) + { + should_stop_stream = true; + read_characteristic_thread.join (); + int res = (int)BrainFlowExitCodes::STATUS_OK; + // for sanity check + for (int i = 0; i < 5; i++) + { + const char *stop_cmd = "h"; + res = config_device (stop_cmd); + } + last_fifth_chan_timestamp = -1.0; + last_aux_timestamp = -1.0; + last_eeg_timestamp = -1.0; + last_ppg_timestamp = -1.0; + return res; + } + else + { + return (int)BrainFlowExitCodes::STREAM_THREAD_IS_NOT_RUNNING; + } +} + +int MuseBGLibHelper::start_stream () +{ + // from silicanlabs forum - write 0x00001 to enable notifications + if (!initialized) + { + return (int)BrainFlowExitCodes::BOARD_NOT_CREATED_ERROR; + } + if (should_stop_stream == false) + { + return (int)BrainFlowExitCodes::STREAM_ALREADY_RUN_ERROR; + } + uint8 configuration[] = {0x01, 0x00}; + for (uint16 ccid : ccids) + { + state = (int)DeviceState::WRITE_TO_CLIENT_CHAR; + exit_code = (int)BrainFlowExitCodes::SYNC_TIMEOUT_ERROR; + ble_cmd_attclient_attribute_write (connection, ccid, 2, &configuration); + ble_cmd_attclient_execute_write (connection, 1); + int res = wait_for_callback (); + if (res != (int)BrainFlowExitCodes::STATUS_OK) + { + return res; + } + } + int res = config_device ("d"); + if (res == (int)BrainFlowExitCodes::STATUS_OK) + { + should_stop_stream = false; + read_characteristic_thread = std::thread ([this] { this->thread_worker (); }); + } + + return res; +} + +int MuseBGLibHelper::close_device () +{ + if (!initialized) + { + return (int)BrainFlowExitCodes::BOARD_NOT_CREATED_ERROR; + } + state = (int)DeviceState::CLOSE_CALLED; + stop_stream (); + uart_close (); + return (int)BrainFlowExitCodes::STATUS_OK; +} + +int MuseBGLibHelper::get_data_default (void *param) +{ + if (!initialized) + { + return (int)BrainFlowExitCodes::BOARD_NOT_CREATED_ERROR; + } + state = (int)DeviceState::GET_DATA_CALLED; + int res = (int)BrainFlowExitCodes::STATUS_OK; + size_t num_points = db_default->get_data (1, (double *)param); + if (num_points != 1) + { + res = (int)BrainFlowExitCodes::EMPTY_BUFFER_ERROR; + } + return res; +} + +int MuseBGLibHelper::get_data_aux (void *param) +{ + if (!initialized) + { + return (int)BrainFlowExitCodes::BOARD_NOT_CREATED_ERROR; + } + state = (int)DeviceState::GET_DATA_CALLED; + int res = (int)BrainFlowExitCodes::STATUS_OK; + size_t num_points = db_aux->get_data (1, (double *)param); + if (num_points != 1) + { + res = (int)BrainFlowExitCodes::EMPTY_BUFFER_ERROR; + } + return res; +} + +int MuseBGLibHelper::get_data_anc (void *param) +{ + if (!initialized) + { + return (int)BrainFlowExitCodes::BOARD_NOT_CREATED_ERROR; + } + state = (int)DeviceState::GET_DATA_CALLED; + int res = (int)BrainFlowExitCodes::STATUS_OK; + size_t num_points = db_anc->get_data (1, (double *)param); + if (num_points != 1) + { + res = (int)BrainFlowExitCodes::EMPTY_BUFFER_ERROR; + } + return res; +} + +int MuseBGLibHelper::release () +{ + close_device (); + exit_code = (int)BrainFlowExitCodes::SYNC_TIMEOUT_ERROR; + connection = -1; + muse_handle_start = 0; + muse_handle_end = 0; + state = (int)DeviceState::NONE; + should_stop_stream = true; + initialized = false; + control_char_handle = 0; + ccids.clear (); + characteristics.clear (); + if (db_default) + { + delete db_default; + db_default = NULL; + } + if (db_aux) + { + delete db_aux; + db_aux = NULL; + } + if (db_anc) + { + delete db_anc; + db_anc = NULL; + } + new_eeg_data.clear (); + for (size_t i = 0; i < current_default_buf.size (); i++) + { + current_default_buf[i].clear (); + } + current_default_buf.clear (); + for (size_t i = 0; i < current_aux_buf.size (); i++) + { + current_aux_buf[i].clear (); + } + current_aux_buf.clear (); + for (size_t i = 0; i < current_anc_buf.size (); i++) + { + current_anc_buf[i].clear (); + } + current_anc_buf.clear (); + + return (int)BrainFlowExitCodes::STATUS_OK; +} + +int MuseBGLibHelper::config_device (const char *config) +{ + if (!initialized) + { + return (int)BrainFlowExitCodes::BOARD_NOT_CREATED_ERROR; + } + uint8 command[16]; + int len = (int)strlen ((char *)config); + command[0] = (uint8)len + 1; + for (int i = 0; i < len; i++) + { + command[i + 1] = int (config[i]); + } + command[len + 1] = 10; + if (control_char_handle == 0) + { + return (int)BrainFlowExitCodes::BOARD_WRITE_ERROR; + } + ble_cmd_attclient_write_command (connection, control_char_handle, len + 2, command); + return (int)BrainFlowExitCodes::STATUS_OK; +} + +///////////////// +/// Callbacks /// +///////////////// + +void MuseBGLibHelper::ble_evt_connection_status (const struct ble_msg_connection_status_evt_t *msg) +{ + // New connection + if (msg->flags & connection_connected) + { + connection = msg->connection; + // this method is called from ble_evt_connection_disconnected need to set exit code only + // when we call this method from connect_ble_device + if (state == (int)DeviceState::INITIAL_CONNECTION) + { + exit_code = (int)BrainFlowExitCodes::STATUS_OK; + } + } +} + +void MuseBGLibHelper::ble_evt_connection_disconnected ( + const struct ble_msg_connection_disconnected_evt_t *msg) +{ + // atempt to reconnect + // changing values here leads to package loss, dont touch it + ble_cmd_gap_connect_direct (&connect_addr, gap_address_type_random, 10, 76, 100, 0); +} + +// ble_evt_attclient_group_found and ble_evt_attclient_procedure_completed are called after the same +// command(ble_cmd_attclient_read_by_group_type) +void MuseBGLibHelper::ble_evt_attclient_group_found ( + const struct ble_msg_attclient_group_found_evt_t *msg) +{ + if (msg->uuid.len == 0) + { + return; + } + uint16 uuid = (msg->uuid.data[1] << 8) | msg->uuid.data[0]; + if (uuid == MUSE_SERVICE_UUID) + { + muse_handle_start = msg->start; + muse_handle_end = msg->end; + } +} + +void MuseBGLibHelper::ble_evt_attclient_procedure_completed ( + const struct ble_msg_attclient_procedure_completed_evt_t *msg) +{ + if ((state == (int)DeviceState::WRITE_TO_CLIENT_CHAR) || + (state == (int)DeviceState::CONFIG_CALLED)) + { + if (msg->result == 0) + { + exit_code = (int)BrainFlowExitCodes::STATUS_OK; + } + } + if (state == (int)DeviceState::OPEN_CALLED) + { + if ((muse_handle_start) && (muse_handle_end)) + { + ble_cmd_attclient_find_information (msg->connection, muse_handle_start, + muse_handle_end); // triggers + // ble_evt_attclient_find_information_found + } + } +} + +void MuseBGLibHelper::ble_evt_attclient_find_information_found ( + const struct ble_msg_attclient_find_information_found_evt_t *msg) +{ + size_t chars_to_find = 10; + size_t ccids_to_find = 14; + if (board_id == (int)BoardIds::MUSE_2016_BLED_BOARD) + { + // no ppg for old muse + chars_to_find = 6; + ccids_to_find = 10; + } + + if (state == (int)DeviceState::OPEN_CALLED) + { + if (msg->uuid.len == 2) + { + uint16 uuid = (msg->uuid.data[1] << 8) | msg->uuid.data[0]; + if (uuid == CLIENT_CHARACTERISTIC_UUID) + { + ccids.insert (msg->chrhandle); + } + } + + if (msg->uuid.len == 16) + { + uint16 uuid_int = (msg->uuid.data[1] << 8) | msg->uuid.data[0]; + char str[37] = {}; + sprintf (str, "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x", + msg->uuid.data[15], msg->uuid.data[14], msg->uuid.data[13], msg->uuid.data[12], + msg->uuid.data[11], msg->uuid.data[10], msg->uuid.data[9], msg->uuid.data[8], + msg->uuid.data[7], msg->uuid.data[6], msg->uuid.data[5], msg->uuid.data[4], + msg->uuid.data[3], msg->uuid.data[2], msg->uuid.data[1], msg->uuid.data[0]); + std::string uuid (str); + if (strcmp (str, MUSE_GATT_ATTR_STREAM_TOGGLE) == 0) + { + control_char_handle = msg->chrhandle; + } + if (strcmp (str, MUSE_GATT_ATTR_TP9) == 0) + { + characteristics[msg->chrhandle] = uuid; + } + if (strcmp (str, MUSE_GATT_ATTR_AF7) == 0) + { + characteristics[msg->chrhandle] = uuid; + } + if (strcmp (str, MUSE_GATT_ATTR_AF8) == 0) + { + characteristics[msg->chrhandle] = uuid; + } + if (strcmp (str, MUSE_GATT_ATTR_TP10) == 0) + { + characteristics[msg->chrhandle] = uuid; + } + if (strcmp (str, MUSE_GATT_ATTR_ACCELEROMETER) == 0) + { + characteristics[msg->chrhandle] = uuid; + } + if (strcmp (str, MUSE_GATT_ATTR_GYRO) == 0) + { + characteristics[msg->chrhandle] = uuid; + } + if (strcmp (str, MUSE_GATT_ATTR_PPG0) == 0) + { + characteristics[msg->chrhandle] = uuid; + } + if (strcmp (str, MUSE_GATT_ATTR_PPG1) == 0) + { + characteristics[msg->chrhandle] = uuid; + } + if (strcmp (str, MUSE_GATT_ATTR_PPG2) == 0) + { + characteristics[msg->chrhandle] = uuid; + } + if (strcmp (str, MUSE_GATT_ATTR_RIGHTAUX) == 0) + { + characteristics[msg->chrhandle] = uuid; + } + } + if ((characteristics.size () == chars_to_find) && + (state == (int)DeviceState::OPEN_CALLED) && (ccids.size () >= ccids_to_find)) + { + exit_code = (int)BrainFlowExitCodes::STATUS_OK; + } + } +} + +void MuseBGLibHelper::ble_evt_attclient_attribute_value ( + const struct ble_msg_attclient_attribute_value_evt_t *msg) +{ + if ((int)msg->value.len != 20) + { + return; + } + std::string uuid = ""; + if (characteristics.find (msg->atthandle) != characteristics.end ()) + { + uuid = characteristics[msg->atthandle]; + } + else + { + return; + } + unsigned char *data = (unsigned char *)msg->value.data; + double current_timestamp = get_timestamp (); + + if (uuid == MUSE_GATT_ATTR_ACCELEROMETER) + { + for (int i = 0; i < 3; i++) + { + double accel_valx = (double)cast_16bit_to_int32 (&data[2 + i * 6]) / 16384; + double accel_valy = (double)cast_16bit_to_int32 (&data[4 + i * 6]) / 16384; + double accel_valz = (double)cast_16bit_to_int32 (&data[6 + i * 6]) / 16384; + current_aux_buf[i][board_descr["auxiliary"]["accel_channels"][0].get ()] = + accel_valx; + current_aux_buf[i][board_descr["auxiliary"]["accel_channels"][1].get ()] = + accel_valy; + current_aux_buf[i][board_descr["auxiliary"]["accel_channels"][2].get ()] = + accel_valz; + } + } + else if (uuid == MUSE_GATT_ATTR_GYRO) + { + unsigned int package_num = data[0] * 256 + data[1]; + for (int i = 0; i < 3; i++) + { + double gyro_valx = + (double)cast_16bit_to_int32 (&data[2 + i * 6]) * MUSE_GYRO_SCALE_FACTOR; + double gyro_valy = + (double)cast_16bit_to_int32 (&data[4 + i * 6]) * MUSE_GYRO_SCALE_FACTOR; + double gyro_valz = + (double)cast_16bit_to_int32 (&data[6 + i * 6]) * MUSE_GYRO_SCALE_FACTOR; + current_aux_buf[i][board_descr["auxiliary"]["gyro_channels"][0].get ()] = + gyro_valx; + current_aux_buf[i][board_descr["auxiliary"]["gyro_channels"][1].get ()] = + gyro_valy; + current_aux_buf[i][board_descr["auxiliary"]["gyro_channels"][2].get ()] = + gyro_valz; + current_aux_buf[i][board_descr["auxiliary"]["package_num_channel"].get ()] = + package_num; + } + // skip first package for timestamp correction + if (last_aux_timestamp > 0) + { + double step = (current_timestamp - last_aux_timestamp) / current_aux_buf.size (); + // push aux packages from gyro callback + for (size_t i = 0; i < current_aux_buf.size (); i++) + { + current_aux_buf[i][board_descr["auxiliary"]["timestamp_channel"].get ()] = + last_aux_timestamp + step * (i + 1); + db_aux->add_data (¤t_aux_buf[i][0]); + } + } + last_aux_timestamp = current_timestamp; + } + else if (((uuid == MUSE_GATT_ATTR_PPG0) || (uuid == MUSE_GATT_ATTR_PPG1) || + (uuid == MUSE_GATT_ATTR_PPG2)) && + (board_id != (int)BoardIds::MUSE_2016_BLED_BOARD)) + { + int ppg_chann_num = 0; + if (uuid == MUSE_GATT_ATTR_PPG0) + { + ppg_chann_num = 0; + } + if (uuid == MUSE_GATT_ATTR_PPG1) + { + ppg_chann_num = 1; + } + if (uuid == MUSE_GATT_ATTR_PPG2) + { + ppg_chann_num = 2; + } + + new_ppg_data[ppg_chann_num] = true; + unsigned int package_num = data[0] * 256 + data[1]; + std::vector ppg_channels = board_descr["ancillary"]["ppg_channels"]; + // format is: 2 bytes for package num, 6 int24 values for actual data + for (int i = 0; i < 6; i++) + { + double ppg_val = (double)cast_24bit_to_int32 (&data[2 + i * 3]); + current_anc_buf[i][ppg_channels[ppg_chann_num]] = ppg_val; + current_anc_buf[i][board_descr["ancillary"]["package_num_channel"].get ()] = + package_num; + } + int num_trues = 0; + for (size_t i = 0; i < new_ppg_data.size (); i++) + { + if (new_ppg_data[i]) + { + num_trues++; + } + } + + if (num_trues == new_ppg_data.size () - 1) // actually it streams only 2 of 3 ppg data types + // and I am not sure that these 2 are freezed + { + if (last_ppg_timestamp > 0) + { + double step = (current_timestamp - last_ppg_timestamp) / current_anc_buf.size (); + for (size_t i = 0; i < current_anc_buf.size (); i++) + { + current_anc_buf[i][board_descr["ancillary"]["timestamp_channel"].get ()] = + last_ppg_timestamp + step * (i + 1); + db_anc->add_data (¤t_anc_buf[i][0]); + } + } + last_ppg_timestamp = current_timestamp; + std::fill (new_ppg_data.begin (), new_ppg_data.end (), false); + } + } + else + { + int pos = -1; + if (uuid == MUSE_GATT_ATTR_TP9) + { + pos = board_descr["default"]["eeg_channels"][0].get (); + new_eeg_data[0] = true; + } + if (uuid == MUSE_GATT_ATTR_AF7) + { + pos = board_descr["default"]["eeg_channels"][1].get (); + new_eeg_data[1] = true; + } + if (uuid == MUSE_GATT_ATTR_AF8) + { + pos = board_descr["default"]["eeg_channels"][2].get (); + new_eeg_data[2] = true; + } + if (uuid == MUSE_GATT_ATTR_TP10) + { + pos = board_descr["default"]["eeg_channels"][3].get (); + new_eeg_data[3] = true; + } + if (uuid == MUSE_GATT_ATTR_RIGHTAUX) + { + pos = board_descr["default"]["other_channels"][0].get (); + new_eeg_data[4] = true; + last_fifth_chan_timestamp = get_timestamp (); + } + + if (pos < 0) + { + return; + } + + unsigned int package_num = data[0] * 256 + data[1]; + for (int i = 2, counter = 0; i < msg->value.len; i += 3, counter += 2) + { + double val1 = data[i] << 4 | data[i + 1] >> 4; + double val2 = (data[i + 1] & 0xF) << 8 | data[i + 2]; + val1 = (val1 - 0x800) * 125.0 / 256.0; + val2 = (val2 - 0x800) * 125.0 / 256.0; + current_default_buf[counter][pos] = val1; + current_default_buf[counter + 1][pos] = val2; + current_default_buf[counter] + [board_descr["default"]["package_num_channel"].get ()] = + package_num; + current_default_buf[counter + + 1][board_descr["default"]["package_num_channel"].get ()] = package_num; + } + + int num_trues = 0; + for (size_t i = 0; i < new_eeg_data.size (); i++) + { + if (new_eeg_data[i]) + { + num_trues++; + } + } + + if ((num_trues == new_eeg_data.size ()) || + ((num_trues == new_eeg_data.size () - 1) && + (current_timestamp - last_fifth_chan_timestamp > 1))) + { + if (last_eeg_timestamp > 0) + { + double step = + (current_timestamp - last_eeg_timestamp) / current_default_buf.size (); + for (size_t i = 0; i < current_default_buf.size (); i++) + { + current_default_buf[i] + [board_descr["default"]["timestamp_channel"].get ()] = + last_eeg_timestamp + step * (i + 1); + db_default->add_data (¤t_default_buf[i][0]); + } + } + last_eeg_timestamp = current_timestamp; + std::fill (new_eeg_data.begin (), new_eeg_data.end (), false); + } + } +} + +void MuseBGLibHelper::ble_evt_gap_scan_response (const struct ble_msg_gap_scan_response_evt_t *msg) +{ + char name[512]; + bool name_found_in_response = false; + for (int i = 0; i < msg->data.len;) + { + int8 len = msg->data.data[i++]; + if (!len) + { + continue; + } + if (i + len > msg->data.len) + { + break; // not enough data + } + uint8 type = msg->data.data[i++]; + if (type == 0x09) // no idea what is 0x09 + { + name_found_in_response = true; + memcpy (name, msg->data.data + i, len - 1); + name[len - 1] = '\0'; + } + + i += len - 1; + } + + bool is_valid = true; + if (name_found_in_response) + { + if (!input_params.serial_number.empty ()) + { + if (strcmp (name, input_params.serial_number.c_str ()) != 0) + { + is_valid = false; + } + } + else + { + if (strstr (name, "Muse") == NULL) + { + is_valid = false; + } + } + if (is_valid) + { + memcpy ((void *)connect_addr.addr, msg->sender.addr, sizeof (bd_addr)); + exit_code = (int)BrainFlowExitCodes::STATUS_OK; + } + } +} + +/////////////// +/// Helpers /// +/////////////// + +void MuseBGLibHelper::thread_worker () +{ + while (!should_stop_stream) + { + read_message (); + } +} + +int MuseBGLibHelper::read_message () +{ + unsigned char *data = NULL; + struct ble_header hdr; + int r; + + r = uart_rx (sizeof (hdr), (unsigned char *)&hdr, 1000); + if (!r) + { + return -1; // timeout + } + else if (r < 0) + { + exit_code = (int)BrainFlowExitCodes::INITIAL_MSG_ERROR; + return 1; // fails to read + } + if (hdr.lolen) + { + data = new unsigned char[hdr.lolen]; + r = uart_rx (hdr.lolen, data, 3000); + if (r <= 0) + { + exit_code = (int)BrainFlowExitCodes::INCOMMING_MSG_ERROR; + delete[] data; + return 1; // fails to read + } + } + + const struct ble_msg *msg = ble_get_msg_hdr (hdr); + if (msg) + { + msg->handler (data); + } + delete[] data; + return 0; +} + +int MuseBGLibHelper::connect_ble_dev () +{ + exit_code = (int)BrainFlowExitCodes::SYNC_TIMEOUT_ERROR; + // send command to connect + state = (int)DeviceState::INITIAL_CONNECTION; + ble_cmd_gap_connect_direct (&connect_addr, gap_address_type_public, 10, 76, 100, 0); + int res = wait_for_callback (); + if (res != (int)BrainFlowExitCodes::STATUS_OK) + { + return res; + } + state = (int)DeviceState::OPEN_CALLED; + exit_code = (int)BrainFlowExitCodes::SYNC_TIMEOUT_ERROR; + uint8 primary_service_uuid[] = {0x00, 0x28}; + + ble_cmd_attclient_read_by_group_type ( + connection, FIRST_HANDLE, LAST_HANDLE, 2, primary_service_uuid); + + res = wait_for_callback (); + if (res != (int)BrainFlowExitCodes::STATUS_OK) + { + return res; + } + // from siliconlabs forum - write 0x00001 to enable notifications + // copypasted in start_stream method but lets keep it in 2 places + uint8 configuration[] = {0x01, 0x00}; + for (uint16 ccid : ccids) + { + state = (int)DeviceState::WRITE_TO_CLIENT_CHAR; + exit_code = (int)BrainFlowExitCodes::SYNC_TIMEOUT_ERROR; + ble_cmd_attclient_attribute_write (connection, ccid, 2, &configuration); + ble_cmd_attclient_execute_write (connection, 1); + wait_for_callback (); + } + return (int)BrainFlowExitCodes::STATUS_OK; +} + +int MuseBGLibHelper::wait_for_callback () +{ + auto start_time = std::chrono::high_resolution_clock::now (); + int run_time = 0; + while ((run_time < input_params.timeout) && + (exit_code == (int)BrainFlowExitCodes::SYNC_TIMEOUT_ERROR)) + { + if (read_message () > 0) + { + break; + } + auto end_time = std::chrono::high_resolution_clock::now (); + run_time = + (int)std::chrono::duration_cast (end_time - start_time).count (); + } + return exit_code; +} + +int MuseBGLibHelper::reset_ble_dev () +{ + // Reset dongle to get it into known state + if (uart_open (input_params.serial_port.c_str ())) + { + return (int)BrainFlowExitCodes::SET_PORT_ERROR; + } + ble_cmd_system_reset (0); + uart_close (); + bool is_open = false; + for (int i = 0; i < 5; i++) + { +#ifdef _WIN32 + Sleep (1000); +#else + usleep (1000000); +#endif + if (!uart_open (input_params.serial_port.c_str ())) + { + is_open = true; + break; + } + } +#ifdef _WIN32 + Sleep (100); +#else + usleep (100000); +#endif + if (!is_open) + { + return (int)BrainFlowExitCodes::UNABLE_TO_OPEN_PORT_ERROR; + } + return (int)BrainFlowExitCodes::STATUS_OK; +} diff --git a/deps/include/brainflow/board_controller/muse/muse_bglib/stubs.cpp b/deps/include/brainflow/board_controller/muse/muse_bglib/stubs.cpp new file mode 100644 index 000000000..801140cde --- /dev/null +++ b/deps/include/brainflow/board_controller/muse/muse_bglib/stubs.cpp @@ -0,0 +1,568 @@ + +/***************************************************************************** + * + * + * + * + * + ****************************************************************************/ + +#include "cmd_def.h" + + +void ble_rsp_system_get_info (const struct ble_msg_system_get_info_rsp_t *msg) +{ +} + +void ble_default (const void *v) +{ +} + +void ble_rsp_attclient_attribute_write (const struct ble_msg_attclient_attribute_write_rsp_t *msg) +{ +} + +void ble_rsp_attributes_send (const struct ble_msg_attributes_send_rsp_t *msg) +{ +} + +void ble_rsp_hardware_set_rxgain (const void *nul) +{ +} + +void ble_rsp_system_aes_setkey (const void *nul) +{ +} + +void ble_rsp_system_aes_encrypt (const struct ble_msg_system_aes_encrypt_rsp_t *msg) +{ +} + +void ble_rsp_system_aes_decrypt (const struct ble_msg_system_aes_decrypt_rsp_t *msg) +{ +} + +void ble_rsp_flash_read_data (const struct ble_msg_flash_read_data_rsp_t *msg) +{ +} + +void ble_rsp_test_channel_mode (const void *nul) +{ +} + +void ble_evt_system_protocol_error (const struct ble_msg_system_protocol_error_evt_t *msg) +{ +} + +void ble_rsp_system_reset (const void *nul) +{ +} + +void ble_rsp_system_hello (const void *nul) +{ +} + +void ble_rsp_system_address_get (const struct ble_msg_system_address_get_rsp_t *msg) +{ +} + +void ble_rsp_system_reg_write (const struct ble_msg_system_reg_write_rsp_t *msg) +{ +} + +void ble_rsp_system_reg_read (const struct ble_msg_system_reg_read_rsp_t *msg) +{ +} + +void ble_rsp_system_get_counters (const struct ble_msg_system_get_counters_rsp_t *msg) +{ +} + +void ble_rsp_system_get_connections (const struct ble_msg_system_get_connections_rsp_t *msg) +{ +} + +void ble_rsp_system_read_memory (const struct ble_msg_system_read_memory_rsp_t *msg) +{ +} + +void ble_rsp_system_endpoint_tx (const struct ble_msg_system_endpoint_tx_rsp_t *msg) +{ +} + +void ble_rsp_system_whitelist_append (const struct ble_msg_system_whitelist_append_rsp_t *msg) +{ +} + +void ble_rsp_system_whitelist_remove (const struct ble_msg_system_whitelist_remove_rsp_t *msg) +{ +} + +void ble_rsp_system_whitelist_clear (const void *nul) +{ +} + +void ble_rsp_system_endpoint_rx (const struct ble_msg_system_endpoint_rx_rsp_t *msg) +{ +} + +void ble_rsp_system_endpoint_set_watermarks ( + const struct ble_msg_system_endpoint_set_watermarks_rsp_t *msg) +{ +} + +void ble_rsp_hardware_usb_enable (const struct ble_msg_hardware_usb_enable_rsp_t *msg) +{ +} + +void ble_rsp_flash_ps_defrag (const void *nul) +{ +} + +void ble_rsp_flash_ps_dump (const void *nul) +{ +} + +void ble_rsp_flash_ps_erase_all (const void *nul) +{ +} + +void ble_rsp_flash_ps_save (const struct ble_msg_flash_ps_save_rsp_t *msg) +{ +} + +void ble_rsp_flash_ps_load (const struct ble_msg_flash_ps_load_rsp_t *msg) +{ +} + +void ble_rsp_flash_ps_erase (const void *nul) +{ +} + +void ble_rsp_flash_erase_page (const struct ble_msg_flash_erase_page_rsp_t *msg) +{ +} + +void ble_rsp_flash_write_data (const struct ble_msg_flash_write_data_rsp_t *msg) +{ +} + +void ble_rsp_attributes_write (const struct ble_msg_attributes_write_rsp_t *msg) +{ +} + +void ble_rsp_attributes_read (const struct ble_msg_attributes_read_rsp_t *msg) +{ +} + +void ble_rsp_attributes_read_type (const struct ble_msg_attributes_read_type_rsp_t *msg) +{ +} + +void ble_rsp_attributes_user_read_response (const void *nul) +{ +} + +void ble_rsp_attributes_user_write_response (const void *nul) +{ +} + +void ble_rsp_connection_disconnect (const struct ble_msg_connection_disconnect_rsp_t *msg) +{ +} + +void ble_rsp_connection_get_rssi (const struct ble_msg_connection_get_rssi_rsp_t *msg) +{ +} + +void ble_rsp_connection_update (const struct ble_msg_connection_update_rsp_t *msg) +{ +} + +void ble_rsp_connection_version_update (const struct ble_msg_connection_version_update_rsp_t *msg) +{ +} + +void ble_rsp_connection_channel_map_get (const struct ble_msg_connection_channel_map_get_rsp_t *msg) +{ +} + +void ble_rsp_connection_channel_map_set (const struct ble_msg_connection_channel_map_set_rsp_t *msg) +{ +} + +void ble_rsp_connection_features_get (const struct ble_msg_connection_features_get_rsp_t *msg) +{ +} + +void ble_rsp_connection_get_status (const struct ble_msg_connection_get_status_rsp_t *msg) +{ +} + +void ble_rsp_connection_raw_tx (const struct ble_msg_connection_raw_tx_rsp_t *msg) +{ +} + +void ble_rsp_attclient_find_by_type_value ( + const struct ble_msg_attclient_find_by_type_value_rsp_t *msg) +{ +} + +void ble_rsp_attclient_read_by_group_type ( + const struct ble_msg_attclient_read_by_group_type_rsp_t *msg) +{ +} + +void ble_rsp_attclient_read_by_type (const struct ble_msg_attclient_read_by_type_rsp_t *msg) +{ +} + +void ble_rsp_attclient_find_information (const struct ble_msg_attclient_find_information_rsp_t *msg) +{ +} + +void ble_rsp_attclient_read_by_handle (const struct ble_msg_attclient_read_by_handle_rsp_t *msg) +{ +} + +void ble_rsp_attclient_write_command (const struct ble_msg_attclient_write_command_rsp_t *msg) +{ +} + +void ble_rsp_attclient_indicate_confirm (const struct ble_msg_attclient_indicate_confirm_rsp_t *msg) +{ +} + +void ble_rsp_attclient_read_long (const struct ble_msg_attclient_read_long_rsp_t *msg) +{ +} + +void ble_rsp_attclient_prepare_write (const struct ble_msg_attclient_prepare_write_rsp_t *msg) +{ +} + +void ble_rsp_attclient_execute_write (const struct ble_msg_attclient_execute_write_rsp_t *msg) +{ +} + +void ble_rsp_attclient_read_multiple (const struct ble_msg_attclient_read_multiple_rsp_t *msg) +{ +} + +void ble_rsp_sm_encrypt_start (const struct ble_msg_sm_encrypt_start_rsp_t *msg) +{ +} + +void ble_rsp_sm_set_bondable_mode (const void *nul) +{ +} + +void ble_rsp_sm_delete_bonding (const struct ble_msg_sm_delete_bonding_rsp_t *msg) +{ +} + +void ble_rsp_sm_set_parameters (const void *nul) +{ +} + +void ble_rsp_sm_passkey_entry (const struct ble_msg_sm_passkey_entry_rsp_t *msg) +{ +} + +void ble_rsp_sm_get_bonds (const struct ble_msg_sm_get_bonds_rsp_t *msg) +{ +} + +void ble_rsp_sm_set_oob_data (const void *nul) +{ +} + +void ble_rsp_sm_whitelist_bonds (const struct ble_msg_sm_whitelist_bonds_rsp_t *msg) +{ +} + +void ble_rsp_gap_set_privacy_flags (const void *nul) +{ +} + +void ble_rsp_gap_set_mode (const struct ble_msg_gap_set_mode_rsp_t *msg) +{ +} + +void ble_rsp_gap_discover (const struct ble_msg_gap_discover_rsp_t *msg) +{ +} + +void ble_rsp_gap_connect_direct (const struct ble_msg_gap_connect_direct_rsp_t *msg) +{ +} + +void ble_rsp_gap_end_procedure (const struct ble_msg_gap_end_procedure_rsp_t *msg) +{ +} + +void ble_rsp_gap_connect_selective (const struct ble_msg_gap_connect_selective_rsp_t *msg) +{ +} + +void ble_rsp_gap_set_filtering (const struct ble_msg_gap_set_filtering_rsp_t *msg) +{ +} + +void ble_rsp_gap_set_scan_parameters (const struct ble_msg_gap_set_scan_parameters_rsp_t *msg) +{ +} + +void ble_rsp_gap_set_adv_parameters (const struct ble_msg_gap_set_adv_parameters_rsp_t *msg) +{ +} + +void ble_rsp_gap_set_adv_data (const struct ble_msg_gap_set_adv_data_rsp_t *msg) +{ +} + +void ble_rsp_gap_set_directed_connectable_mode ( + const struct ble_msg_gap_set_directed_connectable_mode_rsp_t *msg) +{ +} + +void ble_rsp_hardware_io_port_config_irq ( + const struct ble_msg_hardware_io_port_config_irq_rsp_t *msg) +{ +} + +void ble_rsp_hardware_set_soft_timer (const struct ble_msg_hardware_set_soft_timer_rsp_t *msg) +{ +} + +void ble_rsp_hardware_adc_read (const struct ble_msg_hardware_adc_read_rsp_t *msg) +{ +} + +void ble_rsp_hardware_io_port_config_direction ( + const struct ble_msg_hardware_io_port_config_direction_rsp_t *msg) +{ +} + +void ble_rsp_hardware_io_port_config_function ( + const struct ble_msg_hardware_io_port_config_function_rsp_t *msg) +{ +} + +void ble_rsp_hardware_io_port_config_pull ( + const struct ble_msg_hardware_io_port_config_pull_rsp_t *msg) +{ +} + +void ble_rsp_hardware_io_port_write (const struct ble_msg_hardware_io_port_write_rsp_t *msg) +{ +} + +void ble_rsp_hardware_io_port_read (const struct ble_msg_hardware_io_port_read_rsp_t *msg) +{ +} + +void ble_rsp_hardware_spi_config (const struct ble_msg_hardware_spi_config_rsp_t *msg) +{ +} + +void ble_rsp_hardware_spi_transfer (const struct ble_msg_hardware_spi_transfer_rsp_t *msg) +{ +} + +void ble_rsp_hardware_i2c_read (const struct ble_msg_hardware_i2c_read_rsp_t *msg) +{ +} + +void ble_rsp_hardware_i2c_write (const struct ble_msg_hardware_i2c_write_rsp_t *msg) +{ +} + +void ble_rsp_hardware_set_txpower (const void *nul) +{ +} + +void ble_rsp_hardware_timer_comparator (const struct ble_msg_hardware_timer_comparator_rsp_t *msg) +{ +} + +void ble_rsp_hardware_io_port_irq_enable ( + const struct ble_msg_hardware_io_port_irq_enable_rsp_t *msg) +{ +} + +void ble_rsp_hardware_io_port_irq_direction ( + const struct ble_msg_hardware_io_port_irq_direction_rsp_t *msg) +{ +} + +void ble_rsp_hardware_analog_comparator_enable (const void *nul) +{ +} + +void ble_rsp_hardware_analog_comparator_read ( + const struct ble_msg_hardware_analog_comparator_read_rsp_t *msg) +{ +} + +void ble_rsp_hardware_analog_comparator_config_irq ( + const struct ble_msg_hardware_analog_comparator_config_irq_rsp_t *msg) +{ +} + +void ble_rsp_test_phy_tx (const void *nul) +{ +} + +void ble_rsp_test_phy_rx (const void *nul) +{ +} + +void ble_rsp_test_phy_end (const struct ble_msg_test_phy_end_rsp_t *msg) +{ +} + +void ble_rsp_test_phy_reset (const void *nul) +{ +} + +void ble_rsp_test_get_channel_map (const struct ble_msg_test_get_channel_map_rsp_t *msg) +{ +} + +void ble_rsp_test_debug (const struct ble_msg_test_debug_rsp_t *msg) +{ +} + +void ble_evt_system_boot (const struct ble_msg_system_boot_evt_t *msg) +{ +} + +void ble_evt_system_debug (const struct ble_msg_system_debug_evt_t *msg) +{ +} + +void ble_evt_system_endpoint_watermark_rx ( + const struct ble_msg_system_endpoint_watermark_rx_evt_t *msg) +{ +} + +void ble_evt_system_endpoint_watermark_tx ( + const struct ble_msg_system_endpoint_watermark_tx_evt_t *msg) +{ +} + +void ble_evt_system_script_failure (const struct ble_msg_system_script_failure_evt_t *msg) +{ +} + +void ble_evt_system_no_license_key (const void *nul) +{ +} + +void ble_evt_flash_ps_key (const struct ble_msg_flash_ps_key_evt_t *msg) +{ +} + +void ble_evt_attributes_value (const struct ble_msg_attributes_value_evt_t *msg) +{ +} + +void ble_evt_attributes_user_read_request ( + const struct ble_msg_attributes_user_read_request_evt_t *msg) +{ +} + +void ble_evt_attributes_status (const struct ble_msg_attributes_status_evt_t *msg) +{ +} + +void ble_evt_connection_version_ind (const struct ble_msg_connection_version_ind_evt_t *msg) +{ +} + +void ble_evt_connection_feature_ind (const struct ble_msg_connection_feature_ind_evt_t *msg) +{ +} + +void ble_evt_connection_raw_rx (const struct ble_msg_connection_raw_rx_evt_t *msg) +{ +} + +void ble_evt_attclient_indicated (const struct ble_msg_attclient_indicated_evt_t *msg) +{ +} + +void ble_evt_attclient_attribute_found (const struct ble_msg_attclient_attribute_found_evt_t *msg) +{ +} + +void ble_evt_attclient_read_multiple_response ( + const struct ble_msg_attclient_read_multiple_response_evt_t *msg) +{ +} + +void ble_evt_sm_smp_data (const struct ble_msg_sm_smp_data_evt_t *msg) +{ +} + +void ble_evt_sm_bonding_fail (const struct ble_msg_sm_bonding_fail_evt_t *msg) +{ +} + +void ble_evt_sm_passkey_display (const struct ble_msg_sm_passkey_display_evt_t *msg) +{ +} + +void ble_evt_sm_passkey_request (const struct ble_msg_sm_passkey_request_evt_t *msg) +{ +} + +void ble_evt_sm_bond_status (const struct ble_msg_sm_bond_status_evt_t *msg) +{ +} + +void ble_evt_gap_mode_changed (const struct ble_msg_gap_mode_changed_evt_t *msg) +{ +} + +void ble_evt_hardware_io_port_status (const struct ble_msg_hardware_io_port_status_evt_t *msg) +{ +} + +void ble_evt_hardware_soft_timer (const struct ble_msg_hardware_soft_timer_evt_t *msg) +{ +} + +void ble_evt_hardware_adc_result (const struct ble_msg_hardware_adc_result_evt_t *msg) +{ +} + +void ble_evt_hardware_analog_comparator_status ( + const struct ble_msg_hardware_analog_comparator_status_evt_t *msg) +{ +} + + +/**Reset system**/ +void ble_rsp_dfu_reset (const void *nul) +{ +} + +/**set address for flashing**/ +void ble_rsp_dfu_flash_set_address (const struct ble_msg_dfu_flash_set_address_rsp_t *msg) +{ +} + +/**Upload binary for flashing. Address will be updated automatically.**/ +void ble_rsp_dfu_flash_upload (const struct ble_msg_dfu_flash_upload_rsp_t *msg) +{ +} +/**Uploading is finished.**/ +void ble_rsp_dfu_flash_upload_finish (const struct ble_msg_dfu_flash_upload_finish_rsp_t *msg) +{ +} +/**Device booted up in dfu, and is ready to receive commands**/ +void ble_evt_dfu_boot (const struct ble_msg_dfu_boot_evt_t *msg) +{ +} diff --git a/deps/include/brainflow/board_controller/muse/muse_bglib/uart.cpp b/deps/include/brainflow/board_controller/muse/muse_bglib/uart.cpp new file mode 100644 index 000000000..47d259baa --- /dev/null +++ b/deps/include/brainflow/board_controller/muse/muse_bglib/uart.cpp @@ -0,0 +1,362 @@ +// +// Bluegiga�s Bluetooth Smart Demo Application +// Contact: support@bluegiga.com. +// +// This is free software distributed under the terms of the MIT license reproduced below. +// +// Copyright (c) 2012, Bluegiga Technologies +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this +// software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +// EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +// MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. +// + +#include + +#include "uart.h" + +#ifdef _WIN32 + +#ifdef _MSC_VER +#define snprintf _snprintf +#endif + +#include + +#include +#pragma comment(lib, "Setupapi.lib") + +HANDLE serial_handle; + +void uart_list_devices () +{ + char name[] = "Bluegiga Bluetooth Low Energy"; + + BYTE *pbuf = NULL; + DWORD reqSize = 0; + DWORD n = 0; + HDEVINFO hDevInfo; + // guid for ports + static const GUID guid = { + 0x4d36e978, 0xe325, 0x11ce, {0xbf, 0xc1, 0x08, 0x00, 0x2b, 0xe1, 0x03, 0x18}}; + char *str; + char tmp[MAX_PATH + 1]; + int i; + SP_DEVINFO_DATA DeviceInfoData; + + snprintf (tmp, MAX_PATH, "%s (COM%%d)", name); + + + DeviceInfoData.cbSize = sizeof (SP_DEVINFO_DATA); + hDevInfo = SetupDiGetClassDevs (&guid, // Retrieve all ports + 0L, NULL, DIGCF_PRESENT); + if (hDevInfo == INVALID_HANDLE_VALUE) + return; + while (1) + { + + if (!SetupDiEnumDeviceInfo (hDevInfo, n++, &DeviceInfoData)) + { + SetupDiDestroyDeviceInfoList (hDevInfo); + return; + } + reqSize = 0; + SetupDiGetDeviceRegistryPropertyA ( + hDevInfo, &DeviceInfoData, SPDRP_FRIENDLYNAME, NULL, NULL, 0, &reqSize); + pbuf = (BYTE *)malloc (reqSize > 1 ? reqSize : 1); + if (!SetupDiGetDeviceRegistryPropertyA ( + hDevInfo, &DeviceInfoData, SPDRP_FRIENDLYNAME, NULL, pbuf, reqSize, NULL)) + { + free (pbuf); + continue; + } + str = (char *)pbuf; + if (sscanf (str, tmp, &i) == 1) + { + + printf ("%s\n", str); + // emit DeviceFound(str,QString("\\\\.\\COM%1").arg(i)); + } + free (pbuf); + } + return; +} + +int uart_find_serialport (char *name) +{ + BYTE *pbuf = NULL; + DWORD reqSize = 0; + DWORD n = 0; + HDEVINFO hDevInfo; + // guid for ports + static const GUID guid = { + 0x4d36e978, 0xe325, 0x11ce, {0xbf, 0xc1, 0x08, 0x00, 0x2b, 0xe1, 0x03, 0x18}}; + char *str; + char tmp[MAX_PATH + 1]; + int i; + SP_DEVINFO_DATA DeviceInfoData; + + snprintf (tmp, MAX_PATH, "%s (COM%%d)", name); + + + DeviceInfoData.cbSize = sizeof (SP_DEVINFO_DATA); + hDevInfo = SetupDiGetClassDevs (&guid, // Retrieve all ports + 0L, NULL, DIGCF_PRESENT); + if (hDevInfo == INVALID_HANDLE_VALUE) + return -1; + while (1) + { + + if (!SetupDiEnumDeviceInfo (hDevInfo, n++, &DeviceInfoData)) + { + SetupDiDestroyDeviceInfoList (hDevInfo); + return -1; + } + reqSize = 0; + SetupDiGetDeviceRegistryPropertyA ( + hDevInfo, &DeviceInfoData, SPDRP_FRIENDLYNAME, NULL, NULL, 0, &reqSize); + pbuf = (BYTE *)malloc (reqSize > 1 ? reqSize : 1); + if (!SetupDiGetDeviceRegistryPropertyA ( + hDevInfo, &DeviceInfoData, SPDRP_FRIENDLYNAME, NULL, pbuf, reqSize, NULL)) + { + free (pbuf); + continue; + } + str = (char *)pbuf; + if (sscanf (str, tmp, &i) == 1) + { + free (pbuf); + SetupDiDestroyDeviceInfoList (hDevInfo); + return i; + } + free (pbuf); + } + return -1; +} + +int uart_open (const char *port) +{ + char str[20]; + + snprintf (str, sizeof (str) - 1, "\\\\.\\%s", port); + serial_handle = CreateFileA (str, GENERIC_READ | GENERIC_WRITE, + FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, + 0, // FILE_FLAG_OVERLAPPED, + NULL); + + + if (serial_handle == INVALID_HANDLE_VALUE) + { + return -1; + } + + DCB dcb_serial_params = {0}; + dcb_serial_params.DCBlength = sizeof (dcb_serial_params); + if (GetCommState (serial_handle, &dcb_serial_params) == 0) + { + CloseHandle (serial_handle); + return -1; + } + + dcb_serial_params.BaudRate = CBR_256000; + dcb_serial_params.ByteSize = 8; + dcb_serial_params.StopBits = ONESTOPBIT; + dcb_serial_params.Parity = NOPARITY; + if (SetCommState (serial_handle, &dcb_serial_params) == 0) + { + CloseHandle (serial_handle); + return -1; + } + + return 0; +} + +void uart_close () +{ + if (serial_handle != INVALID_HANDLE_VALUE) + { + CloseHandle (serial_handle); + serial_handle = INVALID_HANDLE_VALUE; + } +} + +int uart_tx (int len, unsigned char *data) +{ + DWORD r, written; + while (len) + { + + r = WriteFile (serial_handle, data, len, &written, NULL); + if (!r) + { + return -1; + } + len -= written; + data += written; + } + + return 0; +} +int uart_rx (int len, unsigned char *data, int timeout_ms) +{ + int l = len; + DWORD r, rread; + COMMTIMEOUTS timeouts; + timeouts.ReadIntervalTimeout = MAXDWORD; + timeouts.ReadTotalTimeoutMultiplier = 0; + timeouts.ReadTotalTimeoutConstant = timeout_ms; + timeouts.WriteTotalTimeoutMultiplier = 0; + timeouts.WriteTotalTimeoutConstant = 0; + + SetCommTimeouts (serial_handle, &timeouts); + while (len) + { + r = ReadFile (serial_handle, data, len, &rread, NULL); + + if (!r) + { + l = GetLastError (); + if (l == ERROR_SUCCESS) + return 0; + return -1; + } + else + { + if (rread == 0) + return 0; + } + len -= rread; + data += rread; + } + + return l; +} + +#else + +#include +#include +#include +#include + +int serial_handle; + +void uart_list_devices () +{ +} + +int uart_open (const char *port) +{ + struct termios options; + int i; + + serial_handle = open (port, (O_RDWR | O_NOCTTY /*| O_NDELAY*/)); + + if (serial_handle < 0) + { + return -1; + } + + /* + * Get the current options for the port... + */ + tcgetattr (serial_handle, &options); + + /* + * Set the baud rates to 230400... + */ + cfsetispeed (&options, B230400); + cfsetospeed (&options, B230400); + + /* + * Enable the receiver and set parameters ... + */ + options.c_cflag &= ~(PARENB | CSTOPB | CSIZE | CRTSCTS | HUPCL); + options.c_cflag |= (CS8 | CLOCAL | CREAD); + options.c_lflag &= + ~(ICANON | ISIG | ECHO | ECHOE | ECHOK | ECHONL | ECHOCTL | ECHOPRT | ECHOKE | IEXTEN); + options.c_iflag &= ~(INPCK | IXON | IXOFF | IXANY | ICRNL); + options.c_oflag &= ~(OPOST | ONLCR); + + // printf( "size of c_cc = %d\n", sizeof( options.c_cc ) ); + for (i = 0; i < sizeof (options.c_cc); i++) + options.c_cc[i] = _POSIX_VDISABLE; + + options.c_cc[VTIME] = 0; + options.c_cc[VMIN] = 1; + + /* + * Set the new options for the port... + */ + tcsetattr (serial_handle, TCSAFLUSH, &options); + + return 0; +} + +void uart_close () +{ + if (serial_handle >= 0) + { + close (serial_handle); + serial_handle = -1; + } +} + +int uart_tx (int len, unsigned char *data) +{ + ssize_t written; + + while (len) + { + written = write (serial_handle, data, len); + if (!written) + { + return -1; + } + len -= written; + data += written; + } + + return 0; +} +int uart_rx (int len, unsigned char *data, int timeout_ms) +{ + int l = len; + ssize_t rread; + struct termios options; + + tcgetattr (serial_handle, &options); + options.c_cc[VTIME] = timeout_ms / 100; + options.c_cc[VMIN] = 0; + tcsetattr (serial_handle, TCSANOW, &options); + + while (len) + { + rread = read (serial_handle, data, len); + + if (!rread) + { + return 0; + } + else if (rread < 0) + { + return -1; + } + len -= rread; + data += rread; + } + + return l; +} + +#endif diff --git a/deps/include/brainflow/board_controller/muse/muse_bled.h b/deps/include/brainflow/board_controller/muse/muse_bled.h new file mode 100644 index 000000000..4540e4694 --- /dev/null +++ b/deps/include/brainflow/board_controller/muse/muse_bled.h @@ -0,0 +1,22 @@ +#pragma once + +#include "dyn_lib_board.h" + + +class MuseBLED : public DynLibBoard +{ + +private: + static int num_objects; + bool is_valid; + +public: + MuseBLED (int board_id, struct BrainFlowInputParams params); + ~MuseBLED (); + + int prepare_session (); + +protected: + std::string get_lib_name (); + void read_thread (); +}; diff --git a/deps/include/brainflow/board_controller/muse/muse_constants.h b/deps/include/brainflow/board_controller/muse/muse_constants.h new file mode 100644 index 000000000..2aca4e8dd --- /dev/null +++ b/deps/include/brainflow/board_controller/muse/muse_constants.h @@ -0,0 +1,33 @@ +#pragma once + +// common constants +#define MUSE_S_DATA_SIZE 15 + +// handles for bglib +#define FIRST_HANDLE 0x0001 +#define LAST_HANDLE 0xffff + +// info about services and chars +#define CLIENT_CHARACTERISTIC_UUID 0x2902 +#define MUSE_SERVICE_UUID 0xFE8D + +#define MUSE_GATT_ATTR_SERVICECHANGED "00002a05-0000-1000-8000-00805f9b34fb" +#define MUSE_GATT_ATTR_STREAM_TOGGLE "273e0001-4c4d-454d-96be-f03bac821358" +#define MUSE_GATT_ATTR_LEFTAUX "273e0002-4c4d-454d-96be-f03bac821358" +#define MUSE_GATT_ATTR_TP9 "273e0003-4c4d-454d-96be-f03bac821358" +#define MUSE_GATT_ATTR_AF7 "273e0004-4c4d-454d-96be-f03bac821358" +#define MUSE_GATT_ATTR_AF8 "273e0005-4c4d-454d-96be-f03bac821358" +#define MUSE_GATT_ATTR_TP10 "273e0006-4c4d-454d-96be-f03bac821358" +#define MUSE_GATT_ATTR_RIGHTAUX "273e0007-4c4d-454d-96be-f03bac821358" +#define MUSE_GATT_ATTR_REFDRL "273e0008-4c4d-454d-96be-f03bac821358" +#define MUSE_GATT_ATTR_GYRO "273e0009-4c4d-454d-96be-f03bac821358" +#define MUSE_GATT_ATTR_ACCELEROMETER "273e000a-4c4d-454d-96be-f03bac821358" +#define MUSE_GATT_ATTR_TELEMETRY "273e000b-4c4d-454d-96be-f03bac821358" +#define MUSE_GATT_ATTR_PPG0 "273e000f-4c4d-454d-96be-f03bac821358" +#define MUSE_GATT_ATTR_PPG1 "273e0010-4c4d-454d-96be-f03bac821358" +#define MUSE_GATT_ATTR_PPG2 "273e0011-4c4d-454d-96be-f03bac821358" +#define MUSE_GATT_ATTR_THERMISTOR "273e0012-4c4d-454d-96be-f03bac821358" + +// info for equations +#define MUSE_ACCELEROMETER_SCALE_FACTOR 0.0000610352 +#define MUSE_GYRO_SCALE_FACTOR 0.007476 diff --git a/deps/include/brainflow/board_controller/neuromd/brainbit.h b/deps/include/brainflow/board_controller/neuromd/brainbit.h index 3b80ab099..c83ec837a 100644 --- a/deps/include/brainflow/board_controller/neuromd/brainbit.h +++ b/deps/include/brainflow/board_controller/neuromd/brainbit.h @@ -36,6 +36,7 @@ class BrainBit : public NeuromdBoard SignalDoubleChannel *signal_t3; SignalDoubleChannel *signal_o1; SignalDoubleChannel *signal_o2; + volatile size_t counter; #endif @@ -44,7 +45,7 @@ class BrainBit : public NeuromdBoard ~BrainBit (); int prepare_session (); - int start_stream (int buffer_size, char *streamer_params); + int start_stream (int buffer_size, const char *streamer_params); int stop_stream (); int release_session (); int config_board (std::string config, std::string &response); diff --git a/deps/include/brainflow/board_controller/neuromd/brainbit_bglib/apitypes.h b/deps/include/brainflow/board_controller/neuromd/brainbit_bglib/apitypes.h new file mode 100644 index 000000000..1747bb7b3 --- /dev/null +++ b/deps/include/brainflow/board_controller/neuromd/brainbit_bglib/apitypes.h @@ -0,0 +1,45 @@ + +#ifndef APITYPES_H_ +#define APITYPES_H_ + +#ifdef __GNUC__ + +#define PACKSTRUCT(decl) decl __attribute__ ((__packed__)) +#define ALIGNED __attribute__ ((aligned (0x4))) + +#else // msvc + +#define PACKSTRUCT(decl) __pragma (pack (push, 1)) decl __pragma (pack (pop)) +#define ALIGNED + +#pragma warning(disable : 4200) + +#endif + +typedef unsigned char uint8; +typedef unsigned short uint16; +typedef signed short int16; +typedef unsigned long uint32; +typedef signed char int8; + +typedef struct bd_addr_t +{ + uint8 addr[6]; + +} bd_addr; + +typedef bd_addr hwaddr; +typedef struct +{ + uint8 len; + uint8 data[]; +} uint8array; + +typedef struct +{ + uint8 len; + int8 data[]; +} string; + + +#endif diff --git a/deps/include/brainflow/board_controller/neuromd/brainbit_bglib/brainbit_functions.h b/deps/include/brainflow/board_controller/neuromd/brainbit_bglib/brainbit_functions.h new file mode 100644 index 000000000..f57a670c0 --- /dev/null +++ b/deps/include/brainflow/board_controller/neuromd/brainbit_bglib/brainbit_functions.h @@ -0,0 +1,21 @@ +#include "shared_export.h" + +namespace BrainBitBLEDLib +{ +#ifdef __cplusplus + extern "C" + { +#endif + SHARED_EXPORT int CALLING_CONVENTION initialize (void *param); + SHARED_EXPORT int CALLING_CONVENTION open_device (void *param); + SHARED_EXPORT int CALLING_CONVENTION open_device_mac_addr (void *param); + SHARED_EXPORT int CALLING_CONVENTION stop_stream (void *param); + SHARED_EXPORT int CALLING_CONVENTION start_stream (void *param); + SHARED_EXPORT int CALLING_CONVENTION close_device (void *param); + SHARED_EXPORT int CALLING_CONVENTION get_data (void *param); + SHARED_EXPORT int CALLING_CONVENTION release (void *param); + SHARED_EXPORT int CALLING_CONVENTION config_device (void *param); +#ifdef __cplusplus + } +#endif +} // namespace BrainBitBLEDLib diff --git a/deps/include/brainflow/board_controller/neuromd/brainbit_bglib/cmd_def.h b/deps/include/brainflow/board_controller/neuromd/brainbit_bglib/cmd_def.h new file mode 100644 index 000000000..994518d36 --- /dev/null +++ b/deps/include/brainflow/board_controller/neuromd/brainbit_bglib/cmd_def.h @@ -0,0 +1,2791 @@ +#ifndef cmd_def_h +#define cmd_def_h + +/***************************************************************************** + * + * + * !!!!!!!! THIS IS AUTOGENERATED FILE, DO NOT EDIT !!!!!!!! + * + * + ****************************************************************************/ + +#include +/***************************************************************************** + * + * Support for compilers other than GCC and MSVC: + * + * To support specific compiler add compiler's structure packing directives to following macro: + * PACKSTRUCT( decl ) + * + * BGLIB uses PACKSTRUCT macro to add packing information for structures: + * PACKSTRUCT(struct wifi_msg_dfu_reset_cmd_t + * { + * uint8 dfu; + * }); + * + * + ****************************************************************************/ + +/*lint -save --e{528,572,778,845,835,849}*/ +#include "apitypes.h" +#ifdef __cplusplus +extern "C" +{ +#endif + +/* Compability */ +#ifndef PACKSTRUCT +#ifdef PACKED +#define PACKSTRUCT(a) a PACKED +#else +/*Default packed configuration*/ +#ifdef __GNUC__ +#ifdef _WIN32 +#define PACKSTRUCT(decl) decl __attribute__ ((__packed__, gcc_struct)) +#else +#define PACKSTRUCT(decl) decl __attribute__ ((__packed__)) +#endif +#define ALIGNED __attribute__ ((aligned (0x4))) + +#else // msvc + +#define PACKSTRUCT(decl) __pragma (pack (push, 1)) decl __pragma (pack (pop)) +#define ALIGNED + +#endif +#endif +#endif + struct ble_cmd_packet; + typedef void (*ble_cmd_handler) (const void *); + struct ble_header + { + uint8 type_hilen; + uint8 lolen; + uint8 cls; + uint8 command; + }; + + + struct ble_msg + { + struct ble_header hdr; + uint32 params; + ble_cmd_handler handler; + }; + + const struct ble_msg *ble_find_msg_hdr (struct ble_header hdr); + const struct ble_msg *ble_get_msg (uint8 idx); + const struct ble_msg *ble_get_msg_hdr (struct ble_header hdr); + extern void (*bglib_output) (uint8 len1, uint8 *data1, uint16 len2, uint8 *data2); + void ble_send_message (uint8 msgid, ...); + + enum system_endpoints + { + system_endpoint_api = 0, + system_endpoint_test = 1, + system_endpoint_script = 2, + system_endpoint_usb = 3, + system_endpoint_uart0 = 4, + system_endpoint_uart1 = 5, + system_endpoints_max = 6 + }; + + enum attributes_attribute_change_reason + { + attributes_attribute_change_reason_write_request = 0, + attributes_attribute_change_reason_write_command = 1, + attributes_attribute_change_reason_write_request_user = 2, + attributes_attribute_change_reason_max = 3 + }; + + enum attributes_attribute_status_flag + { + attributes_attribute_status_flag_notify = 1, + attributes_attribute_status_flag_indicate = 2, + attributes_attribute_status_flag_max = 3 + }; + + enum connection_connstatus + { + connection_connected = 1, + connection_encrypted = 2, + connection_completed = 4, + connection_parameters_change = 8, + connection_connstatus_max = 9 + }; + + enum attclient_attribute_value_types + { + attclient_attribute_value_type_read = 0, + attclient_attribute_value_type_notify = 1, + attclient_attribute_value_type_indicate = 2, + attclient_attribute_value_type_read_by_type = 3, + attclient_attribute_value_type_read_blob = 4, + attclient_attribute_value_type_indicate_rsp_req = 5, + attclient_attribute_value_types_max = 6 + }; + + enum sm_bonding_key + { + sm_bonding_key_ltk = 0x01, + sm_bonding_key_addr_public = 0x02, + sm_bonding_key_addr_static = 0x04, + sm_bonding_key_irk = 0x08, + sm_bonding_key_edivrand = 0x10, + sm_bonding_key_csrk = 0x20, + sm_bonding_key_masterid = 0x40, + sm_bonding_key_max = 65 + }; + + enum sm_io_capability + { + sm_io_capability_displayonly = 0, + sm_io_capability_displayyesno = 1, + sm_io_capability_keyboardonly = 2, + sm_io_capability_noinputnooutput = 3, + sm_io_capability_keyboarddisplay = 4, + sm_io_capability_max = 5 + }; + +#define GAP_SCAN_HEADER_ADV_IND 0 +#define GAP_SCAN_HEADER_ADV_DIRECT_IND 1 +#define GAP_SCAN_HEADER_ADV_NONCONN_IND 2 +#define GAP_SCAN_HEADER_SCAN_REQ 3 +#define GAP_SCAN_HEADER_SCAN_RSP 4 +#define GAP_SCAN_HEADER_CONNECT_REQ 5 +#define GAP_SCAN_HEADER_ADV_DISCOVER_IND 6 + +#define GAP_AD_FLAG_LIMITED_DISCOVERABLE 0x01 +#define GAP_AD_FLAG_GENERAL_DISCOVERABLE 0x02 +#define GAP_AD_FLAG_BREDR_NOT_SUPPORTED 0x04 +#define GAP_AD_FLAG_SIMULTANEOUS_LEBREDR_CTRL 0x10 +#define GAP_AD_FLAG_SIMULTANEOUS_LEBREDR_HOST 0x20 +#define GAP_AD_FLAG_MASK 0x1f + + enum gap_address_type + { + gap_address_type_public = 0, + gap_address_type_random = 1, + gap_address_type_max = 2 + }; + + enum gap_discoverable_mode + { + gap_non_discoverable = 0, + gap_limited_discoverable = 1, + gap_general_discoverable = 2, + gap_broadcast = 3, + gap_user_data = 4, + gap_discoverable_mode_max = 5 + }; + + enum gap_connectable_mode + { + gap_non_connectable = 0, + gap_directed_connectable = 1, + gap_undirected_connectable = 2, + gap_scannable_non_connectable = 3, + gap_connectable_mode_max = 4 + }; + + enum gap_discover_mode + { + gap_discover_limited = 0, + gap_discover_generic = 1, + gap_discover_observation = 2, + gap_discover_mode_max = 3 + }; + + enum gap_ad_types + { + gap_ad_type_none = 0, + gap_ad_type_flags = 1, + gap_ad_type_services_16bit_more = 2, + gap_ad_type_services_16bit_all = 3, + gap_ad_type_services_32bit_more = 4, + gap_ad_type_services_32bit_all = 5, + gap_ad_type_services_128bit_more = 6, + gap_ad_type_services_128bit_all = 7, + gap_ad_type_localname_short = 8, + gap_ad_type_localname_complete = 9, + gap_ad_type_txpower = 10, + gap_ad_types_max = 11 + }; + + enum gap_advertising_policy + { + gap_adv_policy_all = 0, + gap_adv_policy_whitelist_scan = 1, + gap_adv_policy_whitelist_connect = 2, + gap_adv_policy_whitelist_all = 3, + gap_advertising_policy_max = 4 + }; + + enum gap_scan_policy + { + gap_scan_policy_all = 0, + gap_scan_policy_whitelist = 1, + gap_scan_policy_max = 2 + }; + + + enum ble_parameter_types + { + ble_msg_parameter_uint8 = 2, + ble_msg_parameter_int8 = 3, + ble_msg_parameter_uint16 = 4, + ble_msg_parameter_int16 = 5, + ble_msg_parameter_uint32 = 6, + ble_msg_parameter_int32 = 7, + ble_msg_parameter_uint8array = 8, + ble_msg_parameter_string = 9, + ble_msg_parameter_hwaddr = 10, + ble_msg_parameter_uint16array = 11 + }; + + enum ble_msg_types + { + ble_msg_type_cmd = 0x00, + ble_msg_type_rsp = 0x00, + ble_msg_type_evt = 0x80 + }; + enum ble_dev_types + { + ble_dev_type_ble = 0x00, + ble_dev_type_wifi = 0x08, + ble_dev_type_iwrap = 0x10, + ble_dev_type_dumo = 0x20, + ble_dev_type_test = 0x20 + }; + + enum ble_classes + { + ble_cls_system, + ble_cls_flash, + ble_cls_attributes, + ble_cls_connection, + ble_cls_attclient, + ble_cls_sm, + ble_cls_gap, + ble_cls_hardware, + ble_cls_test, + ble_cls_dfu, + ble_cls_last + }; + enum ble_command_ids + { + ble_cmd_system_reset_id = 0, + ble_cmd_system_hello_id = 1, + ble_cmd_system_address_get_id = 2, + ble_cmd_system_reg_write_id = 3, + ble_cmd_system_reg_read_id = 4, + ble_cmd_system_get_counters_id = 5, + ble_cmd_system_get_connections_id = 6, + ble_cmd_system_read_memory_id = 7, + ble_cmd_system_get_info_id = 8, + ble_cmd_system_endpoint_tx_id = 9, + ble_cmd_system_whitelist_append_id = 10, + ble_cmd_system_whitelist_remove_id = 11, + ble_cmd_system_whitelist_clear_id = 12, + ble_cmd_system_endpoint_rx_id = 13, + ble_cmd_system_endpoint_set_watermarks_id = 14, + ble_cmd_system_aes_setkey_id = 15, + ble_cmd_system_aes_encrypt_id = 16, + ble_cmd_system_aes_decrypt_id = 17, + ble_cmd_flash_ps_defrag_id = 0, + ble_cmd_flash_ps_dump_id = 1, + ble_cmd_flash_ps_erase_all_id = 2, + ble_cmd_flash_ps_save_id = 3, + ble_cmd_flash_ps_load_id = 4, + ble_cmd_flash_ps_erase_id = 5, + ble_cmd_flash_erase_page_id = 6, + ble_cmd_flash_write_data_id = 7, + ble_cmd_flash_read_data_id = 8, + ble_cmd_attributes_write_id = 0, + ble_cmd_attributes_read_id = 1, + ble_cmd_attributes_read_type_id = 2, + ble_cmd_attributes_user_read_response_id = 3, + ble_cmd_attributes_user_write_response_id = 4, + ble_cmd_attributes_send_id = 5, + ble_cmd_connection_disconnect_id = 0, + ble_cmd_connection_get_rssi_id = 1, + ble_cmd_connection_update_id = 2, + ble_cmd_connection_version_update_id = 3, + ble_cmd_connection_channel_map_get_id = 4, + ble_cmd_connection_channel_map_set_id = 5, + ble_cmd_connection_features_get_id = 6, + ble_cmd_connection_get_status_id = 7, + ble_cmd_connection_raw_tx_id = 8, + ble_cmd_attclient_find_by_type_value_id = 0, + ble_cmd_attclient_read_by_group_type_id = 1, + ble_cmd_attclient_read_by_type_id = 2, + ble_cmd_attclient_find_information_id = 3, + ble_cmd_attclient_read_by_handle_id = 4, + ble_cmd_attclient_attribute_write_id = 5, + ble_cmd_attclient_write_command_id = 6, + ble_cmd_attclient_indicate_confirm_id = 7, + ble_cmd_attclient_read_long_id = 8, + ble_cmd_attclient_prepare_write_id = 9, + ble_cmd_attclient_execute_write_id = 10, + ble_cmd_attclient_read_multiple_id = 11, + ble_cmd_sm_encrypt_start_id = 0, + ble_cmd_sm_set_bondable_mode_id = 1, + ble_cmd_sm_delete_bonding_id = 2, + ble_cmd_sm_set_parameters_id = 3, + ble_cmd_sm_passkey_entry_id = 4, + ble_cmd_sm_get_bonds_id = 5, + ble_cmd_sm_set_oob_data_id = 6, + ble_cmd_sm_whitelist_bonds_id = 7, + ble_cmd_gap_set_privacy_flags_id = 0, + ble_cmd_gap_set_mode_id = 1, + ble_cmd_gap_discover_id = 2, + ble_cmd_gap_connect_direct_id = 3, + ble_cmd_gap_end_procedure_id = 4, + ble_cmd_gap_connect_selective_id = 5, + ble_cmd_gap_set_filtering_id = 6, + ble_cmd_gap_set_scan_parameters_id = 7, + ble_cmd_gap_set_adv_parameters_id = 8, + ble_cmd_gap_set_adv_data_id = 9, + ble_cmd_gap_set_directed_connectable_mode_id = 10, + ble_cmd_hardware_io_port_config_irq_id = 0, + ble_cmd_hardware_set_soft_timer_id = 1, + ble_cmd_hardware_adc_read_id = 2, + ble_cmd_hardware_io_port_config_direction_id = 3, + ble_cmd_hardware_io_port_config_function_id = 4, + ble_cmd_hardware_io_port_config_pull_id = 5, + ble_cmd_hardware_io_port_write_id = 6, + ble_cmd_hardware_io_port_read_id = 7, + ble_cmd_hardware_spi_config_id = 8, + ble_cmd_hardware_spi_transfer_id = 9, + ble_cmd_hardware_i2c_read_id = 10, + ble_cmd_hardware_i2c_write_id = 11, + ble_cmd_hardware_set_txpower_id = 12, + ble_cmd_hardware_timer_comparator_id = 13, + ble_cmd_hardware_io_port_irq_enable_id = 14, + ble_cmd_hardware_io_port_irq_direction_id = 15, + ble_cmd_hardware_analog_comparator_enable_id = 16, + ble_cmd_hardware_analog_comparator_read_id = 17, + ble_cmd_hardware_analog_comparator_config_irq_id = 18, + ble_cmd_hardware_set_rxgain_id = 19, + ble_cmd_hardware_usb_enable_id = 20, + ble_cmd_test_phy_tx_id = 0, + ble_cmd_test_phy_rx_id = 1, + ble_cmd_test_phy_end_id = 2, + ble_cmd_test_phy_reset_id = 3, + ble_cmd_test_get_channel_map_id = 4, + ble_cmd_test_debug_id = 5, + ble_cmd_test_channel_mode_id = 6, + ble_cmd_dfu_reset_id = 0, + ble_cmd_dfu_flash_set_address_id = 1, + ble_cmd_dfu_flash_upload_id = 2, + ble_cmd_dfu_flash_upload_finish_id = 3 + }; + enum ble_response_ids + { + ble_rsp_system_reset_id = 0, + ble_rsp_system_hello_id = 1, + ble_rsp_system_address_get_id = 2, + ble_rsp_system_reg_write_id = 3, + ble_rsp_system_reg_read_id = 4, + ble_rsp_system_get_counters_id = 5, + ble_rsp_system_get_connections_id = 6, + ble_rsp_system_read_memory_id = 7, + ble_rsp_system_get_info_id = 8, + ble_rsp_system_endpoint_tx_id = 9, + ble_rsp_system_whitelist_append_id = 10, + ble_rsp_system_whitelist_remove_id = 11, + ble_rsp_system_whitelist_clear_id = 12, + ble_rsp_system_endpoint_rx_id = 13, + ble_rsp_system_endpoint_set_watermarks_id = 14, + ble_rsp_system_aes_setkey_id = 15, + ble_rsp_system_aes_encrypt_id = 16, + ble_rsp_system_aes_decrypt_id = 17, + ble_rsp_flash_ps_defrag_id = 0, + ble_rsp_flash_ps_dump_id = 1, + ble_rsp_flash_ps_erase_all_id = 2, + ble_rsp_flash_ps_save_id = 3, + ble_rsp_flash_ps_load_id = 4, + ble_rsp_flash_ps_erase_id = 5, + ble_rsp_flash_erase_page_id = 6, + ble_rsp_flash_write_data_id = 7, + ble_rsp_flash_read_data_id = 8, + ble_rsp_attributes_write_id = 0, + ble_rsp_attributes_read_id = 1, + ble_rsp_attributes_read_type_id = 2, + ble_rsp_attributes_user_read_response_id = 3, + ble_rsp_attributes_user_write_response_id = 4, + ble_rsp_attributes_send_id = 5, + ble_rsp_connection_disconnect_id = 0, + ble_rsp_connection_get_rssi_id = 1, + ble_rsp_connection_update_id = 2, + ble_rsp_connection_version_update_id = 3, + ble_rsp_connection_channel_map_get_id = 4, + ble_rsp_connection_channel_map_set_id = 5, + ble_rsp_connection_features_get_id = 6, + ble_rsp_connection_get_status_id = 7, + ble_rsp_connection_raw_tx_id = 8, + ble_rsp_attclient_find_by_type_value_id = 0, + ble_rsp_attclient_read_by_group_type_id = 1, + ble_rsp_attclient_read_by_type_id = 2, + ble_rsp_attclient_find_information_id = 3, + ble_rsp_attclient_read_by_handle_id = 4, + ble_rsp_attclient_attribute_write_id = 5, + ble_rsp_attclient_write_command_id = 6, + ble_rsp_attclient_indicate_confirm_id = 7, + ble_rsp_attclient_read_long_id = 8, + ble_rsp_attclient_prepare_write_id = 9, + ble_rsp_attclient_execute_write_id = 10, + ble_rsp_attclient_read_multiple_id = 11, + ble_rsp_sm_encrypt_start_id = 0, + ble_rsp_sm_set_bondable_mode_id = 1, + ble_rsp_sm_delete_bonding_id = 2, + ble_rsp_sm_set_parameters_id = 3, + ble_rsp_sm_passkey_entry_id = 4, + ble_rsp_sm_get_bonds_id = 5, + ble_rsp_sm_set_oob_data_id = 6, + ble_rsp_sm_whitelist_bonds_id = 7, + ble_rsp_gap_set_privacy_flags_id = 0, + ble_rsp_gap_set_mode_id = 1, + ble_rsp_gap_discover_id = 2, + ble_rsp_gap_connect_direct_id = 3, + ble_rsp_gap_end_procedure_id = 4, + ble_rsp_gap_connect_selective_id = 5, + ble_rsp_gap_set_filtering_id = 6, + ble_rsp_gap_set_scan_parameters_id = 7, + ble_rsp_gap_set_adv_parameters_id = 8, + ble_rsp_gap_set_adv_data_id = 9, + ble_rsp_gap_set_directed_connectable_mode_id = 10, + ble_rsp_hardware_io_port_config_irq_id = 0, + ble_rsp_hardware_set_soft_timer_id = 1, + ble_rsp_hardware_adc_read_id = 2, + ble_rsp_hardware_io_port_config_direction_id = 3, + ble_rsp_hardware_io_port_config_function_id = 4, + ble_rsp_hardware_io_port_config_pull_id = 5, + ble_rsp_hardware_io_port_write_id = 6, + ble_rsp_hardware_io_port_read_id = 7, + ble_rsp_hardware_spi_config_id = 8, + ble_rsp_hardware_spi_transfer_id = 9, + ble_rsp_hardware_i2c_read_id = 10, + ble_rsp_hardware_i2c_write_id = 11, + ble_rsp_hardware_set_txpower_id = 12, + ble_rsp_hardware_timer_comparator_id = 13, + ble_rsp_hardware_io_port_irq_enable_id = 14, + ble_rsp_hardware_io_port_irq_direction_id = 15, + ble_rsp_hardware_analog_comparator_enable_id = 16, + ble_rsp_hardware_analog_comparator_read_id = 17, + ble_rsp_hardware_analog_comparator_config_irq_id = 18, + ble_rsp_hardware_set_rxgain_id = 19, + ble_rsp_hardware_usb_enable_id = 20, + ble_rsp_test_phy_tx_id = 0, + ble_rsp_test_phy_rx_id = 1, + ble_rsp_test_phy_end_id = 2, + ble_rsp_test_phy_reset_id = 3, + ble_rsp_test_get_channel_map_id = 4, + ble_rsp_test_debug_id = 5, + ble_rsp_test_channel_mode_id = 6, + ble_rsp_dfu_reset_id = 0, + ble_rsp_dfu_flash_set_address_id = 1, + ble_rsp_dfu_flash_upload_id = 2, + ble_rsp_dfu_flash_upload_finish_id = 3 + }; + enum ble_event_ids + { + ble_evt_system_boot_id = 0, + ble_evt_system_debug_id = 1, + ble_evt_system_endpoint_watermark_rx_id = 2, + ble_evt_system_endpoint_watermark_tx_id = 3, + ble_evt_system_script_failure_id = 4, + ble_evt_system_no_license_key_id = 5, + ble_evt_system_protocol_error_id = 6, + ble_evt_flash_ps_key_id = 0, + ble_evt_attributes_value_id = 0, + ble_evt_attributes_user_read_request_id = 1, + ble_evt_attributes_status_id = 2, + ble_evt_connection_status_id = 0, + ble_evt_connection_version_ind_id = 1, + ble_evt_connection_feature_ind_id = 2, + ble_evt_connection_raw_rx_id = 3, + ble_evt_connection_disconnected_id = 4, + ble_evt_attclient_indicated_id = 0, + ble_evt_attclient_procedure_completed_id = 1, + ble_evt_attclient_group_found_id = 2, + ble_evt_attclient_attribute_found_id = 3, + ble_evt_attclient_find_information_found_id = 4, + ble_evt_attclient_attribute_value_id = 5, + ble_evt_attclient_read_multiple_response_id = 6, + ble_evt_sm_smp_data_id = 0, + ble_evt_sm_bonding_fail_id = 1, + ble_evt_sm_passkey_display_id = 2, + ble_evt_sm_passkey_request_id = 3, + ble_evt_sm_bond_status_id = 4, + ble_evt_gap_scan_response_id = 0, + ble_evt_gap_mode_changed_id = 1, + ble_evt_hardware_io_port_status_id = 0, + ble_evt_hardware_soft_timer_id = 1, + ble_evt_hardware_adc_result_id = 2, + ble_evt_hardware_analog_comparator_status_id = 3, + ble_evt_dfu_boot_id = 0 + }; + enum ble_msg_idx + { + ble_cmd_system_reset_idx = 0, + ble_cmd_system_hello_idx = 1, + ble_cmd_system_address_get_idx = 2, + ble_cmd_system_reg_write_idx = 3, + ble_cmd_system_reg_read_idx = 4, + ble_cmd_system_get_counters_idx = 5, + ble_cmd_system_get_connections_idx = 6, + ble_cmd_system_read_memory_idx = 7, + ble_cmd_system_get_info_idx = 8, + ble_cmd_system_endpoint_tx_idx = 9, + ble_cmd_system_whitelist_append_idx = 10, + ble_cmd_system_whitelist_remove_idx = 11, + ble_cmd_system_whitelist_clear_idx = 12, + ble_cmd_system_endpoint_rx_idx = 13, + ble_cmd_system_endpoint_set_watermarks_idx = 14, + ble_cmd_system_aes_setkey_idx = 15, + ble_cmd_system_aes_encrypt_idx = 16, + ble_cmd_system_aes_decrypt_idx = 17, + ble_cmd_flash_ps_defrag_idx = 18, + ble_cmd_flash_ps_dump_idx = 19, + ble_cmd_flash_ps_erase_all_idx = 20, + ble_cmd_flash_ps_save_idx = 21, + ble_cmd_flash_ps_load_idx = 22, + ble_cmd_flash_ps_erase_idx = 23, + ble_cmd_flash_erase_page_idx = 24, + ble_cmd_flash_write_data_idx = 25, + ble_cmd_flash_read_data_idx = 26, + ble_cmd_attributes_write_idx = 27, + ble_cmd_attributes_read_idx = 28, + ble_cmd_attributes_read_type_idx = 29, + ble_cmd_attributes_user_read_response_idx = 30, + ble_cmd_attributes_user_write_response_idx = 31, + ble_cmd_attributes_send_idx = 32, + ble_cmd_connection_disconnect_idx = 33, + ble_cmd_connection_get_rssi_idx = 34, + ble_cmd_connection_update_idx = 35, + ble_cmd_connection_version_update_idx = 36, + ble_cmd_connection_channel_map_get_idx = 37, + ble_cmd_connection_channel_map_set_idx = 38, + ble_cmd_connection_features_get_idx = 39, + ble_cmd_connection_get_status_idx = 40, + ble_cmd_connection_raw_tx_idx = 41, + ble_cmd_attclient_find_by_type_value_idx = 42, + ble_cmd_attclient_read_by_group_type_idx = 43, + ble_cmd_attclient_read_by_type_idx = 44, + ble_cmd_attclient_find_information_idx = 45, + ble_cmd_attclient_read_by_handle_idx = 46, + ble_cmd_attclient_attribute_write_idx = 47, + ble_cmd_attclient_write_command_idx = 48, + ble_cmd_attclient_indicate_confirm_idx = 49, + ble_cmd_attclient_read_long_idx = 50, + ble_cmd_attclient_prepare_write_idx = 51, + ble_cmd_attclient_execute_write_idx = 52, + ble_cmd_attclient_read_multiple_idx = 53, + ble_cmd_sm_encrypt_start_idx = 54, + ble_cmd_sm_set_bondable_mode_idx = 55, + ble_cmd_sm_delete_bonding_idx = 56, + ble_cmd_sm_set_parameters_idx = 57, + ble_cmd_sm_passkey_entry_idx = 58, + ble_cmd_sm_get_bonds_idx = 59, + ble_cmd_sm_set_oob_data_idx = 60, + ble_cmd_sm_whitelist_bonds_idx = 61, + ble_cmd_gap_set_privacy_flags_idx = 62, + ble_cmd_gap_set_mode_idx = 63, + ble_cmd_gap_discover_idx = 64, + ble_cmd_gap_connect_direct_idx = 65, + ble_cmd_gap_end_procedure_idx = 66, + ble_cmd_gap_connect_selective_idx = 67, + ble_cmd_gap_set_filtering_idx = 68, + ble_cmd_gap_set_scan_parameters_idx = 69, + ble_cmd_gap_set_adv_parameters_idx = 70, + ble_cmd_gap_set_adv_data_idx = 71, + ble_cmd_gap_set_directed_connectable_mode_idx = 72, + ble_cmd_hardware_io_port_config_irq_idx = 73, + ble_cmd_hardware_set_soft_timer_idx = 74, + ble_cmd_hardware_adc_read_idx = 75, + ble_cmd_hardware_io_port_config_direction_idx = 76, + ble_cmd_hardware_io_port_config_function_idx = 77, + ble_cmd_hardware_io_port_config_pull_idx = 78, + ble_cmd_hardware_io_port_write_idx = 79, + ble_cmd_hardware_io_port_read_idx = 80, + ble_cmd_hardware_spi_config_idx = 81, + ble_cmd_hardware_spi_transfer_idx = 82, + ble_cmd_hardware_i2c_read_idx = 83, + ble_cmd_hardware_i2c_write_idx = 84, + ble_cmd_hardware_set_txpower_idx = 85, + ble_cmd_hardware_timer_comparator_idx = 86, + ble_cmd_hardware_io_port_irq_enable_idx = 87, + ble_cmd_hardware_io_port_irq_direction_idx = 88, + ble_cmd_hardware_analog_comparator_enable_idx = 89, + ble_cmd_hardware_analog_comparator_read_idx = 90, + ble_cmd_hardware_analog_comparator_config_irq_idx = 91, + ble_cmd_hardware_set_rxgain_idx = 92, + ble_cmd_hardware_usb_enable_idx = 93, + ble_cmd_test_phy_tx_idx = 94, + ble_cmd_test_phy_rx_idx = 95, + ble_cmd_test_phy_end_idx = 96, + ble_cmd_test_phy_reset_idx = 97, + ble_cmd_test_get_channel_map_idx = 98, + ble_cmd_test_debug_idx = 99, + ble_cmd_test_channel_mode_idx = 100, + ble_cmd_dfu_reset_idx = 101, + ble_cmd_dfu_flash_set_address_idx = 102, + ble_cmd_dfu_flash_upload_idx = 103, + ble_cmd_dfu_flash_upload_finish_idx = 104, + ble_rsp_system_reset_idx = 105, + ble_rsp_system_hello_idx = 106, + ble_rsp_system_address_get_idx = 107, + ble_rsp_system_reg_write_idx = 108, + ble_rsp_system_reg_read_idx = 109, + ble_rsp_system_get_counters_idx = 110, + ble_rsp_system_get_connections_idx = 111, + ble_rsp_system_read_memory_idx = 112, + ble_rsp_system_get_info_idx = 113, + ble_rsp_system_endpoint_tx_idx = 114, + ble_rsp_system_whitelist_append_idx = 115, + ble_rsp_system_whitelist_remove_idx = 116, + ble_rsp_system_whitelist_clear_idx = 117, + ble_rsp_system_endpoint_rx_idx = 118, + ble_rsp_system_endpoint_set_watermarks_idx = 119, + ble_rsp_system_aes_setkey_idx = 120, + ble_rsp_system_aes_encrypt_idx = 121, + ble_rsp_system_aes_decrypt_idx = 122, + ble_rsp_flash_ps_defrag_idx = 123, + ble_rsp_flash_ps_dump_idx = 124, + ble_rsp_flash_ps_erase_all_idx = 125, + ble_rsp_flash_ps_save_idx = 126, + ble_rsp_flash_ps_load_idx = 127, + ble_rsp_flash_ps_erase_idx = 128, + ble_rsp_flash_erase_page_idx = 129, + ble_rsp_flash_write_data_idx = 130, + ble_rsp_flash_read_data_idx = 131, + ble_rsp_attributes_write_idx = 132, + ble_rsp_attributes_read_idx = 133, + ble_rsp_attributes_read_type_idx = 134, + ble_rsp_attributes_user_read_response_idx = 135, + ble_rsp_attributes_user_write_response_idx = 136, + ble_rsp_attributes_send_idx = 137, + ble_rsp_connection_disconnect_idx = 138, + ble_rsp_connection_get_rssi_idx = 139, + ble_rsp_connection_update_idx = 140, + ble_rsp_connection_version_update_idx = 141, + ble_rsp_connection_channel_map_get_idx = 142, + ble_rsp_connection_channel_map_set_idx = 143, + ble_rsp_connection_features_get_idx = 144, + ble_rsp_connection_get_status_idx = 145, + ble_rsp_connection_raw_tx_idx = 146, + ble_rsp_attclient_find_by_type_value_idx = 147, + ble_rsp_attclient_read_by_group_type_idx = 148, + ble_rsp_attclient_read_by_type_idx = 149, + ble_rsp_attclient_find_information_idx = 150, + ble_rsp_attclient_read_by_handle_idx = 151, + ble_rsp_attclient_attribute_write_idx = 152, + ble_rsp_attclient_write_command_idx = 153, + ble_rsp_attclient_indicate_confirm_idx = 154, + ble_rsp_attclient_read_long_idx = 155, + ble_rsp_attclient_prepare_write_idx = 156, + ble_rsp_attclient_execute_write_idx = 157, + ble_rsp_attclient_read_multiple_idx = 158, + ble_rsp_sm_encrypt_start_idx = 159, + ble_rsp_sm_set_bondable_mode_idx = 160, + ble_rsp_sm_delete_bonding_idx = 161, + ble_rsp_sm_set_parameters_idx = 162, + ble_rsp_sm_passkey_entry_idx = 163, + ble_rsp_sm_get_bonds_idx = 164, + ble_rsp_sm_set_oob_data_idx = 165, + ble_rsp_sm_whitelist_bonds_idx = 166, + ble_rsp_gap_set_privacy_flags_idx = 167, + ble_rsp_gap_set_mode_idx = 168, + ble_rsp_gap_discover_idx = 169, + ble_rsp_gap_connect_direct_idx = 170, + ble_rsp_gap_end_procedure_idx = 171, + ble_rsp_gap_connect_selective_idx = 172, + ble_rsp_gap_set_filtering_idx = 173, + ble_rsp_gap_set_scan_parameters_idx = 174, + ble_rsp_gap_set_adv_parameters_idx = 175, + ble_rsp_gap_set_adv_data_idx = 176, + ble_rsp_gap_set_directed_connectable_mode_idx = 177, + ble_rsp_hardware_io_port_config_irq_idx = 178, + ble_rsp_hardware_set_soft_timer_idx = 179, + ble_rsp_hardware_adc_read_idx = 180, + ble_rsp_hardware_io_port_config_direction_idx = 181, + ble_rsp_hardware_io_port_config_function_idx = 182, + ble_rsp_hardware_io_port_config_pull_idx = 183, + ble_rsp_hardware_io_port_write_idx = 184, + ble_rsp_hardware_io_port_read_idx = 185, + ble_rsp_hardware_spi_config_idx = 186, + ble_rsp_hardware_spi_transfer_idx = 187, + ble_rsp_hardware_i2c_read_idx = 188, + ble_rsp_hardware_i2c_write_idx = 189, + ble_rsp_hardware_set_txpower_idx = 190, + ble_rsp_hardware_timer_comparator_idx = 191, + ble_rsp_hardware_io_port_irq_enable_idx = 192, + ble_rsp_hardware_io_port_irq_direction_idx = 193, + ble_rsp_hardware_analog_comparator_enable_idx = 194, + ble_rsp_hardware_analog_comparator_read_idx = 195, + ble_rsp_hardware_analog_comparator_config_irq_idx = 196, + ble_rsp_hardware_set_rxgain_idx = 197, + ble_rsp_hardware_usb_enable_idx = 198, + ble_rsp_test_phy_tx_idx = 199, + ble_rsp_test_phy_rx_idx = 200, + ble_rsp_test_phy_end_idx = 201, + ble_rsp_test_phy_reset_idx = 202, + ble_rsp_test_get_channel_map_idx = 203, + ble_rsp_test_debug_idx = 204, + ble_rsp_test_channel_mode_idx = 205, + ble_rsp_dfu_reset_idx = 206, + ble_rsp_dfu_flash_set_address_idx = 207, + ble_rsp_dfu_flash_upload_idx = 208, + ble_rsp_dfu_flash_upload_finish_idx = 209, + ble_evt_system_boot_idx = 210, + ble_evt_system_debug_idx = 211, + ble_evt_system_endpoint_watermark_rx_idx = 212, + ble_evt_system_endpoint_watermark_tx_idx = 213, + ble_evt_system_script_failure_idx = 214, + ble_evt_system_no_license_key_idx = 215, + ble_evt_system_protocol_error_idx = 216, + ble_evt_flash_ps_key_idx = 217, + ble_evt_attributes_value_idx = 218, + ble_evt_attributes_user_read_request_idx = 219, + ble_evt_attributes_status_idx = 220, + ble_evt_connection_status_idx = 221, + ble_evt_connection_version_ind_idx = 222, + ble_evt_connection_feature_ind_idx = 223, + ble_evt_connection_raw_rx_idx = 224, + ble_evt_connection_disconnected_idx = 225, + ble_evt_attclient_indicated_idx = 226, + ble_evt_attclient_procedure_completed_idx = 227, + ble_evt_attclient_group_found_idx = 228, + ble_evt_attclient_attribute_found_idx = 229, + ble_evt_attclient_find_information_found_idx = 230, + ble_evt_attclient_attribute_value_idx = 231, + ble_evt_attclient_read_multiple_response_idx = 232, + ble_evt_sm_smp_data_idx = 233, + ble_evt_sm_bonding_fail_idx = 234, + ble_evt_sm_passkey_display_idx = 235, + ble_evt_sm_passkey_request_idx = 236, + ble_evt_sm_bond_status_idx = 237, + ble_evt_gap_scan_response_idx = 238, + ble_evt_gap_mode_changed_idx = 239, + ble_evt_hardware_io_port_status_idx = 240, + ble_evt_hardware_soft_timer_idx = 241, + ble_evt_hardware_adc_result_idx = 242, + ble_evt_hardware_analog_comparator_status_idx = 243, + ble_evt_dfu_boot_idx = 244 + }; +#ifndef BG_ERRORCODES +#define BG_ERRORCODES + enum ble_error_spaces + { + ble_errspc_bt = 512, + ble_errspc_att = 1024, + ble_errspc_bg = 256, + ble_errspc_smp = 768, + }; + typedef enum ble_error + { + ble_err_bt_error_success = ble_errspc_bt + 0, // Command completed succesfully + ble_err_bt_bt_error_authentication_failure = ble_errspc_bt + + 5, // Pairing or authentication failed due to incorrect results in the pairing or + // authentication procedure. This could be due to an incorrect PIN or Link Key + ble_err_bt_pin_or_key_missing = + ble_errspc_bt + 6, // Pairing failed because of missing PIN, or authentication failed + // because of missing Key + ble_err_bt_bt_error_memory_capacity_exceeded = + ble_errspc_bt + 7, // Controller is out of memory. + ble_err_bt_connection_timeout = ble_errspc_bt + 8, // Link supervision timeout has expired. + ble_err_bt_connection_limit_exceeded = + ble_errspc_bt + 9, // Controller is at limit of connections it can support. + ble_err_bt_bt_error_command_disallowed = + ble_errspc_bt + 12, // Command requested cannot be executed because the Controller is in + // a state where it cannot process this command at this time. + ble_err_bt_bt_error_invalid_command_parameters = + ble_errspc_bt + 18, // Command contained invalid parameters. + ble_err_bt_bt_error_remote_user_terminated = + ble_errspc_bt + 19, // User on the remote device terminated the connection. + ble_err_bt_bt_error_connection_terminated_by_local_host = + ble_errspc_bt + 22, // Local device terminated the connection. + ble_err_bt_bt_error_ll_response_timeout = + ble_errspc_bt + 34, // Connection terminated due to link-layer procedure timeout. + ble_err_bt_bt_error_ll_instant_passed = + ble_errspc_bt + 40, // Received link-layer control packet where instant was in the past. + ble_err_bt_bt_error_controller_busy = + ble_errspc_bt + 58, // Operation was rejected because the controller is busy and unable + // to process the request. + ble_err_bt_bt_error_unacceptable_connection_interval = + ble_errspc_bt + 59, // Remote evice terminated the connection because of an unacceptable + // connection interval. + ble_err_bt_bt_error_directed_advertising_timeout = ble_errspc_bt + + 60, // Directed advertising completed without a connection being created. + ble_err_bt_bt_error_connection_terminated_due_to_mic_failure = + ble_errspc_bt + 61, // Connection was terminated because the Message Integrity Check + // (MIC) failed on a received packet. + ble_err_bt_bt_error_connection_failed_to_be_established = ble_errspc_bt + + 62, // LL initiated a connection but the connection has failed to be established. + // Controller did not receive any packets from remote end. + ble_err_att_invalid_handle = + ble_errspc_att + 1, // The attribute handle given was not valid on this server + ble_err_att_read_not_permitted = ble_errspc_att + 2, // The attribute cannot be read + ble_err_att_write_not_permitted = ble_errspc_att + 3, // The attribute cannot be written + ble_err_att_invalid_pdu = ble_errspc_att + 4, // The attribute PDU was invalid + ble_err_att_insufficient_authentication = ble_errspc_att + + 5, // The attribute requires authentication before it can be read or written. + ble_err_att_request_not_supported = ble_errspc_att + + 6, // Attribute Server does not support the request received from the client. + ble_err_att_invalid_offset = + ble_errspc_att + 7, // Offset specified was past the end of the attribute + ble_err_att_insufficient_authorization = ble_errspc_att + + 8, // The attribute requires authorization before it can be read or written. + ble_err_att_prepare_queue_full = + ble_errspc_att + 9, // Too many prepare writes have been queueud + ble_err_att_att_not_found = + ble_errspc_att + 10, // No attribute found within the given attribute handle range. + ble_err_att_att_not_long = ble_errspc_att + + 11, // The attribute cannot be read or written using the Read Blob Request + ble_err_att_insufficient_enc_key_size = ble_errspc_att + + 12, // The Encryption Key Size used for encrypting this link is insufficient. + ble_err_att_invalid_att_length = + ble_errspc_att + 13, // The attribute value length is invalid for the operation + ble_err_att_unlikely_error = ble_errspc_att + + 14, // The attribute request that was requested has encountered an error that was + // unlikely, and therefore could not be completed as requested. + ble_err_att_insufficient_encryption = ble_errspc_att + + 15, // The attribute requires encryption before it can be read or written. + ble_err_att_unsupported_group_type = + ble_errspc_att + 16, // The attribute type is not a supported grouping attribute as + // defined by a higher layer specification. + ble_err_att_insufficient_resources = + ble_errspc_att + 17, // Insufficient Resources to complete the request + ble_err_att_application = + ble_errspc_att + 128, // Application error code defined by a higher layer specification. + ble_err_success = 0, // No error + ble_err_invalid_param = ble_errspc_bg + 128, // Command contained invalid parameter + ble_err_wrong_state = ble_errspc_bg + 129, // Device is in wrong state to receive command + ble_err_out_of_memory = ble_errspc_bg + 130, // Device has run out of memory + ble_err_not_implemented = ble_errspc_bg + 131, // Feature is not implemented + ble_err_invalid_command = ble_errspc_bg + 132, // Command was not recognized + ble_err_timeout = ble_errspc_bg + 133, // Command or Procedure failed due to timeout + ble_err_not_connected = + ble_errspc_bg + 134, // Connection handle passed is to command is not a valid handle + ble_err_flow = + ble_errspc_bg + 135, // Command would cause either underflow or overflow error + ble_err_user_attribute = + ble_errspc_bg + 136, // User attribute was accessed through API which is not supported + ble_err_invalid_license_key = ble_errspc_bg + 137, // No valid license key found + ble_err_command_too_long = ble_errspc_bg + 138, // Command maximum length exceeded + ble_err_out_of_bonds = ble_errspc_bg + + 139, // Bonding procedure can't be started because device has no space left for bond. + ble_err_smp_passkey_entry_failed = ble_errspc_smp + + 1, // The user input of passkey failed, for example, the user cancelled the operation + ble_err_smp_oob_not_available = + ble_errspc_smp + 2, // Out of Band data is not available for authentication + ble_err_smp_authentication_requirements = ble_errspc_smp + + 3, // The pairing procedure cannot be performed as authentication requirements cannot be + // met due to IO capabilities of one or both devices + ble_err_smp_confirm_value_failed = + ble_errspc_smp + 4, // The confirm value does not match the calculated compare value + ble_err_smp_pairing_not_supported = + ble_errspc_smp + 5, // Pairing is not supported by the device + ble_err_smp_encryption_key_size = + ble_errspc_smp + 6, // The resultant encryption key size is insufficient for the + // security requirements of this device + ble_err_smp_command_not_supported = + ble_errspc_smp + 7, // The SMP command received is not supported on this device + ble_err_smp_unspecified_reason = + ble_errspc_smp + 8, // Pairing failed due to an unspecified reason + ble_err_smp_repeated_attempts = ble_errspc_smp + + 9, // Pairing or authentication procedure is disallowed because too little time has + // elapsed since last pairing request or security request + ble_err_smp_invalid_parameters = + ble_errspc_smp + 10, // The Invalid Parameters error code indicates: the command length + // is invalid or a parameter is outside of the specified range. + ble_err_last + } errorcode_t; +#endif + PACKSTRUCT (struct ble_msg_system_reset_cmd_t { uint8 boot_in_dfu; }); + + PACKSTRUCT (struct ble_msg_system_address_get_rsp_t { bd_addr address; }); + + PACKSTRUCT (struct ble_msg_system_reg_write_cmd_t { + uint16 address; + uint8 value; + }); + + PACKSTRUCT (struct ble_msg_system_reg_write_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_system_reg_read_cmd_t { uint16 address; }); + + PACKSTRUCT (struct ble_msg_system_reg_read_rsp_t { + uint16 address; + uint8 value; + }); + + PACKSTRUCT (struct ble_msg_system_get_counters_rsp_t { + uint8 txok; + uint8 txretry; + uint8 rxok; + uint8 rxfail; + uint8 mbuf; + }); + + PACKSTRUCT (struct ble_msg_system_get_connections_rsp_t { uint8 maxconn; }); + + PACKSTRUCT (struct ble_msg_system_read_memory_cmd_t { + uint32 address; + uint8 length; + }); + + PACKSTRUCT (struct ble_msg_system_read_memory_rsp_t { + uint32 address; + uint8array data; + }); + + PACKSTRUCT (struct ble_msg_system_get_info_rsp_t { + uint16 major; + uint16 minor; + uint16 patch; + uint16 build; + uint16 ll_version; + uint8 protocol_version; + uint8 hw; + }); + + PACKSTRUCT (struct ble_msg_system_endpoint_tx_cmd_t { + uint8 endpoint; + uint8array data; + }); + + PACKSTRUCT (struct ble_msg_system_endpoint_tx_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_system_whitelist_append_cmd_t { + bd_addr address; + uint8 address_type; + }); + + PACKSTRUCT (struct ble_msg_system_whitelist_append_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_system_whitelist_remove_cmd_t { + bd_addr address; + uint8 address_type; + }); + + PACKSTRUCT (struct ble_msg_system_whitelist_remove_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_system_endpoint_rx_cmd_t { + uint8 endpoint; + uint8 size; + }); + + PACKSTRUCT (struct ble_msg_system_endpoint_rx_rsp_t { + uint16 result; + uint8array data; + }); + + PACKSTRUCT (struct ble_msg_system_endpoint_set_watermarks_cmd_t { + uint8 endpoint; + uint8 rx; + uint8 tx; + }); + + PACKSTRUCT (struct ble_msg_system_endpoint_set_watermarks_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_system_aes_setkey_cmd_t { uint8array key; }); + + PACKSTRUCT (struct ble_msg_system_aes_encrypt_cmd_t { uint8array data; }); + + PACKSTRUCT (struct ble_msg_system_aes_encrypt_rsp_t { uint8array data; }); + + PACKSTRUCT (struct ble_msg_system_aes_decrypt_cmd_t { uint8array data; }); + + PACKSTRUCT (struct ble_msg_system_aes_decrypt_rsp_t { uint8array data; }); + + PACKSTRUCT (struct ble_msg_system_boot_evt_t { + uint16 major; + uint16 minor; + uint16 patch; + uint16 build; + uint16 ll_version; + uint8 protocol_version; + uint8 hw; + }); + + PACKSTRUCT (struct ble_msg_system_debug_evt_t { uint8array data; }); + + PACKSTRUCT (struct ble_msg_system_endpoint_watermark_rx_evt_t { + uint8 endpoint; + uint8 data; + }); + + PACKSTRUCT (struct ble_msg_system_endpoint_watermark_tx_evt_t { + uint8 endpoint; + uint8 data; + }); + + PACKSTRUCT (struct ble_msg_system_script_failure_evt_t { + uint16 address; + uint16 reason; + }); + + PACKSTRUCT (struct ble_msg_system_protocol_error_evt_t { uint16 reason; }); + + PACKSTRUCT (struct ble_msg_flash_ps_save_cmd_t { + uint16 key; + uint8array value; + }); + + PACKSTRUCT (struct ble_msg_flash_ps_save_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_flash_ps_load_cmd_t { uint16 key; }); + + PACKSTRUCT (struct ble_msg_flash_ps_load_rsp_t { + uint16 result; + uint8array value; + }); + + PACKSTRUCT (struct ble_msg_flash_ps_erase_cmd_t { uint16 key; }); + + PACKSTRUCT (struct ble_msg_flash_erase_page_cmd_t { uint8 page; }); + + PACKSTRUCT (struct ble_msg_flash_erase_page_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_flash_write_data_cmd_t { + uint32 address; + uint8array data; + }); + + PACKSTRUCT (struct ble_msg_flash_write_data_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_flash_read_data_cmd_t { + uint32 address; + uint8 length; + }); + + PACKSTRUCT (struct ble_msg_flash_read_data_rsp_t { uint8array data; }); + + PACKSTRUCT (struct ble_msg_flash_ps_key_evt_t { + uint16 key; + uint8array value; + }); + + PACKSTRUCT (struct ble_msg_attributes_write_cmd_t { + uint16 handle; + uint8 offset; + uint8array value; + }); + + PACKSTRUCT (struct ble_msg_attributes_write_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_attributes_read_cmd_t { + uint16 handle; + uint16 offset; + }); + + PACKSTRUCT (struct ble_msg_attributes_read_rsp_t { + uint16 handle; + uint16 offset; + uint16 result; + uint8array value; + }); + + PACKSTRUCT (struct ble_msg_attributes_read_type_cmd_t { uint16 handle; }); + + PACKSTRUCT (struct ble_msg_attributes_read_type_rsp_t { + uint16 handle; + uint16 result; + uint8array value; + }); + + PACKSTRUCT (struct ble_msg_attributes_user_read_response_cmd_t { + uint8 connection; + uint8 att_error; + uint8array value; + }); + + PACKSTRUCT (struct ble_msg_attributes_user_write_response_cmd_t { + uint8 connection; + uint8 att_error; + }); + + PACKSTRUCT (struct ble_msg_attributes_send_cmd_t { + uint8 connection; + uint16 handle; + uint8array value; + }); + + PACKSTRUCT (struct ble_msg_attributes_send_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_attributes_value_evt_t { + uint8 connection; + uint8 reason; + uint16 handle; + uint16 offset; + uint8array value; + }); + + PACKSTRUCT (struct ble_msg_attributes_user_read_request_evt_t { + uint8 connection; + uint16 handle; + uint16 offset; + uint8 maxsize; + }); + + PACKSTRUCT (struct ble_msg_attributes_status_evt_t { + uint16 handle; + uint8 flags; + }); + + PACKSTRUCT (struct ble_msg_connection_disconnect_cmd_t { uint8 connection; }); + + PACKSTRUCT (struct ble_msg_connection_disconnect_rsp_t { + uint8 connection; + uint16 result; + }); + + PACKSTRUCT (struct ble_msg_connection_get_rssi_cmd_t { uint8 connection; }); + + PACKSTRUCT (struct ble_msg_connection_get_rssi_rsp_t { + uint8 connection; + int8 rssi; + }); + + PACKSTRUCT (struct ble_msg_connection_update_cmd_t { + uint8 connection; + uint16 interval_min; + uint16 interval_max; + uint16 latency; + uint16 timeout; + }); + + PACKSTRUCT (struct ble_msg_connection_update_rsp_t { + uint8 connection; + uint16 result; + }); + + PACKSTRUCT (struct ble_msg_connection_version_update_cmd_t { uint8 connection; }); + + PACKSTRUCT (struct ble_msg_connection_version_update_rsp_t { + uint8 connection; + uint16 result; + }); + + PACKSTRUCT (struct ble_msg_connection_channel_map_get_cmd_t { uint8 connection; }); + + PACKSTRUCT (struct ble_msg_connection_channel_map_get_rsp_t { + uint8 connection; + uint8array map; + }); + + PACKSTRUCT (struct ble_msg_connection_channel_map_set_cmd_t { + uint8 connection; + uint8array map; + }); + + PACKSTRUCT (struct ble_msg_connection_channel_map_set_rsp_t { + uint8 connection; + uint16 result; + }); + + PACKSTRUCT (struct ble_msg_connection_features_get_cmd_t { uint8 connection; }); + + PACKSTRUCT (struct ble_msg_connection_features_get_rsp_t { + uint8 connection; + uint16 result; + }); + + PACKSTRUCT (struct ble_msg_connection_get_status_cmd_t { uint8 connection; }); + + PACKSTRUCT (struct ble_msg_connection_get_status_rsp_t { uint8 connection; }); + + PACKSTRUCT (struct ble_msg_connection_raw_tx_cmd_t { + uint8 connection; + uint8array data; + }); + + PACKSTRUCT (struct ble_msg_connection_raw_tx_rsp_t { uint8 connection; }); + + PACKSTRUCT (struct ble_msg_connection_status_evt_t { + uint8 connection; + uint8 flags; + bd_addr address; + uint8 address_type; + uint16 conn_interval; + uint16 timeout; + uint16 latency; + uint8 bonding; + }); + + PACKSTRUCT (struct ble_msg_connection_version_ind_evt_t { + uint8 connection; + uint8 vers_nr; + uint16 comp_id; + uint16 sub_vers_nr; + }); + + PACKSTRUCT (struct ble_msg_connection_feature_ind_evt_t { + uint8 connection; + uint8array features; + }); + + PACKSTRUCT (struct ble_msg_connection_raw_rx_evt_t { + uint8 connection; + uint8array data; + }); + + PACKSTRUCT (struct ble_msg_connection_disconnected_evt_t { + uint8 connection; + uint16 reason; + }); + + PACKSTRUCT (struct ble_msg_attclient_find_by_type_value_cmd_t { + uint8 connection; + uint16 start; + uint16 end; + uint16 uuid; + uint8array value; + }); + + PACKSTRUCT (struct ble_msg_attclient_find_by_type_value_rsp_t { + uint8 connection; + uint16 result; + }); + + PACKSTRUCT (struct ble_msg_attclient_read_by_group_type_cmd_t { + uint8 connection; + uint16 start; + uint16 end; + uint8array uuid; + }); + + PACKSTRUCT (struct ble_msg_attclient_read_by_group_type_rsp_t { + uint8 connection; + uint16 result; + }); + + PACKSTRUCT (struct ble_msg_attclient_read_by_type_cmd_t { + uint8 connection; + uint16 start; + uint16 end; + uint8array uuid; + }); + + PACKSTRUCT (struct ble_msg_attclient_read_by_type_rsp_t { + uint8 connection; + uint16 result; + }); + + PACKSTRUCT (struct ble_msg_attclient_find_information_cmd_t { + uint8 connection; + uint16 start; + uint16 end; + }); + + PACKSTRUCT (struct ble_msg_attclient_find_information_rsp_t { + uint8 connection; + uint16 result; + }); + + PACKSTRUCT (struct ble_msg_attclient_read_by_handle_cmd_t { + uint8 connection; + uint16 chrhandle; + }); + + PACKSTRUCT (struct ble_msg_attclient_read_by_handle_rsp_t { + uint8 connection; + uint16 result; + }); + + PACKSTRUCT (struct ble_msg_attclient_attribute_write_cmd_t { + uint8 connection; + uint16 atthandle; + uint8array data; + }); + + PACKSTRUCT (struct ble_msg_attclient_attribute_write_rsp_t { + uint8 connection; + uint16 result; + }); + + PACKSTRUCT (struct ble_msg_attclient_write_command_cmd_t { + uint8 connection; + uint16 atthandle; + uint8array data; + }); + + PACKSTRUCT (struct ble_msg_attclient_write_command_rsp_t { + uint8 connection; + uint16 result; + }); + + PACKSTRUCT (struct ble_msg_attclient_indicate_confirm_cmd_t { uint8 connection; }); + + PACKSTRUCT (struct ble_msg_attclient_indicate_confirm_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_attclient_read_long_cmd_t { + uint8 connection; + uint16 chrhandle; + }); + + PACKSTRUCT (struct ble_msg_attclient_read_long_rsp_t { + uint8 connection; + uint16 result; + }); + + PACKSTRUCT (struct ble_msg_attclient_prepare_write_cmd_t { + uint8 connection; + uint16 atthandle; + uint16 offset; + uint8array data; + }); + + PACKSTRUCT (struct ble_msg_attclient_prepare_write_rsp_t { + uint8 connection; + uint16 result; + }); + + PACKSTRUCT (struct ble_msg_attclient_execute_write_cmd_t { + uint8 connection; + uint8 commit; + }); + + PACKSTRUCT (struct ble_msg_attclient_execute_write_rsp_t { + uint8 connection; + uint16 result; + }); + + PACKSTRUCT (struct ble_msg_attclient_read_multiple_cmd_t { + uint8 connection; + uint8array handles; + }); + + PACKSTRUCT (struct ble_msg_attclient_read_multiple_rsp_t { + uint8 connection; + uint16 result; + }); + + PACKSTRUCT (struct ble_msg_attclient_indicated_evt_t { + uint8 connection; + uint16 attrhandle; + }); + + PACKSTRUCT (struct ble_msg_attclient_procedure_completed_evt_t { + uint8 connection; + uint16 result; + uint16 chrhandle; + }); + + PACKSTRUCT (struct ble_msg_attclient_group_found_evt_t { + uint8 connection; + uint16 start; + uint16 end; + uint8array uuid; + }); + + PACKSTRUCT (struct ble_msg_attclient_attribute_found_evt_t { + uint8 connection; + uint16 chrdecl; + uint16 value; + uint8 properties; + uint8array uuid; + }); + + PACKSTRUCT (struct ble_msg_attclient_find_information_found_evt_t { + uint8 connection; + uint16 chrhandle; + uint8array uuid; + }); + + PACKSTRUCT (struct ble_msg_attclient_attribute_value_evt_t { + uint8 connection; + uint16 atthandle; + uint8 type; + uint8array value; + }); + + PACKSTRUCT (struct ble_msg_attclient_read_multiple_response_evt_t { + uint8 connection; + uint8array handles; + }); + + PACKSTRUCT (struct ble_msg_sm_encrypt_start_cmd_t { + uint8 handle; + uint8 bonding; + }); + + PACKSTRUCT (struct ble_msg_sm_encrypt_start_rsp_t { + uint8 handle; + uint16 result; + }); + + PACKSTRUCT (struct ble_msg_sm_set_bondable_mode_cmd_t { uint8 bondable; }); + + PACKSTRUCT (struct ble_msg_sm_delete_bonding_cmd_t { uint8 handle; }); + + PACKSTRUCT (struct ble_msg_sm_delete_bonding_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_sm_set_parameters_cmd_t { + uint8 mitm; + uint8 min_key_size; + uint8 io_capabilities; + }); + + PACKSTRUCT (struct ble_msg_sm_passkey_entry_cmd_t { + uint8 handle; + uint32 passkey; + }); + + PACKSTRUCT (struct ble_msg_sm_passkey_entry_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_sm_get_bonds_rsp_t { uint8 bonds; }); + + PACKSTRUCT (struct ble_msg_sm_set_oob_data_cmd_t { uint8array oob; }); + + PACKSTRUCT (struct ble_msg_sm_whitelist_bonds_rsp_t { + uint16 result; + uint8 count; + }); + + PACKSTRUCT (struct ble_msg_sm_smp_data_evt_t { + uint8 handle; + uint8 packet; + uint8array data; + }); + + PACKSTRUCT (struct ble_msg_sm_bonding_fail_evt_t { + uint8 handle; + uint16 result; + }); + + PACKSTRUCT (struct ble_msg_sm_passkey_display_evt_t { + uint8 handle; + uint32 passkey; + }); + + PACKSTRUCT (struct ble_msg_sm_passkey_request_evt_t { uint8 handle; }); + + PACKSTRUCT (struct ble_msg_sm_bond_status_evt_t { + uint8 bond; + uint8 keysize; + uint8 mitm; + uint8 keys; + }); + + PACKSTRUCT (struct ble_msg_gap_set_privacy_flags_cmd_t { + uint8 peripheral_privacy; + uint8 central_privacy; + }); + + PACKSTRUCT (struct ble_msg_gap_set_mode_cmd_t { + uint8 discover; + uint8 connect; + }); + + PACKSTRUCT (struct ble_msg_gap_set_mode_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_gap_discover_cmd_t { uint8 mode; }); + + PACKSTRUCT (struct ble_msg_gap_discover_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_gap_connect_direct_cmd_t { + bd_addr address; + uint8 addr_type; + uint16 conn_interval_min; + uint16 conn_interval_max; + uint16 timeout; + uint16 latency; + }); + + PACKSTRUCT (struct ble_msg_gap_connect_direct_rsp_t { + uint16 result; + uint8 connection_handle; + }); + + PACKSTRUCT (struct ble_msg_gap_end_procedure_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_gap_connect_selective_cmd_t { + uint16 conn_interval_min; + uint16 conn_interval_max; + uint16 timeout; + uint16 latency; + }); + + PACKSTRUCT (struct ble_msg_gap_connect_selective_rsp_t { + uint16 result; + uint8 connection_handle; + }); + + PACKSTRUCT (struct ble_msg_gap_set_filtering_cmd_t { + uint8 scan_policy; + uint8 adv_policy; + uint8 scan_duplicate_filtering; + }); + + PACKSTRUCT (struct ble_msg_gap_set_filtering_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_gap_set_scan_parameters_cmd_t { + uint16 scan_interval; + uint16 scan_window; + uint8 active; + }); + + PACKSTRUCT (struct ble_msg_gap_set_scan_parameters_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_gap_set_adv_parameters_cmd_t { + uint16 adv_interval_min; + uint16 adv_interval_max; + uint8 adv_channels; + }); + + PACKSTRUCT (struct ble_msg_gap_set_adv_parameters_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_gap_set_adv_data_cmd_t { + uint8 set_scanrsp; + uint8array adv_data; + }); + + PACKSTRUCT (struct ble_msg_gap_set_adv_data_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_gap_set_directed_connectable_mode_cmd_t { + bd_addr address; + uint8 addr_type; + }); + + PACKSTRUCT (struct ble_msg_gap_set_directed_connectable_mode_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_gap_scan_response_evt_t { + int8 rssi; + uint8 packet_type; + bd_addr sender; + uint8 address_type; + uint8 bond; + uint8array data; + }); + + PACKSTRUCT (struct ble_msg_gap_mode_changed_evt_t { + uint8 discover; + uint8 connect; + }); + + PACKSTRUCT (struct ble_msg_hardware_io_port_config_irq_cmd_t { + uint8 port; + uint8 enable_bits; + uint8 falling_edge; + }); + + PACKSTRUCT (struct ble_msg_hardware_io_port_config_irq_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_hardware_set_soft_timer_cmd_t { + uint32 time; + uint8 handle; + uint8 single_shot; + }); + + PACKSTRUCT (struct ble_msg_hardware_set_soft_timer_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_hardware_adc_read_cmd_t { + uint8 input; + uint8 decimation; + uint8 reference_selection; + }); + + PACKSTRUCT (struct ble_msg_hardware_adc_read_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_hardware_io_port_config_direction_cmd_t { + uint8 port; + uint8 direction; + }); + + PACKSTRUCT (struct ble_msg_hardware_io_port_config_direction_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_hardware_io_port_config_function_cmd_t { + uint8 port; + uint8 function; + }); + + PACKSTRUCT (struct ble_msg_hardware_io_port_config_function_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_hardware_io_port_config_pull_cmd_t { + uint8 port; + uint8 tristate_mask; + uint8 pull_up; + }); + + PACKSTRUCT (struct ble_msg_hardware_io_port_config_pull_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_hardware_io_port_write_cmd_t { + uint8 port; + uint8 mask; + uint8 data; + }); + + PACKSTRUCT (struct ble_msg_hardware_io_port_write_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_hardware_io_port_read_cmd_t { + uint8 port; + uint8 mask; + }); + + PACKSTRUCT (struct ble_msg_hardware_io_port_read_rsp_t { + uint16 result; + uint8 port; + uint8 data; + }); + + PACKSTRUCT (struct ble_msg_hardware_spi_config_cmd_t { + uint8 channel; + uint8 polarity; + uint8 phase; + uint8 bit_order; + uint8 baud_e; + uint8 baud_m; + }); + + PACKSTRUCT (struct ble_msg_hardware_spi_config_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_hardware_spi_transfer_cmd_t { + uint8 channel; + uint8array data; + }); + + PACKSTRUCT (struct ble_msg_hardware_spi_transfer_rsp_t { + uint16 result; + uint8 channel; + uint8array data; + }); + + PACKSTRUCT (struct ble_msg_hardware_i2c_read_cmd_t { + uint8 address; + uint8 stop; + uint8 length; + }); + + PACKSTRUCT (struct ble_msg_hardware_i2c_read_rsp_t { + uint16 result; + uint8array data; + }); + + PACKSTRUCT (struct ble_msg_hardware_i2c_write_cmd_t { + uint8 address; + uint8 stop; + uint8array data; + }); + + PACKSTRUCT (struct ble_msg_hardware_i2c_write_rsp_t { uint8 written; }); + + PACKSTRUCT (struct ble_msg_hardware_set_txpower_cmd_t { uint8 power; }); + + PACKSTRUCT (struct ble_msg_hardware_timer_comparator_cmd_t { + uint8 timer; + uint8 channel; + uint8 mode; + uint16 comparator_value; + }); + + PACKSTRUCT (struct ble_msg_hardware_timer_comparator_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_hardware_io_port_irq_enable_cmd_t { + uint8 port; + uint8 enable_bits; + }); + + PACKSTRUCT (struct ble_msg_hardware_io_port_irq_enable_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_hardware_io_port_irq_direction_cmd_t { + uint8 port; + uint8 falling_edge; + }); + + PACKSTRUCT (struct ble_msg_hardware_io_port_irq_direction_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_hardware_analog_comparator_enable_cmd_t { uint8 enable; }); + + PACKSTRUCT (struct ble_msg_hardware_analog_comparator_read_rsp_t { + uint16 result; + uint8 output; + }); + + PACKSTRUCT (struct ble_msg_hardware_analog_comparator_config_irq_cmd_t { uint8 enabled; }); + + PACKSTRUCT (struct ble_msg_hardware_analog_comparator_config_irq_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_hardware_set_rxgain_cmd_t { uint8 gain; }); + + PACKSTRUCT (struct ble_msg_hardware_usb_enable_cmd_t { uint8 enable; }); + + PACKSTRUCT (struct ble_msg_hardware_usb_enable_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_hardware_io_port_status_evt_t { + uint32 timestamp; + uint8 port; + uint8 irq; + uint8 state; + }); + + PACKSTRUCT (struct ble_msg_hardware_soft_timer_evt_t { uint8 handle; }); + + PACKSTRUCT (struct ble_msg_hardware_adc_result_evt_t { + uint8 input; + int16 value; + }); + + PACKSTRUCT (struct ble_msg_hardware_analog_comparator_status_evt_t { + uint32 timestamp; + uint8 output; + }); + + PACKSTRUCT (struct ble_msg_test_phy_tx_cmd_t { + uint8 channel; + uint8 length; + uint8 type; + }); + + PACKSTRUCT (struct ble_msg_test_phy_rx_cmd_t { uint8 channel; }); + + PACKSTRUCT (struct ble_msg_test_phy_end_rsp_t { uint16 counter; }); + + PACKSTRUCT (struct ble_msg_test_get_channel_map_rsp_t { uint8array channel_map; }); + + PACKSTRUCT (struct ble_msg_test_debug_cmd_t { uint8array input; }); + + PACKSTRUCT (struct ble_msg_test_debug_rsp_t { uint8array output; }); + + PACKSTRUCT (struct ble_msg_test_channel_mode_cmd_t { uint8 mode; }); + + PACKSTRUCT (struct ble_msg_dfu_reset_cmd_t { uint8 dfu; }); + + PACKSTRUCT (struct ble_msg_dfu_flash_set_address_cmd_t { uint32 address; }); + + PACKSTRUCT (struct ble_msg_dfu_flash_set_address_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_dfu_flash_upload_cmd_t { uint8array data; }); + + PACKSTRUCT (struct ble_msg_dfu_flash_upload_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_dfu_flash_upload_finish_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_dfu_boot_evt_t { uint32 version; }); + + PACKSTRUCT (struct ble_cmd_packet { + struct ble_header header; + + union { + uint8 handle; + + uint8 payload; + + struct ble_msg_system_reset_cmd_t system_reset_cmd; + struct ble_msg_system_reg_write_cmd_t system_reg_write_cmd; + struct ble_msg_system_reg_read_cmd_t system_reg_read_cmd; + struct ble_msg_system_read_memory_cmd_t system_read_memory_cmd; + struct ble_msg_system_endpoint_tx_cmd_t system_endpoint_tx_cmd; + struct ble_msg_system_whitelist_append_cmd_t system_whitelist_append_cmd; + struct ble_msg_system_whitelist_remove_cmd_t system_whitelist_remove_cmd; + struct ble_msg_system_endpoint_rx_cmd_t system_endpoint_rx_cmd; + struct ble_msg_system_endpoint_set_watermarks_cmd_t system_endpoint_set_watermarks_cmd; + struct ble_msg_system_aes_setkey_cmd_t system_aes_setkey_cmd; + struct ble_msg_system_aes_encrypt_cmd_t system_aes_encrypt_cmd; + struct ble_msg_system_aes_decrypt_cmd_t system_aes_decrypt_cmd; + struct ble_msg_system_boot_evt_t system_boot_evt; + struct ble_msg_system_debug_evt_t system_debug_evt; + struct ble_msg_system_endpoint_watermark_rx_evt_t system_endpoint_watermark_rx_evt; + struct ble_msg_system_endpoint_watermark_tx_evt_t system_endpoint_watermark_tx_evt; + struct ble_msg_system_script_failure_evt_t system_script_failure_evt; + struct ble_msg_system_protocol_error_evt_t system_protocol_error_evt; + struct ble_msg_system_address_get_rsp_t system_address_get_rsp; + struct ble_msg_system_reg_write_rsp_t system_reg_write_rsp; + struct ble_msg_system_reg_read_rsp_t system_reg_read_rsp; + struct ble_msg_system_get_counters_rsp_t system_get_counters_rsp; + struct ble_msg_system_get_connections_rsp_t system_get_connections_rsp; + struct ble_msg_system_read_memory_rsp_t system_read_memory_rsp; + struct ble_msg_system_get_info_rsp_t system_get_info_rsp; + struct ble_msg_system_endpoint_tx_rsp_t system_endpoint_tx_rsp; + struct ble_msg_system_whitelist_append_rsp_t system_whitelist_append_rsp; + struct ble_msg_system_whitelist_remove_rsp_t system_whitelist_remove_rsp; + struct ble_msg_system_endpoint_rx_rsp_t system_endpoint_rx_rsp; + struct ble_msg_system_endpoint_set_watermarks_rsp_t system_endpoint_set_watermarks_rsp; + struct ble_msg_system_aes_encrypt_rsp_t system_aes_encrypt_rsp; + struct ble_msg_system_aes_decrypt_rsp_t system_aes_decrypt_rsp; + struct ble_msg_flash_ps_save_cmd_t flash_ps_save_cmd; + struct ble_msg_flash_ps_load_cmd_t flash_ps_load_cmd; + struct ble_msg_flash_ps_erase_cmd_t flash_ps_erase_cmd; + struct ble_msg_flash_erase_page_cmd_t flash_erase_page_cmd; + struct ble_msg_flash_write_data_cmd_t flash_write_data_cmd; + struct ble_msg_flash_read_data_cmd_t flash_read_data_cmd; + struct ble_msg_flash_ps_key_evt_t flash_ps_key_evt; + struct ble_msg_flash_ps_save_rsp_t flash_ps_save_rsp; + struct ble_msg_flash_ps_load_rsp_t flash_ps_load_rsp; + struct ble_msg_flash_erase_page_rsp_t flash_erase_page_rsp; + struct ble_msg_flash_write_data_rsp_t flash_write_data_rsp; + struct ble_msg_flash_read_data_rsp_t flash_read_data_rsp; + struct ble_msg_attributes_write_cmd_t attributes_write_cmd; + struct ble_msg_attributes_read_cmd_t attributes_read_cmd; + struct ble_msg_attributes_read_type_cmd_t attributes_read_type_cmd; + struct ble_msg_attributes_user_read_response_cmd_t attributes_user_read_response_cmd; + struct ble_msg_attributes_user_write_response_cmd_t attributes_user_write_response_cmd; + struct ble_msg_attributes_send_cmd_t attributes_send_cmd; + struct ble_msg_attributes_value_evt_t attributes_value_evt; + struct ble_msg_attributes_user_read_request_evt_t attributes_user_read_request_evt; + struct ble_msg_attributes_status_evt_t attributes_status_evt; + struct ble_msg_attributes_write_rsp_t attributes_write_rsp; + struct ble_msg_attributes_read_rsp_t attributes_read_rsp; + struct ble_msg_attributes_read_type_rsp_t attributes_read_type_rsp; + struct ble_msg_attributes_send_rsp_t attributes_send_rsp; + struct ble_msg_connection_disconnect_cmd_t connection_disconnect_cmd; + struct ble_msg_connection_get_rssi_cmd_t connection_get_rssi_cmd; + struct ble_msg_connection_update_cmd_t connection_update_cmd; + struct ble_msg_connection_version_update_cmd_t connection_version_update_cmd; + struct ble_msg_connection_channel_map_get_cmd_t connection_channel_map_get_cmd; + struct ble_msg_connection_channel_map_set_cmd_t connection_channel_map_set_cmd; + struct ble_msg_connection_features_get_cmd_t connection_features_get_cmd; + struct ble_msg_connection_get_status_cmd_t connection_get_status_cmd; + struct ble_msg_connection_raw_tx_cmd_t connection_raw_tx_cmd; + struct ble_msg_connection_status_evt_t connection_status_evt; + struct ble_msg_connection_version_ind_evt_t connection_version_ind_evt; + struct ble_msg_connection_feature_ind_evt_t connection_feature_ind_evt; + struct ble_msg_connection_raw_rx_evt_t connection_raw_rx_evt; + struct ble_msg_connection_disconnected_evt_t connection_disconnected_evt; + struct ble_msg_connection_disconnect_rsp_t connection_disconnect_rsp; + struct ble_msg_connection_get_rssi_rsp_t connection_get_rssi_rsp; + struct ble_msg_connection_update_rsp_t connection_update_rsp; + struct ble_msg_connection_version_update_rsp_t connection_version_update_rsp; + struct ble_msg_connection_channel_map_get_rsp_t connection_channel_map_get_rsp; + struct ble_msg_connection_channel_map_set_rsp_t connection_channel_map_set_rsp; + struct ble_msg_connection_features_get_rsp_t connection_features_get_rsp; + struct ble_msg_connection_get_status_rsp_t connection_get_status_rsp; + struct ble_msg_connection_raw_tx_rsp_t connection_raw_tx_rsp; + struct ble_msg_attclient_find_by_type_value_cmd_t attclient_find_by_type_value_cmd; + struct ble_msg_attclient_read_by_group_type_cmd_t attclient_read_by_group_type_cmd; + struct ble_msg_attclient_read_by_type_cmd_t attclient_read_by_type_cmd; + struct ble_msg_attclient_find_information_cmd_t attclient_find_information_cmd; + struct ble_msg_attclient_read_by_handle_cmd_t attclient_read_by_handle_cmd; + struct ble_msg_attclient_attribute_write_cmd_t attclient_attribute_write_cmd; + struct ble_msg_attclient_write_command_cmd_t attclient_write_command_cmd; + struct ble_msg_attclient_indicate_confirm_cmd_t attclient_indicate_confirm_cmd; + struct ble_msg_attclient_read_long_cmd_t attclient_read_long_cmd; + struct ble_msg_attclient_prepare_write_cmd_t attclient_prepare_write_cmd; + struct ble_msg_attclient_execute_write_cmd_t attclient_execute_write_cmd; + struct ble_msg_attclient_read_multiple_cmd_t attclient_read_multiple_cmd; + struct ble_msg_attclient_indicated_evt_t attclient_indicated_evt; + struct ble_msg_attclient_procedure_completed_evt_t attclient_procedure_completed_evt; + struct ble_msg_attclient_group_found_evt_t attclient_group_found_evt; + struct ble_msg_attclient_attribute_found_evt_t attclient_attribute_found_evt; + struct ble_msg_attclient_find_information_found_evt_t + attclient_find_information_found_evt; + struct ble_msg_attclient_attribute_value_evt_t attclient_attribute_value_evt; + struct ble_msg_attclient_read_multiple_response_evt_t + attclient_read_multiple_response_evt; + struct ble_msg_attclient_find_by_type_value_rsp_t attclient_find_by_type_value_rsp; + struct ble_msg_attclient_read_by_group_type_rsp_t attclient_read_by_group_type_rsp; + struct ble_msg_attclient_read_by_type_rsp_t attclient_read_by_type_rsp; + struct ble_msg_attclient_find_information_rsp_t attclient_find_information_rsp; + struct ble_msg_attclient_read_by_handle_rsp_t attclient_read_by_handle_rsp; + struct ble_msg_attclient_attribute_write_rsp_t attclient_attribute_write_rsp; + struct ble_msg_attclient_write_command_rsp_t attclient_write_command_rsp; + struct ble_msg_attclient_indicate_confirm_rsp_t attclient_indicate_confirm_rsp; + struct ble_msg_attclient_read_long_rsp_t attclient_read_long_rsp; + struct ble_msg_attclient_prepare_write_rsp_t attclient_prepare_write_rsp; + struct ble_msg_attclient_execute_write_rsp_t attclient_execute_write_rsp; + struct ble_msg_attclient_read_multiple_rsp_t attclient_read_multiple_rsp; + struct ble_msg_sm_encrypt_start_cmd_t sm_encrypt_start_cmd; + struct ble_msg_sm_set_bondable_mode_cmd_t sm_set_bondable_mode_cmd; + struct ble_msg_sm_delete_bonding_cmd_t sm_delete_bonding_cmd; + struct ble_msg_sm_set_parameters_cmd_t sm_set_parameters_cmd; + struct ble_msg_sm_passkey_entry_cmd_t sm_passkey_entry_cmd; + struct ble_msg_sm_set_oob_data_cmd_t sm_set_oob_data_cmd; + struct ble_msg_sm_smp_data_evt_t sm_smp_data_evt; + struct ble_msg_sm_bonding_fail_evt_t sm_bonding_fail_evt; + struct ble_msg_sm_passkey_display_evt_t sm_passkey_display_evt; + struct ble_msg_sm_passkey_request_evt_t sm_passkey_request_evt; + struct ble_msg_sm_bond_status_evt_t sm_bond_status_evt; + struct ble_msg_sm_encrypt_start_rsp_t sm_encrypt_start_rsp; + struct ble_msg_sm_delete_bonding_rsp_t sm_delete_bonding_rsp; + struct ble_msg_sm_passkey_entry_rsp_t sm_passkey_entry_rsp; + struct ble_msg_sm_get_bonds_rsp_t sm_get_bonds_rsp; + struct ble_msg_sm_whitelist_bonds_rsp_t sm_whitelist_bonds_rsp; + struct ble_msg_gap_set_privacy_flags_cmd_t gap_set_privacy_flags_cmd; + struct ble_msg_gap_set_mode_cmd_t gap_set_mode_cmd; + struct ble_msg_gap_discover_cmd_t gap_discover_cmd; + struct ble_msg_gap_connect_direct_cmd_t gap_connect_direct_cmd; + struct ble_msg_gap_connect_selective_cmd_t gap_connect_selective_cmd; + struct ble_msg_gap_set_filtering_cmd_t gap_set_filtering_cmd; + struct ble_msg_gap_set_scan_parameters_cmd_t gap_set_scan_parameters_cmd; + struct ble_msg_gap_set_adv_parameters_cmd_t gap_set_adv_parameters_cmd; + struct ble_msg_gap_set_adv_data_cmd_t gap_set_adv_data_cmd; + struct ble_msg_gap_set_directed_connectable_mode_cmd_t + gap_set_directed_connectable_mode_cmd; + struct ble_msg_gap_scan_response_evt_t gap_scan_response_evt; + struct ble_msg_gap_mode_changed_evt_t gap_mode_changed_evt; + struct ble_msg_gap_set_mode_rsp_t gap_set_mode_rsp; + struct ble_msg_gap_discover_rsp_t gap_discover_rsp; + struct ble_msg_gap_connect_direct_rsp_t gap_connect_direct_rsp; + struct ble_msg_gap_end_procedure_rsp_t gap_end_procedure_rsp; + struct ble_msg_gap_connect_selective_rsp_t gap_connect_selective_rsp; + struct ble_msg_gap_set_filtering_rsp_t gap_set_filtering_rsp; + struct ble_msg_gap_set_scan_parameters_rsp_t gap_set_scan_parameters_rsp; + struct ble_msg_gap_set_adv_parameters_rsp_t gap_set_adv_parameters_rsp; + struct ble_msg_gap_set_adv_data_rsp_t gap_set_adv_data_rsp; + struct ble_msg_gap_set_directed_connectable_mode_rsp_t + gap_set_directed_connectable_mode_rsp; + struct ble_msg_hardware_io_port_config_irq_cmd_t hardware_io_port_config_irq_cmd; + struct ble_msg_hardware_set_soft_timer_cmd_t hardware_set_soft_timer_cmd; + struct ble_msg_hardware_adc_read_cmd_t hardware_adc_read_cmd; + struct ble_msg_hardware_io_port_config_direction_cmd_t + hardware_io_port_config_direction_cmd; + struct ble_msg_hardware_io_port_config_function_cmd_t + hardware_io_port_config_function_cmd; + struct ble_msg_hardware_io_port_config_pull_cmd_t hardware_io_port_config_pull_cmd; + struct ble_msg_hardware_io_port_write_cmd_t hardware_io_port_write_cmd; + struct ble_msg_hardware_io_port_read_cmd_t hardware_io_port_read_cmd; + struct ble_msg_hardware_spi_config_cmd_t hardware_spi_config_cmd; + struct ble_msg_hardware_spi_transfer_cmd_t hardware_spi_transfer_cmd; + struct ble_msg_hardware_i2c_read_cmd_t hardware_i2c_read_cmd; + struct ble_msg_hardware_i2c_write_cmd_t hardware_i2c_write_cmd; + struct ble_msg_hardware_set_txpower_cmd_t hardware_set_txpower_cmd; + struct ble_msg_hardware_timer_comparator_cmd_t hardware_timer_comparator_cmd; + struct ble_msg_hardware_io_port_irq_enable_cmd_t hardware_io_port_irq_enable_cmd; + struct ble_msg_hardware_io_port_irq_direction_cmd_t hardware_io_port_irq_direction_cmd; + struct ble_msg_hardware_analog_comparator_enable_cmd_t + hardware_analog_comparator_enable_cmd; + struct ble_msg_hardware_analog_comparator_config_irq_cmd_t + hardware_analog_comparator_config_irq_cmd; + struct ble_msg_hardware_set_rxgain_cmd_t hardware_set_rxgain_cmd; + struct ble_msg_hardware_usb_enable_cmd_t hardware_usb_enable_cmd; + struct ble_msg_hardware_io_port_status_evt_t hardware_io_port_status_evt; + struct ble_msg_hardware_soft_timer_evt_t hardware_soft_timer_evt; + struct ble_msg_hardware_adc_result_evt_t hardware_adc_result_evt; + struct ble_msg_hardware_analog_comparator_status_evt_t + hardware_analog_comparator_status_evt; + struct ble_msg_hardware_io_port_config_irq_rsp_t hardware_io_port_config_irq_rsp; + struct ble_msg_hardware_set_soft_timer_rsp_t hardware_set_soft_timer_rsp; + struct ble_msg_hardware_adc_read_rsp_t hardware_adc_read_rsp; + struct ble_msg_hardware_io_port_config_direction_rsp_t + hardware_io_port_config_direction_rsp; + struct ble_msg_hardware_io_port_config_function_rsp_t + hardware_io_port_config_function_rsp; + struct ble_msg_hardware_io_port_config_pull_rsp_t hardware_io_port_config_pull_rsp; + struct ble_msg_hardware_io_port_write_rsp_t hardware_io_port_write_rsp; + struct ble_msg_hardware_io_port_read_rsp_t hardware_io_port_read_rsp; + struct ble_msg_hardware_spi_config_rsp_t hardware_spi_config_rsp; + struct ble_msg_hardware_spi_transfer_rsp_t hardware_spi_transfer_rsp; + struct ble_msg_hardware_i2c_read_rsp_t hardware_i2c_read_rsp; + struct ble_msg_hardware_i2c_write_rsp_t hardware_i2c_write_rsp; + struct ble_msg_hardware_timer_comparator_rsp_t hardware_timer_comparator_rsp; + struct ble_msg_hardware_io_port_irq_enable_rsp_t hardware_io_port_irq_enable_rsp; + struct ble_msg_hardware_io_port_irq_direction_rsp_t hardware_io_port_irq_direction_rsp; + struct ble_msg_hardware_analog_comparator_read_rsp_t + hardware_analog_comparator_read_rsp; + struct ble_msg_hardware_analog_comparator_config_irq_rsp_t + hardware_analog_comparator_config_irq_rsp; + struct ble_msg_hardware_usb_enable_rsp_t hardware_usb_enable_rsp; + struct ble_msg_test_phy_tx_cmd_t test_phy_tx_cmd; + struct ble_msg_test_phy_rx_cmd_t test_phy_rx_cmd; + struct ble_msg_test_debug_cmd_t test_debug_cmd; + struct ble_msg_test_channel_mode_cmd_t test_channel_mode_cmd; + struct ble_msg_test_phy_end_rsp_t test_phy_end_rsp; + struct ble_msg_test_get_channel_map_rsp_t test_get_channel_map_rsp; + struct ble_msg_test_debug_rsp_t test_debug_rsp; + struct ble_msg_dfu_reset_cmd_t dfu_reset_cmd; + struct ble_msg_dfu_flash_set_address_cmd_t dfu_flash_set_address_cmd; + struct ble_msg_dfu_flash_upload_cmd_t dfu_flash_upload_cmd; + struct ble_msg_dfu_boot_evt_t dfu_boot_evt; + struct ble_msg_dfu_flash_set_address_rsp_t dfu_flash_set_address_rsp; + struct ble_msg_dfu_flash_upload_rsp_t dfu_flash_upload_rsp; + struct ble_msg_dfu_flash_upload_finish_rsp_t dfu_flash_upload_finish_rsp; + }; + } ALIGNED); +/**Reset device**/ +#define ble_cmd_system_reset(boot_in_dfu) ble_send_message (ble_cmd_system_reset_idx, boot_in_dfu) +/**Hello - command for testing**/ +#define ble_cmd_system_hello() ble_send_message (ble_cmd_system_hello_idx) +/**Get device bluetooth address**/ +#define ble_cmd_system_address_get() ble_send_message (ble_cmd_system_address_get_idx) +/**write register**/ +#define ble_cmd_system_reg_write(address, value) \ + ble_send_message (ble_cmd_system_reg_write_idx, address, value) +/**read register**/ +#define ble_cmd_system_reg_read(address) ble_send_message (ble_cmd_system_reg_read_idx, address) +/**get and reset packet counters**/ +#define ble_cmd_system_get_counters() ble_send_message (ble_cmd_system_get_counters_idx) +/**Get status from all connections**/ +#define ble_cmd_system_get_connections() ble_send_message (ble_cmd_system_get_connections_idx) +/**Read Memory**/ +#define ble_cmd_system_read_memory(address, length) \ + ble_send_message (ble_cmd_system_read_memory_idx, address, length) +/**Get Device info**/ +#define ble_cmd_system_get_info() ble_send_message (ble_cmd_system_get_info_idx) +/**Send data to endpoint, error is returned if endpoint does not have enough space**/ +#define ble_cmd_system_endpoint_tx(endpoint, data_len, data_data) \ + ble_send_message (ble_cmd_system_endpoint_tx_idx, endpoint, data_len, data_data) +/**Add entry to whitelist**/ +#define ble_cmd_system_whitelist_append(address, address_type) \ + ble_send_message (ble_cmd_system_whitelist_append_idx, address, address_type) +/**Remove entry from whitelist**/ +#define ble_cmd_system_whitelist_remove(address, address_type) \ + ble_send_message (ble_cmd_system_whitelist_remove_idx, address, address_type) +/**Add entry to whitelist**/ +#define ble_cmd_system_whitelist_clear() ble_send_message (ble_cmd_system_whitelist_clear_idx) +/**Read data from endpoint, error is returned if endpoint does not have enough data.**/ +#define ble_cmd_system_endpoint_rx(endpoint, size) \ + ble_send_message (ble_cmd_system_endpoint_rx_idx, endpoint, size) +/**Set watermarks on both input and output side**/ +#define ble_cmd_system_endpoint_set_watermarks(endpoint, rx, tx) \ + ble_send_message (ble_cmd_system_endpoint_set_watermarks_idx, endpoint, rx, tx) +/**Set encryption key that will be used with aes_encrypt and aes_decrypt commands.**/ +#define ble_cmd_system_aes_setkey(key_len, key_data) \ + ble_send_message (ble_cmd_system_aes_setkey_idx, key_len, key_data) +/**Encrypt one block of data**/ +#define ble_cmd_system_aes_encrypt(data_len, data_data) \ + ble_send_message (ble_cmd_system_aes_encrypt_idx, data_len, data_data) +/**Decrypt one block of data**/ +#define ble_cmd_system_aes_decrypt(data_len, data_data) \ + ble_send_message (ble_cmd_system_aes_decrypt_idx, data_len, data_data) +/**Defragment persistent store**/ +#define ble_cmd_flash_ps_defrag() ble_send_message (ble_cmd_flash_ps_defrag_idx) +/**Dump all ps keys**/ +#define ble_cmd_flash_ps_dump() ble_send_message (ble_cmd_flash_ps_dump_idx) +/**erase all ps keys**/ +#define ble_cmd_flash_ps_erase_all() ble_send_message (ble_cmd_flash_ps_erase_all_idx) +/**save ps key**/ +#define ble_cmd_flash_ps_save(key, value_len, value_data) \ + ble_send_message (ble_cmd_flash_ps_save_idx, key, value_len, value_data) +/**load ps key**/ +#define ble_cmd_flash_ps_load(key) ble_send_message (ble_cmd_flash_ps_load_idx, key) +/**erase ps key**/ +#define ble_cmd_flash_ps_erase(key) ble_send_message (ble_cmd_flash_ps_erase_idx, key) +/**erase flash page**/ +#define ble_cmd_flash_erase_page(page) ble_send_message (ble_cmd_flash_erase_page_idx, page) +/**write data to user data area**/ +#define ble_cmd_flash_write_data(address, data_len, data_data) \ + ble_send_message (ble_cmd_flash_write_data_idx, address, data_len, data_data) +/**read data from user data area.**/ +#define ble_cmd_flash_read_data(address, length) \ + ble_send_message (ble_cmd_flash_read_data_idx, address, length) +/**Write to attribute database**/ +#define ble_cmd_attributes_write(handle, offset, value_len, value_data) \ + ble_send_message (ble_cmd_attributes_write_idx, handle, offset, value_len, value_data) +/**Read from attribute database**/ +#define ble_cmd_attributes_read(handle, offset) \ + ble_send_message (ble_cmd_attributes_read_idx, handle, offset) +/**Read attribute type from database**/ +#define ble_cmd_attributes_read_type(handle) \ + ble_send_message (ble_cmd_attributes_read_type_idx, handle) +/**Respond to user attribute read request**/ +#define ble_cmd_attributes_user_read_response(connection, att_error, value_len, value_data) \ + ble_send_message ( \ + ble_cmd_attributes_user_read_response_idx, connection, att_error, value_len, value_data) +/**Response to attribute_changed event where reason is user-attribute write.**/ +#define ble_cmd_attributes_user_write_response(connection, att_error) \ + ble_send_message (ble_cmd_attributes_user_write_response_idx, connection, att_error) +/**Send notification or indication to remote device.**/ +#define ble_cmd_attributes_send(connection, handle, value_len, value_data) \ + ble_send_message (ble_cmd_attributes_send_idx, connection, handle, value_len, value_data) +/**Disconnect connection, starts a disconnection procedure on connection**/ +#define ble_cmd_connection_disconnect(connection) \ + ble_send_message (ble_cmd_connection_disconnect_idx, connection) +/**Get Link RSSI**/ +#define ble_cmd_connection_get_rssi(connection) \ + ble_send_message (ble_cmd_connection_get_rssi_idx, connection) +/**Update connection parameters**/ +#define ble_cmd_connection_update(connection, interval_min, interval_max, latency, timeout) \ + ble_send_message ( \ + ble_cmd_connection_update_idx, connection, interval_min, interval_max, latency, timeout) +/**Request version exchange**/ +#define ble_cmd_connection_version_update(connection) \ + ble_send_message (ble_cmd_connection_version_update_idx, connection) +/**Get Current channel map**/ +#define ble_cmd_connection_channel_map_get(connection) \ + ble_send_message (ble_cmd_connection_channel_map_get_idx, connection) +/**Set Channel map**/ +#define ble_cmd_connection_channel_map_set(connection, map_len, map_data) \ + ble_send_message (ble_cmd_connection_channel_map_set_idx, connection, map_len, map_data) +/**Remote feature request**/ +#define ble_cmd_connection_features_get(connection) \ + ble_send_message (ble_cmd_connection_features_get_idx, connection) +/**Get Connection Status Parameters**/ +#define ble_cmd_connection_get_status(connection) \ + ble_send_message (ble_cmd_connection_get_status_idx, connection) +/**Raw TX**/ +#define ble_cmd_connection_raw_tx(connection, data_len, data_data) \ + ble_send_message (ble_cmd_connection_raw_tx_idx, connection, data_len, data_data) +/**Discover attributes by type and value**/ +#define ble_cmd_attclient_find_by_type_value(connection, start, end, uuid, value_len, value_data) \ + ble_send_message (ble_cmd_attclient_find_by_type_value_idx, connection, start, end, uuid, \ + value_len, value_data) +/**Discover attributes by type and value**/ +#define ble_cmd_attclient_read_by_group_type(connection, start, end, uuid_len, uuid_data) \ + ble_send_message ( \ + ble_cmd_attclient_read_by_group_type_idx, connection, start, end, uuid_len, uuid_data) +/**Read all attributes where type matches**/ +#define ble_cmd_attclient_read_by_type(connection, start, end, uuid_len, uuid_data) \ + ble_send_message ( \ + ble_cmd_attclient_read_by_type_idx, connection, start, end, uuid_len, uuid_data) +/**Discover Attribute handle and type mappings**/ +#define ble_cmd_attclient_find_information(connection, start, end) \ + ble_send_message (ble_cmd_attclient_find_information_idx, connection, start, end) +/**Read Characteristic value using handle**/ +#define ble_cmd_attclient_read_by_handle(connection, chrhandle) \ + ble_send_message (ble_cmd_attclient_read_by_handle_idx, connection, chrhandle) +/**write data to attribute**/ +#define ble_cmd_attclient_attribute_write(connection, atthandle, data_len, data_data) \ + ble_send_message ( \ + ble_cmd_attclient_attribute_write_idx, connection, atthandle, data_len, data_data) +/**write data to attribute using ATT write command**/ +#define ble_cmd_attclient_write_command(connection, atthandle, data_len, data_data) \ + ble_send_message ( \ + ble_cmd_attclient_write_command_idx, connection, atthandle, data_len, data_data) +/**Send confirmation for received indication, use only if manual indications are enabled**/ +#define ble_cmd_attclient_indicate_confirm(connection) \ + ble_send_message (ble_cmd_attclient_indicate_confirm_idx, connection) +/**Read Long Characteristic value**/ +#define ble_cmd_attclient_read_long(connection, chrhandle) \ + ble_send_message (ble_cmd_attclient_read_long_idx, connection, chrhandle) +/**Send prepare write request to remote host**/ +#define ble_cmd_attclient_prepare_write(connection, atthandle, offset, data_len, data_data) \ + ble_send_message ( \ + ble_cmd_attclient_prepare_write_idx, connection, atthandle, offset, data_len, data_data) +/**Send prepare write request to remote host**/ +#define ble_cmd_attclient_execute_write(connection, commit) \ + ble_send_message (ble_cmd_attclient_execute_write_idx, connection, commit) +/**Read multiple attributes from server**/ +#define ble_cmd_attclient_read_multiple(connection, handles_len, handles_data) \ + ble_send_message (ble_cmd_attclient_read_multiple_idx, connection, handles_len, handles_data) +/**Enable encryption on link**/ +#define ble_cmd_sm_encrypt_start(handle, bonding) \ + ble_send_message (ble_cmd_sm_encrypt_start_idx, handle, bonding) +/**Set device to bondable mode**/ +#define ble_cmd_sm_set_bondable_mode(bondable) \ + ble_send_message (ble_cmd_sm_set_bondable_mode_idx, bondable) +/**delete bonding information from ps store**/ +#define ble_cmd_sm_delete_bonding(handle) ble_send_message (ble_cmd_sm_delete_bonding_idx, handle) +/**set pairing requirements**/ +#define ble_cmd_sm_set_parameters(mitm, min_key_size, io_capabilities) \ + ble_send_message (ble_cmd_sm_set_parameters_idx, mitm, min_key_size, io_capabilities) +/**Passkey entered**/ +#define ble_cmd_sm_passkey_entry(handle, passkey) \ + ble_send_message (ble_cmd_sm_passkey_entry_idx, handle, passkey) +/**List all bonded devices**/ +#define ble_cmd_sm_get_bonds() ble_send_message (ble_cmd_sm_get_bonds_idx) +/** + Set out-of-band encryption data for device + Device does not allow any other kind of pairing except oob if oob data is set. + **/ +#define ble_cmd_sm_set_oob_data(oob_len, oob_data) \ + ble_send_message (ble_cmd_sm_set_oob_data_idx, oob_len, oob_data) +/** + Add all bonded devices with a known public or static address to + the whitelist. Previous entries in the whitelist are first + cleared. This command can't be used while advertising, scanning + or being connected. + **/ +#define ble_cmd_sm_whitelist_bonds() ble_send_message (ble_cmd_sm_whitelist_bonds_idx) +/**Set GAP central/peripheral privacy flags + **/ +#define ble_cmd_gap_set_privacy_flags(peripheral_privacy, central_privacy) \ + ble_send_message (ble_cmd_gap_set_privacy_flags_idx, peripheral_privacy, central_privacy) +/**Set discoverable and connectable mode**/ +#define ble_cmd_gap_set_mode(discover, connect) \ + ble_send_message (ble_cmd_gap_set_mode_idx, discover, connect) +/**start or stop discover procedure**/ +#define ble_cmd_gap_discover(mode) ble_send_message (ble_cmd_gap_discover_idx, mode) +/**Direct connection**/ +#define ble_cmd_gap_connect_direct( \ + address, addr_type, conn_interval_min, conn_interval_max, timeout, latency) \ + ble_send_message (ble_cmd_gap_connect_direct_idx, address, addr_type, conn_interval_min, \ + conn_interval_max, timeout, latency) +/**End current GAP procedure**/ +#define ble_cmd_gap_end_procedure() ble_send_message (ble_cmd_gap_end_procedure_idx) +/**Connect to any device on whitelist**/ +#define ble_cmd_gap_connect_selective(conn_interval_min, conn_interval_max, timeout, latency) \ + ble_send_message ( \ + ble_cmd_gap_connect_selective_idx, conn_interval_min, conn_interval_max, timeout, latency) +/**Set scan and advertising filtering parameters**/ +#define ble_cmd_gap_set_filtering(scan_policy, adv_policy, scan_duplicate_filtering) \ + ble_send_message ( \ + ble_cmd_gap_set_filtering_idx, scan_policy, adv_policy, scan_duplicate_filtering) +/**Set scan parameters**/ +#define ble_cmd_gap_set_scan_parameters(scan_interval, scan_window, active) \ + ble_send_message (ble_cmd_gap_set_scan_parameters_idx, scan_interval, scan_window, active) +/**Set advertising parameters**/ +#define ble_cmd_gap_set_adv_parameters(adv_interval_min, adv_interval_max, adv_channels) \ + ble_send_message ( \ + ble_cmd_gap_set_adv_parameters_idx, adv_interval_min, adv_interval_max, adv_channels) +/**Set advertisement or scan response data. Use broadcast mode to advertise data**/ +#define ble_cmd_gap_set_adv_data(set_scanrsp, adv_data_len, adv_data_data) \ + ble_send_message (ble_cmd_gap_set_adv_data_idx, set_scanrsp, adv_data_len, adv_data_data) +/**Sets device to Directed Connectable Mode + Uses fast advertisement procedure for 1.28s after which device enters + nonconnectable mode. If device has valid reconnection characteristic value, it is used for + connection otherwise passed address and address type are used + **/ +#define ble_cmd_gap_set_directed_connectable_mode(address, addr_type) \ + ble_send_message (ble_cmd_gap_set_directed_connectable_mode_idx, address, addr_type) +/**Configure I/O-port interrupts**/ +#define ble_cmd_hardware_io_port_config_irq(port, enable_bits, falling_edge) \ + ble_send_message (ble_cmd_hardware_io_port_config_irq_idx, port, enable_bits, falling_edge) +/**Set soft timer to send events**/ +#define ble_cmd_hardware_set_soft_timer(time, handle, single_shot) \ + ble_send_message (ble_cmd_hardware_set_soft_timer_idx, time, handle, single_shot) +/**Read A/D conversion**/ +#define ble_cmd_hardware_adc_read(input, decimation, reference_selection) \ + ble_send_message (ble_cmd_hardware_adc_read_idx, input, decimation, reference_selection) +/**Configure I/O-port direction**/ +#define ble_cmd_hardware_io_port_config_direction(port, direction) \ + ble_send_message (ble_cmd_hardware_io_port_config_direction_idx, port, direction) +/**Configure I/O-port function**/ +#define ble_cmd_hardware_io_port_config_function(port, function) \ + ble_send_message (ble_cmd_hardware_io_port_config_function_idx, port, function) +/**Configure I/O-port pull-up/pull-down**/ +#define ble_cmd_hardware_io_port_config_pull(port, tristate_mask, pull_up) \ + ble_send_message (ble_cmd_hardware_io_port_config_pull_idx, port, tristate_mask, pull_up) +/**Write I/O-port**/ +#define ble_cmd_hardware_io_port_write(port, mask, data) \ + ble_send_message (ble_cmd_hardware_io_port_write_idx, port, mask, data) +/**Read I/O-port**/ +#define ble_cmd_hardware_io_port_read(port, mask) \ + ble_send_message (ble_cmd_hardware_io_port_read_idx, port, mask) +/**Configure SPI**/ +#define ble_cmd_hardware_spi_config(channel, polarity, phase, bit_order, baud_e, baud_m) \ + ble_send_message ( \ + ble_cmd_hardware_spi_config_idx, channel, polarity, phase, bit_order, baud_e, baud_m) +/**Transfer SPI data**/ +#define ble_cmd_hardware_spi_transfer(channel, data_len, data_data) \ + ble_send_message (ble_cmd_hardware_spi_transfer_idx, channel, data_len, data_data) +/**Read data from I2C bus using bit-bang in cc2540. I2C clk is in P1.7 data in P1.6. Pull-up must be + * enabled on pins**/ +#define ble_cmd_hardware_i2c_read(address, stop, length) \ + ble_send_message (ble_cmd_hardware_i2c_read_idx, address, stop, length) +/**Write data to I2C bus using bit-bang in cc2540. I2C clk is in P1.7 data in P1.6. Pull-up must be + * enabled on pins**/ +#define ble_cmd_hardware_i2c_write(address, stop, data_len, data_data) \ + ble_send_message (ble_cmd_hardware_i2c_write_idx, address, stop, data_len, data_data) +/**Set TX Power**/ +#define ble_cmd_hardware_set_txpower(power) \ + ble_send_message (ble_cmd_hardware_set_txpower_idx, power) +/**Set comparator for timer channel**/ +#define ble_cmd_hardware_timer_comparator(timer, channel, mode, comparator_value) \ + ble_send_message (ble_cmd_hardware_timer_comparator_idx, timer, channel, mode, comparator_value) +/**Enable I/O-port interrupts**/ +#define ble_cmd_hardware_io_port_irq_enable(port, enable_bits) \ + ble_send_message (ble_cmd_hardware_io_port_irq_enable_idx, port, enable_bits) +/**Set I/O-port interrupt direction**/ +#define ble_cmd_hardware_io_port_irq_direction(port, falling_edge) \ + ble_send_message (ble_cmd_hardware_io_port_irq_direction_idx, port, falling_edge) +/**Enable or disable analog comparator**/ +#define ble_cmd_hardware_analog_comparator_enable(enable) \ + ble_send_message (ble_cmd_hardware_analog_comparator_enable_idx, enable) +/**Read analog comparator output**/ +#define ble_cmd_hardware_analog_comparator_read() \ + ble_send_message (ble_cmd_hardware_analog_comparator_read_idx) +/**Configure analog comparator interrupt**/ +#define ble_cmd_hardware_analog_comparator_config_irq(enabled) \ + ble_send_message (ble_cmd_hardware_analog_comparator_config_irq_idx, enabled) +/**Set RX Sensitivity**/ +#define ble_cmd_hardware_set_rxgain(gain) ble_send_message (ble_cmd_hardware_set_rxgain_idx, gain) +/**Enable or disable USB**/ +#define ble_cmd_hardware_usb_enable(enable) \ + ble_send_message (ble_cmd_hardware_usb_enable_idx, enable) +/**Start packet transmission, send one packet at every 625us**/ +#define ble_cmd_test_phy_tx(channel, length, type) \ + ble_send_message (ble_cmd_test_phy_tx_idx, channel, length, type) +/**Start receive test**/ +#define ble_cmd_test_phy_rx(channel) ble_send_message (ble_cmd_test_phy_rx_idx, channel) +/**End test, and report received packets**/ +#define ble_cmd_test_phy_end() ble_send_message (ble_cmd_test_phy_end_idx) +/**Reset test**/ +#define ble_cmd_test_phy_reset() ble_send_message (ble_cmd_test_phy_reset_idx) +/**Get current channel quality map**/ +#define ble_cmd_test_get_channel_map() ble_send_message (ble_cmd_test_get_channel_map_idx) +/**Debug command**/ +#define ble_cmd_test_debug(input_len, input_data) \ + ble_send_message (ble_cmd_test_debug_idx, input_len, input_data) +/**Set channel quality measurement mode**/ +#define ble_cmd_test_channel_mode(mode) ble_send_message (ble_cmd_test_channel_mode_idx, mode) +/**Reset system**/ +#define ble_cmd_dfu_reset(dfu) ble_send_message (ble_cmd_dfu_reset_idx, dfu) +/**set address for flashing**/ +#define ble_cmd_dfu_flash_set_address(address) \ + ble_send_message (ble_cmd_dfu_flash_set_address_idx, address) +/**Upload binary for flashing. Address will be updated automatically.**/ +#define ble_cmd_dfu_flash_upload(data_len, data_data) \ + ble_send_message (ble_cmd_dfu_flash_upload_idx, data_len, data_data) +/**Uploading is finished.**/ +#define ble_cmd_dfu_flash_upload_finish() ble_send_message (ble_cmd_dfu_flash_upload_finish_idx) + /**Reset device**/ + void ble_rsp_system_reset (const void *nul); + + /**Hello - command for testing**/ + void ble_rsp_system_hello (const void *nul); + + /**Get device bluetooth address**/ + void ble_rsp_system_address_get (const struct ble_msg_system_address_get_rsp_t *msg); + + /**write register**/ + void ble_rsp_system_reg_write (const struct ble_msg_system_reg_write_rsp_t *msg); + + /**read register**/ + void ble_rsp_system_reg_read (const struct ble_msg_system_reg_read_rsp_t *msg); + + /**get and reset packet counters**/ + void ble_rsp_system_get_counters (const struct ble_msg_system_get_counters_rsp_t *msg); + + /**Get status from all connections**/ + void ble_rsp_system_get_connections (const struct ble_msg_system_get_connections_rsp_t *msg); + + /**Read Memory**/ + void ble_rsp_system_read_memory (const struct ble_msg_system_read_memory_rsp_t *msg); + + /**Get Device info**/ + void ble_rsp_system_get_info (const struct ble_msg_system_get_info_rsp_t *msg); + + /**Send data to endpoint, error is returned if endpoint does not have enough space**/ + void ble_rsp_system_endpoint_tx (const struct ble_msg_system_endpoint_tx_rsp_t *msg); + + /**Add entry to whitelist**/ + void ble_rsp_system_whitelist_append (const struct ble_msg_system_whitelist_append_rsp_t *msg); + + /**Remove entry from whitelist**/ + void ble_rsp_system_whitelist_remove (const struct ble_msg_system_whitelist_remove_rsp_t *msg); + + /**Add entry to whitelist**/ + void ble_rsp_system_whitelist_clear (const void *nul); + + /**Read data from endpoint, error is returned if endpoint does not have enough data.**/ + void ble_rsp_system_endpoint_rx (const struct ble_msg_system_endpoint_rx_rsp_t *msg); + + /**Set watermarks on both input and output side**/ + void ble_rsp_system_endpoint_set_watermarks ( + const struct ble_msg_system_endpoint_set_watermarks_rsp_t *msg); + + /**Set encryption key that will be used with aes_encrypt and aes_decrypt commands.**/ + void ble_rsp_system_aes_setkey (const void *nul); + + /**Encrypt one block of data**/ + void ble_rsp_system_aes_encrypt (const struct ble_msg_system_aes_encrypt_rsp_t *msg); + + /**Decrypt one block of data**/ + void ble_rsp_system_aes_decrypt (const struct ble_msg_system_aes_decrypt_rsp_t *msg); + + /**Defragment persistent store**/ + void ble_rsp_flash_ps_defrag (const void *nul); + + /**Dump all ps keys**/ + void ble_rsp_flash_ps_dump (const void *nul); + + /**erase all ps keys**/ + void ble_rsp_flash_ps_erase_all (const void *nul); + + /**save ps key**/ + void ble_rsp_flash_ps_save (const struct ble_msg_flash_ps_save_rsp_t *msg); + + /**load ps key**/ + void ble_rsp_flash_ps_load (const struct ble_msg_flash_ps_load_rsp_t *msg); + + /**erase ps key**/ + void ble_rsp_flash_ps_erase (const void *nul); + + /**erase flash page**/ + void ble_rsp_flash_erase_page (const struct ble_msg_flash_erase_page_rsp_t *msg); + + /**write data to user data area**/ + void ble_rsp_flash_write_data (const struct ble_msg_flash_write_data_rsp_t *msg); + + /**read data from user data area.**/ + void ble_rsp_flash_read_data (const struct ble_msg_flash_read_data_rsp_t *msg); + + /**Write to attribute database**/ + void ble_rsp_attributes_write (const struct ble_msg_attributes_write_rsp_t *msg); + + /**Read from attribute database**/ + void ble_rsp_attributes_read (const struct ble_msg_attributes_read_rsp_t *msg); + + /**Read attribute type from database**/ + void ble_rsp_attributes_read_type (const struct ble_msg_attributes_read_type_rsp_t *msg); + + /**Respond to user attribute read request**/ + void ble_rsp_attributes_user_read_response (const void *nul); + + /**Response to attribute_changed event where reason is user-attribute write.**/ + void ble_rsp_attributes_user_write_response (const void *nul); + + /**Send notification or indication to remote device.**/ + void ble_rsp_attributes_send (const struct ble_msg_attributes_send_rsp_t *msg); + + /**Disconnect connection, starts a disconnection procedure on connection**/ + void ble_rsp_connection_disconnect (const struct ble_msg_connection_disconnect_rsp_t *msg); + + /**Get Link RSSI**/ + void ble_rsp_connection_get_rssi (const struct ble_msg_connection_get_rssi_rsp_t *msg); + + /**Update connection parameters**/ + void ble_rsp_connection_update (const struct ble_msg_connection_update_rsp_t *msg); + + /**Request version exchange**/ + void ble_rsp_connection_version_update ( + const struct ble_msg_connection_version_update_rsp_t *msg); + + /**Get Current channel map**/ + void ble_rsp_connection_channel_map_get ( + const struct ble_msg_connection_channel_map_get_rsp_t *msg); + + /**Set Channel map**/ + void ble_rsp_connection_channel_map_set ( + const struct ble_msg_connection_channel_map_set_rsp_t *msg); + + /**Remote feature request**/ + void ble_rsp_connection_features_get (const struct ble_msg_connection_features_get_rsp_t *msg); + + /**Get Connection Status Parameters**/ + void ble_rsp_connection_get_status (const struct ble_msg_connection_get_status_rsp_t *msg); + + /**Raw TX**/ + void ble_rsp_connection_raw_tx (const struct ble_msg_connection_raw_tx_rsp_t *msg); + + /**Discover attributes by type and value**/ + void ble_rsp_attclient_find_by_type_value ( + const struct ble_msg_attclient_find_by_type_value_rsp_t *msg); + + /**Discover attributes by type and value**/ + void ble_rsp_attclient_read_by_group_type ( + const struct ble_msg_attclient_read_by_group_type_rsp_t *msg); + + /**Read all attributes where type matches**/ + void ble_rsp_attclient_read_by_type (const struct ble_msg_attclient_read_by_type_rsp_t *msg); + + /**Discover Attribute handle and type mappings**/ + void ble_rsp_attclient_find_information ( + const struct ble_msg_attclient_find_information_rsp_t *msg); + + /**Read Characteristic value using handle**/ + void ble_rsp_attclient_read_by_handle ( + const struct ble_msg_attclient_read_by_handle_rsp_t *msg); + + /**write data to attribute**/ + void ble_rsp_attclient_attribute_write ( + const struct ble_msg_attclient_attribute_write_rsp_t *msg); + + /**write data to attribute using ATT write command**/ + void ble_rsp_attclient_write_command (const struct ble_msg_attclient_write_command_rsp_t *msg); + + /**Send confirmation for received indication, use only if manual indications are enabled**/ + void ble_rsp_attclient_indicate_confirm ( + const struct ble_msg_attclient_indicate_confirm_rsp_t *msg); + + /**Read Long Characteristic value**/ + void ble_rsp_attclient_read_long (const struct ble_msg_attclient_read_long_rsp_t *msg); + + /**Send prepare write request to remote host**/ + void ble_rsp_attclient_prepare_write (const struct ble_msg_attclient_prepare_write_rsp_t *msg); + + /**Send prepare write request to remote host**/ + void ble_rsp_attclient_execute_write (const struct ble_msg_attclient_execute_write_rsp_t *msg); + + /**Read multiple attributes from server**/ + void ble_rsp_attclient_read_multiple (const struct ble_msg_attclient_read_multiple_rsp_t *msg); + + /**Enable encryption on link**/ + void ble_rsp_sm_encrypt_start (const struct ble_msg_sm_encrypt_start_rsp_t *msg); + + /**Set device to bondable mode**/ + void ble_rsp_sm_set_bondable_mode (const void *nul); + + /**delete bonding information from ps store**/ + void ble_rsp_sm_delete_bonding (const struct ble_msg_sm_delete_bonding_rsp_t *msg); + + /**set pairing requirements**/ + void ble_rsp_sm_set_parameters (const void *nul); + + /**Passkey entered**/ + void ble_rsp_sm_passkey_entry (const struct ble_msg_sm_passkey_entry_rsp_t *msg); + + /**List all bonded devices**/ + void ble_rsp_sm_get_bonds (const struct ble_msg_sm_get_bonds_rsp_t *msg); + + /** + Set out-of-band encryption data for device + Device does not allow any other kind of pairing except oob if oob data is set. + **/ + void ble_rsp_sm_set_oob_data (const void *nul); + + /** + Add all bonded devices with a known public or static address to + the whitelist. Previous entries in the whitelist are first + cleared. This command can't be used while advertising, scanning + or being connected. + **/ + void ble_rsp_sm_whitelist_bonds (const struct ble_msg_sm_whitelist_bonds_rsp_t *msg); + + /**Set GAP central/peripheral privacy flags + **/ + void ble_rsp_gap_set_privacy_flags (const void *nul); + + /**Set discoverable and connectable mode**/ + void ble_rsp_gap_set_mode (const struct ble_msg_gap_set_mode_rsp_t *msg); + + /**start or stop discover procedure**/ + void ble_rsp_gap_discover (const struct ble_msg_gap_discover_rsp_t *msg); + + /**Direct connection**/ + void ble_rsp_gap_connect_direct (const struct ble_msg_gap_connect_direct_rsp_t *msg); + + /**End current GAP procedure**/ + void ble_rsp_gap_end_procedure (const struct ble_msg_gap_end_procedure_rsp_t *msg); + + /**Connect to any device on whitelist**/ + void ble_rsp_gap_connect_selective (const struct ble_msg_gap_connect_selective_rsp_t *msg); + + /**Set scan and advertising filtering parameters**/ + void ble_rsp_gap_set_filtering (const struct ble_msg_gap_set_filtering_rsp_t *msg); + + /**Set scan parameters**/ + void ble_rsp_gap_set_scan_parameters (const struct ble_msg_gap_set_scan_parameters_rsp_t *msg); + + /**Set advertising parameters**/ + void ble_rsp_gap_set_adv_parameters (const struct ble_msg_gap_set_adv_parameters_rsp_t *msg); + + /**Set advertisement or scan response data. Use broadcast mode to advertise data**/ + void ble_rsp_gap_set_adv_data (const struct ble_msg_gap_set_adv_data_rsp_t *msg); + + /**Sets device to Directed Connectable Mode + Uses fast advertisement procedure for 1.28s after which device enters + nonconnectable mode. If device has valid reconnection characteristic value, it is used for + connection otherwise passed address and address type are used + **/ + void ble_rsp_gap_set_directed_connectable_mode ( + const struct ble_msg_gap_set_directed_connectable_mode_rsp_t *msg); + + /**Configure I/O-port interrupts**/ + void ble_rsp_hardware_io_port_config_irq ( + const struct ble_msg_hardware_io_port_config_irq_rsp_t *msg); + + /**Set soft timer to send events**/ + void ble_rsp_hardware_set_soft_timer (const struct ble_msg_hardware_set_soft_timer_rsp_t *msg); + + /**Read A/D conversion**/ + void ble_rsp_hardware_adc_read (const struct ble_msg_hardware_adc_read_rsp_t *msg); + + /**Configure I/O-port direction**/ + void ble_rsp_hardware_io_port_config_direction ( + const struct ble_msg_hardware_io_port_config_direction_rsp_t *msg); + + /**Configure I/O-port function**/ + void ble_rsp_hardware_io_port_config_function ( + const struct ble_msg_hardware_io_port_config_function_rsp_t *msg); + + /**Configure I/O-port pull-up/pull-down**/ + void ble_rsp_hardware_io_port_config_pull ( + const struct ble_msg_hardware_io_port_config_pull_rsp_t *msg); + + /**Write I/O-port**/ + void ble_rsp_hardware_io_port_write (const struct ble_msg_hardware_io_port_write_rsp_t *msg); + + /**Read I/O-port**/ + void ble_rsp_hardware_io_port_read (const struct ble_msg_hardware_io_port_read_rsp_t *msg); + + /**Configure SPI**/ + void ble_rsp_hardware_spi_config (const struct ble_msg_hardware_spi_config_rsp_t *msg); + + /**Transfer SPI data**/ + void ble_rsp_hardware_spi_transfer (const struct ble_msg_hardware_spi_transfer_rsp_t *msg); + + /**Read data from I2C bus using bit-bang in cc2540. I2C clk is in P1.7 data in P1.6. Pull-up + * must be enabled on pins**/ + void ble_rsp_hardware_i2c_read (const struct ble_msg_hardware_i2c_read_rsp_t *msg); + + /**Write data to I2C bus using bit-bang in cc2540. I2C clk is in P1.7 data in P1.6. Pull-up must + * be enabled on pins**/ + void ble_rsp_hardware_i2c_write (const struct ble_msg_hardware_i2c_write_rsp_t *msg); + + /**Set TX Power**/ + void ble_rsp_hardware_set_txpower (const void *nul); + + /**Set comparator for timer channel**/ + void ble_rsp_hardware_timer_comparator ( + const struct ble_msg_hardware_timer_comparator_rsp_t *msg); + + /**Enable I/O-port interrupts**/ + void ble_rsp_hardware_io_port_irq_enable ( + const struct ble_msg_hardware_io_port_irq_enable_rsp_t *msg); + + /**Set I/O-port interrupt direction**/ + void ble_rsp_hardware_io_port_irq_direction ( + const struct ble_msg_hardware_io_port_irq_direction_rsp_t *msg); + + /**Enable or disable analog comparator**/ + void ble_rsp_hardware_analog_comparator_enable (const void *nul); + + /**Read analog comparator output**/ + void ble_rsp_hardware_analog_comparator_read ( + const struct ble_msg_hardware_analog_comparator_read_rsp_t *msg); + + /**Configure analog comparator interrupt**/ + void ble_rsp_hardware_analog_comparator_config_irq ( + const struct ble_msg_hardware_analog_comparator_config_irq_rsp_t *msg); + + /**Set RX Sensitivity**/ + void ble_rsp_hardware_set_rxgain (const void *nul); + + /**Enable or disable USB**/ + void ble_rsp_hardware_usb_enable (const struct ble_msg_hardware_usb_enable_rsp_t *msg); + + /**Start packet transmission, send one packet at every 625us**/ + void ble_rsp_test_phy_tx (const void *nul); + + /**Start receive test**/ + void ble_rsp_test_phy_rx (const void *nul); + + /**End test, and report received packets**/ + void ble_rsp_test_phy_end (const struct ble_msg_test_phy_end_rsp_t *msg); + + /**Reset test**/ + void ble_rsp_test_phy_reset (const void *nul); + + /**Get current channel quality map**/ + void ble_rsp_test_get_channel_map (const struct ble_msg_test_get_channel_map_rsp_t *msg); + + /**Debug command**/ + void ble_rsp_test_debug (const struct ble_msg_test_debug_rsp_t *msg); + + /**Set channel quality measurement mode**/ + void ble_rsp_test_channel_mode (const void *nul); + + /**Reset system**/ + void ble_rsp_dfu_reset (const void *nul); + + /**set address for flashing**/ + void ble_rsp_dfu_flash_set_address (const struct ble_msg_dfu_flash_set_address_rsp_t *msg); + + /**Upload binary for flashing. Address will be updated automatically.**/ + void ble_rsp_dfu_flash_upload (const struct ble_msg_dfu_flash_upload_rsp_t *msg); + + /**Uploading is finished.**/ + void ble_rsp_dfu_flash_upload_finish (const struct ble_msg_dfu_flash_upload_finish_rsp_t *msg); + + /**Device booted up, and is ready to receive commands**/ + void ble_evt_system_boot (const struct ble_msg_system_boot_evt_t *msg); + + /**Debug data output**/ + void ble_evt_system_debug (const struct ble_msg_system_debug_evt_t *msg); + + /**Endpoint receive size crossed watermark**/ + void ble_evt_system_endpoint_watermark_rx ( + const struct ble_msg_system_endpoint_watermark_rx_evt_t *msg); + + /**Endpoint transmit size crossed watermark**/ + void ble_evt_system_endpoint_watermark_tx ( + const struct ble_msg_system_endpoint_watermark_tx_evt_t *msg); + + /**Script failure detected**/ + void ble_evt_system_script_failure (const struct ble_msg_system_script_failure_evt_t *msg); + + /**No valid license key found**/ + void ble_evt_system_no_license_key (const void *nul); + + /**Protocol error in command parser**/ + void ble_evt_system_protocol_error (const struct ble_msg_system_protocol_error_evt_t *msg); + + /**Dump key result**/ + void ble_evt_flash_ps_key (const struct ble_msg_flash_ps_key_evt_t *msg); + + /**Attribute value has changed**/ + void ble_evt_attributes_value (const struct ble_msg_attributes_value_evt_t *msg); + + /**User-backed attribute data requested**/ + void ble_evt_attributes_user_read_request ( + const struct ble_msg_attributes_user_read_request_evt_t *msg); + + /**attribute status flags has changed**/ + void ble_evt_attributes_status (const struct ble_msg_attributes_status_evt_t *msg); + + /**Connection opened**/ + void ble_evt_connection_status (const struct ble_msg_connection_status_evt_t *msg); + + /**Remote version information**/ + void ble_evt_connection_version_ind (const struct ble_msg_connection_version_ind_evt_t *msg); + + /**Remote feature information**/ + void ble_evt_connection_feature_ind (const struct ble_msg_connection_feature_ind_evt_t *msg); + + /**Raw RX**/ + void ble_evt_connection_raw_rx (const struct ble_msg_connection_raw_rx_evt_t *msg); + + /**Link Disconnected**/ + void ble_evt_connection_disconnected (const struct ble_msg_connection_disconnected_evt_t *msg); + + /**Attribute indication has been acknowledged**/ + void ble_evt_attclient_indicated (const struct ble_msg_attclient_indicated_evt_t *msg); + + /**GATT procedure completed**/ + void ble_evt_attclient_procedure_completed ( + const struct ble_msg_attclient_procedure_completed_evt_t *msg); + + /**group discovery return**/ + void ble_evt_attclient_group_found (const struct ble_msg_attclient_group_found_evt_t *msg); + + /**characteristics found**/ + void ble_evt_attclient_attribute_found ( + const struct ble_msg_attclient_attribute_found_evt_t *msg); + + /**Handle type mapping found**/ + void ble_evt_attclient_find_information_found ( + const struct ble_msg_attclient_find_information_found_evt_t *msg); + + /**attribute value returned**/ + void ble_evt_attclient_attribute_value ( + const struct ble_msg_attclient_attribute_value_evt_t *msg); + + /**Response to read multiple request**/ + void ble_evt_attclient_read_multiple_response ( + const struct ble_msg_attclient_read_multiple_response_evt_t *msg); + + /**SMP data output**/ + void ble_evt_sm_smp_data (const struct ble_msg_sm_smp_data_evt_t *msg); + + /**Link bonding has failed**/ + void ble_evt_sm_bonding_fail (const struct ble_msg_sm_bonding_fail_evt_t *msg); + + /**Passkey to be entered to remote device**/ + void ble_evt_sm_passkey_display (const struct ble_msg_sm_passkey_display_evt_t *msg); + + /**Passkey Requested**/ + void ble_evt_sm_passkey_request (const struct ble_msg_sm_passkey_request_evt_t *msg); + + /**Bond status information**/ + void ble_evt_sm_bond_status (const struct ble_msg_sm_bond_status_evt_t *msg); + + /**Scan Response**/ + void ble_evt_gap_scan_response (const struct ble_msg_gap_scan_response_evt_t *msg); + + /**Not used**/ + void ble_evt_gap_mode_changed (const struct ble_msg_gap_mode_changed_evt_t *msg); + + /**I/O-port state**/ + void ble_evt_hardware_io_port_status (const struct ble_msg_hardware_io_port_status_evt_t *msg); + + /**soft timer event**/ + void ble_evt_hardware_soft_timer (const struct ble_msg_hardware_soft_timer_evt_t *msg); + + /**adc result**/ + void ble_evt_hardware_adc_result (const struct ble_msg_hardware_adc_result_evt_t *msg); + + /**This event is produced when analog comparator output changes**/ + void ble_evt_hardware_analog_comparator_status ( + const struct ble_msg_hardware_analog_comparator_status_evt_t *msg); + + /**Device booted up in dfu, and is ready to receive commands**/ + void ble_evt_dfu_boot (const struct ble_msg_dfu_boot_evt_t *msg); + + + struct ble_class_handler_t + { + const struct ble_msg *const *msgs; + uint8 maxhandlers; + }; + extern const struct ble_class_handler_t ble_class_rsp_handlers[ble_cls_last]; + extern const struct ble_class_handler_t ble_class_evt_handlers[ble_cls_last]; + + void ble_default (const void *); +#ifdef __cplusplus +} +#endif +/*lint -restore*/ +#endif diff --git a/deps/include/brainflow/board_controller/neuromd/brainbit_bglib/helpers.h b/deps/include/brainflow/board_controller/neuromd/brainbit_bglib/helpers.h new file mode 100644 index 000000000..e7e2e2743 --- /dev/null +++ b/deps/include/brainflow/board_controller/neuromd/brainbit_bglib/helpers.h @@ -0,0 +1,32 @@ +#pragma once + +#include +#include + +#include "cmd_def.h" +#include "uart.h" + +#define UART_TIMEOUT 1000 +#define BRAINBIT_BLED_DATA_SIZE 8 + +namespace BrainBitBLEDLib +{ + enum State + { + NONE = 0, + INIT_CALLED = 1, + INITIAL_CONNECTION = 2, + OPEN_CALLED = 3, + CONFIG_CALLED = 4, + CLOSE_CALLED = 5, + GET_DATA_CALLED = 6, + WRITE_TO_CLIENT_CHAR = 7 + }; + + void output (uint8 len1, uint8 *data1, uint16 len2, uint8 *data2); + int read_message (int timeout_ms); + int open_ble_dev (); + int wait_for_callback (int num_seconds); + int reset_ble_dev (); + int config_board (uint8 *command, int len); +} \ No newline at end of file diff --git a/deps/include/brainflow/board_controller/neuromd/brainbit_bglib/uart.h b/deps/include/brainflow/board_controller/neuromd/brainbit_bglib/uart.h new file mode 100644 index 000000000..f2efcd150 --- /dev/null +++ b/deps/include/brainflow/board_controller/neuromd/brainbit_bglib/uart.h @@ -0,0 +1,10 @@ +#ifndef UART_H +#define UART_H + +void uart_list_devices (); +int uart_find_serialport (char *name); +int uart_open (const char *port); +void uart_close (); +int uart_tx (int len, unsigned char *data); +int uart_rx (int len, unsigned char *data, int timeout_ms); +#endif // UART_H diff --git a/deps/include/brainflow/board_controller/neuromd/brainbit_bled.h b/deps/include/brainflow/board_controller/neuromd/brainbit_bled.h new file mode 100644 index 000000000..cdc643e52 --- /dev/null +++ b/deps/include/brainflow/board_controller/neuromd/brainbit_bled.h @@ -0,0 +1,23 @@ +#pragma once + +#include "dyn_lib_board.h" + + +class BrainBitBLED : public DynLibBoard +{ + +private: + static int num_objects; + bool is_valid; + bool use_mac_addr; + +public: + BrainBitBLED (struct BrainFlowInputParams params); + ~BrainBitBLED (); + + int prepare_session (); + +protected: + std::string get_lib_name (); + virtual int call_open (); +}; diff --git a/deps/include/brainflow/board_controller/neuromd/callibri.h b/deps/include/brainflow/board_controller/neuromd/callibri.h index 2fb6baaf1..876804d5d 100644 --- a/deps/include/brainflow/board_controller/neuromd/callibri.h +++ b/deps/include/brainflow/board_controller/neuromd/callibri.h @@ -19,6 +19,7 @@ class Callibri : public NeuromdBoard bool initialized; bool is_streaming; std::thread streaming_thread; + volatile size_t counter; void read_thread (); void free_channels (); @@ -32,7 +33,7 @@ class Callibri : public NeuromdBoard ~Callibri (); int prepare_session (); - int start_stream (int buffer_size, char *streamer_params); + int start_stream (int buffer_size, const char *streamer_params); int stop_stream (); int release_session (); int config_board (std::string config, std::string &response); diff --git a/deps/include/brainflow/board_controller/neurosity/notion_osc.h b/deps/include/brainflow/board_controller/neurosity/notion_osc.h index 6eeac5c6a..81a356481 100644 --- a/deps/include/brainflow/board_controller/neurosity/notion_osc.h +++ b/deps/include/brainflow/board_controller/neurosity/notion_osc.h @@ -30,12 +30,12 @@ class NotionOSC : public Board void handle_packet (double *package, const OSCPP::Server::Packet &packet); public: - NotionOSC (struct BrainFlowInputParams params); + NotionOSC (int board_id, struct BrainFlowInputParams params); ~NotionOSC (); int prepare_session (); - int start_stream (int buffer_size, char *streamer_params); + int start_stream (int buffer_size, const char *streamer_params); int stop_stream (); int release_session (); int config_board (std::string config, std::string &response); -}; \ No newline at end of file +}; diff --git a/deps/include/brainflow/board_controller/openbci/cyton.h b/deps/include/brainflow/board_controller/openbci/cyton.h index fd25ba546..a1f905fa2 100644 --- a/deps/include/brainflow/board_controller/openbci/cyton.h +++ b/deps/include/brainflow/board_controller/openbci/cyton.h @@ -1,18 +1,16 @@ #pragma once #include +#include +#include "openbci_gain_tracker.h" #include "openbci_serial_board.h" -#define ADS1299_Vref 4.5 -#define ADS1299_gain 24.0 - class Cyton : public OpenBCISerialBoard { - double eeg_scale = (double)(ADS1299_Vref / float ((pow (2, 23) - 1)) / ADS1299_gain * 1000000.); - double accel_scale = (double)(0.002 / (pow (2, 4))); - protected: + CytonGainTracker gain_tracker; + void read_thread (); public: @@ -20,4 +18,6 @@ class Cyton : public OpenBCISerialBoard : OpenBCISerialBoard (params, (int)BoardIds::CYTON_BOARD) { } + + int config_board (std::string config, std::string &response); }; diff --git a/deps/include/brainflow/board_controller/openbci/cyton_daisy.h b/deps/include/brainflow/board_controller/openbci/cyton_daisy.h index c618243fa..b2b4a7368 100644 --- a/deps/include/brainflow/board_controller/openbci/cyton_daisy.h +++ b/deps/include/brainflow/board_controller/openbci/cyton_daisy.h @@ -1,18 +1,17 @@ #pragma once #include +#include +#include +#include "openbci_gain_tracker.h" #include "openbci_serial_board.h" -#define ADS1299_Vref 4.5 -#define ADS1299_gain 24.0 - class CytonDaisy : public OpenBCISerialBoard { - double eeg_scale = (double)(ADS1299_Vref / float ((pow (2, 23) - 1)) / ADS1299_gain * 1000000.); - double accel_scale = (double)(0.002 / (pow (2, 4))); - protected: + CytonDaisyGainTracker gain_tracker; + void read_thread (); public: @@ -20,4 +19,6 @@ class CytonDaisy : public OpenBCISerialBoard : OpenBCISerialBoard (params, (int)BoardIds::CYTON_DAISY_BOARD) { } + + int config_board (std::string config, std::string &response); }; diff --git a/deps/include/brainflow/board_controller/openbci/cyton_daisy_wifi.h b/deps/include/brainflow/board_controller/openbci/cyton_daisy_wifi.h index 200a9288e..4b5c16e84 100644 --- a/deps/include/brainflow/board_controller/openbci/cyton_daisy_wifi.h +++ b/deps/include/brainflow/board_controller/openbci/cyton_daisy_wifi.h @@ -1,18 +1,16 @@ #pragma once #include +#include +#include "openbci_gain_tracker.h" #include "openbci_wifi_shield_board.h" -#define ADS1299_Vref 4.5 -#define ADS1299_gain 24.0 - class CytonDaisyWifi : public OpenBCIWifiShieldBoard { - double eeg_scale = (double)(ADS1299_Vref / float ((pow (2, 23) - 1)) / ADS1299_gain * 1000000.); - double accel_scale = (double)(0.002 / (pow (2, 4))); - protected: + CytonDaisyGainTracker gain_tracker; + void read_thread (); public: @@ -23,4 +21,5 @@ class CytonDaisyWifi : public OpenBCIWifiShieldBoard } int prepare_session (); + int config_board (std::string config, std::string &response); }; diff --git a/deps/include/brainflow/board_controller/openbci/cyton_wifi.h b/deps/include/brainflow/board_controller/openbci/cyton_wifi.h index 1c1c4f885..df559e4d0 100644 --- a/deps/include/brainflow/board_controller/openbci/cyton_wifi.h +++ b/deps/include/brainflow/board_controller/openbci/cyton_wifi.h @@ -2,17 +2,14 @@ #include +#include "openbci_gain_tracker.h" #include "openbci_wifi_shield_board.h" -#define ADS1299_Vref 4.5 -#define ADS1299_gain 24.0 - class CytonWifi : public OpenBCIWifiShieldBoard { - double eeg_scale = (double)(ADS1299_Vref / float ((pow (2, 23) - 1)) / ADS1299_gain * 1000000.); - double accel_scale = (double)(0.002 / (pow (2, 4))); - protected: + CytonGainTracker gain_tracker; + void read_thread (); public: @@ -23,4 +20,5 @@ class CytonWifi : public OpenBCIWifiShieldBoard } int prepare_session (); + int config_board (std::string config, std::string &response); }; diff --git a/deps/include/brainflow/board_controller/openbci/galea.h b/deps/include/brainflow/board_controller/openbci/galea.h index 62af6bdb3..d73eb5e01 100644 --- a/deps/include/brainflow/board_controller/openbci/galea.h +++ b/deps/include/brainflow/board_controller/openbci/galea.h @@ -3,37 +3,33 @@ #include #include #include +#include #include #include "board.h" #include "board_controller.h" +#include "openbci_gain_tracker.h" #include "socket_client_udp.h" -#define ADS1299_Vref 4.5 - class Galea : public Board { private: - // different default gains - const double eeg_scale_main_board = ADS1299_Vref / double ((pow (2, 23) - 1)) / 2.0 * 1000000.; - const double eeg_scale_sister_board = - ADS1299_Vref / double ((pow (2, 23) - 1)) / 12.0 * 1000000.; - const double emg_scale = ADS1299_Vref / double ((pow (2, 23) - 1)) / 4.0 * 1000000.; - volatile bool keep_alive; + volatile int state; + volatile double half_rtt; bool initialized; bool is_streaming; std::thread streaming_thread; SocketClientUDP *socket; - std::mutex m; std::condition_variable cv; - volatile int state; - volatile double half_rtt; + GaleaGainTracker gain_tracker; + + std::string find_device (); void read_thread (); - int calc_time (); + int calc_time (std::string &resp); public: @@ -41,12 +37,13 @@ class Galea : public Board ~Galea (); int prepare_session (); - int start_stream (int buffer_size, char *streamer_params); + int start_stream (int buffer_size, const char *streamer_params); int stop_stream (); int release_session (); int config_board (std::string config, std::string &response); static constexpr int package_size = 72; - static constexpr int num_packages = 19; - static constexpr int transaction_size = package_size * num_packages; -}; + static constexpr int max_num_packages = 25; + static constexpr int max_transaction_size = package_size * max_num_packages; + static constexpr int socket_timeout = 2; +}; \ No newline at end of file diff --git a/deps/include/brainflow/board_controller/openbci/galea_serial.h b/deps/include/brainflow/board_controller/openbci/galea_serial.h new file mode 100644 index 000000000..2ee2ad68e --- /dev/null +++ b/deps/include/brainflow/board_controller/openbci/galea_serial.h @@ -0,0 +1,43 @@ +#pragma once + +#include +#include +#include +#include +#include + +#include "board.h" +#include "board_controller.h" +#include "openbci_gain_tracker.h" +#include "serial.h" + + +class GaleaSerial : public Board +{ + +private: + volatile bool keep_alive; + bool initialized; + bool is_streaming; + std::thread streaming_thread; + Serial *serial; + GaleaGainTracker gain_tracker; + std::mutex m; + std::condition_variable cv; + volatile int state; + volatile double half_rtt; + + void read_thread (); + int calc_time (std::string &resp); + + +public: + GaleaSerial (struct BrainFlowInputParams params); + ~GaleaSerial (); + + int prepare_session (); + int start_stream (int buffer_size, const char *streamer_params); + int stop_stream (); + int release_session (); + int config_board (std::string config, std::string &response); +}; \ No newline at end of file diff --git a/deps/include/brainflow/board_controller/openbci/ganglion.h b/deps/include/brainflow/board_controller/openbci/ganglion.h index 0bd07ddfa..689ad9059 100644 --- a/deps/include/brainflow/board_controller/openbci/ganglion.h +++ b/deps/include/brainflow/board_controller/openbci/ganglion.h @@ -56,7 +56,7 @@ class Ganglion : public Board ~Ganglion (); int prepare_session (); - int start_stream (int buffer_size, char *streamer_params); + int start_stream (int buffer_size, const char *streamer_params); int stop_stream (); int release_session (); int config_board (std::string config, std::string &response); diff --git a/deps/include/brainflow/board_controller/openbci/ganglion_bglib/apitypes.h b/deps/include/brainflow/board_controller/openbci/ganglion_bglib/apitypes.h new file mode 100644 index 000000000..1747bb7b3 --- /dev/null +++ b/deps/include/brainflow/board_controller/openbci/ganglion_bglib/apitypes.h @@ -0,0 +1,45 @@ + +#ifndef APITYPES_H_ +#define APITYPES_H_ + +#ifdef __GNUC__ + +#define PACKSTRUCT(decl) decl __attribute__ ((__packed__)) +#define ALIGNED __attribute__ ((aligned (0x4))) + +#else // msvc + +#define PACKSTRUCT(decl) __pragma (pack (push, 1)) decl __pragma (pack (pop)) +#define ALIGNED + +#pragma warning(disable : 4200) + +#endif + +typedef unsigned char uint8; +typedef unsigned short uint16; +typedef signed short int16; +typedef unsigned long uint32; +typedef signed char int8; + +typedef struct bd_addr_t +{ + uint8 addr[6]; + +} bd_addr; + +typedef bd_addr hwaddr; +typedef struct +{ + uint8 len; + uint8 data[]; +} uint8array; + +typedef struct +{ + uint8 len; + int8 data[]; +} string; + + +#endif diff --git a/deps/include/brainflow/board_controller/openbci/ganglion_bglib/cmd_def.h b/deps/include/brainflow/board_controller/openbci/ganglion_bglib/cmd_def.h new file mode 100644 index 000000000..4e7a6b053 --- /dev/null +++ b/deps/include/brainflow/board_controller/openbci/ganglion_bglib/cmd_def.h @@ -0,0 +1,2794 @@ +#ifndef cmd_def_h +#define cmd_def_h + +// clang-format off + +/***************************************************************************** + * + * + * !!!!!!!! THIS IS AUTOGENERATED FILE, DO NOT EDIT !!!!!!!! + * + * + ****************************************************************************/ + +#include +/***************************************************************************** + * + * Support for compilers other than GCC and MSVC: + * + * To support specific compiler add compiler's structure packing directives to following macro: + * PACKSTRUCT( decl ) + * + * BGLIB uses PACKSTRUCT macro to add packing information for structures: + * PACKSTRUCT(struct wifi_msg_dfu_reset_cmd_t + * { + * uint8 dfu; + * }); + * + * + ****************************************************************************/ + +/*lint -save --e{528,572,778,845,835,849}*/ +#include "apitypes.h" +#ifdef __cplusplus +extern "C" +{ +#endif + +/* Compability */ +#ifndef PACKSTRUCT +#ifdef PACKED +#define PACKSTRUCT(a) a PACKED +#else +/*Default packed configuration*/ +#ifdef __GNUC__ +#ifdef _WIN32 +#define PACKSTRUCT(decl) decl __attribute__ ((__packed__, gcc_struct)) +#else +#define PACKSTRUCT(decl) decl __attribute__ ((__packed__)) +#endif +#define ALIGNED __attribute__ ((aligned (0x4))) + +#else // msvc + +#define PACKSTRUCT(decl) __pragma (pack (push, 1)) decl __pragma (pack (pop)) +#define ALIGNED + +#endif +#endif +#endif + struct ble_cmd_packet; + typedef void (*ble_cmd_handler) (const void *); + struct ble_header + { + uint8 type_hilen; + uint8 lolen; + uint8 cls; + uint8 command; + }; + + + struct ble_msg + { + struct ble_header hdr; + uint32 params; + ble_cmd_handler handler; + }; + + const struct ble_msg *ble_find_msg_hdr (struct ble_header hdr); + const struct ble_msg *ble_get_msg (uint8 idx); + const struct ble_msg *ble_get_msg_hdr (struct ble_header hdr); + extern void (*bglib_output) (uint8 len1, uint8 *data1, uint16 len2, uint8 *data2); + void ble_send_message (uint8 msgid, ...); + + enum system_endpoints + { + system_endpoint_api = 0, + system_endpoint_test = 1, + system_endpoint_script = 2, + system_endpoint_usb = 3, + system_endpoint_uart0 = 4, + system_endpoint_uart1 = 5, + system_endpoints_max = 6 + }; + + enum attributes_attribute_change_reason + { + attributes_attribute_change_reason_write_request = 0, + attributes_attribute_change_reason_write_command = 1, + attributes_attribute_change_reason_write_request_user = 2, + attributes_attribute_change_reason_max = 3 + }; + + enum attributes_attribute_status_flag + { + attributes_attribute_status_flag_notify = 1, + attributes_attribute_status_flag_indicate = 2, + attributes_attribute_status_flag_max = 3 + }; + + enum connection_connstatus + { + connection_connected = 1, + connection_encrypted = 2, + connection_completed = 4, + connection_parameters_change = 8, + connection_connstatus_max = 9 + }; + + enum attclient_attribute_value_types + { + attclient_attribute_value_type_read = 0, + attclient_attribute_value_type_notify = 1, + attclient_attribute_value_type_indicate = 2, + attclient_attribute_value_type_read_by_type = 3, + attclient_attribute_value_type_read_blob = 4, + attclient_attribute_value_type_indicate_rsp_req = 5, + attclient_attribute_value_types_max = 6 + }; + + enum sm_bonding_key + { + sm_bonding_key_ltk = 0x01, + sm_bonding_key_addr_public = 0x02, + sm_bonding_key_addr_static = 0x04, + sm_bonding_key_irk = 0x08, + sm_bonding_key_edivrand = 0x10, + sm_bonding_key_csrk = 0x20, + sm_bonding_key_masterid = 0x40, + sm_bonding_key_max = 65 + }; + + enum sm_io_capability + { + sm_io_capability_displayonly = 0, + sm_io_capability_displayyesno = 1, + sm_io_capability_keyboardonly = 2, + sm_io_capability_noinputnooutput = 3, + sm_io_capability_keyboarddisplay = 4, + sm_io_capability_max = 5 + }; + +#define GAP_SCAN_HEADER_ADV_IND 0 +#define GAP_SCAN_HEADER_ADV_DIRECT_IND 1 +#define GAP_SCAN_HEADER_ADV_NONCONN_IND 2 +#define GAP_SCAN_HEADER_SCAN_REQ 3 +#define GAP_SCAN_HEADER_SCAN_RSP 4 +#define GAP_SCAN_HEADER_CONNECT_REQ 5 +#define GAP_SCAN_HEADER_ADV_DISCOVER_IND 6 + +#define GAP_AD_FLAG_LIMITED_DISCOVERABLE 0x01 +#define GAP_AD_FLAG_GENERAL_DISCOVERABLE 0x02 +#define GAP_AD_FLAG_BREDR_NOT_SUPPORTED 0x04 +#define GAP_AD_FLAG_SIMULTANEOUS_LEBREDR_CTRL 0x10 +#define GAP_AD_FLAG_SIMULTANEOUS_LEBREDR_HOST 0x20 +#define GAP_AD_FLAG_MASK 0x1f + + enum gap_address_type + { + gap_address_type_public = 0, + gap_address_type_random = 1, + gap_address_type_max = 2 + }; + + enum gap_discoverable_mode + { + gap_non_discoverable = 0, + gap_limited_discoverable = 1, + gap_general_discoverable = 2, + gap_broadcast = 3, + gap_user_data = 4, + gap_discoverable_mode_max = 5 + }; + + enum gap_connectable_mode + { + gap_non_connectable = 0, + gap_directed_connectable = 1, + gap_undirected_connectable = 2, + gap_scannable_non_connectable = 3, + gap_connectable_mode_max = 4 + }; + + enum gap_discover_mode + { + gap_discover_limited = 0, + gap_discover_generic = 1, + gap_discover_observation = 2, + gap_discover_mode_max = 3 + }; + + enum gap_ad_types + { + gap_ad_type_none = 0, + gap_ad_type_flags = 1, + gap_ad_type_services_16bit_more = 2, + gap_ad_type_services_16bit_all = 3, + gap_ad_type_services_32bit_more = 4, + gap_ad_type_services_32bit_all = 5, + gap_ad_type_services_128bit_more = 6, + gap_ad_type_services_128bit_all = 7, + gap_ad_type_localname_short = 8, + gap_ad_type_localname_complete = 9, + gap_ad_type_txpower = 10, + gap_ad_types_max = 11 + }; + + enum gap_advertising_policy + { + gap_adv_policy_all = 0, + gap_adv_policy_whitelist_scan = 1, + gap_adv_policy_whitelist_connect = 2, + gap_adv_policy_whitelist_all = 3, + gap_advertising_policy_max = 4 + }; + + enum gap_scan_policy + { + gap_scan_policy_all = 0, + gap_scan_policy_whitelist = 1, + gap_scan_policy_max = 2 + }; + + + enum ble_parameter_types + { + ble_msg_parameter_uint8 = 2, + ble_msg_parameter_int8 = 3, + ble_msg_parameter_uint16 = 4, + ble_msg_parameter_int16 = 5, + ble_msg_parameter_uint32 = 6, + ble_msg_parameter_int32 = 7, + ble_msg_parameter_uint8array = 8, + ble_msg_parameter_string = 9, + ble_msg_parameter_hwaddr = 10, + ble_msg_parameter_uint16array = 11 + }; + + enum ble_msg_types + { + ble_msg_type_cmd = 0x00, + ble_msg_type_rsp = 0x00, + ble_msg_type_evt = 0x80 + }; + enum ble_dev_types + { + ble_dev_type_ble = 0x00, + ble_dev_type_wifi = 0x08, + ble_dev_type_iwrap = 0x10, + ble_dev_type_dumo = 0x20, + ble_dev_type_test = 0x20 + }; + + enum ble_classes + { + ble_cls_system, + ble_cls_flash, + ble_cls_attributes, + ble_cls_connection, + ble_cls_attclient, + ble_cls_sm, + ble_cls_gap, + ble_cls_hardware, + ble_cls_test, + ble_cls_dfu, + ble_cls_last + }; + enum ble_command_ids + { + ble_cmd_system_reset_id = 0, + ble_cmd_system_hello_id = 1, + ble_cmd_system_address_get_id = 2, + ble_cmd_system_reg_write_id = 3, + ble_cmd_system_reg_read_id = 4, + ble_cmd_system_get_counters_id = 5, + ble_cmd_system_get_connections_id = 6, + ble_cmd_system_read_memory_id = 7, + ble_cmd_system_get_info_id = 8, + ble_cmd_system_endpoint_tx_id = 9, + ble_cmd_system_whitelist_append_id = 10, + ble_cmd_system_whitelist_remove_id = 11, + ble_cmd_system_whitelist_clear_id = 12, + ble_cmd_system_endpoint_rx_id = 13, + ble_cmd_system_endpoint_set_watermarks_id = 14, + ble_cmd_system_aes_setkey_id = 15, + ble_cmd_system_aes_encrypt_id = 16, + ble_cmd_system_aes_decrypt_id = 17, + ble_cmd_flash_ps_defrag_id = 0, + ble_cmd_flash_ps_dump_id = 1, + ble_cmd_flash_ps_erase_all_id = 2, + ble_cmd_flash_ps_save_id = 3, + ble_cmd_flash_ps_load_id = 4, + ble_cmd_flash_ps_erase_id = 5, + ble_cmd_flash_erase_page_id = 6, + ble_cmd_flash_write_data_id = 7, + ble_cmd_flash_read_data_id = 8, + ble_cmd_attributes_write_id = 0, + ble_cmd_attributes_read_id = 1, + ble_cmd_attributes_read_type_id = 2, + ble_cmd_attributes_user_read_response_id = 3, + ble_cmd_attributes_user_write_response_id = 4, + ble_cmd_attributes_send_id = 5, + ble_cmd_connection_disconnect_id = 0, + ble_cmd_connection_get_rssi_id = 1, + ble_cmd_connection_update_id = 2, + ble_cmd_connection_version_update_id = 3, + ble_cmd_connection_channel_map_get_id = 4, + ble_cmd_connection_channel_map_set_id = 5, + ble_cmd_connection_features_get_id = 6, + ble_cmd_connection_get_status_id = 7, + ble_cmd_connection_raw_tx_id = 8, + ble_cmd_attclient_find_by_type_value_id = 0, + ble_cmd_attclient_read_by_group_type_id = 1, + ble_cmd_attclient_read_by_type_id = 2, + ble_cmd_attclient_find_information_id = 3, + ble_cmd_attclient_read_by_handle_id = 4, + ble_cmd_attclient_attribute_write_id = 5, + ble_cmd_attclient_write_command_id = 6, + ble_cmd_attclient_indicate_confirm_id = 7, + ble_cmd_attclient_read_long_id = 8, + ble_cmd_attclient_prepare_write_id = 9, + ble_cmd_attclient_execute_write_id = 10, + ble_cmd_attclient_read_multiple_id = 11, + ble_cmd_sm_encrypt_start_id = 0, + ble_cmd_sm_set_bondable_mode_id = 1, + ble_cmd_sm_delete_bonding_id = 2, + ble_cmd_sm_set_parameters_id = 3, + ble_cmd_sm_passkey_entry_id = 4, + ble_cmd_sm_get_bonds_id = 5, + ble_cmd_sm_set_oob_data_id = 6, + ble_cmd_sm_whitelist_bonds_id = 7, + ble_cmd_gap_set_privacy_flags_id = 0, + ble_cmd_gap_set_mode_id = 1, + ble_cmd_gap_discover_id = 2, + ble_cmd_gap_connect_direct_id = 3, + ble_cmd_gap_end_procedure_id = 4, + ble_cmd_gap_connect_selective_id = 5, + ble_cmd_gap_set_filtering_id = 6, + ble_cmd_gap_set_scan_parameters_id = 7, + ble_cmd_gap_set_adv_parameters_id = 8, + ble_cmd_gap_set_adv_data_id = 9, + ble_cmd_gap_set_directed_connectable_mode_id = 10, + ble_cmd_hardware_io_port_config_irq_id = 0, + ble_cmd_hardware_set_soft_timer_id = 1, + ble_cmd_hardware_adc_read_id = 2, + ble_cmd_hardware_io_port_config_direction_id = 3, + ble_cmd_hardware_io_port_config_function_id = 4, + ble_cmd_hardware_io_port_config_pull_id = 5, + ble_cmd_hardware_io_port_write_id = 6, + ble_cmd_hardware_io_port_read_id = 7, + ble_cmd_hardware_spi_config_id = 8, + ble_cmd_hardware_spi_transfer_id = 9, + ble_cmd_hardware_i2c_read_id = 10, + ble_cmd_hardware_i2c_write_id = 11, + ble_cmd_hardware_set_txpower_id = 12, + ble_cmd_hardware_timer_comparator_id = 13, + ble_cmd_hardware_io_port_irq_enable_id = 14, + ble_cmd_hardware_io_port_irq_direction_id = 15, + ble_cmd_hardware_analog_comparator_enable_id = 16, + ble_cmd_hardware_analog_comparator_read_id = 17, + ble_cmd_hardware_analog_comparator_config_irq_id = 18, + ble_cmd_hardware_set_rxgain_id = 19, + ble_cmd_hardware_usb_enable_id = 20, + ble_cmd_test_phy_tx_id = 0, + ble_cmd_test_phy_rx_id = 1, + ble_cmd_test_phy_end_id = 2, + ble_cmd_test_phy_reset_id = 3, + ble_cmd_test_get_channel_map_id = 4, + ble_cmd_test_debug_id = 5, + ble_cmd_test_channel_mode_id = 6, + ble_cmd_dfu_reset_id = 0, + ble_cmd_dfu_flash_set_address_id = 1, + ble_cmd_dfu_flash_upload_id = 2, + ble_cmd_dfu_flash_upload_finish_id = 3 + }; + enum ble_response_ids + { + ble_rsp_system_reset_id = 0, + ble_rsp_system_hello_id = 1, + ble_rsp_system_address_get_id = 2, + ble_rsp_system_reg_write_id = 3, + ble_rsp_system_reg_read_id = 4, + ble_rsp_system_get_counters_id = 5, + ble_rsp_system_get_connections_id = 6, + ble_rsp_system_read_memory_id = 7, + ble_rsp_system_get_info_id = 8, + ble_rsp_system_endpoint_tx_id = 9, + ble_rsp_system_whitelist_append_id = 10, + ble_rsp_system_whitelist_remove_id = 11, + ble_rsp_system_whitelist_clear_id = 12, + ble_rsp_system_endpoint_rx_id = 13, + ble_rsp_system_endpoint_set_watermarks_id = 14, + ble_rsp_system_aes_setkey_id = 15, + ble_rsp_system_aes_encrypt_id = 16, + ble_rsp_system_aes_decrypt_id = 17, + ble_rsp_flash_ps_defrag_id = 0, + ble_rsp_flash_ps_dump_id = 1, + ble_rsp_flash_ps_erase_all_id = 2, + ble_rsp_flash_ps_save_id = 3, + ble_rsp_flash_ps_load_id = 4, + ble_rsp_flash_ps_erase_id = 5, + ble_rsp_flash_erase_page_id = 6, + ble_rsp_flash_write_data_id = 7, + ble_rsp_flash_read_data_id = 8, + ble_rsp_attributes_write_id = 0, + ble_rsp_attributes_read_id = 1, + ble_rsp_attributes_read_type_id = 2, + ble_rsp_attributes_user_read_response_id = 3, + ble_rsp_attributes_user_write_response_id = 4, + ble_rsp_attributes_send_id = 5, + ble_rsp_connection_disconnect_id = 0, + ble_rsp_connection_get_rssi_id = 1, + ble_rsp_connection_update_id = 2, + ble_rsp_connection_version_update_id = 3, + ble_rsp_connection_channel_map_get_id = 4, + ble_rsp_connection_channel_map_set_id = 5, + ble_rsp_connection_features_get_id = 6, + ble_rsp_connection_get_status_id = 7, + ble_rsp_connection_raw_tx_id = 8, + ble_rsp_attclient_find_by_type_value_id = 0, + ble_rsp_attclient_read_by_group_type_id = 1, + ble_rsp_attclient_read_by_type_id = 2, + ble_rsp_attclient_find_information_id = 3, + ble_rsp_attclient_read_by_handle_id = 4, + ble_rsp_attclient_attribute_write_id = 5, + ble_rsp_attclient_write_command_id = 6, + ble_rsp_attclient_indicate_confirm_id = 7, + ble_rsp_attclient_read_long_id = 8, + ble_rsp_attclient_prepare_write_id = 9, + ble_rsp_attclient_execute_write_id = 10, + ble_rsp_attclient_read_multiple_id = 11, + ble_rsp_sm_encrypt_start_id = 0, + ble_rsp_sm_set_bondable_mode_id = 1, + ble_rsp_sm_delete_bonding_id = 2, + ble_rsp_sm_set_parameters_id = 3, + ble_rsp_sm_passkey_entry_id = 4, + ble_rsp_sm_get_bonds_id = 5, + ble_rsp_sm_set_oob_data_id = 6, + ble_rsp_sm_whitelist_bonds_id = 7, + ble_rsp_gap_set_privacy_flags_id = 0, + ble_rsp_gap_set_mode_id = 1, + ble_rsp_gap_discover_id = 2, + ble_rsp_gap_connect_direct_id = 3, + ble_rsp_gap_end_procedure_id = 4, + ble_rsp_gap_connect_selective_id = 5, + ble_rsp_gap_set_filtering_id = 6, + ble_rsp_gap_set_scan_parameters_id = 7, + ble_rsp_gap_set_adv_parameters_id = 8, + ble_rsp_gap_set_adv_data_id = 9, + ble_rsp_gap_set_directed_connectable_mode_id = 10, + ble_rsp_hardware_io_port_config_irq_id = 0, + ble_rsp_hardware_set_soft_timer_id = 1, + ble_rsp_hardware_adc_read_id = 2, + ble_rsp_hardware_io_port_config_direction_id = 3, + ble_rsp_hardware_io_port_config_function_id = 4, + ble_rsp_hardware_io_port_config_pull_id = 5, + ble_rsp_hardware_io_port_write_id = 6, + ble_rsp_hardware_io_port_read_id = 7, + ble_rsp_hardware_spi_config_id = 8, + ble_rsp_hardware_spi_transfer_id = 9, + ble_rsp_hardware_i2c_read_id = 10, + ble_rsp_hardware_i2c_write_id = 11, + ble_rsp_hardware_set_txpower_id = 12, + ble_rsp_hardware_timer_comparator_id = 13, + ble_rsp_hardware_io_port_irq_enable_id = 14, + ble_rsp_hardware_io_port_irq_direction_id = 15, + ble_rsp_hardware_analog_comparator_enable_id = 16, + ble_rsp_hardware_analog_comparator_read_id = 17, + ble_rsp_hardware_analog_comparator_config_irq_id = 18, + ble_rsp_hardware_set_rxgain_id = 19, + ble_rsp_hardware_usb_enable_id = 20, + ble_rsp_test_phy_tx_id = 0, + ble_rsp_test_phy_rx_id = 1, + ble_rsp_test_phy_end_id = 2, + ble_rsp_test_phy_reset_id = 3, + ble_rsp_test_get_channel_map_id = 4, + ble_rsp_test_debug_id = 5, + ble_rsp_test_channel_mode_id = 6, + ble_rsp_dfu_reset_id = 0, + ble_rsp_dfu_flash_set_address_id = 1, + ble_rsp_dfu_flash_upload_id = 2, + ble_rsp_dfu_flash_upload_finish_id = 3 + }; + enum ble_event_ids + { + ble_evt_system_boot_id = 0, + ble_evt_system_debug_id = 1, + ble_evt_system_endpoint_watermark_rx_id = 2, + ble_evt_system_endpoint_watermark_tx_id = 3, + ble_evt_system_script_failure_id = 4, + ble_evt_system_no_license_key_id = 5, + ble_evt_system_protocol_error_id = 6, + ble_evt_flash_ps_key_id = 0, + ble_evt_attributes_value_id = 0, + ble_evt_attributes_user_read_request_id = 1, + ble_evt_attributes_status_id = 2, + ble_evt_connection_status_id = 0, + ble_evt_connection_version_ind_id = 1, + ble_evt_connection_feature_ind_id = 2, + ble_evt_connection_raw_rx_id = 3, + ble_evt_connection_disconnected_id = 4, + ble_evt_attclient_indicated_id = 0, + ble_evt_attclient_procedure_completed_id = 1, + ble_evt_attclient_group_found_id = 2, + ble_evt_attclient_attribute_found_id = 3, + ble_evt_attclient_find_information_found_id = 4, + ble_evt_attclient_attribute_value_id = 5, + ble_evt_attclient_read_multiple_response_id = 6, + ble_evt_sm_smp_data_id = 0, + ble_evt_sm_bonding_fail_id = 1, + ble_evt_sm_passkey_display_id = 2, + ble_evt_sm_passkey_request_id = 3, + ble_evt_sm_bond_status_id = 4, + ble_evt_gap_scan_response_id = 0, + ble_evt_gap_mode_changed_id = 1, + ble_evt_hardware_io_port_status_id = 0, + ble_evt_hardware_soft_timer_id = 1, + ble_evt_hardware_adc_result_id = 2, + ble_evt_hardware_analog_comparator_status_id = 3, + ble_evt_dfu_boot_id = 0 + }; + enum ble_msg_idx + { + ble_cmd_system_reset_idx = 0, + ble_cmd_system_hello_idx = 1, + ble_cmd_system_address_get_idx = 2, + ble_cmd_system_reg_write_idx = 3, + ble_cmd_system_reg_read_idx = 4, + ble_cmd_system_get_counters_idx = 5, + ble_cmd_system_get_connections_idx = 6, + ble_cmd_system_read_memory_idx = 7, + ble_cmd_system_get_info_idx = 8, + ble_cmd_system_endpoint_tx_idx = 9, + ble_cmd_system_whitelist_append_idx = 10, + ble_cmd_system_whitelist_remove_idx = 11, + ble_cmd_system_whitelist_clear_idx = 12, + ble_cmd_system_endpoint_rx_idx = 13, + ble_cmd_system_endpoint_set_watermarks_idx = 14, + ble_cmd_system_aes_setkey_idx = 15, + ble_cmd_system_aes_encrypt_idx = 16, + ble_cmd_system_aes_decrypt_idx = 17, + ble_cmd_flash_ps_defrag_idx = 18, + ble_cmd_flash_ps_dump_idx = 19, + ble_cmd_flash_ps_erase_all_idx = 20, + ble_cmd_flash_ps_save_idx = 21, + ble_cmd_flash_ps_load_idx = 22, + ble_cmd_flash_ps_erase_idx = 23, + ble_cmd_flash_erase_page_idx = 24, + ble_cmd_flash_write_data_idx = 25, + ble_cmd_flash_read_data_idx = 26, + ble_cmd_attributes_write_idx = 27, + ble_cmd_attributes_read_idx = 28, + ble_cmd_attributes_read_type_idx = 29, + ble_cmd_attributes_user_read_response_idx = 30, + ble_cmd_attributes_user_write_response_idx = 31, + ble_cmd_attributes_send_idx = 32, + ble_cmd_connection_disconnect_idx = 33, + ble_cmd_connection_get_rssi_idx = 34, + ble_cmd_connection_update_idx = 35, + ble_cmd_connection_version_update_idx = 36, + ble_cmd_connection_channel_map_get_idx = 37, + ble_cmd_connection_channel_map_set_idx = 38, + ble_cmd_connection_features_get_idx = 39, + ble_cmd_connection_get_status_idx = 40, + ble_cmd_connection_raw_tx_idx = 41, + ble_cmd_attclient_find_by_type_value_idx = 42, + ble_cmd_attclient_read_by_group_type_idx = 43, + ble_cmd_attclient_read_by_type_idx = 44, + ble_cmd_attclient_find_information_idx = 45, + ble_cmd_attclient_read_by_handle_idx = 46, + ble_cmd_attclient_attribute_write_idx = 47, + ble_cmd_attclient_write_command_idx = 48, + ble_cmd_attclient_indicate_confirm_idx = 49, + ble_cmd_attclient_read_long_idx = 50, + ble_cmd_attclient_prepare_write_idx = 51, + ble_cmd_attclient_execute_write_idx = 52, + ble_cmd_attclient_read_multiple_idx = 53, + ble_cmd_sm_encrypt_start_idx = 54, + ble_cmd_sm_set_bondable_mode_idx = 55, + ble_cmd_sm_delete_bonding_idx = 56, + ble_cmd_sm_set_parameters_idx = 57, + ble_cmd_sm_passkey_entry_idx = 58, + ble_cmd_sm_get_bonds_idx = 59, + ble_cmd_sm_set_oob_data_idx = 60, + ble_cmd_sm_whitelist_bonds_idx = 61, + ble_cmd_gap_set_privacy_flags_idx = 62, + ble_cmd_gap_set_mode_idx = 63, + ble_cmd_gap_discover_idx = 64, + ble_cmd_gap_connect_direct_idx = 65, + ble_cmd_gap_end_procedure_idx = 66, + ble_cmd_gap_connect_selective_idx = 67, + ble_cmd_gap_set_filtering_idx = 68, + ble_cmd_gap_set_scan_parameters_idx = 69, + ble_cmd_gap_set_adv_parameters_idx = 70, + ble_cmd_gap_set_adv_data_idx = 71, + ble_cmd_gap_set_directed_connectable_mode_idx = 72, + ble_cmd_hardware_io_port_config_irq_idx = 73, + ble_cmd_hardware_set_soft_timer_idx = 74, + ble_cmd_hardware_adc_read_idx = 75, + ble_cmd_hardware_io_port_config_direction_idx = 76, + ble_cmd_hardware_io_port_config_function_idx = 77, + ble_cmd_hardware_io_port_config_pull_idx = 78, + ble_cmd_hardware_io_port_write_idx = 79, + ble_cmd_hardware_io_port_read_idx = 80, + ble_cmd_hardware_spi_config_idx = 81, + ble_cmd_hardware_spi_transfer_idx = 82, + ble_cmd_hardware_i2c_read_idx = 83, + ble_cmd_hardware_i2c_write_idx = 84, + ble_cmd_hardware_set_txpower_idx = 85, + ble_cmd_hardware_timer_comparator_idx = 86, + ble_cmd_hardware_io_port_irq_enable_idx = 87, + ble_cmd_hardware_io_port_irq_direction_idx = 88, + ble_cmd_hardware_analog_comparator_enable_idx = 89, + ble_cmd_hardware_analog_comparator_read_idx = 90, + ble_cmd_hardware_analog_comparator_config_irq_idx = 91, + ble_cmd_hardware_set_rxgain_idx = 92, + ble_cmd_hardware_usb_enable_idx = 93, + ble_cmd_test_phy_tx_idx = 94, + ble_cmd_test_phy_rx_idx = 95, + ble_cmd_test_phy_end_idx = 96, + ble_cmd_test_phy_reset_idx = 97, + ble_cmd_test_get_channel_map_idx = 98, + ble_cmd_test_debug_idx = 99, + ble_cmd_test_channel_mode_idx = 100, + ble_cmd_dfu_reset_idx = 101, + ble_cmd_dfu_flash_set_address_idx = 102, + ble_cmd_dfu_flash_upload_idx = 103, + ble_cmd_dfu_flash_upload_finish_idx = 104, + ble_rsp_system_reset_idx = 105, + ble_rsp_system_hello_idx = 106, + ble_rsp_system_address_get_idx = 107, + ble_rsp_system_reg_write_idx = 108, + ble_rsp_system_reg_read_idx = 109, + ble_rsp_system_get_counters_idx = 110, + ble_rsp_system_get_connections_idx = 111, + ble_rsp_system_read_memory_idx = 112, + ble_rsp_system_get_info_idx = 113, + ble_rsp_system_endpoint_tx_idx = 114, + ble_rsp_system_whitelist_append_idx = 115, + ble_rsp_system_whitelist_remove_idx = 116, + ble_rsp_system_whitelist_clear_idx = 117, + ble_rsp_system_endpoint_rx_idx = 118, + ble_rsp_system_endpoint_set_watermarks_idx = 119, + ble_rsp_system_aes_setkey_idx = 120, + ble_rsp_system_aes_encrypt_idx = 121, + ble_rsp_system_aes_decrypt_idx = 122, + ble_rsp_flash_ps_defrag_idx = 123, + ble_rsp_flash_ps_dump_idx = 124, + ble_rsp_flash_ps_erase_all_idx = 125, + ble_rsp_flash_ps_save_idx = 126, + ble_rsp_flash_ps_load_idx = 127, + ble_rsp_flash_ps_erase_idx = 128, + ble_rsp_flash_erase_page_idx = 129, + ble_rsp_flash_write_data_idx = 130, + ble_rsp_flash_read_data_idx = 131, + ble_rsp_attributes_write_idx = 132, + ble_rsp_attributes_read_idx = 133, + ble_rsp_attributes_read_type_idx = 134, + ble_rsp_attributes_user_read_response_idx = 135, + ble_rsp_attributes_user_write_response_idx = 136, + ble_rsp_attributes_send_idx = 137, + ble_rsp_connection_disconnect_idx = 138, + ble_rsp_connection_get_rssi_idx = 139, + ble_rsp_connection_update_idx = 140, + ble_rsp_connection_version_update_idx = 141, + ble_rsp_connection_channel_map_get_idx = 142, + ble_rsp_connection_channel_map_set_idx = 143, + ble_rsp_connection_features_get_idx = 144, + ble_rsp_connection_get_status_idx = 145, + ble_rsp_connection_raw_tx_idx = 146, + ble_rsp_attclient_find_by_type_value_idx = 147, + ble_rsp_attclient_read_by_group_type_idx = 148, + ble_rsp_attclient_read_by_type_idx = 149, + ble_rsp_attclient_find_information_idx = 150, + ble_rsp_attclient_read_by_handle_idx = 151, + ble_rsp_attclient_attribute_write_idx = 152, + ble_rsp_attclient_write_command_idx = 153, + ble_rsp_attclient_indicate_confirm_idx = 154, + ble_rsp_attclient_read_long_idx = 155, + ble_rsp_attclient_prepare_write_idx = 156, + ble_rsp_attclient_execute_write_idx = 157, + ble_rsp_attclient_read_multiple_idx = 158, + ble_rsp_sm_encrypt_start_idx = 159, + ble_rsp_sm_set_bondable_mode_idx = 160, + ble_rsp_sm_delete_bonding_idx = 161, + ble_rsp_sm_set_parameters_idx = 162, + ble_rsp_sm_passkey_entry_idx = 163, + ble_rsp_sm_get_bonds_idx = 164, + ble_rsp_sm_set_oob_data_idx = 165, + ble_rsp_sm_whitelist_bonds_idx = 166, + ble_rsp_gap_set_privacy_flags_idx = 167, + ble_rsp_gap_set_mode_idx = 168, + ble_rsp_gap_discover_idx = 169, + ble_rsp_gap_connect_direct_idx = 170, + ble_rsp_gap_end_procedure_idx = 171, + ble_rsp_gap_connect_selective_idx = 172, + ble_rsp_gap_set_filtering_idx = 173, + ble_rsp_gap_set_scan_parameters_idx = 174, + ble_rsp_gap_set_adv_parameters_idx = 175, + ble_rsp_gap_set_adv_data_idx = 176, + ble_rsp_gap_set_directed_connectable_mode_idx = 177, + ble_rsp_hardware_io_port_config_irq_idx = 178, + ble_rsp_hardware_set_soft_timer_idx = 179, + ble_rsp_hardware_adc_read_idx = 180, + ble_rsp_hardware_io_port_config_direction_idx = 181, + ble_rsp_hardware_io_port_config_function_idx = 182, + ble_rsp_hardware_io_port_config_pull_idx = 183, + ble_rsp_hardware_io_port_write_idx = 184, + ble_rsp_hardware_io_port_read_idx = 185, + ble_rsp_hardware_spi_config_idx = 186, + ble_rsp_hardware_spi_transfer_idx = 187, + ble_rsp_hardware_i2c_read_idx = 188, + ble_rsp_hardware_i2c_write_idx = 189, + ble_rsp_hardware_set_txpower_idx = 190, + ble_rsp_hardware_timer_comparator_idx = 191, + ble_rsp_hardware_io_port_irq_enable_idx = 192, + ble_rsp_hardware_io_port_irq_direction_idx = 193, + ble_rsp_hardware_analog_comparator_enable_idx = 194, + ble_rsp_hardware_analog_comparator_read_idx = 195, + ble_rsp_hardware_analog_comparator_config_irq_idx = 196, + ble_rsp_hardware_set_rxgain_idx = 197, + ble_rsp_hardware_usb_enable_idx = 198, + ble_rsp_test_phy_tx_idx = 199, + ble_rsp_test_phy_rx_idx = 200, + ble_rsp_test_phy_end_idx = 201, + ble_rsp_test_phy_reset_idx = 202, + ble_rsp_test_get_channel_map_idx = 203, + ble_rsp_test_debug_idx = 204, + ble_rsp_test_channel_mode_idx = 205, + ble_rsp_dfu_reset_idx = 206, + ble_rsp_dfu_flash_set_address_idx = 207, + ble_rsp_dfu_flash_upload_idx = 208, + ble_rsp_dfu_flash_upload_finish_idx = 209, + ble_evt_system_boot_idx = 210, + ble_evt_system_debug_idx = 211, + ble_evt_system_endpoint_watermark_rx_idx = 212, + ble_evt_system_endpoint_watermark_tx_idx = 213, + ble_evt_system_script_failure_idx = 214, + ble_evt_system_no_license_key_idx = 215, + ble_evt_system_protocol_error_idx = 216, + ble_evt_flash_ps_key_idx = 217, + ble_evt_attributes_value_idx = 218, + ble_evt_attributes_user_read_request_idx = 219, + ble_evt_attributes_status_idx = 220, + ble_evt_connection_status_idx = 221, + ble_evt_connection_version_ind_idx = 222, + ble_evt_connection_feature_ind_idx = 223, + ble_evt_connection_raw_rx_idx = 224, + ble_evt_connection_disconnected_idx = 225, + ble_evt_attclient_indicated_idx = 226, + ble_evt_attclient_procedure_completed_idx = 227, + ble_evt_attclient_group_found_idx = 228, + ble_evt_attclient_attribute_found_idx = 229, + ble_evt_attclient_find_information_found_idx = 230, + ble_evt_attclient_attribute_value_idx = 231, + ble_evt_attclient_read_multiple_response_idx = 232, + ble_evt_sm_smp_data_idx = 233, + ble_evt_sm_bonding_fail_idx = 234, + ble_evt_sm_passkey_display_idx = 235, + ble_evt_sm_passkey_request_idx = 236, + ble_evt_sm_bond_status_idx = 237, + ble_evt_gap_scan_response_idx = 238, + ble_evt_gap_mode_changed_idx = 239, + ble_evt_hardware_io_port_status_idx = 240, + ble_evt_hardware_soft_timer_idx = 241, + ble_evt_hardware_adc_result_idx = 242, + ble_evt_hardware_analog_comparator_status_idx = 243, + ble_evt_dfu_boot_idx = 244 + }; +#ifndef BG_ERRORCODES +#define BG_ERRORCODES + enum ble_error_spaces + { + ble_errspc_bt = 512, + ble_errspc_att = 1024, + ble_errspc_bg = 256, + ble_errspc_smp = 768, + }; + typedef enum ble_error + { + ble_err_bt_error_success = ble_errspc_bt + 0, // Command completed succesfully + ble_err_bt_bt_error_authentication_failure = ble_errspc_bt + + 5, // Pairing or authentication failed due to incorrect results in the pairing or + // authentication procedure. This could be due to an incorrect PIN or Link Key + ble_err_bt_pin_or_key_missing = + ble_errspc_bt + 6, // Pairing failed because of missing PIN, or authentication failed + // because of missing Key + ble_err_bt_bt_error_memory_capacity_exceeded = + ble_errspc_bt + 7, // Controller is out of memory. + ble_err_bt_connection_timeout = ble_errspc_bt + 8, // Link supervision timeout has expired. + ble_err_bt_connection_limit_exceeded = + ble_errspc_bt + 9, // Controller is at limit of connections it can support. + ble_err_bt_bt_error_command_disallowed = + ble_errspc_bt + 12, // Command requested cannot be executed because the Controller is in + // a state where it cannot process this command at this time. + ble_err_bt_bt_error_invalid_command_parameters = + ble_errspc_bt + 18, // Command contained invalid parameters. + ble_err_bt_bt_error_remote_user_terminated = + ble_errspc_bt + 19, // User on the remote device terminated the connection. + ble_err_bt_bt_error_connection_terminated_by_local_host = + ble_errspc_bt + 22, // Local device terminated the connection. + ble_err_bt_bt_error_ll_response_timeout = + ble_errspc_bt + 34, // Connection terminated due to link-layer procedure timeout. + ble_err_bt_bt_error_ll_instant_passed = + ble_errspc_bt + 40, // Received link-layer control packet where instant was in the past. + ble_err_bt_bt_error_controller_busy = + ble_errspc_bt + 58, // Operation was rejected because the controller is busy and unable + // to process the request. + ble_err_bt_bt_error_unacceptable_connection_interval = + ble_errspc_bt + 59, // Remote evice terminated the connection because of an unacceptable + // connection interval. + ble_err_bt_bt_error_directed_advertising_timeout = ble_errspc_bt + + 60, // Directed advertising completed without a connection being created. + ble_err_bt_bt_error_connection_terminated_due_to_mic_failure = + ble_errspc_bt + 61, // Connection was terminated because the Message Integrity Check + // (MIC) failed on a received packet. + ble_err_bt_bt_error_connection_failed_to_be_established = ble_errspc_bt + + 62, // LL initiated a connection but the connection has failed to be established. + // Controller did not receive any packets from remote end. + ble_err_att_invalid_handle = + ble_errspc_att + 1, // The attribute handle given was not valid on this server + ble_err_att_read_not_permitted = ble_errspc_att + 2, // The attribute cannot be read + ble_err_att_write_not_permitted = ble_errspc_att + 3, // The attribute cannot be written + ble_err_att_invalid_pdu = ble_errspc_att + 4, // The attribute PDU was invalid + ble_err_att_insufficient_authentication = ble_errspc_att + + 5, // The attribute requires authentication before it can be read or written. + ble_err_att_request_not_supported = ble_errspc_att + + 6, // Attribute Server does not support the request received from the client. + ble_err_att_invalid_offset = + ble_errspc_att + 7, // Offset specified was past the end of the attribute + ble_err_att_insufficient_authorization = ble_errspc_att + + 8, // The attribute requires authorization before it can be read or written. + ble_err_att_prepare_queue_full = + ble_errspc_att + 9, // Too many prepare writes have been queueud + ble_err_att_att_not_found = + ble_errspc_att + 10, // No attribute found within the given attribute handle range. + ble_err_att_att_not_long = ble_errspc_att + + 11, // The attribute cannot be read or written using the Read Blob Request + ble_err_att_insufficient_enc_key_size = ble_errspc_att + + 12, // The Encryption Key Size used for encrypting this link is insufficient. + ble_err_att_invalid_att_length = + ble_errspc_att + 13, // The attribute value length is invalid for the operation + ble_err_att_unlikely_error = ble_errspc_att + + 14, // The attribute request that was requested has encountered an error that was + // unlikely, and therefore could not be completed as requested. + ble_err_att_insufficient_encryption = ble_errspc_att + + 15, // The attribute requires encryption before it can be read or written. + ble_err_att_unsupported_group_type = + ble_errspc_att + 16, // The attribute type is not a supported grouping attribute as + // defined by a higher layer specification. + ble_err_att_insufficient_resources = + ble_errspc_att + 17, // Insufficient Resources to complete the request + ble_err_att_application = + ble_errspc_att + 128, // Application error code defined by a higher layer specification. + ble_err_success = 0, // No error + ble_err_invalid_param = ble_errspc_bg + 128, // Command contained invalid parameter + ble_err_wrong_state = ble_errspc_bg + 129, // Device is in wrong state to receive command + ble_err_out_of_memory = ble_errspc_bg + 130, // Device has run out of memory + ble_err_not_implemented = ble_errspc_bg + 131, // Feature is not implemented + ble_err_invalid_command = ble_errspc_bg + 132, // Command was not recognized + ble_err_timeout = ble_errspc_bg + 133, // Command or Procedure failed due to timeout + ble_err_not_connected = + ble_errspc_bg + 134, // Connection handle passed is to command is not a valid handle + ble_err_flow = + ble_errspc_bg + 135, // Command would cause either underflow or overflow error + ble_err_user_attribute = + ble_errspc_bg + 136, // User attribute was accessed through API which is not supported + ble_err_invalid_license_key = ble_errspc_bg + 137, // No valid license key found + ble_err_command_too_long = ble_errspc_bg + 138, // Command maximum length exceeded + ble_err_out_of_bonds = ble_errspc_bg + + 139, // Bonding procedure can't be started because device has no space left for bond. + ble_err_smp_passkey_entry_failed = ble_errspc_smp + + 1, // The user input of passkey failed, for example, the user cancelled the operation + ble_err_smp_oob_not_available = + ble_errspc_smp + 2, // Out of Band data is not available for authentication + ble_err_smp_authentication_requirements = ble_errspc_smp + + 3, // The pairing procedure cannot be performed as authentication requirements cannot be + // met due to IO capabilities of one or both devices + ble_err_smp_confirm_value_failed = + ble_errspc_smp + 4, // The confirm value does not match the calculated compare value + ble_err_smp_pairing_not_supported = + ble_errspc_smp + 5, // Pairing is not supported by the device + ble_err_smp_encryption_key_size = + ble_errspc_smp + 6, // The resultant encryption key size is insufficient for the + // security requirements of this device + ble_err_smp_command_not_supported = + ble_errspc_smp + 7, // The SMP command received is not supported on this device + ble_err_smp_unspecified_reason = + ble_errspc_smp + 8, // Pairing failed due to an unspecified reason + ble_err_smp_repeated_attempts = ble_errspc_smp + + 9, // Pairing or authentication procedure is disallowed because too little time has + // elapsed since last pairing request or security request + ble_err_smp_invalid_parameters = + ble_errspc_smp + 10, // The Invalid Parameters error code indicates: the command length + // is invalid or a parameter is outside of the specified range. + ble_err_last + } errorcode_t; +#endif + PACKSTRUCT (struct ble_msg_system_reset_cmd_t { uint8 boot_in_dfu; }); + + PACKSTRUCT (struct ble_msg_system_address_get_rsp_t { bd_addr address; }); + + PACKSTRUCT (struct ble_msg_system_reg_write_cmd_t { + uint16 address; + uint8 value; + }); + + PACKSTRUCT (struct ble_msg_system_reg_write_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_system_reg_read_cmd_t { uint16 address; }); + + PACKSTRUCT (struct ble_msg_system_reg_read_rsp_t { + uint16 address; + uint8 value; + }); + + PACKSTRUCT (struct ble_msg_system_get_counters_rsp_t { + uint8 txok; + uint8 txretry; + uint8 rxok; + uint8 rxfail; + uint8 mbuf; + }); + + PACKSTRUCT (struct ble_msg_system_get_connections_rsp_t { uint8 maxconn; }); + + PACKSTRUCT (struct ble_msg_system_read_memory_cmd_t { + uint32 address; + uint8 length; + }); + + PACKSTRUCT (struct ble_msg_system_read_memory_rsp_t { + uint32 address; + uint8array data; + }); + + PACKSTRUCT (struct ble_msg_system_get_info_rsp_t { + uint16 major; + uint16 minor; + uint16 patch; + uint16 build; + uint16 ll_version; + uint8 protocol_version; + uint8 hw; + }); + + PACKSTRUCT (struct ble_msg_system_endpoint_tx_cmd_t { + uint8 endpoint; + uint8array data; + }); + + PACKSTRUCT (struct ble_msg_system_endpoint_tx_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_system_whitelist_append_cmd_t { + bd_addr address; + uint8 address_type; + }); + + PACKSTRUCT (struct ble_msg_system_whitelist_append_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_system_whitelist_remove_cmd_t { + bd_addr address; + uint8 address_type; + }); + + PACKSTRUCT (struct ble_msg_system_whitelist_remove_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_system_endpoint_rx_cmd_t { + uint8 endpoint; + uint8 size; + }); + + PACKSTRUCT (struct ble_msg_system_endpoint_rx_rsp_t { + uint16 result; + uint8array data; + }); + + PACKSTRUCT (struct ble_msg_system_endpoint_set_watermarks_cmd_t { + uint8 endpoint; + uint8 rx; + uint8 tx; + }); + + PACKSTRUCT (struct ble_msg_system_endpoint_set_watermarks_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_system_aes_setkey_cmd_t { uint8array key; }); + + PACKSTRUCT (struct ble_msg_system_aes_encrypt_cmd_t { uint8array data; }); + + PACKSTRUCT (struct ble_msg_system_aes_encrypt_rsp_t { uint8array data; }); + + PACKSTRUCT (struct ble_msg_system_aes_decrypt_cmd_t { uint8array data; }); + + PACKSTRUCT (struct ble_msg_system_aes_decrypt_rsp_t { uint8array data; }); + + PACKSTRUCT (struct ble_msg_system_boot_evt_t { + uint16 major; + uint16 minor; + uint16 patch; + uint16 build; + uint16 ll_version; + uint8 protocol_version; + uint8 hw; + }); + + PACKSTRUCT (struct ble_msg_system_debug_evt_t { uint8array data; }); + + PACKSTRUCT (struct ble_msg_system_endpoint_watermark_rx_evt_t { + uint8 endpoint; + uint8 data; + }); + + PACKSTRUCT (struct ble_msg_system_endpoint_watermark_tx_evt_t { + uint8 endpoint; + uint8 data; + }); + + PACKSTRUCT (struct ble_msg_system_script_failure_evt_t { + uint16 address; + uint16 reason; + }); + + PACKSTRUCT (struct ble_msg_system_protocol_error_evt_t { uint16 reason; }); + + PACKSTRUCT (struct ble_msg_flash_ps_save_cmd_t { + uint16 key; + uint8array value; + }); + + PACKSTRUCT (struct ble_msg_flash_ps_save_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_flash_ps_load_cmd_t { uint16 key; }); + + PACKSTRUCT (struct ble_msg_flash_ps_load_rsp_t { + uint16 result; + uint8array value; + }); + + PACKSTRUCT (struct ble_msg_flash_ps_erase_cmd_t { uint16 key; }); + + PACKSTRUCT (struct ble_msg_flash_erase_page_cmd_t { uint8 page; }); + + PACKSTRUCT (struct ble_msg_flash_erase_page_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_flash_write_data_cmd_t { + uint32 address; + uint8array data; + }); + + PACKSTRUCT (struct ble_msg_flash_write_data_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_flash_read_data_cmd_t { + uint32 address; + uint8 length; + }); + + PACKSTRUCT (struct ble_msg_flash_read_data_rsp_t { uint8array data; }); + + PACKSTRUCT (struct ble_msg_flash_ps_key_evt_t { + uint16 key; + uint8array value; + }); + + PACKSTRUCT (struct ble_msg_attributes_write_cmd_t { + uint16 handle; + uint8 offset; + uint8array value; + }); + + PACKSTRUCT (struct ble_msg_attributes_write_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_attributes_read_cmd_t { + uint16 handle; + uint16 offset; + }); + + PACKSTRUCT (struct ble_msg_attributes_read_rsp_t { + uint16 handle; + uint16 offset; + uint16 result; + uint8array value; + }); + + PACKSTRUCT (struct ble_msg_attributes_read_type_cmd_t { uint16 handle; }); + + PACKSTRUCT (struct ble_msg_attributes_read_type_rsp_t { + uint16 handle; + uint16 result; + uint8array value; + }); + + PACKSTRUCT (struct ble_msg_attributes_user_read_response_cmd_t { + uint8 connection; + uint8 att_error; + uint8array value; + }); + + PACKSTRUCT (struct ble_msg_attributes_user_write_response_cmd_t { + uint8 connection; + uint8 att_error; + }); + + PACKSTRUCT (struct ble_msg_attributes_send_cmd_t { + uint8 connection; + uint16 handle; + uint8array value; + }); + + PACKSTRUCT (struct ble_msg_attributes_send_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_attributes_value_evt_t { + uint8 connection; + uint8 reason; + uint16 handle; + uint16 offset; + uint8array value; + }); + + PACKSTRUCT (struct ble_msg_attributes_user_read_request_evt_t { + uint8 connection; + uint16 handle; + uint16 offset; + uint8 maxsize; + }); + + PACKSTRUCT (struct ble_msg_attributes_status_evt_t { + uint16 handle; + uint8 flags; + }); + + PACKSTRUCT (struct ble_msg_connection_disconnect_cmd_t { uint8 connection; }); + + PACKSTRUCT (struct ble_msg_connection_disconnect_rsp_t { + uint8 connection; + uint16 result; + }); + + PACKSTRUCT (struct ble_msg_connection_get_rssi_cmd_t { uint8 connection; }); + + PACKSTRUCT (struct ble_msg_connection_get_rssi_rsp_t { + uint8 connection; + int8 rssi; + }); + + PACKSTRUCT (struct ble_msg_connection_update_cmd_t { + uint8 connection; + uint16 interval_min; + uint16 interval_max; + uint16 latency; + uint16 timeout; + }); + + PACKSTRUCT (struct ble_msg_connection_update_rsp_t { + uint8 connection; + uint16 result; + }); + + PACKSTRUCT (struct ble_msg_connection_version_update_cmd_t { uint8 connection; }); + + PACKSTRUCT (struct ble_msg_connection_version_update_rsp_t { + uint8 connection; + uint16 result; + }); + + PACKSTRUCT (struct ble_msg_connection_channel_map_get_cmd_t { uint8 connection; }); + + PACKSTRUCT (struct ble_msg_connection_channel_map_get_rsp_t { + uint8 connection; + uint8array map; + }); + + PACKSTRUCT (struct ble_msg_connection_channel_map_set_cmd_t { + uint8 connection; + uint8array map; + }); + + PACKSTRUCT (struct ble_msg_connection_channel_map_set_rsp_t { + uint8 connection; + uint16 result; + }); + + PACKSTRUCT (struct ble_msg_connection_features_get_cmd_t { uint8 connection; }); + + PACKSTRUCT (struct ble_msg_connection_features_get_rsp_t { + uint8 connection; + uint16 result; + }); + + PACKSTRUCT (struct ble_msg_connection_get_status_cmd_t { uint8 connection; }); + + PACKSTRUCT (struct ble_msg_connection_get_status_rsp_t { uint8 connection; }); + + PACKSTRUCT (struct ble_msg_connection_raw_tx_cmd_t { + uint8 connection; + uint8array data; + }); + + PACKSTRUCT (struct ble_msg_connection_raw_tx_rsp_t { uint8 connection; }); + + PACKSTRUCT (struct ble_msg_connection_status_evt_t { + uint8 connection; + uint8 flags; + bd_addr address; + uint8 address_type; + uint16 conn_interval; + uint16 timeout; + uint16 latency; + uint8 bonding; + }); + + PACKSTRUCT (struct ble_msg_connection_version_ind_evt_t { + uint8 connection; + uint8 vers_nr; + uint16 comp_id; + uint16 sub_vers_nr; + }); + + PACKSTRUCT (struct ble_msg_connection_feature_ind_evt_t { + uint8 connection; + uint8array features; + }); + + PACKSTRUCT (struct ble_msg_connection_raw_rx_evt_t { + uint8 connection; + uint8array data; + }); + + PACKSTRUCT (struct ble_msg_connection_disconnected_evt_t { + uint8 connection; + uint16 reason; + }); + + PACKSTRUCT (struct ble_msg_attclient_find_by_type_value_cmd_t { + uint8 connection; + uint16 start; + uint16 end; + uint16 uuid; + uint8array value; + }); + + PACKSTRUCT (struct ble_msg_attclient_find_by_type_value_rsp_t { + uint8 connection; + uint16 result; + }); + + PACKSTRUCT (struct ble_msg_attclient_read_by_group_type_cmd_t { + uint8 connection; + uint16 start; + uint16 end; + uint8array uuid; + }); + + PACKSTRUCT (struct ble_msg_attclient_read_by_group_type_rsp_t { + uint8 connection; + uint16 result; + }); + + PACKSTRUCT (struct ble_msg_attclient_read_by_type_cmd_t { + uint8 connection; + uint16 start; + uint16 end; + uint8array uuid; + }); + + PACKSTRUCT (struct ble_msg_attclient_read_by_type_rsp_t { + uint8 connection; + uint16 result; + }); + + PACKSTRUCT (struct ble_msg_attclient_find_information_cmd_t { + uint8 connection; + uint16 start; + uint16 end; + }); + + PACKSTRUCT (struct ble_msg_attclient_find_information_rsp_t { + uint8 connection; + uint16 result; + }); + + PACKSTRUCT (struct ble_msg_attclient_read_by_handle_cmd_t { + uint8 connection; + uint16 chrhandle; + }); + + PACKSTRUCT (struct ble_msg_attclient_read_by_handle_rsp_t { + uint8 connection; + uint16 result; + }); + + PACKSTRUCT (struct ble_msg_attclient_attribute_write_cmd_t { + uint8 connection; + uint16 atthandle; + uint8array data; + }); + + PACKSTRUCT (struct ble_msg_attclient_attribute_write_rsp_t { + uint8 connection; + uint16 result; + }); + + PACKSTRUCT (struct ble_msg_attclient_write_command_cmd_t { + uint8 connection; + uint16 atthandle; + uint8array data; + }); + + PACKSTRUCT (struct ble_msg_attclient_write_command_rsp_t { + uint8 connection; + uint16 result; + }); + + PACKSTRUCT (struct ble_msg_attclient_indicate_confirm_cmd_t { uint8 connection; }); + + PACKSTRUCT (struct ble_msg_attclient_indicate_confirm_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_attclient_read_long_cmd_t { + uint8 connection; + uint16 chrhandle; + }); + + PACKSTRUCT (struct ble_msg_attclient_read_long_rsp_t { + uint8 connection; + uint16 result; + }); + + PACKSTRUCT (struct ble_msg_attclient_prepare_write_cmd_t { + uint8 connection; + uint16 atthandle; + uint16 offset; + uint8array data; + }); + + PACKSTRUCT (struct ble_msg_attclient_prepare_write_rsp_t { + uint8 connection; + uint16 result; + }); + + PACKSTRUCT (struct ble_msg_attclient_execute_write_cmd_t { + uint8 connection; + uint8 commit; + }); + + PACKSTRUCT (struct ble_msg_attclient_execute_write_rsp_t { + uint8 connection; + uint16 result; + }); + + PACKSTRUCT (struct ble_msg_attclient_read_multiple_cmd_t { + uint8 connection; + uint8array handles; + }); + + PACKSTRUCT (struct ble_msg_attclient_read_multiple_rsp_t { + uint8 connection; + uint16 result; + }); + + PACKSTRUCT (struct ble_msg_attclient_indicated_evt_t { + uint8 connection; + uint16 attrhandle; + }); + + PACKSTRUCT (struct ble_msg_attclient_procedure_completed_evt_t { + uint8 connection; + uint16 result; + uint16 chrhandle; + }); + + PACKSTRUCT (struct ble_msg_attclient_group_found_evt_t { + uint8 connection; + uint16 start; + uint16 end; + uint8array uuid; + }); + + PACKSTRUCT (struct ble_msg_attclient_attribute_found_evt_t { + uint8 connection; + uint16 chrdecl; + uint16 value; + uint8 properties; + uint8array uuid; + }); + + PACKSTRUCT (struct ble_msg_attclient_find_information_found_evt_t { + uint8 connection; + uint16 chrhandle; + uint8array uuid; + }); + + PACKSTRUCT (struct ble_msg_attclient_attribute_value_evt_t { + uint8 connection; + uint16 atthandle; + uint8 type; + uint8array value; + }); + + PACKSTRUCT (struct ble_msg_attclient_read_multiple_response_evt_t { + uint8 connection; + uint8array handles; + }); + + PACKSTRUCT (struct ble_msg_sm_encrypt_start_cmd_t { + uint8 handle; + uint8 bonding; + }); + + PACKSTRUCT (struct ble_msg_sm_encrypt_start_rsp_t { + uint8 handle; + uint16 result; + }); + + PACKSTRUCT (struct ble_msg_sm_set_bondable_mode_cmd_t { uint8 bondable; }); + + PACKSTRUCT (struct ble_msg_sm_delete_bonding_cmd_t { uint8 handle; }); + + PACKSTRUCT (struct ble_msg_sm_delete_bonding_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_sm_set_parameters_cmd_t { + uint8 mitm; + uint8 min_key_size; + uint8 io_capabilities; + }); + + PACKSTRUCT (struct ble_msg_sm_passkey_entry_cmd_t { + uint8 handle; + uint32 passkey; + }); + + PACKSTRUCT (struct ble_msg_sm_passkey_entry_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_sm_get_bonds_rsp_t { uint8 bonds; }); + + PACKSTRUCT (struct ble_msg_sm_set_oob_data_cmd_t { uint8array oob; }); + + PACKSTRUCT (struct ble_msg_sm_whitelist_bonds_rsp_t { + uint16 result; + uint8 count; + }); + + PACKSTRUCT (struct ble_msg_sm_smp_data_evt_t { + uint8 handle; + uint8 packet; + uint8array data; + }); + + PACKSTRUCT (struct ble_msg_sm_bonding_fail_evt_t { + uint8 handle; + uint16 result; + }); + + PACKSTRUCT (struct ble_msg_sm_passkey_display_evt_t { + uint8 handle; + uint32 passkey; + }); + + PACKSTRUCT (struct ble_msg_sm_passkey_request_evt_t { uint8 handle; }); + + PACKSTRUCT (struct ble_msg_sm_bond_status_evt_t { + uint8 bond; + uint8 keysize; + uint8 mitm; + uint8 keys; + }); + + PACKSTRUCT (struct ble_msg_gap_set_privacy_flags_cmd_t { + uint8 peripheral_privacy; + uint8 central_privacy; + }); + + PACKSTRUCT (struct ble_msg_gap_set_mode_cmd_t { + uint8 discover; + uint8 connect; + }); + + PACKSTRUCT (struct ble_msg_gap_set_mode_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_gap_discover_cmd_t { uint8 mode; }); + + PACKSTRUCT (struct ble_msg_gap_discover_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_gap_connect_direct_cmd_t { + bd_addr address; + uint8 addr_type; + uint16 conn_interval_min; + uint16 conn_interval_max; + uint16 timeout; + uint16 latency; + }); + + PACKSTRUCT (struct ble_msg_gap_connect_direct_rsp_t { + uint16 result; + uint8 connection_handle; + }); + + PACKSTRUCT (struct ble_msg_gap_end_procedure_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_gap_connect_selective_cmd_t { + uint16 conn_interval_min; + uint16 conn_interval_max; + uint16 timeout; + uint16 latency; + }); + + PACKSTRUCT (struct ble_msg_gap_connect_selective_rsp_t { + uint16 result; + uint8 connection_handle; + }); + + PACKSTRUCT (struct ble_msg_gap_set_filtering_cmd_t { + uint8 scan_policy; + uint8 adv_policy; + uint8 scan_duplicate_filtering; + }); + + PACKSTRUCT (struct ble_msg_gap_set_filtering_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_gap_set_scan_parameters_cmd_t { + uint16 scan_interval; + uint16 scan_window; + uint8 active; + }); + + PACKSTRUCT (struct ble_msg_gap_set_scan_parameters_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_gap_set_adv_parameters_cmd_t { + uint16 adv_interval_min; + uint16 adv_interval_max; + uint8 adv_channels; + }); + + PACKSTRUCT (struct ble_msg_gap_set_adv_parameters_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_gap_set_adv_data_cmd_t { + uint8 set_scanrsp; + uint8array adv_data; + }); + + PACKSTRUCT (struct ble_msg_gap_set_adv_data_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_gap_set_directed_connectable_mode_cmd_t { + bd_addr address; + uint8 addr_type; + }); + + PACKSTRUCT (struct ble_msg_gap_set_directed_connectable_mode_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_gap_scan_response_evt_t { + int8 rssi; + uint8 packet_type; + bd_addr sender; + uint8 address_type; + uint8 bond; + uint8array data; + }); + + PACKSTRUCT (struct ble_msg_gap_mode_changed_evt_t { + uint8 discover; + uint8 connect; + }); + + PACKSTRUCT (struct ble_msg_hardware_io_port_config_irq_cmd_t { + uint8 port; + uint8 enable_bits; + uint8 falling_edge; + }); + + PACKSTRUCT (struct ble_msg_hardware_io_port_config_irq_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_hardware_set_soft_timer_cmd_t { + uint32 time; + uint8 handle; + uint8 single_shot; + }); + + PACKSTRUCT (struct ble_msg_hardware_set_soft_timer_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_hardware_adc_read_cmd_t { + uint8 input; + uint8 decimation; + uint8 reference_selection; + }); + + PACKSTRUCT (struct ble_msg_hardware_adc_read_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_hardware_io_port_config_direction_cmd_t { + uint8 port; + uint8 direction; + }); + + PACKSTRUCT (struct ble_msg_hardware_io_port_config_direction_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_hardware_io_port_config_function_cmd_t { + uint8 port; + uint8 function; + }); + + PACKSTRUCT (struct ble_msg_hardware_io_port_config_function_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_hardware_io_port_config_pull_cmd_t { + uint8 port; + uint8 tristate_mask; + uint8 pull_up; + }); + + PACKSTRUCT (struct ble_msg_hardware_io_port_config_pull_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_hardware_io_port_write_cmd_t { + uint8 port; + uint8 mask; + uint8 data; + }); + + PACKSTRUCT (struct ble_msg_hardware_io_port_write_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_hardware_io_port_read_cmd_t { + uint8 port; + uint8 mask; + }); + + PACKSTRUCT (struct ble_msg_hardware_io_port_read_rsp_t { + uint16 result; + uint8 port; + uint8 data; + }); + + PACKSTRUCT (struct ble_msg_hardware_spi_config_cmd_t { + uint8 channel; + uint8 polarity; + uint8 phase; + uint8 bit_order; + uint8 baud_e; + uint8 baud_m; + }); + + PACKSTRUCT (struct ble_msg_hardware_spi_config_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_hardware_spi_transfer_cmd_t { + uint8 channel; + uint8array data; + }); + + PACKSTRUCT (struct ble_msg_hardware_spi_transfer_rsp_t { + uint16 result; + uint8 channel; + uint8array data; + }); + + PACKSTRUCT (struct ble_msg_hardware_i2c_read_cmd_t { + uint8 address; + uint8 stop; + uint8 length; + }); + + PACKSTRUCT (struct ble_msg_hardware_i2c_read_rsp_t { + uint16 result; + uint8array data; + }); + + PACKSTRUCT (struct ble_msg_hardware_i2c_write_cmd_t { + uint8 address; + uint8 stop; + uint8array data; + }); + + PACKSTRUCT (struct ble_msg_hardware_i2c_write_rsp_t { uint8 written; }); + + PACKSTRUCT (struct ble_msg_hardware_set_txpower_cmd_t { uint8 power; }); + + PACKSTRUCT (struct ble_msg_hardware_timer_comparator_cmd_t { + uint8 timer; + uint8 channel; + uint8 mode; + uint16 comparator_value; + }); + + PACKSTRUCT (struct ble_msg_hardware_timer_comparator_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_hardware_io_port_irq_enable_cmd_t { + uint8 port; + uint8 enable_bits; + }); + + PACKSTRUCT (struct ble_msg_hardware_io_port_irq_enable_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_hardware_io_port_irq_direction_cmd_t { + uint8 port; + uint8 falling_edge; + }); + + PACKSTRUCT (struct ble_msg_hardware_io_port_irq_direction_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_hardware_analog_comparator_enable_cmd_t { uint8 enable; }); + + PACKSTRUCT (struct ble_msg_hardware_analog_comparator_read_rsp_t { + uint16 result; + uint8 output; + }); + + PACKSTRUCT (struct ble_msg_hardware_analog_comparator_config_irq_cmd_t { uint8 enabled; }); + + PACKSTRUCT (struct ble_msg_hardware_analog_comparator_config_irq_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_hardware_set_rxgain_cmd_t { uint8 gain; }); + + PACKSTRUCT (struct ble_msg_hardware_usb_enable_cmd_t { uint8 enable; }); + + PACKSTRUCT (struct ble_msg_hardware_usb_enable_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_hardware_io_port_status_evt_t { + uint32 timestamp; + uint8 port; + uint8 irq; + uint8 state; + }); + + PACKSTRUCT (struct ble_msg_hardware_soft_timer_evt_t { uint8 handle; }); + + PACKSTRUCT (struct ble_msg_hardware_adc_result_evt_t { + uint8 input; + int16 value; + }); + + PACKSTRUCT (struct ble_msg_hardware_analog_comparator_status_evt_t { + uint32 timestamp; + uint8 output; + }); + + PACKSTRUCT (struct ble_msg_test_phy_tx_cmd_t { + uint8 channel; + uint8 length; + uint8 type; + }); + + PACKSTRUCT (struct ble_msg_test_phy_rx_cmd_t { uint8 channel; }); + + PACKSTRUCT (struct ble_msg_test_phy_end_rsp_t { uint16 counter; }); + + PACKSTRUCT (struct ble_msg_test_get_channel_map_rsp_t { uint8array channel_map; }); + + PACKSTRUCT (struct ble_msg_test_debug_cmd_t { uint8array input; }); + + PACKSTRUCT (struct ble_msg_test_debug_rsp_t { uint8array output; }); + + PACKSTRUCT (struct ble_msg_test_channel_mode_cmd_t { uint8 mode; }); + + PACKSTRUCT (struct ble_msg_dfu_reset_cmd_t { uint8 dfu; }); + + PACKSTRUCT (struct ble_msg_dfu_flash_set_address_cmd_t { uint32 address; }); + + PACKSTRUCT (struct ble_msg_dfu_flash_set_address_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_dfu_flash_upload_cmd_t { uint8array data; }); + + PACKSTRUCT (struct ble_msg_dfu_flash_upload_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_dfu_flash_upload_finish_rsp_t { uint16 result; }); + + PACKSTRUCT (struct ble_msg_dfu_boot_evt_t { uint32 version; }); + + PACKSTRUCT (struct ble_cmd_packet { + struct ble_header header; + + union { + uint8 handle; + + uint8 payload; + + struct ble_msg_system_reset_cmd_t system_reset_cmd; + struct ble_msg_system_reg_write_cmd_t system_reg_write_cmd; + struct ble_msg_system_reg_read_cmd_t system_reg_read_cmd; + struct ble_msg_system_read_memory_cmd_t system_read_memory_cmd; + struct ble_msg_system_endpoint_tx_cmd_t system_endpoint_tx_cmd; + struct ble_msg_system_whitelist_append_cmd_t system_whitelist_append_cmd; + struct ble_msg_system_whitelist_remove_cmd_t system_whitelist_remove_cmd; + struct ble_msg_system_endpoint_rx_cmd_t system_endpoint_rx_cmd; + struct ble_msg_system_endpoint_set_watermarks_cmd_t system_endpoint_set_watermarks_cmd; + struct ble_msg_system_aes_setkey_cmd_t system_aes_setkey_cmd; + struct ble_msg_system_aes_encrypt_cmd_t system_aes_encrypt_cmd; + struct ble_msg_system_aes_decrypt_cmd_t system_aes_decrypt_cmd; + struct ble_msg_system_boot_evt_t system_boot_evt; + struct ble_msg_system_debug_evt_t system_debug_evt; + struct ble_msg_system_endpoint_watermark_rx_evt_t system_endpoint_watermark_rx_evt; + struct ble_msg_system_endpoint_watermark_tx_evt_t system_endpoint_watermark_tx_evt; + struct ble_msg_system_script_failure_evt_t system_script_failure_evt; + struct ble_msg_system_protocol_error_evt_t system_protocol_error_evt; + struct ble_msg_system_address_get_rsp_t system_address_get_rsp; + struct ble_msg_system_reg_write_rsp_t system_reg_write_rsp; + struct ble_msg_system_reg_read_rsp_t system_reg_read_rsp; + struct ble_msg_system_get_counters_rsp_t system_get_counters_rsp; + struct ble_msg_system_get_connections_rsp_t system_get_connections_rsp; + struct ble_msg_system_read_memory_rsp_t system_read_memory_rsp; + struct ble_msg_system_get_info_rsp_t system_get_info_rsp; + struct ble_msg_system_endpoint_tx_rsp_t system_endpoint_tx_rsp; + struct ble_msg_system_whitelist_append_rsp_t system_whitelist_append_rsp; + struct ble_msg_system_whitelist_remove_rsp_t system_whitelist_remove_rsp; + struct ble_msg_system_endpoint_rx_rsp_t system_endpoint_rx_rsp; + struct ble_msg_system_endpoint_set_watermarks_rsp_t system_endpoint_set_watermarks_rsp; + struct ble_msg_system_aes_encrypt_rsp_t system_aes_encrypt_rsp; + struct ble_msg_system_aes_decrypt_rsp_t system_aes_decrypt_rsp; + struct ble_msg_flash_ps_save_cmd_t flash_ps_save_cmd; + struct ble_msg_flash_ps_load_cmd_t flash_ps_load_cmd; + struct ble_msg_flash_ps_erase_cmd_t flash_ps_erase_cmd; + struct ble_msg_flash_erase_page_cmd_t flash_erase_page_cmd; + struct ble_msg_flash_write_data_cmd_t flash_write_data_cmd; + struct ble_msg_flash_read_data_cmd_t flash_read_data_cmd; + struct ble_msg_flash_ps_key_evt_t flash_ps_key_evt; + struct ble_msg_flash_ps_save_rsp_t flash_ps_save_rsp; + struct ble_msg_flash_ps_load_rsp_t flash_ps_load_rsp; + struct ble_msg_flash_erase_page_rsp_t flash_erase_page_rsp; + struct ble_msg_flash_write_data_rsp_t flash_write_data_rsp; + struct ble_msg_flash_read_data_rsp_t flash_read_data_rsp; + struct ble_msg_attributes_write_cmd_t attributes_write_cmd; + struct ble_msg_attributes_read_cmd_t attributes_read_cmd; + struct ble_msg_attributes_read_type_cmd_t attributes_read_type_cmd; + struct ble_msg_attributes_user_read_response_cmd_t attributes_user_read_response_cmd; + struct ble_msg_attributes_user_write_response_cmd_t attributes_user_write_response_cmd; + struct ble_msg_attributes_send_cmd_t attributes_send_cmd; + struct ble_msg_attributes_value_evt_t attributes_value_evt; + struct ble_msg_attributes_user_read_request_evt_t attributes_user_read_request_evt; + struct ble_msg_attributes_status_evt_t attributes_status_evt; + struct ble_msg_attributes_write_rsp_t attributes_write_rsp; + struct ble_msg_attributes_read_rsp_t attributes_read_rsp; + struct ble_msg_attributes_read_type_rsp_t attributes_read_type_rsp; + struct ble_msg_attributes_send_rsp_t attributes_send_rsp; + struct ble_msg_connection_disconnect_cmd_t connection_disconnect_cmd; + struct ble_msg_connection_get_rssi_cmd_t connection_get_rssi_cmd; + struct ble_msg_connection_update_cmd_t connection_update_cmd; + struct ble_msg_connection_version_update_cmd_t connection_version_update_cmd; + struct ble_msg_connection_channel_map_get_cmd_t connection_channel_map_get_cmd; + struct ble_msg_connection_channel_map_set_cmd_t connection_channel_map_set_cmd; + struct ble_msg_connection_features_get_cmd_t connection_features_get_cmd; + struct ble_msg_connection_get_status_cmd_t connection_get_status_cmd; + struct ble_msg_connection_raw_tx_cmd_t connection_raw_tx_cmd; + struct ble_msg_connection_status_evt_t connection_status_evt; + struct ble_msg_connection_version_ind_evt_t connection_version_ind_evt; + struct ble_msg_connection_feature_ind_evt_t connection_feature_ind_evt; + struct ble_msg_connection_raw_rx_evt_t connection_raw_rx_evt; + struct ble_msg_connection_disconnected_evt_t connection_disconnected_evt; + struct ble_msg_connection_disconnect_rsp_t connection_disconnect_rsp; + struct ble_msg_connection_get_rssi_rsp_t connection_get_rssi_rsp; + struct ble_msg_connection_update_rsp_t connection_update_rsp; + struct ble_msg_connection_version_update_rsp_t connection_version_update_rsp; + struct ble_msg_connection_channel_map_get_rsp_t connection_channel_map_get_rsp; + struct ble_msg_connection_channel_map_set_rsp_t connection_channel_map_set_rsp; + struct ble_msg_connection_features_get_rsp_t connection_features_get_rsp; + struct ble_msg_connection_get_status_rsp_t connection_get_status_rsp; + struct ble_msg_connection_raw_tx_rsp_t connection_raw_tx_rsp; + struct ble_msg_attclient_find_by_type_value_cmd_t attclient_find_by_type_value_cmd; + struct ble_msg_attclient_read_by_group_type_cmd_t attclient_read_by_group_type_cmd; + struct ble_msg_attclient_read_by_type_cmd_t attclient_read_by_type_cmd; + struct ble_msg_attclient_find_information_cmd_t attclient_find_information_cmd; + struct ble_msg_attclient_read_by_handle_cmd_t attclient_read_by_handle_cmd; + struct ble_msg_attclient_attribute_write_cmd_t attclient_attribute_write_cmd; + struct ble_msg_attclient_write_command_cmd_t attclient_write_command_cmd; + struct ble_msg_attclient_indicate_confirm_cmd_t attclient_indicate_confirm_cmd; + struct ble_msg_attclient_read_long_cmd_t attclient_read_long_cmd; + struct ble_msg_attclient_prepare_write_cmd_t attclient_prepare_write_cmd; + struct ble_msg_attclient_execute_write_cmd_t attclient_execute_write_cmd; + struct ble_msg_attclient_read_multiple_cmd_t attclient_read_multiple_cmd; + struct ble_msg_attclient_indicated_evt_t attclient_indicated_evt; + struct ble_msg_attclient_procedure_completed_evt_t attclient_procedure_completed_evt; + struct ble_msg_attclient_group_found_evt_t attclient_group_found_evt; + struct ble_msg_attclient_attribute_found_evt_t attclient_attribute_found_evt; + struct ble_msg_attclient_find_information_found_evt_t + attclient_find_information_found_evt; + struct ble_msg_attclient_attribute_value_evt_t attclient_attribute_value_evt; + struct ble_msg_attclient_read_multiple_response_evt_t + attclient_read_multiple_response_evt; + struct ble_msg_attclient_find_by_type_value_rsp_t attclient_find_by_type_value_rsp; + struct ble_msg_attclient_read_by_group_type_rsp_t attclient_read_by_group_type_rsp; + struct ble_msg_attclient_read_by_type_rsp_t attclient_read_by_type_rsp; + struct ble_msg_attclient_find_information_rsp_t attclient_find_information_rsp; + struct ble_msg_attclient_read_by_handle_rsp_t attclient_read_by_handle_rsp; + struct ble_msg_attclient_attribute_write_rsp_t attclient_attribute_write_rsp; + struct ble_msg_attclient_write_command_rsp_t attclient_write_command_rsp; + struct ble_msg_attclient_indicate_confirm_rsp_t attclient_indicate_confirm_rsp; + struct ble_msg_attclient_read_long_rsp_t attclient_read_long_rsp; + struct ble_msg_attclient_prepare_write_rsp_t attclient_prepare_write_rsp; + struct ble_msg_attclient_execute_write_rsp_t attclient_execute_write_rsp; + struct ble_msg_attclient_read_multiple_rsp_t attclient_read_multiple_rsp; + struct ble_msg_sm_encrypt_start_cmd_t sm_encrypt_start_cmd; + struct ble_msg_sm_set_bondable_mode_cmd_t sm_set_bondable_mode_cmd; + struct ble_msg_sm_delete_bonding_cmd_t sm_delete_bonding_cmd; + struct ble_msg_sm_set_parameters_cmd_t sm_set_parameters_cmd; + struct ble_msg_sm_passkey_entry_cmd_t sm_passkey_entry_cmd; + struct ble_msg_sm_set_oob_data_cmd_t sm_set_oob_data_cmd; + struct ble_msg_sm_smp_data_evt_t sm_smp_data_evt; + struct ble_msg_sm_bonding_fail_evt_t sm_bonding_fail_evt; + struct ble_msg_sm_passkey_display_evt_t sm_passkey_display_evt; + struct ble_msg_sm_passkey_request_evt_t sm_passkey_request_evt; + struct ble_msg_sm_bond_status_evt_t sm_bond_status_evt; + struct ble_msg_sm_encrypt_start_rsp_t sm_encrypt_start_rsp; + struct ble_msg_sm_delete_bonding_rsp_t sm_delete_bonding_rsp; + struct ble_msg_sm_passkey_entry_rsp_t sm_passkey_entry_rsp; + struct ble_msg_sm_get_bonds_rsp_t sm_get_bonds_rsp; + struct ble_msg_sm_whitelist_bonds_rsp_t sm_whitelist_bonds_rsp; + struct ble_msg_gap_set_privacy_flags_cmd_t gap_set_privacy_flags_cmd; + struct ble_msg_gap_set_mode_cmd_t gap_set_mode_cmd; + struct ble_msg_gap_discover_cmd_t gap_discover_cmd; + struct ble_msg_gap_connect_direct_cmd_t gap_connect_direct_cmd; + struct ble_msg_gap_connect_selective_cmd_t gap_connect_selective_cmd; + struct ble_msg_gap_set_filtering_cmd_t gap_set_filtering_cmd; + struct ble_msg_gap_set_scan_parameters_cmd_t gap_set_scan_parameters_cmd; + struct ble_msg_gap_set_adv_parameters_cmd_t gap_set_adv_parameters_cmd; + struct ble_msg_gap_set_adv_data_cmd_t gap_set_adv_data_cmd; + struct ble_msg_gap_set_directed_connectable_mode_cmd_t + gap_set_directed_connectable_mode_cmd; + struct ble_msg_gap_scan_response_evt_t gap_scan_response_evt; + struct ble_msg_gap_mode_changed_evt_t gap_mode_changed_evt; + struct ble_msg_gap_set_mode_rsp_t gap_set_mode_rsp; + struct ble_msg_gap_discover_rsp_t gap_discover_rsp; + struct ble_msg_gap_connect_direct_rsp_t gap_connect_direct_rsp; + struct ble_msg_gap_end_procedure_rsp_t gap_end_procedure_rsp; + struct ble_msg_gap_connect_selective_rsp_t gap_connect_selective_rsp; + struct ble_msg_gap_set_filtering_rsp_t gap_set_filtering_rsp; + struct ble_msg_gap_set_scan_parameters_rsp_t gap_set_scan_parameters_rsp; + struct ble_msg_gap_set_adv_parameters_rsp_t gap_set_adv_parameters_rsp; + struct ble_msg_gap_set_adv_data_rsp_t gap_set_adv_data_rsp; + struct ble_msg_gap_set_directed_connectable_mode_rsp_t + gap_set_directed_connectable_mode_rsp; + struct ble_msg_hardware_io_port_config_irq_cmd_t hardware_io_port_config_irq_cmd; + struct ble_msg_hardware_set_soft_timer_cmd_t hardware_set_soft_timer_cmd; + struct ble_msg_hardware_adc_read_cmd_t hardware_adc_read_cmd; + struct ble_msg_hardware_io_port_config_direction_cmd_t + hardware_io_port_config_direction_cmd; + struct ble_msg_hardware_io_port_config_function_cmd_t + hardware_io_port_config_function_cmd; + struct ble_msg_hardware_io_port_config_pull_cmd_t hardware_io_port_config_pull_cmd; + struct ble_msg_hardware_io_port_write_cmd_t hardware_io_port_write_cmd; + struct ble_msg_hardware_io_port_read_cmd_t hardware_io_port_read_cmd; + struct ble_msg_hardware_spi_config_cmd_t hardware_spi_config_cmd; + struct ble_msg_hardware_spi_transfer_cmd_t hardware_spi_transfer_cmd; + struct ble_msg_hardware_i2c_read_cmd_t hardware_i2c_read_cmd; + struct ble_msg_hardware_i2c_write_cmd_t hardware_i2c_write_cmd; + struct ble_msg_hardware_set_txpower_cmd_t hardware_set_txpower_cmd; + struct ble_msg_hardware_timer_comparator_cmd_t hardware_timer_comparator_cmd; + struct ble_msg_hardware_io_port_irq_enable_cmd_t hardware_io_port_irq_enable_cmd; + struct ble_msg_hardware_io_port_irq_direction_cmd_t hardware_io_port_irq_direction_cmd; + struct ble_msg_hardware_analog_comparator_enable_cmd_t + hardware_analog_comparator_enable_cmd; + struct ble_msg_hardware_analog_comparator_config_irq_cmd_t + hardware_analog_comparator_config_irq_cmd; + struct ble_msg_hardware_set_rxgain_cmd_t hardware_set_rxgain_cmd; + struct ble_msg_hardware_usb_enable_cmd_t hardware_usb_enable_cmd; + struct ble_msg_hardware_io_port_status_evt_t hardware_io_port_status_evt; + struct ble_msg_hardware_soft_timer_evt_t hardware_soft_timer_evt; + struct ble_msg_hardware_adc_result_evt_t hardware_adc_result_evt; + struct ble_msg_hardware_analog_comparator_status_evt_t + hardware_analog_comparator_status_evt; + struct ble_msg_hardware_io_port_config_irq_rsp_t hardware_io_port_config_irq_rsp; + struct ble_msg_hardware_set_soft_timer_rsp_t hardware_set_soft_timer_rsp; + struct ble_msg_hardware_adc_read_rsp_t hardware_adc_read_rsp; + struct ble_msg_hardware_io_port_config_direction_rsp_t + hardware_io_port_config_direction_rsp; + struct ble_msg_hardware_io_port_config_function_rsp_t + hardware_io_port_config_function_rsp; + struct ble_msg_hardware_io_port_config_pull_rsp_t hardware_io_port_config_pull_rsp; + struct ble_msg_hardware_io_port_write_rsp_t hardware_io_port_write_rsp; + struct ble_msg_hardware_io_port_read_rsp_t hardware_io_port_read_rsp; + struct ble_msg_hardware_spi_config_rsp_t hardware_spi_config_rsp; + struct ble_msg_hardware_spi_transfer_rsp_t hardware_spi_transfer_rsp; + struct ble_msg_hardware_i2c_read_rsp_t hardware_i2c_read_rsp; + struct ble_msg_hardware_i2c_write_rsp_t hardware_i2c_write_rsp; + struct ble_msg_hardware_timer_comparator_rsp_t hardware_timer_comparator_rsp; + struct ble_msg_hardware_io_port_irq_enable_rsp_t hardware_io_port_irq_enable_rsp; + struct ble_msg_hardware_io_port_irq_direction_rsp_t hardware_io_port_irq_direction_rsp; + struct ble_msg_hardware_analog_comparator_read_rsp_t + hardware_analog_comparator_read_rsp; + struct ble_msg_hardware_analog_comparator_config_irq_rsp_t + hardware_analog_comparator_config_irq_rsp; + struct ble_msg_hardware_usb_enable_rsp_t hardware_usb_enable_rsp; + struct ble_msg_test_phy_tx_cmd_t test_phy_tx_cmd; + struct ble_msg_test_phy_rx_cmd_t test_phy_rx_cmd; + struct ble_msg_test_debug_cmd_t test_debug_cmd; + struct ble_msg_test_channel_mode_cmd_t test_channel_mode_cmd; + struct ble_msg_test_phy_end_rsp_t test_phy_end_rsp; + struct ble_msg_test_get_channel_map_rsp_t test_get_channel_map_rsp; + struct ble_msg_test_debug_rsp_t test_debug_rsp; + struct ble_msg_dfu_reset_cmd_t dfu_reset_cmd; + struct ble_msg_dfu_flash_set_address_cmd_t dfu_flash_set_address_cmd; + struct ble_msg_dfu_flash_upload_cmd_t dfu_flash_upload_cmd; + struct ble_msg_dfu_boot_evt_t dfu_boot_evt; + struct ble_msg_dfu_flash_set_address_rsp_t dfu_flash_set_address_rsp; + struct ble_msg_dfu_flash_upload_rsp_t dfu_flash_upload_rsp; + struct ble_msg_dfu_flash_upload_finish_rsp_t dfu_flash_upload_finish_rsp; + }; + } ALIGNED); +/**Reset device**/ +#define ble_cmd_system_reset(boot_in_dfu) ble_send_message (ble_cmd_system_reset_idx, boot_in_dfu) +/**Hello - command for testing**/ +#define ble_cmd_system_hello() ble_send_message (ble_cmd_system_hello_idx) +/**Get device bluetooth address**/ +#define ble_cmd_system_address_get() ble_send_message (ble_cmd_system_address_get_idx) +/**write register**/ +#define ble_cmd_system_reg_write(address, value) \ + ble_send_message (ble_cmd_system_reg_write_idx, address, value) +/**read register**/ +#define ble_cmd_system_reg_read(address) ble_send_message (ble_cmd_system_reg_read_idx, address) +/**get and reset packet counters**/ +#define ble_cmd_system_get_counters() ble_send_message (ble_cmd_system_get_counters_idx) +/**Get status from all connections**/ +#define ble_cmd_system_get_connections() ble_send_message (ble_cmd_system_get_connections_idx) +/**Read Memory**/ +#define ble_cmd_system_read_memory(address, length) \ + ble_send_message (ble_cmd_system_read_memory_idx, address, length) +/**Get Device info**/ +#define ble_cmd_system_get_info() ble_send_message (ble_cmd_system_get_info_idx) +/**Send data to endpoint, error is returned if endpoint does not have enough space**/ +#define ble_cmd_system_endpoint_tx(endpoint, data_len, data_data) \ + ble_send_message (ble_cmd_system_endpoint_tx_idx, endpoint, data_len, data_data) +/**Add entry to whitelist**/ +#define ble_cmd_system_whitelist_append(address, address_type) \ + ble_send_message (ble_cmd_system_whitelist_append_idx, address, address_type) +/**Remove entry from whitelist**/ +#define ble_cmd_system_whitelist_remove(address, address_type) \ + ble_send_message (ble_cmd_system_whitelist_remove_idx, address, address_type) +/**Add entry to whitelist**/ +#define ble_cmd_system_whitelist_clear() ble_send_message (ble_cmd_system_whitelist_clear_idx) +/**Read data from endpoint, error is returned if endpoint does not have enough data.**/ +#define ble_cmd_system_endpoint_rx(endpoint, size) \ + ble_send_message (ble_cmd_system_endpoint_rx_idx, endpoint, size) +/**Set watermarks on both input and output side**/ +#define ble_cmd_system_endpoint_set_watermarks(endpoint, rx, tx) \ + ble_send_message (ble_cmd_system_endpoint_set_watermarks_idx, endpoint, rx, tx) +/**Set encryption key that will be used with aes_encrypt and aes_decrypt commands.**/ +#define ble_cmd_system_aes_setkey(key_len, key_data) \ + ble_send_message (ble_cmd_system_aes_setkey_idx, key_len, key_data) +/**Encrypt one block of data**/ +#define ble_cmd_system_aes_encrypt(data_len, data_data) \ + ble_send_message (ble_cmd_system_aes_encrypt_idx, data_len, data_data) +/**Decrypt one block of data**/ +#define ble_cmd_system_aes_decrypt(data_len, data_data) \ + ble_send_message (ble_cmd_system_aes_decrypt_idx, data_len, data_data) +/**Defragment persistent store**/ +#define ble_cmd_flash_ps_defrag() ble_send_message (ble_cmd_flash_ps_defrag_idx) +/**Dump all ps keys**/ +#define ble_cmd_flash_ps_dump() ble_send_message (ble_cmd_flash_ps_dump_idx) +/**erase all ps keys**/ +#define ble_cmd_flash_ps_erase_all() ble_send_message (ble_cmd_flash_ps_erase_all_idx) +/**save ps key**/ +#define ble_cmd_flash_ps_save(key, value_len, value_data) \ + ble_send_message (ble_cmd_flash_ps_save_idx, key, value_len, value_data) +/**load ps key**/ +#define ble_cmd_flash_ps_load(key) ble_send_message (ble_cmd_flash_ps_load_idx, key) +/**erase ps key**/ +#define ble_cmd_flash_ps_erase(key) ble_send_message (ble_cmd_flash_ps_erase_idx, key) +/**erase flash page**/ +#define ble_cmd_flash_erase_page(page) ble_send_message (ble_cmd_flash_erase_page_idx, page) +/**write data to user data area**/ +#define ble_cmd_flash_write_data(address, data_len, data_data) \ + ble_send_message (ble_cmd_flash_write_data_idx, address, data_len, data_data) +/**read data from user data area.**/ +#define ble_cmd_flash_read_data(address, length) \ + ble_send_message (ble_cmd_flash_read_data_idx, address, length) +/**Write to attribute database**/ +#define ble_cmd_attributes_write(handle, offset, value_len, value_data) \ + ble_send_message (ble_cmd_attributes_write_idx, handle, offset, value_len, value_data) +/**Read from attribute database**/ +#define ble_cmd_attributes_read(handle, offset) \ + ble_send_message (ble_cmd_attributes_read_idx, handle, offset) +/**Read attribute type from database**/ +#define ble_cmd_attributes_read_type(handle) \ + ble_send_message (ble_cmd_attributes_read_type_idx, handle) +/**Respond to user attribute read request**/ +#define ble_cmd_attributes_user_read_response(connection, att_error, value_len, value_data) \ + ble_send_message ( \ + ble_cmd_attributes_user_read_response_idx, connection, att_error, value_len, value_data) +/**Response to attribute_changed event where reason is user-attribute write.**/ +#define ble_cmd_attributes_user_write_response(connection, att_error) \ + ble_send_message (ble_cmd_attributes_user_write_response_idx, connection, att_error) +/**Send notification or indication to remote device.**/ +#define ble_cmd_attributes_send(connection, handle, value_len, value_data) \ + ble_send_message (ble_cmd_attributes_send_idx, connection, handle, value_len, value_data) +/**Disconnect connection, starts a disconnection procedure on connection**/ +#define ble_cmd_connection_disconnect(connection) \ + ble_send_message (ble_cmd_connection_disconnect_idx, connection) +/**Get Link RSSI**/ +#define ble_cmd_connection_get_rssi(connection) \ + ble_send_message (ble_cmd_connection_get_rssi_idx, connection) +/**Update connection parameters**/ +#define ble_cmd_connection_update(connection, interval_min, interval_max, latency, timeout) \ + ble_send_message ( \ + ble_cmd_connection_update_idx, connection, interval_min, interval_max, latency, timeout) +/**Request version exchange**/ +#define ble_cmd_connection_version_update(connection) \ + ble_send_message (ble_cmd_connection_version_update_idx, connection) +/**Get Current channel map**/ +#define ble_cmd_connection_channel_map_get(connection) \ + ble_send_message (ble_cmd_connection_channel_map_get_idx, connection) +/**Set Channel map**/ +#define ble_cmd_connection_channel_map_set(connection, map_len, map_data) \ + ble_send_message (ble_cmd_connection_channel_map_set_idx, connection, map_len, map_data) +/**Remote feature request**/ +#define ble_cmd_connection_features_get(connection) \ + ble_send_message (ble_cmd_connection_features_get_idx, connection) +/**Get Connection Status Parameters**/ +#define ble_cmd_connection_get_status(connection) \ + ble_send_message (ble_cmd_connection_get_status_idx, connection) +/**Raw TX**/ +#define ble_cmd_connection_raw_tx(connection, data_len, data_data) \ + ble_send_message (ble_cmd_connection_raw_tx_idx, connection, data_len, data_data) +/**Discover attributes by type and value**/ +#define ble_cmd_attclient_find_by_type_value(connection, start, end, uuid, value_len, value_data) \ + ble_send_message (ble_cmd_attclient_find_by_type_value_idx, connection, start, end, uuid, \ + value_len, value_data) +/**Discover attributes by type and value**/ +#define ble_cmd_attclient_read_by_group_type(connection, start, end, uuid_len, uuid_data) \ + ble_send_message ( \ + ble_cmd_attclient_read_by_group_type_idx, connection, start, end, uuid_len, uuid_data) +/**Read all attributes where type matches**/ +#define ble_cmd_attclient_read_by_type(connection, start, end, uuid_len, uuid_data) \ + ble_send_message ( \ + ble_cmd_attclient_read_by_type_idx, connection, start, end, uuid_len, uuid_data) +/**Discover Attribute handle and type mappings**/ +#define ble_cmd_attclient_find_information(connection, start, end) \ + ble_send_message (ble_cmd_attclient_find_information_idx, connection, start, end) +/**Read Characteristic value using handle**/ +#define ble_cmd_attclient_read_by_handle(connection, chrhandle) \ + ble_send_message (ble_cmd_attclient_read_by_handle_idx, connection, chrhandle) +/**write data to attribute**/ +#define ble_cmd_attclient_attribute_write(connection, atthandle, data_len, data_data) \ + ble_send_message ( \ + ble_cmd_attclient_attribute_write_idx, connection, atthandle, data_len, data_data) +/**write data to attribute using ATT write command**/ +#define ble_cmd_attclient_write_command(connection, atthandle, data_len, data_data) \ + ble_send_message ( \ + ble_cmd_attclient_write_command_idx, connection, atthandle, data_len, data_data) +/**Send confirmation for received indication, use only if manual indications are enabled**/ +#define ble_cmd_attclient_indicate_confirm(connection) \ + ble_send_message (ble_cmd_attclient_indicate_confirm_idx, connection) +/**Read Long Characteristic value**/ +#define ble_cmd_attclient_read_long(connection, chrhandle) \ + ble_send_message (ble_cmd_attclient_read_long_idx, connection, chrhandle) +/**Send prepare write request to remote host**/ +#define ble_cmd_attclient_prepare_write(connection, atthandle, offset, data_len, data_data) \ + ble_send_message ( \ + ble_cmd_attclient_prepare_write_idx, connection, atthandle, offset, data_len, data_data) +/**Send prepare write request to remote host**/ +#define ble_cmd_attclient_execute_write(connection, commit) \ + ble_send_message (ble_cmd_attclient_execute_write_idx, connection, commit) +/**Read multiple attributes from server**/ +#define ble_cmd_attclient_read_multiple(connection, handles_len, handles_data) \ + ble_send_message (ble_cmd_attclient_read_multiple_idx, connection, handles_len, handles_data) +/**Enable encryption on link**/ +#define ble_cmd_sm_encrypt_start(handle, bonding) \ + ble_send_message (ble_cmd_sm_encrypt_start_idx, handle, bonding) +/**Set device to bondable mode**/ +#define ble_cmd_sm_set_bondable_mode(bondable) \ + ble_send_message (ble_cmd_sm_set_bondable_mode_idx, bondable) +/**delete bonding information from ps store**/ +#define ble_cmd_sm_delete_bonding(handle) ble_send_message (ble_cmd_sm_delete_bonding_idx, handle) +/**set pairing requirements**/ +#define ble_cmd_sm_set_parameters(mitm, min_key_size, io_capabilities) \ + ble_send_message (ble_cmd_sm_set_parameters_idx, mitm, min_key_size, io_capabilities) +/**Passkey entered**/ +#define ble_cmd_sm_passkey_entry(handle, passkey) \ + ble_send_message (ble_cmd_sm_passkey_entry_idx, handle, passkey) +/**List all bonded devices**/ +#define ble_cmd_sm_get_bonds() ble_send_message (ble_cmd_sm_get_bonds_idx) +/** + Set out-of-band encryption data for device + Device does not allow any other kind of pairing except oob if oob data is set. + **/ +#define ble_cmd_sm_set_oob_data(oob_len, oob_data) \ + ble_send_message (ble_cmd_sm_set_oob_data_idx, oob_len, oob_data) +/** + Add all bonded devices with a known public or static address to + the whitelist. Previous entries in the whitelist are first + cleared. This command can't be used while advertising, scanning + or being connected. + **/ +#define ble_cmd_sm_whitelist_bonds() ble_send_message (ble_cmd_sm_whitelist_bonds_idx) +/**Set GAP central/peripheral privacy flags + **/ +#define ble_cmd_gap_set_privacy_flags(peripheral_privacy, central_privacy) \ + ble_send_message (ble_cmd_gap_set_privacy_flags_idx, peripheral_privacy, central_privacy) +/**Set discoverable and connectable mode**/ +#define ble_cmd_gap_set_mode(discover, connect) \ + ble_send_message (ble_cmd_gap_set_mode_idx, discover, connect) +/**start or stop discover procedure**/ +#define ble_cmd_gap_discover(mode) ble_send_message (ble_cmd_gap_discover_idx, mode) +/**Direct connection**/ +#define ble_cmd_gap_connect_direct( \ + address, addr_type, conn_interval_min, conn_interval_max, timeout, latency) \ + ble_send_message (ble_cmd_gap_connect_direct_idx, address, addr_type, conn_interval_min, \ + conn_interval_max, timeout, latency) +/**End current GAP procedure**/ +#define ble_cmd_gap_end_procedure() ble_send_message (ble_cmd_gap_end_procedure_idx) +/**Connect to any device on whitelist**/ +#define ble_cmd_gap_connect_selective(conn_interval_min, conn_interval_max, timeout, latency) \ + ble_send_message ( \ + ble_cmd_gap_connect_selective_idx, conn_interval_min, conn_interval_max, timeout, latency) +/**Set scan and advertising filtering parameters**/ +#define ble_cmd_gap_set_filtering(scan_policy, adv_policy, scan_duplicate_filtering) \ + ble_send_message ( \ + ble_cmd_gap_set_filtering_idx, scan_policy, adv_policy, scan_duplicate_filtering) +/**Set scan parameters**/ +#define ble_cmd_gap_set_scan_parameters(scan_interval, scan_window, active) \ + ble_send_message (ble_cmd_gap_set_scan_parameters_idx, scan_interval, scan_window, active) +/**Set advertising parameters**/ +#define ble_cmd_gap_set_adv_parameters(adv_interval_min, adv_interval_max, adv_channels) \ + ble_send_message ( \ + ble_cmd_gap_set_adv_parameters_idx, adv_interval_min, adv_interval_max, adv_channels) +/**Set advertisement or scan response data. Use broadcast mode to advertise data**/ +#define ble_cmd_gap_set_adv_data(set_scanrsp, adv_data_len, adv_data_data) \ + ble_send_message (ble_cmd_gap_set_adv_data_idx, set_scanrsp, adv_data_len, adv_data_data) +/**Sets device to Directed Connectable Mode + Uses fast advertisement procedure for 1.28s after which device enters + nonconnectable mode. If device has valid reconnection characteristic value, it is used for + connection otherwise passed address and address type are used + **/ +#define ble_cmd_gap_set_directed_connectable_mode(address, addr_type) \ + ble_send_message (ble_cmd_gap_set_directed_connectable_mode_idx, address, addr_type) +/**Configure I/O-port interrupts**/ +#define ble_cmd_hardware_io_port_config_irq(port, enable_bits, falling_edge) \ + ble_send_message (ble_cmd_hardware_io_port_config_irq_idx, port, enable_bits, falling_edge) +/**Set soft timer to send events**/ +#define ble_cmd_hardware_set_soft_timer(time, handle, single_shot) \ + ble_send_message (ble_cmd_hardware_set_soft_timer_idx, time, handle, single_shot) +/**Read A/D conversion**/ +#define ble_cmd_hardware_adc_read(input, decimation, reference_selection) \ + ble_send_message (ble_cmd_hardware_adc_read_idx, input, decimation, reference_selection) +/**Configure I/O-port direction**/ +#define ble_cmd_hardware_io_port_config_direction(port, direction) \ + ble_send_message (ble_cmd_hardware_io_port_config_direction_idx, port, direction) +/**Configure I/O-port function**/ +#define ble_cmd_hardware_io_port_config_function(port, function) \ + ble_send_message (ble_cmd_hardware_io_port_config_function_idx, port, function) +/**Configure I/O-port pull-up/pull-down**/ +#define ble_cmd_hardware_io_port_config_pull(port, tristate_mask, pull_up) \ + ble_send_message (ble_cmd_hardware_io_port_config_pull_idx, port, tristate_mask, pull_up) +/**Write I/O-port**/ +#define ble_cmd_hardware_io_port_write(port, mask, data) \ + ble_send_message (ble_cmd_hardware_io_port_write_idx, port, mask, data) +/**Read I/O-port**/ +#define ble_cmd_hardware_io_port_read(port, mask) \ + ble_send_message (ble_cmd_hardware_io_port_read_idx, port, mask) +/**Configure SPI**/ +#define ble_cmd_hardware_spi_config(channel, polarity, phase, bit_order, baud_e, baud_m) \ + ble_send_message ( \ + ble_cmd_hardware_spi_config_idx, channel, polarity, phase, bit_order, baud_e, baud_m) +/**Transfer SPI data**/ +#define ble_cmd_hardware_spi_transfer(channel, data_len, data_data) \ + ble_send_message (ble_cmd_hardware_spi_transfer_idx, channel, data_len, data_data) +/**Read data from I2C bus using bit-bang in cc2540. I2C clk is in P1.7 data in P1.6. Pull-up must be + * enabled on pins**/ +#define ble_cmd_hardware_i2c_read(address, stop, length) \ + ble_send_message (ble_cmd_hardware_i2c_read_idx, address, stop, length) +/**Write data to I2C bus using bit-bang in cc2540. I2C clk is in P1.7 data in P1.6. Pull-up must be + * enabled on pins**/ +#define ble_cmd_hardware_i2c_write(address, stop, data_len, data_data) \ + ble_send_message (ble_cmd_hardware_i2c_write_idx, address, stop, data_len, data_data) +/**Set TX Power**/ +#define ble_cmd_hardware_set_txpower(power) \ + ble_send_message (ble_cmd_hardware_set_txpower_idx, power) +/**Set comparator for timer channel**/ +#define ble_cmd_hardware_timer_comparator(timer, channel, mode, comparator_value) \ + ble_send_message (ble_cmd_hardware_timer_comparator_idx, timer, channel, mode, comparator_value) +/**Enable I/O-port interrupts**/ +#define ble_cmd_hardware_io_port_irq_enable(port, enable_bits) \ + ble_send_message (ble_cmd_hardware_io_port_irq_enable_idx, port, enable_bits) +/**Set I/O-port interrupt direction**/ +#define ble_cmd_hardware_io_port_irq_direction(port, falling_edge) \ + ble_send_message (ble_cmd_hardware_io_port_irq_direction_idx, port, falling_edge) +/**Enable or disable analog comparator**/ +#define ble_cmd_hardware_analog_comparator_enable(enable) \ + ble_send_message (ble_cmd_hardware_analog_comparator_enable_idx, enable) +/**Read analog comparator output**/ +#define ble_cmd_hardware_analog_comparator_read() \ + ble_send_message (ble_cmd_hardware_analog_comparator_read_idx) +/**Configure analog comparator interrupt**/ +#define ble_cmd_hardware_analog_comparator_config_irq(enabled) \ + ble_send_message (ble_cmd_hardware_analog_comparator_config_irq_idx, enabled) +/**Set RX Sensitivity**/ +#define ble_cmd_hardware_set_rxgain(gain) ble_send_message (ble_cmd_hardware_set_rxgain_idx, gain) +/**Enable or disable USB**/ +#define ble_cmd_hardware_usb_enable(enable) \ + ble_send_message (ble_cmd_hardware_usb_enable_idx, enable) +/**Start packet transmission, send one packet at every 625us**/ +#define ble_cmd_test_phy_tx(channel, length, type) \ + ble_send_message (ble_cmd_test_phy_tx_idx, channel, length, type) +/**Start receive test**/ +#define ble_cmd_test_phy_rx(channel) ble_send_message (ble_cmd_test_phy_rx_idx, channel) +/**End test, and report received packets**/ +#define ble_cmd_test_phy_end() ble_send_message (ble_cmd_test_phy_end_idx) +/**Reset test**/ +#define ble_cmd_test_phy_reset() ble_send_message (ble_cmd_test_phy_reset_idx) +/**Get current channel quality map**/ +#define ble_cmd_test_get_channel_map() ble_send_message (ble_cmd_test_get_channel_map_idx) +/**Debug command**/ +#define ble_cmd_test_debug(input_len, input_data) \ + ble_send_message (ble_cmd_test_debug_idx, input_len, input_data) +/**Set channel quality measurement mode**/ +#define ble_cmd_test_channel_mode(mode) ble_send_message (ble_cmd_test_channel_mode_idx, mode) +/**Reset system**/ +#define ble_cmd_dfu_reset(dfu) ble_send_message (ble_cmd_dfu_reset_idx, dfu) +/**set address for flashing**/ +#define ble_cmd_dfu_flash_set_address(address) \ + ble_send_message (ble_cmd_dfu_flash_set_address_idx, address) +/**Upload binary for flashing. Address will be updated automatically.**/ +#define ble_cmd_dfu_flash_upload(data_len, data_data) \ + ble_send_message (ble_cmd_dfu_flash_upload_idx, data_len, data_data) +/**Uploading is finished.**/ +#define ble_cmd_dfu_flash_upload_finish() ble_send_message (ble_cmd_dfu_flash_upload_finish_idx) + /**Reset device**/ + void ble_rsp_system_reset (const void *nul); + + /**Hello - command for testing**/ + void ble_rsp_system_hello (const void *nul); + + /**Get device bluetooth address**/ + void ble_rsp_system_address_get (const struct ble_msg_system_address_get_rsp_t *msg); + + /**write register**/ + void ble_rsp_system_reg_write (const struct ble_msg_system_reg_write_rsp_t *msg); + + /**read register**/ + void ble_rsp_system_reg_read (const struct ble_msg_system_reg_read_rsp_t *msg); + + /**get and reset packet counters**/ + void ble_rsp_system_get_counters (const struct ble_msg_system_get_counters_rsp_t *msg); + + /**Get status from all connections**/ + void ble_rsp_system_get_connections (const struct ble_msg_system_get_connections_rsp_t *msg); + + /**Read Memory**/ + void ble_rsp_system_read_memory (const struct ble_msg_system_read_memory_rsp_t *msg); + + /**Get Device info**/ + void ble_rsp_system_get_info (const struct ble_msg_system_get_info_rsp_t *msg); + + /**Send data to endpoint, error is returned if endpoint does not have enough space**/ + void ble_rsp_system_endpoint_tx (const struct ble_msg_system_endpoint_tx_rsp_t *msg); + + /**Add entry to whitelist**/ + void ble_rsp_system_whitelist_append (const struct ble_msg_system_whitelist_append_rsp_t *msg); + + /**Remove entry from whitelist**/ + void ble_rsp_system_whitelist_remove (const struct ble_msg_system_whitelist_remove_rsp_t *msg); + + /**Add entry to whitelist**/ + void ble_rsp_system_whitelist_clear (const void *nul); + + /**Read data from endpoint, error is returned if endpoint does not have enough data.**/ + void ble_rsp_system_endpoint_rx (const struct ble_msg_system_endpoint_rx_rsp_t *msg); + + /**Set watermarks on both input and output side**/ + void ble_rsp_system_endpoint_set_watermarks ( + const struct ble_msg_system_endpoint_set_watermarks_rsp_t *msg); + + /**Set encryption key that will be used with aes_encrypt and aes_decrypt commands.**/ + void ble_rsp_system_aes_setkey (const void *nul); + + /**Encrypt one block of data**/ + void ble_rsp_system_aes_encrypt (const struct ble_msg_system_aes_encrypt_rsp_t *msg); + + /**Decrypt one block of data**/ + void ble_rsp_system_aes_decrypt (const struct ble_msg_system_aes_decrypt_rsp_t *msg); + + /**Defragment persistent store**/ + void ble_rsp_flash_ps_defrag (const void *nul); + + /**Dump all ps keys**/ + void ble_rsp_flash_ps_dump (const void *nul); + + /**erase all ps keys**/ + void ble_rsp_flash_ps_erase_all (const void *nul); + + /**save ps key**/ + void ble_rsp_flash_ps_save (const struct ble_msg_flash_ps_save_rsp_t *msg); + + /**load ps key**/ + void ble_rsp_flash_ps_load (const struct ble_msg_flash_ps_load_rsp_t *msg); + + /**erase ps key**/ + void ble_rsp_flash_ps_erase (const void *nul); + + /**erase flash page**/ + void ble_rsp_flash_erase_page (const struct ble_msg_flash_erase_page_rsp_t *msg); + + /**write data to user data area**/ + void ble_rsp_flash_write_data (const struct ble_msg_flash_write_data_rsp_t *msg); + + /**read data from user data area.**/ + void ble_rsp_flash_read_data (const struct ble_msg_flash_read_data_rsp_t *msg); + + /**Write to attribute database**/ + void ble_rsp_attributes_write (const struct ble_msg_attributes_write_rsp_t *msg); + + /**Read from attribute database**/ + void ble_rsp_attributes_read (const struct ble_msg_attributes_read_rsp_t *msg); + + /**Read attribute type from database**/ + void ble_rsp_attributes_read_type (const struct ble_msg_attributes_read_type_rsp_t *msg); + + /**Respond to user attribute read request**/ + void ble_rsp_attributes_user_read_response (const void *nul); + + /**Response to attribute_changed event where reason is user-attribute write.**/ + void ble_rsp_attributes_user_write_response (const void *nul); + + /**Send notification or indication to remote device.**/ + void ble_rsp_attributes_send (const struct ble_msg_attributes_send_rsp_t *msg); + + /**Disconnect connection, starts a disconnection procedure on connection**/ + void ble_rsp_connection_disconnect (const struct ble_msg_connection_disconnect_rsp_t *msg); + + /**Get Link RSSI**/ + void ble_rsp_connection_get_rssi (const struct ble_msg_connection_get_rssi_rsp_t *msg); + + /**Update connection parameters**/ + void ble_rsp_connection_update (const struct ble_msg_connection_update_rsp_t *msg); + + /**Request version exchange**/ + void ble_rsp_connection_version_update ( + const struct ble_msg_connection_version_update_rsp_t *msg); + + /**Get Current channel map**/ + void ble_rsp_connection_channel_map_get ( + const struct ble_msg_connection_channel_map_get_rsp_t *msg); + + /**Set Channel map**/ + void ble_rsp_connection_channel_map_set ( + const struct ble_msg_connection_channel_map_set_rsp_t *msg); + + /**Remote feature request**/ + void ble_rsp_connection_features_get (const struct ble_msg_connection_features_get_rsp_t *msg); + + /**Get Connection Status Parameters**/ + void ble_rsp_connection_get_status (const struct ble_msg_connection_get_status_rsp_t *msg); + + /**Raw TX**/ + void ble_rsp_connection_raw_tx (const struct ble_msg_connection_raw_tx_rsp_t *msg); + + /**Discover attributes by type and value**/ + void ble_rsp_attclient_find_by_type_value ( + const struct ble_msg_attclient_find_by_type_value_rsp_t *msg); + + /**Discover attributes by type and value**/ + void ble_rsp_attclient_read_by_group_type ( + const struct ble_msg_attclient_read_by_group_type_rsp_t *msg); + + /**Read all attributes where type matches**/ + void ble_rsp_attclient_read_by_type (const struct ble_msg_attclient_read_by_type_rsp_t *msg); + + /**Discover Attribute handle and type mappings**/ + void ble_rsp_attclient_find_information ( + const struct ble_msg_attclient_find_information_rsp_t *msg); + + /**Read Characteristic value using handle**/ + void ble_rsp_attclient_read_by_handle ( + const struct ble_msg_attclient_read_by_handle_rsp_t *msg); + + /**write data to attribute**/ + void ble_rsp_attclient_attribute_write ( + const struct ble_msg_attclient_attribute_write_rsp_t *msg); + + /**write data to attribute using ATT write command**/ + void ble_rsp_attclient_write_command (const struct ble_msg_attclient_write_command_rsp_t *msg); + + /**Send confirmation for received indication, use only if manual indications are enabled**/ + void ble_rsp_attclient_indicate_confirm ( + const struct ble_msg_attclient_indicate_confirm_rsp_t *msg); + + /**Read Long Characteristic value**/ + void ble_rsp_attclient_read_long (const struct ble_msg_attclient_read_long_rsp_t *msg); + + /**Send prepare write request to remote host**/ + void ble_rsp_attclient_prepare_write (const struct ble_msg_attclient_prepare_write_rsp_t *msg); + + /**Send prepare write request to remote host**/ + void ble_rsp_attclient_execute_write (const struct ble_msg_attclient_execute_write_rsp_t *msg); + + /**Read multiple attributes from server**/ + void ble_rsp_attclient_read_multiple (const struct ble_msg_attclient_read_multiple_rsp_t *msg); + + /**Enable encryption on link**/ + void ble_rsp_sm_encrypt_start (const struct ble_msg_sm_encrypt_start_rsp_t *msg); + + /**Set device to bondable mode**/ + void ble_rsp_sm_set_bondable_mode (const void *nul); + + /**delete bonding information from ps store**/ + void ble_rsp_sm_delete_bonding (const struct ble_msg_sm_delete_bonding_rsp_t *msg); + + /**set pairing requirements**/ + void ble_rsp_sm_set_parameters (const void *nul); + + /**Passkey entered**/ + void ble_rsp_sm_passkey_entry (const struct ble_msg_sm_passkey_entry_rsp_t *msg); + + /**List all bonded devices**/ + void ble_rsp_sm_get_bonds (const struct ble_msg_sm_get_bonds_rsp_t *msg); + + /** + Set out-of-band encryption data for device + Device does not allow any other kind of pairing except oob if oob data is set. + **/ + void ble_rsp_sm_set_oob_data (const void *nul); + + /** + Add all bonded devices with a known public or static address to + the whitelist. Previous entries in the whitelist are first + cleared. This command can't be used while advertising, scanning + or being connected. + **/ + void ble_rsp_sm_whitelist_bonds (const struct ble_msg_sm_whitelist_bonds_rsp_t *msg); + + /**Set GAP central/peripheral privacy flags + **/ + void ble_rsp_gap_set_privacy_flags (const void *nul); + + /**Set discoverable and connectable mode**/ + void ble_rsp_gap_set_mode (const struct ble_msg_gap_set_mode_rsp_t *msg); + + /**start or stop discover procedure**/ + void ble_rsp_gap_discover (const struct ble_msg_gap_discover_rsp_t *msg); + + /**Direct connection**/ + void ble_rsp_gap_connect_direct (const struct ble_msg_gap_connect_direct_rsp_t *msg); + + /**End current GAP procedure**/ + void ble_rsp_gap_end_procedure (const struct ble_msg_gap_end_procedure_rsp_t *msg); + + /**Connect to any device on whitelist**/ + void ble_rsp_gap_connect_selective (const struct ble_msg_gap_connect_selective_rsp_t *msg); + + /**Set scan and advertising filtering parameters**/ + void ble_rsp_gap_set_filtering (const struct ble_msg_gap_set_filtering_rsp_t *msg); + + /**Set scan parameters**/ + void ble_rsp_gap_set_scan_parameters (const struct ble_msg_gap_set_scan_parameters_rsp_t *msg); + + /**Set advertising parameters**/ + void ble_rsp_gap_set_adv_parameters (const struct ble_msg_gap_set_adv_parameters_rsp_t *msg); + + /**Set advertisement or scan response data. Use broadcast mode to advertise data**/ + void ble_rsp_gap_set_adv_data (const struct ble_msg_gap_set_adv_data_rsp_t *msg); + + /**Sets device to Directed Connectable Mode + Uses fast advertisement procedure for 1.28s after which device enters + nonconnectable mode. If device has valid reconnection characteristic value, it is used for + connection otherwise passed address and address type are used + **/ + void ble_rsp_gap_set_directed_connectable_mode ( + const struct ble_msg_gap_set_directed_connectable_mode_rsp_t *msg); + + /**Configure I/O-port interrupts**/ + void ble_rsp_hardware_io_port_config_irq ( + const struct ble_msg_hardware_io_port_config_irq_rsp_t *msg); + + /**Set soft timer to send events**/ + void ble_rsp_hardware_set_soft_timer (const struct ble_msg_hardware_set_soft_timer_rsp_t *msg); + + /**Read A/D conversion**/ + void ble_rsp_hardware_adc_read (const struct ble_msg_hardware_adc_read_rsp_t *msg); + + /**Configure I/O-port direction**/ + void ble_rsp_hardware_io_port_config_direction ( + const struct ble_msg_hardware_io_port_config_direction_rsp_t *msg); + + /**Configure I/O-port function**/ + void ble_rsp_hardware_io_port_config_function ( + const struct ble_msg_hardware_io_port_config_function_rsp_t *msg); + + /**Configure I/O-port pull-up/pull-down**/ + void ble_rsp_hardware_io_port_config_pull ( + const struct ble_msg_hardware_io_port_config_pull_rsp_t *msg); + + /**Write I/O-port**/ + void ble_rsp_hardware_io_port_write (const struct ble_msg_hardware_io_port_write_rsp_t *msg); + + /**Read I/O-port**/ + void ble_rsp_hardware_io_port_read (const struct ble_msg_hardware_io_port_read_rsp_t *msg); + + /**Configure SPI**/ + void ble_rsp_hardware_spi_config (const struct ble_msg_hardware_spi_config_rsp_t *msg); + + /**Transfer SPI data**/ + void ble_rsp_hardware_spi_transfer (const struct ble_msg_hardware_spi_transfer_rsp_t *msg); + + /**Read data from I2C bus using bit-bang in cc2540. I2C clk is in P1.7 data in P1.6. Pull-up + * must be enabled on pins**/ + void ble_rsp_hardware_i2c_read (const struct ble_msg_hardware_i2c_read_rsp_t *msg); + + /**Write data to I2C bus using bit-bang in cc2540. I2C clk is in P1.7 data in P1.6. Pull-up must + * be enabled on pins**/ + void ble_rsp_hardware_i2c_write (const struct ble_msg_hardware_i2c_write_rsp_t *msg); + + /**Set TX Power**/ + void ble_rsp_hardware_set_txpower (const void *nul); + + /**Set comparator for timer channel**/ + void ble_rsp_hardware_timer_comparator ( + const struct ble_msg_hardware_timer_comparator_rsp_t *msg); + + /**Enable I/O-port interrupts**/ + void ble_rsp_hardware_io_port_irq_enable ( + const struct ble_msg_hardware_io_port_irq_enable_rsp_t *msg); + + /**Set I/O-port interrupt direction**/ + void ble_rsp_hardware_io_port_irq_direction ( + const struct ble_msg_hardware_io_port_irq_direction_rsp_t *msg); + + /**Enable or disable analog comparator**/ + void ble_rsp_hardware_analog_comparator_enable (const void *nul); + + /**Read analog comparator output**/ + void ble_rsp_hardware_analog_comparator_read ( + const struct ble_msg_hardware_analog_comparator_read_rsp_t *msg); + + /**Configure analog comparator interrupt**/ + void ble_rsp_hardware_analog_comparator_config_irq ( + const struct ble_msg_hardware_analog_comparator_config_irq_rsp_t *msg); + + /**Set RX Sensitivity**/ + void ble_rsp_hardware_set_rxgain (const void *nul); + + /**Enable or disable USB**/ + void ble_rsp_hardware_usb_enable (const struct ble_msg_hardware_usb_enable_rsp_t *msg); + + /**Start packet transmission, send one packet at every 625us**/ + void ble_rsp_test_phy_tx (const void *nul); + + /**Start receive test**/ + void ble_rsp_test_phy_rx (const void *nul); + + /**End test, and report received packets**/ + void ble_rsp_test_phy_end (const struct ble_msg_test_phy_end_rsp_t *msg); + + /**Reset test**/ + void ble_rsp_test_phy_reset (const void *nul); + + /**Get current channel quality map**/ + void ble_rsp_test_get_channel_map (const struct ble_msg_test_get_channel_map_rsp_t *msg); + + /**Debug command**/ + void ble_rsp_test_debug (const struct ble_msg_test_debug_rsp_t *msg); + + /**Set channel quality measurement mode**/ + void ble_rsp_test_channel_mode (const void *nul); + + /**Reset system**/ + void ble_rsp_dfu_reset (const void *nul); + + /**set address for flashing**/ + void ble_rsp_dfu_flash_set_address (const struct ble_msg_dfu_flash_set_address_rsp_t *msg); + + /**Upload binary for flashing. Address will be updated automatically.**/ + void ble_rsp_dfu_flash_upload (const struct ble_msg_dfu_flash_upload_rsp_t *msg); + + /**Uploading is finished.**/ + void ble_rsp_dfu_flash_upload_finish (const struct ble_msg_dfu_flash_upload_finish_rsp_t *msg); + + /**Device booted up, and is ready to receive commands**/ + void ble_evt_system_boot (const struct ble_msg_system_boot_evt_t *msg); + + /**Debug data output**/ + void ble_evt_system_debug (const struct ble_msg_system_debug_evt_t *msg); + + /**Endpoint receive size crossed watermark**/ + void ble_evt_system_endpoint_watermark_rx ( + const struct ble_msg_system_endpoint_watermark_rx_evt_t *msg); + + /**Endpoint transmit size crossed watermark**/ + void ble_evt_system_endpoint_watermark_tx ( + const struct ble_msg_system_endpoint_watermark_tx_evt_t *msg); + + /**Script failure detected**/ + void ble_evt_system_script_failure (const struct ble_msg_system_script_failure_evt_t *msg); + + /**No valid license key found**/ + void ble_evt_system_no_license_key (const void *nul); + + /**Protocol error in command parser**/ + void ble_evt_system_protocol_error (const struct ble_msg_system_protocol_error_evt_t *msg); + + /**Dump key result**/ + void ble_evt_flash_ps_key (const struct ble_msg_flash_ps_key_evt_t *msg); + + /**Attribute value has changed**/ + void ble_evt_attributes_value (const struct ble_msg_attributes_value_evt_t *msg); + + /**User-backed attribute data requested**/ + void ble_evt_attributes_user_read_request ( + const struct ble_msg_attributes_user_read_request_evt_t *msg); + + /**attribute status flags has changed**/ + void ble_evt_attributes_status (const struct ble_msg_attributes_status_evt_t *msg); + + /**Connection opened**/ + void ble_evt_connection_status (const struct ble_msg_connection_status_evt_t *msg); + + /**Remote version information**/ + void ble_evt_connection_version_ind (const struct ble_msg_connection_version_ind_evt_t *msg); + + /**Remote feature information**/ + void ble_evt_connection_feature_ind (const struct ble_msg_connection_feature_ind_evt_t *msg); + + /**Raw RX**/ + void ble_evt_connection_raw_rx (const struct ble_msg_connection_raw_rx_evt_t *msg); + + /**Link Disconnected**/ + void ble_evt_connection_disconnected (const struct ble_msg_connection_disconnected_evt_t *msg); + + /**Attribute indication has been acknowledged**/ + void ble_evt_attclient_indicated (const struct ble_msg_attclient_indicated_evt_t *msg); + + /**GATT procedure completed**/ + void ble_evt_attclient_procedure_completed ( + const struct ble_msg_attclient_procedure_completed_evt_t *msg); + + /**group discovery return**/ + void ble_evt_attclient_group_found (const struct ble_msg_attclient_group_found_evt_t *msg); + + /**characteristics found**/ + void ble_evt_attclient_attribute_found ( + const struct ble_msg_attclient_attribute_found_evt_t *msg); + + /**Handle type mapping found**/ + void ble_evt_attclient_find_information_found ( + const struct ble_msg_attclient_find_information_found_evt_t *msg); + + /**attribute value returned**/ + void ble_evt_attclient_attribute_value ( + const struct ble_msg_attclient_attribute_value_evt_t *msg); + + /**Response to read multiple request**/ + void ble_evt_attclient_read_multiple_response ( + const struct ble_msg_attclient_read_multiple_response_evt_t *msg); + + /**SMP data output**/ + void ble_evt_sm_smp_data (const struct ble_msg_sm_smp_data_evt_t *msg); + + /**Link bonding has failed**/ + void ble_evt_sm_bonding_fail (const struct ble_msg_sm_bonding_fail_evt_t *msg); + + /**Passkey to be entered to remote device**/ + void ble_evt_sm_passkey_display (const struct ble_msg_sm_passkey_display_evt_t *msg); + + /**Passkey Requested**/ + void ble_evt_sm_passkey_request (const struct ble_msg_sm_passkey_request_evt_t *msg); + + /**Bond status information**/ + void ble_evt_sm_bond_status (const struct ble_msg_sm_bond_status_evt_t *msg); + + /**Scan Response**/ + void ble_evt_gap_scan_response (const struct ble_msg_gap_scan_response_evt_t *msg); + + /**Not used**/ + void ble_evt_gap_mode_changed (const struct ble_msg_gap_mode_changed_evt_t *msg); + + /**I/O-port state**/ + void ble_evt_hardware_io_port_status (const struct ble_msg_hardware_io_port_status_evt_t *msg); + + /**soft timer event**/ + void ble_evt_hardware_soft_timer (const struct ble_msg_hardware_soft_timer_evt_t *msg); + + /**adc result**/ + void ble_evt_hardware_adc_result (const struct ble_msg_hardware_adc_result_evt_t *msg); + + /**This event is produced when analog comparator output changes**/ + void ble_evt_hardware_analog_comparator_status ( + const struct ble_msg_hardware_analog_comparator_status_evt_t *msg); + + /**Device booted up in dfu, and is ready to receive commands**/ + void ble_evt_dfu_boot (const struct ble_msg_dfu_boot_evt_t *msg); + + + struct ble_class_handler_t + { + const struct ble_msg *const *msgs; + uint8 maxhandlers; + }; + extern const struct ble_class_handler_t ble_class_rsp_handlers[ble_cls_last]; + extern const struct ble_class_handler_t ble_class_evt_handlers[ble_cls_last]; + + void ble_default (const void *); +#ifdef __cplusplus +} +#endif +/*lint -restore*/ +// clang-format on +#endif diff --git a/deps/include/brainflow/board_controller/openbci/ganglion_bglib/ganglion_functions.h b/deps/include/brainflow/board_controller/openbci/ganglion_bglib/ganglion_functions.h new file mode 100644 index 000000000..1841dc6ae --- /dev/null +++ b/deps/include/brainflow/board_controller/openbci/ganglion_bglib/ganglion_functions.h @@ -0,0 +1,22 @@ +#include "shared_export.h" + +namespace GanglionLib +{ +#ifdef __cplusplus + extern "C" + { +#endif + // void * is a legacy from dynamic library which was loaded via LoadLibrary\dlopen + SHARED_EXPORT int CALLING_CONVENTION initialize (void *param); + SHARED_EXPORT int CALLING_CONVENTION open_ganglion (void *param); + SHARED_EXPORT int CALLING_CONVENTION open_ganglion_mac_addr (void *param); + SHARED_EXPORT int CALLING_CONVENTION stop_stream (void *param); + SHARED_EXPORT int CALLING_CONVENTION start_stream (void *param); + SHARED_EXPORT int CALLING_CONVENTION close_ganglion (void *param); + SHARED_EXPORT int CALLING_CONVENTION get_data (void *param); + SHARED_EXPORT int CALLING_CONVENTION config_board (void *param); + SHARED_EXPORT int CALLING_CONVENTION release (void *param); +#ifdef __cplusplus + } +#endif +} // namespace GanglionLib diff --git a/deps/include/brainflow/board_controller/openbci/ganglion_bglib/ganglion_types.h b/deps/include/brainflow/board_controller/openbci/ganglion_bglib/ganglion_types.h new file mode 100644 index 000000000..c99cdc654 --- /dev/null +++ b/deps/include/brainflow/board_controller/openbci/ganglion_bglib/ganglion_types.h @@ -0,0 +1,89 @@ +#pragma once + +#include "shared_export.h" +#include + +namespace GanglionLib +{ +#pragma pack(push, 1) + struct GanglionData + { + unsigned char data[20]; + double timestamp; + + GanglionData (unsigned char *data, double timestamp) + { + memcpy (this->data, data, sizeof (unsigned char) * 20); + this->timestamp = timestamp; + } + + GanglionData () + { + timestamp = 0.0; + } + + GanglionData (const GanglionData &other) + { + timestamp = other.timestamp; + memcpy (data, other.data, sizeof (unsigned char) * 20); + } + + GanglionData &operator= (const GanglionData &other) + { + timestamp = other.timestamp; + memcpy (data, other.data, sizeof (unsigned char) * 20); + return *this; + } + }; + + // just to pass two args to initialize + struct GanglionInputData + { + int timeout; + char uart_port[1024]; + + GanglionInputData (int timeout, const char *uart_port) + { + this->timeout = timeout; + strcpy (this->uart_port, uart_port); + } + + GanglionInputData (const GanglionInputData &other) + { + timeout = other.timeout; + strcpy (uart_port, other.uart_port); + } + + GanglionInputData &operator= (const GanglionInputData &other) + { + timeout = other.timeout; + strcpy (uart_port, other.uart_port); + return *this; + } + }; + +#pragma pack(pop) + + enum CustomExitCodes + { + STATUS_OK = 0, + GANGLION_NOT_FOUND_ERROR = 1, + GANGLION_IS_NOT_OPEN_ERROR = 2, + GANGLION_ALREADY_PAIR_ERROR = 3, + GANGLION_ALREADY_OPEN_ERROR = 4, + SERVICE_NOT_FOUND_ERROR = 5, + SEND_CHARACTERISTIC_NOT_FOUND_ERROR = 6, + RECEIVE_CHARACTERISTIC_NOT_FOUND_ERROR = 7, + DISCONNECT_CHARACTERISTIC_NOT_FOUND_ERROR = 8, + TIMEOUT_ERROR = 9, + STOP_ERROR = 10, + FAILED_TO_SET_CALLBACK_ERROR = 11, + FAILED_TO_UNSUBSCRIBE_ERROR = 12, + GENERAL_ERROR = 13, + NO_DATA_ERROR = 14, + SYNC_ERROR = 15, + NOT_IMPLEMENTED_ERROR = 16, + INVALID_MAC_ADDR_ERROR = 17, + PORT_OPEN_ERROR = 18 + }; +} \ No newline at end of file diff --git a/deps/include/brainflow/board_controller/openbci/ganglion_bglib/helpers.h b/deps/include/brainflow/board_controller/openbci/ganglion_bglib/helpers.h new file mode 100644 index 000000000..d2f5b7b45 --- /dev/null +++ b/deps/include/brainflow/board_controller/openbci/ganglion_bglib/helpers.h @@ -0,0 +1,30 @@ +#pragma once + +#include +#include + +#include "cmd_def.h" +#include "uart.h" + +#define UART_TIMEOUT 1000 + +namespace GanglionLib +{ + enum State + { + NONE = 0, + INIT_CALLED = 1, + INITIAL_CONNECTION = 2, + OPEN_CALLED = 3, + CONFIG_CALLED = 4, + CLOSE_CALLED = 5, + GET_DATA_CALLED = 6, + WRITE_TO_CLIENT_CHAR = 7 + }; + + void output (uint8 len1, uint8 *data1, uint16 len2, uint8 *data2); + int read_message (int timeout_ms); + int open_ble_dev (); + int wait_for_callback (int num_seconds); + int reset_ble_dev (); +} \ No newline at end of file diff --git a/deps/include/brainflow/board_controller/openbci/ganglion_bglib/uart.h b/deps/include/brainflow/board_controller/openbci/ganglion_bglib/uart.h new file mode 100644 index 000000000..f2efcd150 --- /dev/null +++ b/deps/include/brainflow/board_controller/openbci/ganglion_bglib/uart.h @@ -0,0 +1,10 @@ +#ifndef UART_H +#define UART_H + +void uart_list_devices (); +int uart_find_serialport (char *name); +int uart_open (const char *port); +void uart_close (); +int uart_tx (int len, unsigned char *data); +int uart_rx (int len, unsigned char *data, int timeout_ms); +#endif // UART_H diff --git a/deps/include/brainflow/board_controller/openbci/ganglion_native.h b/deps/include/brainflow/board_controller/openbci/ganglion_native.h new file mode 100644 index 000000000..9f47476c9 --- /dev/null +++ b/deps/include/brainflow/board_controller/openbci/ganglion_native.h @@ -0,0 +1,116 @@ +#include +#include +#include + +#include "ble_lib_board.h" +#include "board.h" +#include "board_controller.h" + +struct GanglionTempData +{ + float last_data[8]; + + double accel_x; + double accel_y; + double accel_z; + + double resist_ref; + double resist_first; + double resist_second; + double resist_third; + double resist_fourth; + + GanglionTempData () + { + memset (last_data, 0, sizeof (float) * 8); + accel_x = 0.0; + accel_y = 0.0; + accel_z = 0.0; + resist_ref = 0.0; + resist_first = 0.0; + resist_second = 0.0; + resist_third = 0.0; + resist_fourth = 0.0; + } + + GanglionTempData (const GanglionTempData &other) + { + memcpy (last_data, other.last_data, sizeof (float) * 8); + accel_x = other.accel_x; + accel_y = other.accel_y; + accel_z = other.accel_z; + resist_ref = other.resist_ref; + resist_first = other.resist_first; + resist_second = other.resist_second; + resist_third = other.resist_third; + resist_fourth = other.resist_fourth; + } + + GanglionTempData &operator= (const GanglionTempData &other) + { + if (this == &other) + return *this; + + memcpy (last_data, other.last_data, sizeof (float) * 8); + accel_x = other.accel_x; + accel_y = other.accel_y; + accel_z = other.accel_z; + resist_ref = other.resist_ref; + resist_first = other.resist_first; + resist_second = other.resist_second; + resist_third = other.resist_third; + resist_fourth = other.resist_fourth; + + return *this; + } + + void reset () + { + memset (last_data, 0, sizeof (float) * 8); + accel_x = 0.0; + accel_y = 0.0; + accel_z = 0.0; + resist_ref = 0.0; + resist_first = 0.0; + resist_second = 0.0; + resist_third = 0.0; + resist_fourth = 0.0; + } +}; + +class GanglionNative : public BLELibBoard +{ +public: + GanglionNative (struct BrainFlowInputParams params); + ~GanglionNative (); + + int prepare_session (); + int start_stream (int buffer_size, const char *streamer_params); + int stop_stream (); + int release_session (); + int config_board (std::string config, std::string &response); + int config_board (std::string config); + int send_command (std::string config); + + void adapter_1_on_scan_start (simpleble_adapter_t adapter); + void adapter_1_on_scan_stop (simpleble_adapter_t adapter); + void adapter_1_on_scan_found (simpleble_adapter_t adapter, simpleble_peripheral_t peripheral); + void read_data ( + simpleble_uuid_t service, simpleble_uuid_t characteristic, uint8_t *data, size_t size); + +protected: + volatile simpleble_adapter_t ganglion_adapter; + volatile simpleble_peripheral_t ganglion_peripheral; + bool initialized; + bool is_streaming; + std::mutex m; + std::condition_variable cv; + std::pair notified_characteristics; + std::pair write_characteristics; + std::string start_command; + std::string stop_command; + struct GanglionTempData temp_data; + + double const accel_scale = 0.016f; + double const eeg_scale = (1.2f * 1000000) / (8388607.0f * 1.5f * 51.0f); +}; diff --git a/deps/include/brainflow/board_controller/openbci/ganglion_wifi.h b/deps/include/brainflow/board_controller/openbci/ganglion_wifi.h index 53c7ee137..c1dcede0c 100644 --- a/deps/include/brainflow/board_controller/openbci/ganglion_wifi.h +++ b/deps/include/brainflow/board_controller/openbci/ganglion_wifi.h @@ -27,7 +27,7 @@ class GanglionWifi : public OpenBCIWifiShieldBoard } // hacks for ganglion and impedance - int start_stream (int buffer_size, char *streamer_params); + int start_stream (int buffer_size, const char *streamer_params); int stop_stream (); int config_board (std::string config, std::string &response); }; diff --git a/deps/include/brainflow/board_controller/openbci/openbci_gain_tracker.h b/deps/include/brainflow/board_controller/openbci/openbci_gain_tracker.h new file mode 100644 index 000000000..c0951f422 --- /dev/null +++ b/deps/include/brainflow/board_controller/openbci/openbci_gain_tracker.h @@ -0,0 +1,217 @@ +#pragma once + +#include +#include +#include +#include + + +enum class OpenBCICommandTypes : int +{ + NOT_CHANNEL_COMMAND = 0, + VALID_COMMAND = 1, + INVALID_COMMAND = 2 +}; + + +class OpenBCIGainTracker +{ +protected: + size_t single_command_size = 9; + std::vector channel_letters; + std::vector current_gains; + std::vector old_gains; + std::vector available_gain_values; + + int apply_single_command (std::string command) + { + // start stop validation + if ((command.size () < single_command_size) || (command.at (0) != 'x') || + (command.at (single_command_size - 1) != 'X')) + { + return (int)OpenBCICommandTypes::NOT_CHANNEL_COMMAND; + } + // bias srb1 srb2 validation + if ((command.at (5) != '0') && (command.at (5) != '1') || + (command.at (6) != '0') && (command.at (6) != '1') || + (command.at (7) != '0') && (command.at (7) != '1')) + { + return (int)OpenBCICommandTypes::INVALID_COMMAND; + } + // input type check + if ((command.at (4) < '0') || (command.at (4) > '7')) + { + return (int)OpenBCICommandTypes::INVALID_COMMAND; + } + // gain check + if ((command.at (3) < '0') || (command.at (3) > '6')) + { + return (int)OpenBCICommandTypes::INVALID_COMMAND; + } + // power check + if ((command.at (2) != '0') && (command.at (2) != '1')) + { + return (int)OpenBCICommandTypes::INVALID_COMMAND; + } + // channel check + auto channel_it = + std::find (channel_letters.begin (), channel_letters.end (), command.at (1)); + if (channel_it == channel_letters.end ()) + { + return (int)OpenBCICommandTypes::INVALID_COMMAND; + } + size_t index = std::distance (channel_letters.begin (), channel_it); + if (index >= current_gains.size ()) + { + return (int)OpenBCICommandTypes::INVALID_COMMAND; + } + old_gains[index] = current_gains[index]; + current_gains[index] = available_gain_values[command.at (3) - '0']; + return (int)OpenBCICommandTypes::VALID_COMMAND; + } + +public: + OpenBCIGainTracker (std::vector default_gains) + : current_gains (default_gains), old_gains (default_gains) + { + channel_letters = std::vector { + '1', '2', '3', '4', '5', '6', '7', '8', 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I'}; + available_gain_values = std::vector {1, 2, 4, 6, 8, 12, 24}; + } + + virtual ~OpenBCIGainTracker () + { + } + + virtual int apply_config (std::string config) + { + // x (CHANNEL, POWER_DOWN, GAIN_SET, INPUT_TYPE_SET, BIAS_SET, SRB2_SET, SRB1_SET) X + // https://docs.openbci.com/Cyton/CytonSDK/ + + int res = (int)OpenBCICommandTypes::NOT_CHANNEL_COMMAND; + + for (size_t i = 0; i < config.size ();) + { + if (config.at (i) == 'x') + { + if ((config.size () >= i + single_command_size) && + (config.at (i + single_command_size - 1) == 'X')) + { + res = apply_single_command (config.substr (i, single_command_size)); + i += single_command_size; + } + else + { + i++; + } + } + else + { + i++; + } + } + return res; + } + + virtual int get_gain_for_channel (int channel) + { + if (channel > (int)current_gains.size ()) + { + return 1; // should never happen + } + return current_gains[channel]; + } + + virtual void revert_config () + { + std::copy (old_gains.begin (), old_gains.end (), current_gains.begin ()); + } +}; + +class CytonGainTracker : public OpenBCIGainTracker +{ +public: + CytonGainTracker () : OpenBCIGainTracker ({24, 24, 24, 24, 24, 24, 24, 24}) + { + } + + virtual int apply_config (std::string config) + { + if (config.size () == 1) + { + // restore default settings + if (config.at (0) == 'd') + { + std::copy (current_gains.begin (), current_gains.end (), old_gains.begin ()); + std::fill (current_gains.begin (), current_gains.end (), 24); + } + } + + return OpenBCIGainTracker::apply_config (config); + } +}; + +class CytonDaisyGainTracker : public OpenBCIGainTracker +{ +public: + CytonDaisyGainTracker () + : OpenBCIGainTracker ({24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24}) + { + } + + virtual int apply_config (std::string config) + { + if (config.size () == 1) + { + // restore default settings + if (config.at (0) == 'd') + { + std::copy (current_gains.begin (), current_gains.end (), old_gains.begin ()); + std::fill (current_gains.begin (), current_gains.end (), 24); + } + } + + return OpenBCIGainTracker::apply_config (config); + } +}; + +class GaleaGainTracker : public OpenBCIGainTracker +{ +public: + GaleaGainTracker () : OpenBCIGainTracker ({4, 4, 4, 4, 4, 4, 12, 12, 2, 2, 2, 2, 2, 2, 2, 2}) + { + } + + virtual int apply_config (std::string config) + { + if (config.size () == 1) + { + if ((config.at (0) == 'f') || (config.at (0) == 'g')) + { + std::copy (current_gains.begin (), current_gains.end (), old_gains.begin ()); + std::fill (current_gains.begin (), current_gains.end (), 1); + } + if ((config.at (0) == 'o') || (config.at (0) == 'd')) + { + std::copy (current_gains.begin (), current_gains.end (), old_gains.begin ()); + for (size_t i = 0; i < current_gains.size (); i++) + { + if (i < 6) + { + current_gains[i] = 4; + } + else if ((i == 6) || (i == 7)) + { + current_gains[i] = 12; + } + else + { + current_gains[i] = 2; + } + } + } + } + + return OpenBCIGainTracker::apply_config (config); + } +}; diff --git a/deps/include/brainflow/board_controller/openbci/openbci_serial_board.h b/deps/include/brainflow/board_controller/openbci/openbci_serial_board.h index 7de5a42db..555c3618d 100644 --- a/deps/include/brainflow/board_controller/openbci/openbci_serial_board.h +++ b/deps/include/brainflow/board_controller/openbci/openbci_serial_board.h @@ -31,7 +31,7 @@ class OpenBCISerialBoard : public Board virtual ~OpenBCISerialBoard (); virtual int prepare_session (); - virtual int start_stream (int buffer_size, char *streamer_params); + virtual int start_stream (int buffer_size, const char *streamer_params); virtual int stop_stream (); virtual int release_session (); virtual int config_board (std::string config, std::string &response); diff --git a/deps/include/brainflow/board_controller/openbci/openbci_wifi_shield_board.h b/deps/include/brainflow/board_controller/openbci/openbci_wifi_shield_board.h index ecc3510ca..da8997458 100644 --- a/deps/include/brainflow/board_controller/openbci/openbci_wifi_shield_board.h +++ b/deps/include/brainflow/board_controller/openbci/openbci_wifi_shield_board.h @@ -33,7 +33,7 @@ class OpenBCIWifiShieldBoard : public Board virtual ~OpenBCIWifiShieldBoard (); virtual int prepare_session (); - virtual int start_stream (int buffer_size, char *streamer_params); + virtual int start_stream (int buffer_size, const char *streamer_params); virtual int stop_stream (); virtual int release_session (); virtual int config_board (std::string config, std::string &response); diff --git a/deps/include/brainflow/board_controller/oymotion/gforce_dual.h b/deps/include/brainflow/board_controller/oymotion/gforce_dual.h new file mode 100644 index 000000000..71daab310 --- /dev/null +++ b/deps/include/brainflow/board_controller/oymotion/gforce_dual.h @@ -0,0 +1,42 @@ +#pragma once + +#ifdef _WIN32 +#include "dyn_lib_board.h" + + +class GforceDual : public DynLibBoard +{ + +private: + static int num_objects; + bool is_valid; + +public: + GforceDual (struct BrainFlowInputParams params); + ~GforceDual (); + + int prepare_session (); + +protected: + std::string get_lib_name (); +}; + +#else + +#include "board.h" + + +class GforceDual : public Board +{ +public: + GforceDual (struct BrainFlowInputParams params); + ~GforceDual (); + + int prepare_session (); + int start_stream (int buffer_size, const char *streamer_params); + int stop_stream (); + int release_session (); + int config_board (std::string config, std::string &response); +}; + +#endif \ No newline at end of file diff --git a/deps/include/brainflow/board_controller/oymotion/gforce_pro.h b/deps/include/brainflow/board_controller/oymotion/gforce_pro.h index 5ab2be502..e4e07d8a7 100644 --- a/deps/include/brainflow/board_controller/oymotion/gforce_pro.h +++ b/deps/include/brainflow/board_controller/oymotion/gforce_pro.h @@ -1,49 +1,42 @@ #pragma once -#include -#include -#include -#include - -#include "board.h" -#include "data_buffer.h" -#include "runtime_dll_loader.h" +#ifdef _WIN32 +#include "dyn_lib_board.h" -class GforcePro : public Board +class GforcePro : public DynLibBoard { -#ifdef _WIN32 private: static int num_objects; bool is_valid; - volatile bool keep_alive; - bool initialized; - bool is_streaming; - std::thread streaming_thread; +public: + GforcePro (struct BrainFlowInputParams params); + ~GforcePro (); - int call_init (); - int call_start (); - int call_stop (); - int call_release (); + int prepare_session (); + +protected: + std::string get_lib_name (); +}; - std::mutex m; - std::condition_variable cv; - volatile int state; +#else - void read_thread (); +#include "board.h" - DLLLoader *dll_loader; -#endif +class GforcePro : public Board +{ public: GforcePro (struct BrainFlowInputParams params); ~GforcePro (); int prepare_session (); - int start_stream (int buffer_size, char *streamer_params); + int start_stream (int buffer_size, const char *streamer_params); int stop_stream (); int release_session (); int config_board (std::string config, std::string &response); }; + +#endif \ No newline at end of file diff --git a/deps/include/brainflow/board_controller/playback_file_board.h b/deps/include/brainflow/board_controller/playback_file_board.h index b6520ecf2..cb59ba2d6 100644 --- a/deps/include/brainflow/board_controller/playback_file_board.h +++ b/deps/include/brainflow/board_controller/playback_file_board.h @@ -3,6 +3,7 @@ #include #include #include +#include #include "board.h" #include "board_controller.h" @@ -15,21 +16,20 @@ class PlaybackFileBoard : public Board volatile bool keep_alive; volatile bool loopback; volatile bool use_new_timestamps; - std::thread streaming_thread; - bool is_streaming; + std::vector pos_percentage; + std::vector streaming_threads; bool initialized; - std::mutex m; - std::condition_variable cv; - volatile int state; + std::vector> file_offsets; - void read_thread (); + void read_thread (int preset, std::string filename); + int get_file_offsets (std::string filename, std::vector &offsets); public: PlaybackFileBoard (struct BrainFlowInputParams params); ~PlaybackFileBoard (); int prepare_session (); - int start_stream (int buffer_size, char *streamer_params); + int start_stream (int buffer_size, const char *streamer_params); int stop_stream (); int release_session (); int config_board (std::string config, std::string &response); diff --git a/deps/include/brainflow/board_controller/streamer.h b/deps/include/brainflow/board_controller/streamer.h index 3fce48506..a007ee752 100644 --- a/deps/include/brainflow/board_controller/streamer.h +++ b/deps/include/brainflow/board_controller/streamer.h @@ -1,13 +1,18 @@ #pragma once +#include class Streamer { public: - Streamer (int len) + Streamer (int len, std::string type, std::string dest, std::string mods) { this->len = len; + streamer_type = type; + streamer_dest = dest; + streamer_mods = mods; } + virtual ~Streamer () { } @@ -15,6 +20,14 @@ class Streamer virtual int init_streamer () = 0; virtual void stream_data (double *data) = 0; + virtual bool check_equals (std::string type, std::string dest, std::string mods) + { + return ((streamer_type == type) && (streamer_dest == dest) && (streamer_mods == mods)); + } + protected: + std::string streamer_type; + std::string streamer_dest; + std::string streamer_mods; int len; }; diff --git a/deps/include/brainflow/board_controller/streaming_board.h b/deps/include/brainflow/board_controller/streaming_board.h index b8aad13ef..7c0696cb5 100644 --- a/deps/include/brainflow/board_controller/streaming_board.h +++ b/deps/include/brainflow/board_controller/streaming_board.h @@ -1,6 +1,8 @@ #pragma once +#include #include +#include #include "board.h" #include "board_controller.h" @@ -13,19 +15,19 @@ class StreamingBoard : public Board private: volatile bool keep_alive; bool initialized; - bool is_streaming; - std::thread streaming_thread; + std::vector streaming_threads; + std::vector clients; + std::vector presets; - MultiCastClient *client; - - void read_thread (); + void read_thread (int num); + void log_socket_error (int error_code); public: StreamingBoard (struct BrainFlowInputParams params); ~StreamingBoard (); int prepare_session (); - int start_stream (int buffer_size, char *streamer_params); + int start_stream (int buffer_size, const char *streamer_params); int stop_stream (); int release_session (); int config_board (std::string config, std::string &response); diff --git a/deps/include/brainflow/board_controller/stub_streamer.h b/deps/include/brainflow/board_controller/stub_streamer.h deleted file mode 100644 index 12ef8ac2e..000000000 --- a/deps/include/brainflow/board_controller/stub_streamer.h +++ /dev/null @@ -1,25 +0,0 @@ -#pragma once - -#include "brainflow_constants.h" -#include "streamer.h" - - -class StubStreamer : public Streamer -{ - -public: - StubStreamer (int data_len) : Streamer (data_len) - { - } - ~StubStreamer () - { - } - - int init_streamer () - { - return (int)BrainFlowExitCodes::STATUS_OK; - } - void stream_data (double *data) - { - } -}; diff --git a/deps/include/brainflow/board_controller/synthetic_board.h b/deps/include/brainflow/board_controller/synthetic_board.h index c9d945a83..f79eb4d18 100644 --- a/deps/include/brainflow/board_controller/synthetic_board.h +++ b/deps/include/brainflow/board_controller/synthetic_board.h @@ -22,7 +22,7 @@ class SyntheticBoard : public Board ~SyntheticBoard (); int prepare_session (); - int start_stream (int buffer_size, char *streamer_params); + int start_stream (int buffer_size, const char *streamer_params); int stop_stream (); int release_session (); int config_board (std::string config, std::string &response); diff --git a/deps/include/brainflow/cpp-package/board_shim.h b/deps/include/brainflow/cpp-package/board_shim.h index cf79c30b4..3c7e94422 100644 --- a/deps/include/brainflow/cpp-package/board_shim.h +++ b/deps/include/brainflow/cpp-package/board_shim.h @@ -12,6 +12,9 @@ #include "brainflow_exception.h" #include "brainflow_input_params.h" +#include "json.hpp" + +using json = nlohmann::json; /// BoardShim class to communicate with a board class BoardShim @@ -20,7 +23,6 @@ class BoardShim struct BrainFlowInputParams params; public: - // clang-format off /// disable BrainFlow loggers static void disable_board_logger (); /// enable BrainFlow logger with LEVEL_INFO @@ -34,132 +36,174 @@ class BoardShim /// write user defined string to BrainFlow logger static void log_message (int log_level, const char *format, ...); + /** + * get board description as json + * @param board_id board id of your device + * @throw BrainFlowException If board id is not valid exit code is UNSUPPORTED_BOARD_ERROR + */ + static json get_board_descr (int board_id, int preset = (int)BrainFlowPresets::DEFAULT_PRESET); /** * get sampling rate for this board * @param board_id board id of your device * @throw BrainFlowException If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR */ - static int get_sampling_rate (int board_id); + static int get_sampling_rate (int board_id, int preset = (int)BrainFlowPresets::DEFAULT_PRESET); /** * get row index which holds package nums * @param board_id board id of your device * @throw BrainFlowException If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR */ - static int get_package_num_channel (int board_id); + static int get_package_num_channel ( + int board_id, int preset = (int)BrainFlowPresets::DEFAULT_PRESET); /** * get row index which holds timestamps * @param board_id board id of your device * @throw BrainFlowException If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR */ - static int get_timestamp_channel (int board_id); + static int get_timestamp_channel ( + int board_id, int preset = (int)BrainFlowPresets::DEFAULT_PRESET); /** * get row index which holds markers * @param board_id board id of your device * @throw BrainFlowException If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR */ - static int get_marker_channel (int board_id); + static int get_marker_channel ( + int board_id, int preset = (int)BrainFlowPresets::DEFAULT_PRESET); /** * get row index which holds battery level info * @param board_id board id of your device * @throw BrainFlowException If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR */ - static int get_battery_channel (int board_id); + static int get_battery_channel ( + int board_id, int preset = (int)BrainFlowPresets::DEFAULT_PRESET); /** * get number of rows in returned from @ref get_board_data() 2d array * @param board_id board id of your device * @throw BrainFlowException If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR */ - static int get_num_rows (int board_id); + static int get_num_rows (int board_id, int preset = (int)BrainFlowPresets::DEFAULT_PRESET); /** * get device name * @param board_id board id of your device * @throw BrainFlowException If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR */ - static std::string get_device_name (int board_id); + static std::string get_device_name ( + int board_id, int preset = (int)BrainFlowPresets::DEFAULT_PRESET); /** * get eeg channel names in 10-20 system for devices with fixed electrode locations * @param board_id board id of your device * @throw BrainFlowException If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR */ - static std::vector get_eeg_names (int board_id); + static std::vector get_eeg_names ( + int board_id, int preset = (int)BrainFlowPresets::DEFAULT_PRESET); /** * get row indices which hold EEG data, for some board we can not split EEG\EMG\... * @param board_id board id of your device * @throw BrainFlowException If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR */ - static std::vector get_eeg_channels (int board_id); + static std::vector get_eeg_channels ( + int board_id, int preset = (int)BrainFlowPresets::DEFAULT_PRESET); /** * get row indices which hold EMG data, for some board we can not split EEG\EMG\... * @param board_id board id of your device * @throw BrainFlowException If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR */ - static std::vector get_emg_channels (int board_id); + static std::vector get_emg_channels ( + int board_id, int preset = (int)BrainFlowPresets::DEFAULT_PRESET); /** * get row indices which hold ECG data, for some board we can not split EEG\EMG\... * @param board_id board id of your device * @throw BrainFlowException If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR */ - static std::vector get_ecg_channels (int board_id); + static std::vector get_ecg_channels ( + int board_id, int preset = (int)BrainFlowPresets::DEFAULT_PRESET); /** * get row indices which hold EOG data, for some board we can not split EEG\EMG\... * @param board_id board id of your device * @throw BrainFlowException If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR */ - static std::vector get_eog_channels (int board_id); + static std::vector get_eog_channels ( + int board_id, int preset = (int)BrainFlowPresets::DEFAULT_PRESET); /** * get row indices which hold EXG data * @param board_id board id of your device * @throw BrainFlowException If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR */ - static std::vector get_exg_channels (int board_id); + static std::vector get_exg_channels ( + int board_id, int preset = (int)BrainFlowPresets::DEFAULT_PRESET); /** * get row indices which hold PPG data * @param board_id board id of your device * @throw BrainFlowException If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR */ - static std::vector get_ppg_channels (int board_id); + static std::vector get_ppg_channels ( + int board_id, int preset = (int)BrainFlowPresets::DEFAULT_PRESET); /** * get row indices which hold EDA data * @param board_id board id of your device * @throw BrainFlowException If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR */ - static std::vector get_eda_channels (int board_id); + static std::vector get_eda_channels ( + int board_id, int preset = (int)BrainFlowPresets::DEFAULT_PRESET); /** * get row indices which hold accel data * @param board_id board id of your device * @throw BrainFlowException If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR */ - static std::vector get_accel_channels (int board_id); + static std::vector get_accel_channels ( + int board_id, int preset = (int)BrainFlowPresets::DEFAULT_PRESET); /** * get row indices which hold analog data * @param board_id board id of your device * @throw BrainFlowException If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR */ - static std::vector get_analog_channels (int board_id); + static std::vector get_analog_channels ( + int board_id, int preset = (int)BrainFlowPresets::DEFAULT_PRESET); /** * get row indices which hold gyro data * @param board_id board id of your device * @throw BrainFlowException If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR */ - static std::vector get_gyro_channels (int board_id); + static std::vector get_gyro_channels ( + int board_id, int preset = (int)BrainFlowPresets::DEFAULT_PRESET); /** * get row indices which hold other information * @param board_id board id of your device * @throw BrainFlowException If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR */ - static std::vector get_other_channels (int board_id); + static std::vector get_other_channels ( + int board_id, int preset = (int)BrainFlowPresets::DEFAULT_PRESET); /** * get row indices which hold temperature data * @param board_id board id of your device * @throw BrainFlowException If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR */ - static std::vector get_temperature_channels (int board_id); + static std::vector get_temperature_channels ( + int board_id, int preset = (int)BrainFlowPresets::DEFAULT_PRESET); /** * get row indices which hold resistance data * @param board_id board id of your device * @throw BrainFlowException If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR */ - static std::vector get_resistance_channels (int board_id); + static std::vector get_resistance_channels ( + int board_id, int preset = (int)BrainFlowPresets::DEFAULT_PRESET); + /** + * get row indices which hold magnetometer data + * @param board_id board id of your device + * @throw BrainFlowException If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR + */ + static std::vector get_magnetometer_channels ( + int board_id, int preset = (int)BrainFlowPresets::DEFAULT_PRESET); + /// release all currently prepared session + static void release_all_sessions (); + /// get brainflow version + static std::string get_version (); + /** + * get available presets for this board + * @param board_id board id of your device + * @throw BrainFlowException + */ + static std::vector get_board_presets (int board_id); int board_id; @@ -173,11 +217,26 @@ class BoardShim /** * start streaming thread and store data in ringbuffer * @param buffer_size size of internal ring buffer - * @param streamer_params use it to pass data packages further or store them directly during streaming, - supported values: "file://%file_name%:w", "file://%file_name%:a", "streaming_board://%multicast_group_ip%:%port%"". - Range for multicast addresses is from "224.0.0.0" to "239.255.255.255" */ void start_stream (int buffer_size = 450000, std::string streamer_params = ""); + /** + * add streamer + * @param streamer_params use it to pass data packages further or store them directly during + streaming, supported values: "file://%file_name%:w", "file://%file_name%:a", + "streaming_board://%multicast_group_ip%:%port%"". Range for multicast addresses is from + "224.0.0.0" to "239.255.255.255" + */ + void add_streamer ( + std::string streamer_params, int preset = (int)BrainFlowPresets::DEFAULT_PRESET); + /** + * delete streamer + * @param streamer_params use it to pass data packages further or store them directly during + streaming, supported values: "file://%file_name%:w", "file://%file_name%:a", + "streaming_board://%multicast_group_ip%:%port%"". Range for multicast addresses is from + "224.0.0.0" to "239.255.255.255" + */ + void delete_streamer ( + std::string streamer_params, int preset = (int)BrainFlowPresets::DEFAULT_PRESET); /// check if session is ready or not bool is_prepared (); /// stop streaming thread, doesnt release other resources @@ -185,16 +244,18 @@ class BoardShim /// release streaming session void release_session (); /// get latest collected data, doesnt remove it from ringbuffer - BrainFlowArray get_current_board_data (int num_samples); + BrainFlowArray get_current_board_data ( + int num_samples, int preset = (int)BrainFlowPresets::DEFAULT_PRESET); /// Get board id, for some boards can be different than provided (playback, streaming) int get_board_id (); /// get number of packages in ringbuffer - int get_board_data_count (); + int get_board_data_count (int preset = (int)BrainFlowPresets::DEFAULT_PRESET); /// get all collected data and flush it from internal buffer - BrainFlowArray get_board_data (); + BrainFlowArray get_board_data (int preset = (int)BrainFlowPresets::DEFAULT_PRESET); + /// get required amount of datapoints or less and flush it from internal buffer + BrainFlowArray get_board_data (int num_datapoints, int preset); /// send string to a board, use it carefully and only if you understand what you are doing - std::string config_board (char *config); + std::string config_board (std::string config); /// insert marker in data stream - void insert_marker (double value); - // clang-format on + void insert_marker (double value, int preset = (int)BrainFlowPresets::DEFAULT_PRESET); }; diff --git a/deps/include/brainflow/cpp-package/data_filter.h b/deps/include/brainflow/cpp-package/data_filter.h index 029b7e965..096af40a3 100644 --- a/deps/include/brainflow/cpp-package/data_filter.h +++ b/deps/include/brainflow/cpp-package/data_filter.h @@ -1,6 +1,7 @@ #pragma once #include +#include #include #include // include it here to allow user include only this single file @@ -24,6 +25,8 @@ class DataFilter static void set_log_level (int log_level); /// set log file static void set_log_file (std::string log_file); + /// write user defined string to BrainFlow logger + static void log_message (int log_level, const char *format, ...); /// perform low pass filter in-place static void perform_lowpass (double *data, int data_len, int sampling_rate, double cutoff, @@ -32,11 +35,14 @@ class DataFilter static void perform_highpass (double *data, int data_len, int sampling_rate, double cutoff, int order, int filter_type, double ripple); /// perform bandpass filter in-place - static void perform_bandpass (double *data, int data_len, int sampling_rate, double center_freq, - double band_width, int order, int filter_type, double ripple); + static void perform_bandpass (double *data, int data_len, int sampling_rate, double start_freq, + double stop_freq, int order, int filter_type, double ripple); /// perform bandstop filter in-place - static void perform_bandstop (double *data, int data_len, int sampling_rate, double center_freq, - double band_width, int order, int filter_type, double ripple); + static void perform_bandstop (double *data, int data_len, int sampling_rate, double start_freq, + double stop_freq, int order, int filter_type, double ripple); + /// apply notch filter to remove env noise + static void remove_environmental_noise ( + double *data, int data_len, int sampling_rate, int noise_type); /// perform moving average or moving median filter in-place static void perform_rolling_filter (double *data, int data_len, int period, int agg_operation); /// perform data downsampling, it just aggregates several data points @@ -47,23 +53,44 @@ class DataFilter * perform wavelet transform * @param data input array, any size * @param data_len length of input array - * @param wavelet supported vals: - * db1..db15,haar,sym2..sym10,coif1..coif5,bior1.1,bior1.3,bior1.5,bior2.2,bior2.4,bior2.6,bior2.8,bior3.1,bior3.3,bior3.5 - * ,bior3.7,bior3.9,bior4.4,bior5.5,bior6.8 + * @param wavelet use WaveletTypes enum * @param decomposition_level level of decomposition in wavelet transform + * @param extension use WaveletExtensionTypes enum * @return std::pair of wavelet coeffs array in format [A(J) D(J) D(J-1) ..... D(1)] where J is * decomposition level A - app coeffs, D - detailed coeffs, and array of lengths for each block * in wavelet coeffs array, length of this array is decomposition_level + 1 */ static std::pair perform_wavelet_transform ( - double *data, int data_len, std::string wavelet, int decomposition_level); + double *data, int data_len, int wavelet, int decomposition_level, int extension_type = (int)WaveletExtensionTypes::SYMMETRIC); // clang-format on /// performs inverse wavelet transform static double *perform_inverse_wavelet_transform (std::pair wavelet_output, - int original_data_len, std::string wavelet, int decomposition_level); - /// perform wavelet denoising - static void perform_wavelet_denoising ( - double *data, int data_len, std::string wavelet, int decomposition_level); + int original_data_len, int wavelet, int decomposition_level, + int extension_type = (int)WaveletExtensionTypes::SYMMETRIC); + // clanf-format off + /** + * perform wavelet denoising + * @param data input array, any size + * @param data_len length of input array + * @param wavelet use WaveletTypes enum + * @param decomposition_level level of decomposition in wavelet transform + * @param wavelet_denoising use WaveletDenoisingTypes enum + * @param threshold use ThresholdTypes enum + * @param extension use WaveletExtensionTypes enum + * @param noise_level use NoiseEstimationLevelTypes enum + */ + // clang-format on + static void perform_wavelet_denoising (double *data, int data_len, int wavelet, + int decomposition_level, int wavelet_denoising = (int)WaveletDenoisingTypes::SURESHRINK, + int threshold = (int)ThresholdTypes::HARD, + int extenstion_type = (int)WaveletExtensionTypes::SYMMETRIC, + int noise_level = (int)NoiseEstimationLevelTypes::FIRST_LEVEL); + /// restore data from selected detailed coeffs + static void restore_data_from_wavelet_detailed_coeffs (double *data, int data_len, int wavelet, + int decomposition_level, int level_to_restore, double *output); + /// z score peak detection, more info https://stackoverflow.com/a/22640362 + static void detect_peaks_z_score ( + double *data, int data_len, int lag, double threshold, double influence, double *output); // clang-format off /** * calculate filters and the corresponding eigenvalues using the Common Spatial Patterns @@ -82,18 +109,20 @@ class DataFilter /** * perform direct fft * @param data input array - * @param data_len must be power of 2 + * @param data_len must be even * @param window window function + * @param fft_len output fft len(data_len / 2 + 1) * @return complex array with size data_len / 2 + 1, it holds only positive im values */ - static std::complex *perform_fft (double *data, int data_len, int window); + static std::complex *perform_fft (double *data, int data_len, int window, int *fft_len); /** * perform inverse fft - * @param data complex array from perform_fft - * @param data_len len of original array, must be power of 2 + * @param fft_data complex array from perform_fft + * @param fft_len len of original array, must be even + * @param data_len output array len * @return restored data */ - static double *perform_ifft (std::complex *data, int data_len); + static double *perform_ifft (std::complex *fft_data, int fft_len, int *data_len); /** * calculate nearest power of 2 * @param value input value @@ -103,22 +132,24 @@ class DataFilter /** * calculate PSD * @param data input array - * @param data_len must be power of 2 + * @param data_len must be even * @param sampling_rate sampling rate * @param window window function + * @param psd_len output len (data_len / 2 + 1) * @return pair of amplitude and freq arrays of size data_len / 2 + 1 */ static std::pair get_psd ( - double *data, int data_len, int sampling_rate, int window); + double *data, int data_len, int sampling_rate, int window, int *psd_len); /** * subtract trend from data * @param data input array * @param data_len + * @param psd_len output len (data_len / 2 + 1) * @param detrend_operation use DetrendOperations enum */ static void detrend (double *data, int data_len, int detrend_operation); - static std::pair get_psd_welch ( - double *data, int data_len, int nfft, int overlap, int sampling_rate, int window); + static std::pair get_psd_welch (double *data, int data_len, int nfft, + int overlap, int sampling_rate, int window, int *psd_len); /** * calculate band power * @param psd psd calculated using get_psd @@ -140,10 +171,71 @@ class DataFilter */ static std::pair get_avg_band_powers (const BrainFlowArray &data, std::vector channels, int sampling_rate, bool apply_filters); - + /** + * calculate avg and stddev of BandPowers across all channels + * @param data input 2d array + * @param bands input bands + * @param cols number of cols in 2d array - number of datapoints + * @param channels vector of rows - eeg channels which should be used + * @param sampling_rate sampling rate + * @param apply_filters set to true to apply filters before band power calculations + * @return pair of float arrays with the same size as bands argument + */ + static std::pair get_custom_band_powers ( + const BrainFlowArray &data, std::vector> bands, + std::vector channels, int sampling_rate, bool apply_filters); + /** + * calculate oxygen level + * @param ppg_ir input 1d array + * @param ppg_red input 1d array + * @param data_len size of array + * @param sampling_rate sampling rate + * @return oxygen level + */ + static double get_oxygen_level (double *ppg_ir, double *ppg_red, int data_len, + int sampling_rate, double coef1 = 0.0, double coef2 = -37.663, double coef3 = 114.91); + /** + * calculate heart rate + * @param ppg_ir input 1d array + * @param ppg_red input 1d array + * @param data_len size of array + * @param sampling_rate sampling rate + * @param fft_size recommended 8192 + * @return heart rate + */ + static double get_heart_rate ( + double *ppg_ir, double *ppg_red, int data_len, int sampling_rate, int fft_size); /// write file, in file data will be transposed static void write_file ( const BrainFlowArray &data, std::string file_name, std::string file_mode); /// read data from file, data will be transposed to original format static BrainFlowArray read_file (std::string file_name); + /// calc stddev + static double calc_stddev (double *data, int start_pos, int end_pos); + /// calc railed percentage + static double get_railed_percentage (double *data, int data_len, int gain); + /** + * calculate ICA + * @param data input 2d array, rows are samples + * @param num_components number of components to find + * @param channels rows to use + * @return unmixed signal + */ + static std::tuple, BrainFlowArray, + BrainFlowArray, BrainFlowArray> + perform_ica ( + const BrainFlowArray &data, int num_components, std::vector channels); + /** + * calculate ICA + * @param data input 2d array, rows are samples + * @param num_components number of components to find + * @return unmixed signal + */ + static std::tuple, BrainFlowArray, + BrainFlowArray, BrainFlowArray> + perform_ica (const BrainFlowArray &data, int num_components); + + + /// get brainflow version + static std::string get_version (); }; diff --git a/deps/include/brainflow/cpp-package/ml_model.h b/deps/include/brainflow/cpp-package/ml_model.h index bf833c07c..c39b48ec2 100644 --- a/deps/include/brainflow/cpp-package/ml_model.h +++ b/deps/include/brainflow/cpp-package/ml_model.h @@ -2,6 +2,7 @@ #include #include +#include // include it here to allow user include only this single file #include "brainflow_constants.h" @@ -33,11 +34,17 @@ class MLModel static void enable_dev_ml_logger (); /// set log level static void set_log_level (int log_level); + /// write user defined string to BrainFlow logger + static void log_message (int log_level, const char *format, ...); + /// release all currently prepared classifiers + static void release_all (); + /// get brainflow version + static std::string get_version (); /// initialize classifier, should be called first void prepare (); /// calculate metric from data - double predict (double *data, int data_len); + std::vector predict (double *data, int data_len); /// release classifier void release (); }; diff --git a/deps/include/brainflow/data_handler/common_data_handler_helpers.h b/deps/include/brainflow/data_handler/common_data_handler_helpers.h new file mode 100644 index 000000000..679da1e46 --- /dev/null +++ b/deps/include/brainflow/data_handler/common_data_handler_helpers.h @@ -0,0 +1,37 @@ +#pragma once + +#include +#include + +inline double rms (double x[], int n) +{ + double sum = 0; + for (int i = 0; i < n; i++) + { + sum += x[i] * x[i]; + } + return sqrt (sum / n); +} + +inline double mean (double x[], int n) +{ + double sum = 0; + for (int i = 0; i < n; i++) + { + sum += x[i]; + } + return sum / n; +} + +inline double stddev (double data[], int len) +{ + double the_mean = mean (data, len); + double deviation = 0.0; + + for (int i = 0; i < len; ++i) + { + deviation += pow (data[i] - the_mean, 2); + } + + return sqrt (deviation / len); +} \ No newline at end of file diff --git a/deps/include/brainflow/data_handler/data_handler.h b/deps/include/brainflow/data_handler/data_handler.h index 58c36de7b..2e50e284c 100644 --- a/deps/include/brainflow/data_handler/data_handler.h +++ b/deps/include/brainflow/data_handler/data_handler.h @@ -13,27 +13,28 @@ extern "C" SHARED_EXPORT int CALLING_CONVENTION perform_highpass (double *data, int data_len, int sampling_rate, double cutoff, int order, int filter_type, double ripple); SHARED_EXPORT int CALLING_CONVENTION perform_bandpass (double *data, int data_len, - int sampling_rate, double center_freq, double band_width, int order, int filter_type, + int sampling_rate, double start_freq, double stop_freq, int order, int filter_type, double ripple); SHARED_EXPORT int CALLING_CONVENTION perform_bandstop (double *data, int data_len, - int sampling_rate, double center_freq, double band_width, int order, int filter_type, + int sampling_rate, double start_freq, double stop_width, int order, int filter_type, double ripple); - + SHARED_EXPORT int CALLING_CONVENTION remove_environmental_noise ( + double *data, int data_len, int sampling_rate, int noise_type); SHARED_EXPORT int CALLING_CONVENTION perform_rolling_filter ( double *data, int data_len, int period, int agg_operation); - SHARED_EXPORT int CALLING_CONVENTION perform_downsampling ( double *data, int data_len, int period, int agg_operation, double *output_data); - SHARED_EXPORT int CALLING_CONVENTION perform_wavelet_transform (double *data, int data_len, - char *wavelet, int decomposition_level, double *output_data, int *decomposition_lengths); + int wavelet, int decomposition_level, int extension, double *output_data, + int *decomposition_lengths); SHARED_EXPORT int CALLING_CONVENTION perform_inverse_wavelet_transform (double *wavelet_coeffs, - int original_data_len, char *wavelet, int decomposition_level, int *decomposition_lengths, - double *output_data); - SHARED_EXPORT int CALLING_CONVENTION perform_wavelet_denoising ( - double *data, int data_len, char *wavelet, int decomposition_level); - SHARED_EXPORT int CALLING_CONVENTION get_csp (double *data, double *labels, int n_epochs, - int n_channels, int n_times, double *output_w, double *output_d); + int original_data_len, int wavelet, int decomposition_level, int extension, + int *decomposition_lengths, double *output_data); + SHARED_EXPORT int CALLING_CONVENTION perform_wavelet_denoising (double *data, int data_len, + int wavelet, int decomposition_level, int wavelet_denoising, int threshold, + int extenstion_type, int noise_level); + SHARED_EXPORT int CALLING_CONVENTION get_csp (const double *data, const double *labels, + int n_epochs, int n_channels, int n_times, double *output_w, double *output_d); SHARED_EXPORT int CALLING_CONVENTION get_window ( int window_function, int window_len, double *output_window); SHARED_EXPORT int CALLING_CONVENTION perform_fft ( @@ -45,25 +46,47 @@ extern "C" int window_function, double *output_ampl, double *output_freq); SHARED_EXPORT int CALLING_CONVENTION detrend ( double *data, int data_len, int detrend_operation); + SHARED_EXPORT int CALLING_CONVENTION calc_stddev ( + double *data, int start_pos, int end_pos, double *output); SHARED_EXPORT int CALLING_CONVENTION get_psd_welch (double *data, int data_len, int nfft, int overlap, int sampling_rate, int window_function, double *output_ampl, double *output_freq); SHARED_EXPORT int CALLING_CONVENTION get_band_power (double *ampl, double *freq, int data_len, double freq_start, double freq_end, double *band_power); + SHARED_EXPORT int CALLING_CONVENTION get_custom_band_powers (double *raw_data, int rows, + int cols, double *start_freqs, double *stop_freqs, int num_bands, int sampling_rate, + int apply_filters, double *avg_band_powers, double *stddev_band_powers); + SHARED_EXPORT int CALLING_CONVENTION get_railed_percentage ( + double *raw_data, int data_len, int gain, double *output); + SHARED_EXPORT int CALLING_CONVENTION get_oxygen_level (double *ppg_ir, double *ppg_red, + int data_size, int sampling_rate, double callib_coef1, double callib_coef2, + double callib_coef3, double *oxygen_level); + SHARED_EXPORT int CALLING_CONVENTION get_heart_rate (double *ppg_ir, double *ppg_red, + int data_size, int sampling_rate, int fft_size, double *rate); + SHARED_EXPORT int CALLING_CONVENTION restore_data_from_wavelet_detailed_coeffs (double *data, + int data_len, int wavelet, int decomposition_level, int level_to_restore, double *output); + SHARED_EXPORT int CALLING_CONVENTION detect_peaks_z_score ( + double *data, int data_len, int lag, double threshold, double influence, double *output); + SHARED_EXPORT int CALLING_CONVENTION perform_ica (double *data, int rows, int cols, + int num_components, double *w_mat, double *k_mat, double *a_mat, double *s_mat); - SHARED_EXPORT int CALLING_CONVENTION get_avg_band_powers (double *raw_data, int rows, int cols, - int sampling_rate, int apply_filters, double *avg_band_powers, double *stddev_band_powers); // logging methods - SHARED_EXPORT int CALLING_CONVENTION set_log_level (int log_level); - SHARED_EXPORT int CALLING_CONVENTION set_log_file (char *log_file); + SHARED_EXPORT int CALLING_CONVENTION set_log_level_data_handler (int log_level); + SHARED_EXPORT int CALLING_CONVENTION set_log_file_data_handler (const char *log_file); + SHARED_EXPORT int CALLING_CONVENTION log_message_data_handler (int log_level, char *message); + // file operations - SHARED_EXPORT int CALLING_CONVENTION write_file ( - double *data, int num_rows, int num_cols, char *file_name, char *file_mode); + SHARED_EXPORT int CALLING_CONVENTION write_file (const double *data, int num_rows, int num_cols, + const char *file_name, const char *file_mode); SHARED_EXPORT int CALLING_CONVENTION read_file ( - double *data, int *num_rows, int *num_cols, char *file_name, int num_elements); + double *data, int *num_rows, int *num_cols, const char *file_name, int num_elements); SHARED_EXPORT int CALLING_CONVENTION get_num_elements_in_file ( - char *file_name, int *num_elements); // its an internal method for bindings its not - // available via high level api + const char *file_name, int *num_elements); // its an internal method for bindings its not + // available via high level api + + // platform types and methods + SHARED_EXPORT int CALLING_CONVENTION get_version_data_handler ( + char *version, int *num_chars, int max_chars); #ifdef __cplusplus } #endif diff --git a/deps/include/brainflow/data_handler/fastica.h b/deps/include/brainflow/data_handler/fastica.h new file mode 100644 index 000000000..f0f5b08e4 --- /dev/null +++ b/deps/include/brainflow/data_handler/fastica.h @@ -0,0 +1,42 @@ +#pragma once + +#include +#include + +#include "Eigen/Dense" +#include "brainflow_constants.h" + + +class FastICA +{ + +public: + FastICA (int num_components, int max_it = 300, double tol = 0.0001) + { + this->max_it = max_it; + this->num_components = num_components; + this->tol = tol; + alpha = 1; + row_norm = false; + } + + int compute (Eigen::MatrixXd &X); + int get_matrixes (double *w_mat, double *k_mat, double *a_mat, double *s_mat); + +private: + Eigen::MatrixXd K; + Eigen::MatrixXd W; + Eigen::MatrixXd A; + Eigen::MatrixXd S; + + Eigen::MatrixXd fast_ica_parallel_compute (const Eigen::MatrixXd &X); + void scale (Eigen::Ref m, bool, bool, bool ignore_invariants = false, + std::vector *zeros = NULL); + void random_normal (Eigen::MatrixXd &m); + + int max_it; + int num_components; + double tol; + int alpha; + bool row_norm; +}; diff --git a/deps/include/brainflow/data_handler/wavelet_helpers.h b/deps/include/brainflow/data_handler/wavelet_helpers.h index 8a4117abc..3e9657a74 100644 --- a/deps/include/brainflow/data_handler/wavelet_helpers.h +++ b/deps/include/brainflow/data_handler/wavelet_helpers.h @@ -3,48 +3,85 @@ #include #include +#include "brainflow_constants.h" -inline bool validate_wavelet (char *wavelet) + +inline std::string get_wavelet_name (int wavelet) +{ + std::string wavelet_names[] = {"haar", "db1", "db2", "db3", "db4", "db5", "db6", "db7", "db8", + "db9", "db10", "db11", "db12", "db13", "db14", "db15", "bior1.1", "bior1.3", "bior1.5", + "bior2.2", "bior2.4", "bior2.6", "bior2.8", "bior3.1", "bior3.3", "bior3.5", "bior3.7", + "bior3.9", "bior4.4", "bior5.5", "bior6.8", "coif1", "coif2", "coif3", "coif4", "coif5", + "sym2", "sym3", "sym4", "sym5", "sym6", "sym7", "sym8", "sym9", "sym10"}; + + if ((wavelet < (int)WaveletTypes::FIRST_WAVELET) || (wavelet > (int)WaveletTypes::LAST_WAVELET)) + { + return ""; + } + + return wavelet_names[wavelet]; +} + +inline std::string get_wavelet_denoising_type (int denoising_type) { - // https://github.com/rafat/wavelib/wiki/wave-object - std::vector supported_wavelets; - supported_wavelets.push_back (std::string ("haar")); - for (int i = 1; i <= 15; i++) - { - supported_wavelets.push_back (std::string ("db") + std::to_string (i)); - } - for (int i = 2; i <= 10; i++) - { - supported_wavelets.push_back (std::string ("sym") + std::to_string (i)); - } - for (int i = 1; i <= 5; i++) - { - supported_wavelets.push_back (std::string ("coif") + std::to_string (i)); - } - supported_wavelets.push_back ("bior1.1"); - supported_wavelets.push_back ("bior1.3"); - supported_wavelets.push_back ("bior1.5"); - supported_wavelets.push_back ("bior2.2"); - supported_wavelets.push_back ("bior2.4"); - supported_wavelets.push_back ("bior2.6"); - supported_wavelets.push_back ("bior2.8"); - supported_wavelets.push_back ("bior3.1"); - supported_wavelets.push_back ("bior3.3"); - supported_wavelets.push_back ("bior3.5"); - supported_wavelets.push_back ("bior3.7"); - supported_wavelets.push_back ("bior3.9"); - supported_wavelets.push_back ("bior4.4"); - supported_wavelets.push_back ("bior5.5"); - supported_wavelets.push_back ("bior6.8"); - - bool is_supported = false; - for (auto cur_wavelet : supported_wavelets) - { - if (std::string (wavelet) == cur_wavelet) - { - is_supported = true; - break; - } - } - return is_supported; -} \ No newline at end of file + if (denoising_type == (int)WaveletDenoisingTypes::VISUSHRINK) + { + return "visushrink"; + } + else if (denoising_type == (int)WaveletDenoisingTypes::SURESHRINK) + { + return "sureshrink"; + } + else + { + return ""; + } +} + +inline std::string get_threshold_type (int threshold_type) +{ + if (threshold_type == (int)ThresholdTypes::SOFT) + { + return "soft"; + } + else if (threshold_type == (int)ThresholdTypes::HARD) + { + return "hard"; + } + else + { + return ""; + } +} + +inline std::string get_extension_type (int extenstion_type) +{ + if (extenstion_type == (int)WaveletExtensionTypes::SYMMETRIC) + { + return "sym"; + } + else if (extenstion_type == (int)WaveletExtensionTypes::PERIODIC) + { + return "per"; + } + else + { + return ""; + } +} + +inline std::string get_noise_estimation_type (int noise_est_type) +{ + if (noise_est_type == (int)NoiseEstimationLevelTypes::FIRST_LEVEL) + { + return "first"; + } + else if (noise_est_type == (int)NoiseEstimationLevelTypes::ALL_LEVELS) + { + return "all"; + } + else + { + return ""; + } +} diff --git a/deps/include/brainflow/ganglion-bglib/ganglion_types.h b/deps/include/brainflow/ganglion-bglib/ganglion_types.h index e98bfb27a..c99cdc654 100644 --- a/deps/include/brainflow/ganglion-bglib/ganglion_types.h +++ b/deps/include/brainflow/ganglion-bglib/ganglion_types.h @@ -27,6 +27,13 @@ namespace GanglionLib timestamp = other.timestamp; memcpy (data, other.data, sizeof (unsigned char) * 20); } + + GanglionData &operator= (const GanglionData &other) + { + timestamp = other.timestamp; + memcpy (data, other.data, sizeof (unsigned char) * 20); + return *this; + } }; // just to pass two args to initialize @@ -46,6 +53,13 @@ namespace GanglionLib timeout = other.timeout; strcpy (uart_port, other.uart_port); } + + GanglionInputData &operator= (const GanglionInputData &other) + { + timeout = other.timeout; + strcpy (uart_port, other.uart_port); + return *this; + } }; #pragma pack(pop) diff --git a/deps/include/brainflow/ganglion-bglib/uart.h b/deps/include/brainflow/ganglion-bglib/uart.h index 9ac2699a8..f2efcd150 100644 --- a/deps/include/brainflow/ganglion-bglib/uart.h +++ b/deps/include/brainflow/ganglion-bglib/uart.h @@ -3,7 +3,7 @@ void uart_list_devices (); int uart_find_serialport (char *name); -int uart_open (char *port); +int uart_open (const char *port); void uart_close (); int uart_tx (int len, unsigned char *data); int uart_rx (int len, unsigned char *data, int timeout_ms); diff --git a/deps/include/brainflow/gforcesdkcxx-wrapper/gforce_handle.h b/deps/include/brainflow/gforcesdkcxx-wrapper/gforce_handle.h index 580881e24..9ea411ddd 100644 --- a/deps/include/brainflow/gforcesdkcxx-wrapper/gforce_handle.h +++ b/deps/include/brainflow/gforcesdkcxx-wrapper/gforce_handle.h @@ -4,28 +4,29 @@ #include "gforce.h" -#include "gforce_wrapper_types.h" - #include "spdlog/sinks/null_sink.h" #include "spdlog/spdlog.h" +#include "brainflow_array.h" +#include "brainflow_constants.h" #include "spinlock.h" #include "timestamp.h" +//#define ENABLE_LOGGER + using namespace gf; using namespace std; extern volatile int iExitCode; extern SpinLock spinLock; extern volatile bool bShouldStopStream; -extern std::deque data_queue; +extern std::deque> dataQueue; -//#define ENABLE_LOGGER class GforceHandle : public HubListener { public: - GforceHandle (gfsPtr &pHub) : mHub (pHub) + GforceHandle (gfsPtr &pHub, int iBoardType) : mHub (pHub) { #ifdef ENABLE_LOGGER logger = spdlog::stderr_logger_mt ("GForceHandleLogger"); @@ -37,6 +38,21 @@ class GforceHandle : public HubListener bIsEMGConfigured = false; bIsFeatureMapConfigured = false; iCounter = 0; + this->iBoardType = iBoardType; + if (iBoardType == (int)BoardIds::GFORCE_PRO_BOARD) + { + iSamplingRate = 500; + iTransactionSize = 128; + iNumPackages = 8; + iChannelMap = 0x00FF; + } + if (iBoardType == (int)BoardIds::GFORCE_DUAL_BOARD) + { + iSamplingRate = 500; + iTransactionSize = 32; + iNumPackages = iTransactionSize / GforceHandle::iADCResolution; + iChannelMap = 0x0001 | 0x0002; + } } /// This callback is called when the Hub finishes scanning devices. @@ -45,7 +61,7 @@ class GforceHandle : public HubListener if (nullptr == mDevice) { logger->error ("device not found"); - iExitCode = (int)GforceWrapperExitCodes::NO_DEVICE_FOUND; + iExitCode = (int)BrainFlowExitCodes::BOARD_NOT_CREATED_ERROR; } else { @@ -56,18 +72,18 @@ class GforceHandle : public HubListener if (GF_RET_CODE::GF_SUCCESS == mDevice->connect ()) { logger->info ("device connected"); - iExitCode = (int)GforceWrapperExitCodes::STATUS_OK; + iExitCode = (int)BrainFlowExitCodes::STATUS_OK; } else { logger->error ("connect error"); - iExitCode = (int)GforceWrapperExitCodes::CONNECT_ERROR; + iExitCode = (int)BrainFlowExitCodes::UNABLE_TO_OPEN_PORT_ERROR; } } else { logger->error ("device found but in connecting state"); - iExitCode = (int)GforceWrapperExitCodes::FOUND_BUT_IN_CONNECTING_STATE; + iExitCode = (int)BrainFlowExitCodes::BOARD_NOT_READY_ERROR; } } } @@ -170,23 +186,49 @@ class GforceHandle : public HubListener } auto ptr = data->data (); - double emgData[GforceData::SIZE] = {0.0}; - if (dataType == DeviceDataType::DDT_EMGRAW) + if (iBoardType == (int)BoardIds::GFORCE_PRO_BOARD) + { + constexpr int size = 11; + double emgData[size] = {0.0}; + if (dataType == DeviceDataType::DDT_EMGRAW) + { + for (int packageNum = 0; packageNum < iNumPackages; packageNum++) + { + emgData[0] = iCounter++; + for (int i = 0; i < 8; i++) + { + emgData[i + 1] = (double)*(reinterpret_cast (ptr)); + ptr += 2; + } + emgData[9] = timestamp; + BrainFlowArray gforceData (emgData, size); + spinLock.lock (); + dataQueue.push_back (std::move (gforceData)); + spinLock.unlock (); + } + } + } + if (iBoardType == (int)BoardIds::GFORCE_DUAL_BOARD) { - emgData[0] = iCounter++; - for (int packageNum = 0; packageNum < GforceHandle::iNumPackages; packageNum++) + constexpr int size = 5; + double emgData[size] = {0.0}; + if (dataType == DeviceDataType::DDT_EMGRAW) { emgData[0] = iCounter++; - for (int i = 0; i < 8; i++) + for (int packageNum = 0; packageNum < iNumPackages; packageNum++) { - emgData[i + 1] = (double)*(reinterpret_cast (ptr)); - ptr += 2; + emgData[0] = iCounter++; + for (int i = 0; i < 2; i++) + { + emgData[i + 1] = (double)*(reinterpret_cast (ptr)); + ptr += 2; + } + emgData[3] = timestamp; + BrainFlowArray gforceData (emgData, size); + spinLock.lock (); + dataQueue.push_back (std::move (gforceData)); + spinLock.unlock (); } - emgData[9] = timestamp; - struct GforceData gforceData (emgData); - spinLock.lock (); - data_queue.push_back (gforceData); - spinLock.unlock (); } } } @@ -194,11 +236,13 @@ class GforceHandle : public HubListener std::shared_ptr logger; bool bIsFeatureMapConfigured; bool bIsEMGConfigured; + int iBoardType; + int iSamplingRate; + int iTransactionSize; + int iNumPackages; + int iChannelMap; static const int iADCResolution = 12; - static const int iTransactionSize = 128; - static const int iNumPackages = 8; - static const int iSamplingRate = 500; private: gfsPtr mHub; @@ -221,27 +265,30 @@ class GforceHandle : public HubListener | DeviceSetting::DNF_EMG_RAW //| DeviceSetting::DNF_HID_MOUSE //| DeviceSetting::DNF_HID_JOYSTICK - //| DeviceSetting::DNF_DEVICE_STATUS - ); + | DeviceSetting::DNF_DEVICE_STATUS); - ds->setDataNotifSwitch ( - (DeviceSetting::DataNotifFlags) (flags & featureMap), [this] (ResponseResult result) { - std::string res = - (result == ResponseResult::RREST_SUCCESS) ? ("sucess") : ("failed"); - bIsFeatureMapConfigured = - (result == ResponseResult::RREST_SUCCESS) ? (true) : (false); - this->logger->info ("setDataNotifSwitch result: {}", res); - }); + flags = (DeviceSetting::DataNotifFlags) (flags & featureMap); - ds->setEMGRawDataConfig (GforceHandle::iSamplingRate, // sample rate - (DeviceSetting::EMGRowDataChannels) (0x00FF), // channel 0~7 - GforceHandle::iTransactionSize, // data length - GforceHandle::iADCResolution, // adc resolution - [this] (ResponseResult result) { + ds->setEMGRawDataConfig (iSamplingRate, (DeviceSetting::EMGRowDataChannels) (iChannelMap), + iTransactionSize, GforceHandle::iADCResolution, + [ds, flags, this] (ResponseResult result) + { std::string res = (result == ResponseResult::RREST_SUCCESS) ? ("sucess") : ("failed"); bIsEMGConfigured = (result == ResponseResult::RREST_SUCCESS) ? (true) : (false); this->logger->info ("setEMGRawDataConfig result: {}", res); + if (bIsEMGConfigured) + { + ds->setDataNotifSwitch (flags, + [this] (ResponseResult result) + { + std::string res = + (result == ResponseResult::RREST_SUCCESS) ? ("sucess") : ("failed"); + bIsFeatureMapConfigured = + (result == ResponseResult::RREST_SUCCESS) ? (true) : (false); + this->logger->info ("setDataNotifSwitch result: {}", res); + }); + } }); } }; diff --git a/deps/include/brainflow/gforcesdkcxx-wrapper/gforce_wrapper_functions.h b/deps/include/brainflow/gforcesdkcxx-wrapper/gforce_wrapper_functions.h index 726a5a8e2..4d4fc54e3 100644 --- a/deps/include/brainflow/gforcesdkcxx-wrapper/gforce_wrapper_functions.h +++ b/deps/include/brainflow/gforcesdkcxx-wrapper/gforce_wrapper_functions.h @@ -11,11 +11,14 @@ extern "C" { #endif - SHARED_EXPORT int CALLING_CONVENTION gforceInitialize (void *param); - SHARED_EXPORT int CALLING_CONVENTION gforceStartStreaming (void *param); - SHARED_EXPORT int CALLING_CONVENTION gforceStopStreaming (void *param); - SHARED_EXPORT int CALLING_CONVENTION gforceGetData (void *param); - SHARED_EXPORT int CALLING_CONVENTION gforceRelease (void *param); + SHARED_EXPORT int CALLING_CONVENTION initialize (void *param); + SHARED_EXPORT int CALLING_CONVENTION open_device (void *param); + SHARED_EXPORT int CALLING_CONVENTION stop_stream (void *param); + SHARED_EXPORT int CALLING_CONVENTION start_stream (void *param); + SHARED_EXPORT int CALLING_CONVENTION close_device (void *param); + SHARED_EXPORT int CALLING_CONVENTION get_data (void *param); + SHARED_EXPORT int CALLING_CONVENTION release (void *param); + SHARED_EXPORT int CALLING_CONVENTION config_device (void *param); #ifdef __cplusplus } #endif diff --git a/deps/include/brainflow/gforcesdkcxx-wrapper/gforce_wrapper_types.h b/deps/include/brainflow/gforcesdkcxx-wrapper/gforce_wrapper_types.h deleted file mode 100644 index 90d68c992..000000000 --- a/deps/include/brainflow/gforcesdkcxx-wrapper/gforce_wrapper_types.h +++ /dev/null @@ -1,46 +0,0 @@ -#pragma once - -#include - -#pragma pack(push, 1) -struct GforceData -{ - static const int SIZE = 11; - - double data[SIZE]; - - GforceData (double *data) - { - memcpy (this->data, data, sizeof (double) * SIZE); - } - - GforceData () - { - for (int i = 0; i < SIZE; i++) - { - data[i] = 0; - } - } - - GforceData (const GforceData &other) - { - memcpy (data, other.data, sizeof (double) * SIZE); - } -}; -#pragma pack(pop) - -enum class GforceWrapperExitCodes : int -{ - STATUS_OK = 0, - HUB_INIT_FAILED = 1, - SCAN_INIT_FAILED = 2, - NO_DEVICE_FOUND = 3, - CONNECT_ERROR = 4, - ALREADY_INITIALIZED = 5, - NOT_INITIALIZED = 6, - SERIAL_DETECT_ERROR = 7, - FOUND_BUT_IN_CONNECTING_STATE = 8, - SYNC_ERROR = 9, - RUN_ERROR = 10, - NO_DATA_ERROR = 11 -}; \ No newline at end of file diff --git a/deps/include/brainflow/ml/base_classifier.h b/deps/include/brainflow/ml/base_classifier.h index 5ce20397f..ccd7abd33 100644 --- a/deps/include/brainflow/ml/base_classifier.h +++ b/deps/include/brainflow/ml/base_classifier.h @@ -5,14 +5,13 @@ class BaseClassifier { -protected: +public: struct BrainFlowModelParams params; bool skip_logs; -public: static std::shared_ptr ml_logger; static int set_log_level (int log_level); - static int set_log_file (char *log_file); + static int set_log_file (const char *log_file); BaseClassifier (struct BrainFlowModelParams model_params) : params (model_params) { @@ -47,6 +46,6 @@ class BaseClassifier } virtual int prepare () = 0; - virtual int predict (double *data, int data_len, double *output) = 0; + virtual int predict (double *data, int data_len, double *output, int *output_len) = 0; virtual int release () = 0; -}; \ No newline at end of file +}; diff --git a/deps/include/brainflow/ml/brainflow_model_params.h b/deps/include/brainflow/ml/brainflow_model_params.h index 8584229e4..3dedebf04 100644 --- a/deps/include/brainflow/ml/brainflow_model_params.h +++ b/deps/include/brainflow/ml/brainflow_model_params.h @@ -11,6 +11,8 @@ struct BrainFlowModelParams int classifier; std::string file; std::string other_info; + std::string output_name; + int max_array_size; BrainFlowModelParams (int metric, int classifier) { @@ -18,12 +20,15 @@ struct BrainFlowModelParams this->classifier = classifier; file = ""; other_info = ""; + output_name = ""; + max_array_size = 8192; } // default copy constructor and assignment operator are ok, need less operator to use in map bool operator< (const struct BrainFlowModelParams &other) const { - return std::tie (metric, classifier, file, other_info) < - std::tie (other.metric, other.classifier, other.file, other.other_info); + return std::tie (metric, classifier, file, other_info, output_name, max_array_size) < + std::tie (other.metric, other.classifier, other.file, other.other_info, output_name, + max_array_size); } }; diff --git a/deps/include/brainflow/ml/concentration_knn_classifier.h b/deps/include/brainflow/ml/concentration_knn_classifier.h deleted file mode 100644 index adb224154..000000000 --- a/deps/include/brainflow/ml/concentration_knn_classifier.h +++ /dev/null @@ -1,34 +0,0 @@ -#pragma once - -#include - -#include "base_classifier.h" -#include "focus_point.h" - -#include "kdtree.h" - - -class ConcentrationKNNClassifier : public BaseClassifier -{ -public: - ConcentrationKNNClassifier (struct BrainFlowModelParams params) : BaseClassifier (params) - { - num_neighbors = 5; - kdtree = NULL; - } - - virtual ~ConcentrationKNNClassifier () - { - skip_logs = true; - release (); - } - - virtual int prepare (); - virtual int predict (double *data, int data_len, double *output); - virtual int release (); - -private: - std::vector dataset; - kdt::KDTree *kdtree; - int num_neighbors; -}; diff --git a/deps/include/brainflow/ml/concentration_regression_classifier.h b/deps/include/brainflow/ml/concentration_regression_classifier.h deleted file mode 100644 index 00db820c6..000000000 --- a/deps/include/brainflow/ml/concentration_regression_classifier.h +++ /dev/null @@ -1,22 +0,0 @@ -#pragma once - -#include "base_classifier.h" - - -class ConcentrationRegressionClassifier : public BaseClassifier -{ -public: - ConcentrationRegressionClassifier (struct BrainFlowModelParams params) : BaseClassifier (params) - { - } - - virtual ~ConcentrationRegressionClassifier () - { - skip_logs = true; - release (); - } - - virtual int prepare (); - virtual int predict (double *data, int data_len, double *output); - virtual int release (); -}; diff --git a/deps/include/brainflow/ml/concentration_svm_classifier.h b/deps/include/brainflow/ml/concentration_svm_classifier.h deleted file mode 100644 index 8092b5a97..000000000 --- a/deps/include/brainflow/ml/concentration_svm_classifier.h +++ /dev/null @@ -1,26 +0,0 @@ -#pragma once - -#include "base_classifier.h" -#include "svm.h" - -class ConcentrationSVMClassifier : public BaseClassifier -{ -public: - ConcentrationSVMClassifier (struct BrainFlowModelParams params) : BaseClassifier (params) - { - model = NULL; - } - - virtual ~ConcentrationSVMClassifier () - { - skip_logs = true; - release (); - } - - virtual int prepare (); - virtual int predict (double *data, int data_len, double *output); - virtual int release (); - -private: - struct svm_model *model; -}; diff --git a/deps/include/brainflow/ml/dyn_lib_classifier.h b/deps/include/brainflow/ml/dyn_lib_classifier.h new file mode 100644 index 000000000..f35da5aa5 --- /dev/null +++ b/deps/include/brainflow/ml/dyn_lib_classifier.h @@ -0,0 +1,34 @@ +#pragma once + +#include + +#include "base_classifier.h" +#include "runtime_dll_loader.h" + + +class DynLibClassifier : public BaseClassifier +{ +public: + DynLibClassifier (struct BrainFlowModelParams params) : BaseClassifier (params) + { + dll_loader = NULL; + } + + virtual ~DynLibClassifier () + { + skip_logs = true; + release (); + } + + virtual int prepare (); + virtual int predict (double *data, int data_len, double *output, int *output_len); + virtual int release (); + +protected: + virtual std::string get_dyn_lib_path () + { + return params.file; + } + + DLLLoader *dll_loader; +}; diff --git a/deps/include/brainflow/ml/focus_dataset.h b/deps/include/brainflow/ml/focus_dataset.h deleted file mode 100644 index 6d6930739..000000000 --- a/deps/include/brainflow/ml/focus_dataset.h +++ /dev/null @@ -1,5 +0,0 @@ - -#pragma once - -extern double brainflow_focus_x[45889][10]; -extern int brainflow_focus_y[45889]; diff --git a/deps/include/brainflow/ml/focus_point.h b/deps/include/brainflow/ml/focus_point.h deleted file mode 100644 index f71c0f55a..000000000 --- a/deps/include/brainflow/ml/focus_point.h +++ /dev/null @@ -1,37 +0,0 @@ -#pragma once - -#include -#include - - -class FocusPoint : public std::array -{ -public: - static const int DIM = 10; // required for kdtree - - int value; - - FocusPoint () - { - value = 0; - for (int i = 0; i < 10; i++) - { - (*this)[i] = 0.0; - } - } - - FocusPoint (double *feature_vector, int vector_len, int value) - { - this->value = value; - int len = std::min (vector_len, 10); - for (int i = 0; i < len; i++) - { - (*this)[i] = feature_vector[i]; - } - // to work without stddev in feature vector if needed - for (int i = vector_len; i < 10; i++) - { - (*this)[i] = 0.0; - } - } -}; diff --git a/deps/include/brainflow/ml/lda_model.h b/deps/include/brainflow/ml/lda_model.h deleted file mode 100644 index a9bf856ff..000000000 --- a/deps/include/brainflow/ml/lda_model.h +++ /dev/null @@ -1,5 +0,0 @@ -#pragma once - - -extern const double lda_coefficients[10]; -extern double lda_intercept; diff --git a/deps/include/brainflow/ml/concentration_lda_classifier.h b/deps/include/brainflow/ml/mindfulness_classifier.h similarity index 54% rename from deps/include/brainflow/ml/concentration_lda_classifier.h rename to deps/include/brainflow/ml/mindfulness_classifier.h index dcba59a44..caf2503be 100644 --- a/deps/include/brainflow/ml/concentration_lda_classifier.h +++ b/deps/include/brainflow/ml/mindfulness_classifier.h @@ -3,20 +3,20 @@ #include "base_classifier.h" -class ConcentrationLDAClassifier : public BaseClassifier +class MindfulnessClassifier : public BaseClassifier { public: - ConcentrationLDAClassifier (struct BrainFlowModelParams params) : BaseClassifier (params) + MindfulnessClassifier (struct BrainFlowModelParams params) : BaseClassifier (params) { } - virtual ~ConcentrationLDAClassifier () + virtual ~MindfulnessClassifier () { skip_logs = true; release (); } virtual int prepare (); - virtual int predict (double *data, int data_len, double *output); + virtual int predict (double *data, int data_len, double *output, int *output_len); virtual int release (); -}; +}; \ No newline at end of file diff --git a/deps/include/brainflow/ml/mindfulness_model.h b/deps/include/brainflow/ml/mindfulness_model.h new file mode 100644 index 000000000..0c720554e --- /dev/null +++ b/deps/include/brainflow/ml/mindfulness_model.h @@ -0,0 +1,5 @@ +#pragma once + + +extern const double mindfulness_coefficients[5]; +extern double mindfulness_intercept; \ No newline at end of file diff --git a/deps/include/brainflow/ml/ml_module.h b/deps/include/brainflow/ml/ml_module.h index 678aa5557..6ac0c42c2 100644 --- a/deps/include/brainflow/ml/ml_module.h +++ b/deps/include/brainflow/ml/ml_module.h @@ -6,14 +6,20 @@ extern "C" { #endif - SHARED_EXPORT int CALLING_CONVENTION prepare (char *json_params); + SHARED_EXPORT int CALLING_CONVENTION prepare (const char *json_params); SHARED_EXPORT int CALLING_CONVENTION predict ( - double *data, int data_len, double *output, char *json_params); - SHARED_EXPORT int CALLING_CONVENTION release (char *json_params); + double *data, int data_len, double *output, int *output_len, const char *json_params); + SHARED_EXPORT int CALLING_CONVENTION release (const char *json_params); + SHARED_EXPORT int CALLING_CONVENTION release_all (); // logging methods - SHARED_EXPORT int CALLING_CONVENTION set_log_level (int log_level); - SHARED_EXPORT int CALLING_CONVENTION set_log_file (char *log_file); + SHARED_EXPORT int CALLING_CONVENTION set_log_level_ml_module (int log_level); + SHARED_EXPORT int CALLING_CONVENTION set_log_file_ml_module (const char *log_file); + SHARED_EXPORT int CALLING_CONVENTION log_message_ml_module (int log_level, char *message); + + // platform types and methods + SHARED_EXPORT int CALLING_CONVENTION get_version_ml_module ( + char *version, int *num_chars, int max_chars); #ifdef __cplusplus } #endif diff --git a/deps/include/brainflow/ml/onnx/onnx_classifier.h b/deps/include/brainflow/ml/onnx/onnx_classifier.h new file mode 100644 index 000000000..c4f3814ce --- /dev/null +++ b/deps/include/brainflow/ml/onnx/onnx_classifier.h @@ -0,0 +1,57 @@ +#pragma once + +#include +#include +#include + +#include "base_classifier.h" +#include "dyn_lib_classifier.h" +#include "onnxruntime_c_api.h" + + +class OnnxClassifier : public BaseClassifier +{ +private: + const OrtApi *ort; + OrtEnv *env; + OrtSessionOptions *session_options; + OrtSession *session; + OrtAllocator *allocator; + + ONNXTensorElementDataType input_type; + std::vector input_node_dims; + std::vector input_node_names; + + ONNXTensorElementDataType output_type; + std::vector output_node_dims; + std::vector output_node_names; + + DLLLoader *dll_loader; + + int load_api (); + int get_input_info (); + int get_output_info (); + std::string get_onnxlib_path (); + + +public: + OnnxClassifier (struct BrainFlowModelParams params) : BaseClassifier (params) + { + ort = NULL; + env = NULL; + session_options = NULL; + session = NULL; + allocator = NULL; + dll_loader = NULL; + } + + ~OnnxClassifier () + { + skip_logs = true; + release (); + } + + int prepare (); + int predict (double *data, int data_len, double *output, int *output_len); + int release (); +}; diff --git a/deps/include/brainflow/ml/regression_model.h b/deps/include/brainflow/ml/regression_model.h deleted file mode 100644 index a8dca7cce..000000000 --- a/deps/include/brainflow/ml/regression_model.h +++ /dev/null @@ -1,5 +0,0 @@ -#pragma once - - -extern const double regression_coefficients[10]; -extern double regression_intercept; diff --git a/deps/include/brainflow/ml/relaxation_knn_classifier.h b/deps/include/brainflow/ml/relaxation_knn_classifier.h deleted file mode 100644 index 367816769..000000000 --- a/deps/include/brainflow/ml/relaxation_knn_classifier.h +++ /dev/null @@ -1,25 +0,0 @@ -#pragma once - -#include "brainflow_constants.h" -#include "concentration_knn_classifier.h" - - -class RelaxationKNNClassifier : public ConcentrationKNNClassifier -{ -public: - RelaxationKNNClassifier (struct BrainFlowModelParams params) - : ConcentrationKNNClassifier (params) - { - } - - int predict (double *data, int data_len, double *output) - { - int res = ConcentrationKNNClassifier::predict (data, data_len, output); - if (res != (int)BrainFlowExitCodes::STATUS_OK) - { - return res; - } - *output = 1.0 - (*output); - return res; - } -}; diff --git a/deps/include/brainflow/ml/relaxation_lda_classifier.h b/deps/include/brainflow/ml/relaxation_lda_classifier.h deleted file mode 100644 index a46cc707d..000000000 --- a/deps/include/brainflow/ml/relaxation_lda_classifier.h +++ /dev/null @@ -1,25 +0,0 @@ -#pragma once - -#include "brainflow_constants.h" -#include "concentration_lda_classifier.h" - - -class RelaxationLDAClassifier : public ConcentrationLDAClassifier -{ -public: - RelaxationLDAClassifier (struct BrainFlowModelParams params) - : ConcentrationLDAClassifier (params) - { - } - - int predict (double *data, int data_len, double *output) - { - int res = ConcentrationLDAClassifier::predict (data, data_len, output); - if (res != (int)BrainFlowExitCodes::STATUS_OK) - { - return res; - } - *output = 1.0 - (*output); - return res; - } -}; diff --git a/deps/include/brainflow/ml/relaxation_regression_classifier.h b/deps/include/brainflow/ml/relaxation_regression_classifier.h deleted file mode 100644 index c6a47d7e8..000000000 --- a/deps/include/brainflow/ml/relaxation_regression_classifier.h +++ /dev/null @@ -1,25 +0,0 @@ -#pragma once - -#include "brainflow_constants.h" -#include "concentration_regression_classifier.h" - - -class RelaxationRegressionClassifier : public ConcentrationRegressionClassifier -{ -public: - RelaxationRegressionClassifier (struct BrainFlowModelParams params) - : ConcentrationRegressionClassifier (params) - { - } - - int predict (double *data, int data_len, double *output) - { - int res = ConcentrationRegressionClassifier::predict (data, data_len, output); - if (res != (int)BrainFlowExitCodes::STATUS_OK) - { - return res; - } - *output = 1.0 - (*output); - return res; - } -}; diff --git a/deps/include/brainflow/ml/relaxation_svm_classifier.h b/deps/include/brainflow/ml/relaxation_svm_classifier.h deleted file mode 100644 index f04273bb2..000000000 --- a/deps/include/brainflow/ml/relaxation_svm_classifier.h +++ /dev/null @@ -1,25 +0,0 @@ -#pragma once - -#include "brainflow_constants.h" -#include "concentration_svm_classifier.h" - - -class RelaxationSVMClassifier : public ConcentrationSVMClassifier -{ -public: - RelaxationSVMClassifier (struct BrainFlowModelParams params) - : ConcentrationSVMClassifier (params) - { - } - - int predict (double *data, int data_len, double *output) - { - int res = ConcentrationSVMClassifier::predict (data, data_len, output); - if (res != (int)BrainFlowExitCodes::STATUS_OK) - { - return res; - } - *output = 1.0 - (*output); - return res; - } -}; diff --git a/deps/include/brainflow/ml/restfulness_classifier.h b/deps/include/brainflow/ml/restfulness_classifier.h new file mode 100644 index 000000000..69e22734a --- /dev/null +++ b/deps/include/brainflow/ml/restfulness_classifier.h @@ -0,0 +1,24 @@ +#pragma once + +#include "brainflow_constants.h" +#include "mindfulness_classifier.h" + + +class RestfulnessClassifier : public MindfulnessClassifier +{ +public: + RestfulnessClassifier (struct BrainFlowModelParams params) : MindfulnessClassifier (params) + { + } + + int predict (double *data, int data_len, double *output, int *output_len) + { + int res = MindfulnessClassifier::predict (data, data_len, output, output_len); + if (res != (int)BrainFlowExitCodes::STATUS_OK) + { + return res; + } + *output = 1.0 - (*output); + return res; + } +}; \ No newline at end of file diff --git a/deps/include/brainflow/third_party/json/json.hpp b/deps/include/brainflow/third_party/json/json.hpp new file mode 100644 index 000000000..7a1aacb55 --- /dev/null +++ b/deps/include/brainflow/third_party/json/json.hpp @@ -0,0 +1,24659 @@ +/* + __ _____ _____ _____ + __| | __| | | | JSON for Modern C++ +| | |__ | | | | | | version 3.7.3 +|_____|_____|_____|_|___| https://github.com/nlohmann/json + +Licensed under the MIT License . +SPDX-License-Identifier: MIT +Copyright (c) 2013-2019 Niels Lohmann . + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ + +#ifndef INCLUDE_NLOHMANN_JSON_HPP_ +#define INCLUDE_NLOHMANN_JSON_HPP_ + +#define NLOHMANN_JSON_VERSION_MAJOR 3 +#define NLOHMANN_JSON_VERSION_MINOR 7 +#define NLOHMANN_JSON_VERSION_PATCH 3 + +#include // all_of, find, for_each +#include // assert +#include // nullptr_t, ptrdiff_t, size_t +#include // hash, less +#include // initializer_list +#include // istream, ostream +#include // random_access_iterator_tag +#include // unique_ptr +#include // accumulate +#include // string, stoi, to_string +#include // declval, forward, move, pair, swap +#include // vector + +// #include + + +#include + +// #include + + +#include // transform +#include // array +#include // forward_list +#include // inserter, front_inserter, end +#include // map +#include // string +#include // tuple, make_tuple +#include // is_arithmetic, is_same, is_enum, underlying_type, is_convertible +#include // unordered_map +#include // pair, declval +#include // valarray + +// #include + + +// Header is removed in C++20. +// See for more information. + +#if __cplusplus <= 201703L + #include // and, not, or +#endif + +// #include + + +#include // exception +#include // runtime_error +#include // to_string + +// #include + + +#include // size_t + +namespace nlohmann +{ +namespace detail +{ +/// struct to capture the start position of the current token +struct position_t +{ + /// the total number of characters read + std::size_t chars_read_total = 0; + /// the number of characters read in the current line + std::size_t chars_read_current_line = 0; + /// the number of lines read + std::size_t lines_read = 0; + + /// conversion to size_t to preserve SAX interface + constexpr operator size_t() const + { + return chars_read_total; + } +}; + +} // namespace detail +} // namespace nlohmann + +// #include + + +#include // pair +// #include +/* Hedley - https://nemequ.github.io/hedley + * Created by Evan Nemerson + * + * To the extent possible under law, the author(s) have dedicated all + * copyright and related and neighboring rights to this software to + * the public domain worldwide. This software is distributed without + * any warranty. + * + * For details, see . + * SPDX-License-Identifier: CC0-1.0 + */ + +#if !defined(JSON_HEDLEY_VERSION) || (JSON_HEDLEY_VERSION < 13) +#if defined(JSON_HEDLEY_VERSION) + #undef JSON_HEDLEY_VERSION +#endif +#define JSON_HEDLEY_VERSION 13 + +#if defined(JSON_HEDLEY_STRINGIFY_EX) + #undef JSON_HEDLEY_STRINGIFY_EX +#endif +#define JSON_HEDLEY_STRINGIFY_EX(x) #x + +#if defined(JSON_HEDLEY_STRINGIFY) + #undef JSON_HEDLEY_STRINGIFY +#endif +#define JSON_HEDLEY_STRINGIFY(x) JSON_HEDLEY_STRINGIFY_EX(x) + +#if defined(JSON_HEDLEY_CONCAT_EX) + #undef JSON_HEDLEY_CONCAT_EX +#endif +#define JSON_HEDLEY_CONCAT_EX(a,b) a##b + +#if defined(JSON_HEDLEY_CONCAT) + #undef JSON_HEDLEY_CONCAT +#endif +#define JSON_HEDLEY_CONCAT(a,b) JSON_HEDLEY_CONCAT_EX(a,b) + +#if defined(JSON_HEDLEY_CONCAT3_EX) + #undef JSON_HEDLEY_CONCAT3_EX +#endif +#define JSON_HEDLEY_CONCAT3_EX(a,b,c) a##b##c + +#if defined(JSON_HEDLEY_CONCAT3) + #undef JSON_HEDLEY_CONCAT3 +#endif +#define JSON_HEDLEY_CONCAT3(a,b,c) JSON_HEDLEY_CONCAT3_EX(a,b,c) + +#if defined(JSON_HEDLEY_VERSION_ENCODE) + #undef JSON_HEDLEY_VERSION_ENCODE +#endif +#define JSON_HEDLEY_VERSION_ENCODE(major,minor,revision) (((major) * 1000000) + ((minor) * 1000) + (revision)) + +#if defined(JSON_HEDLEY_VERSION_DECODE_MAJOR) + #undef JSON_HEDLEY_VERSION_DECODE_MAJOR +#endif +#define JSON_HEDLEY_VERSION_DECODE_MAJOR(version) ((version) / 1000000) + +#if defined(JSON_HEDLEY_VERSION_DECODE_MINOR) + #undef JSON_HEDLEY_VERSION_DECODE_MINOR +#endif +#define JSON_HEDLEY_VERSION_DECODE_MINOR(version) (((version) % 1000000) / 1000) + +#if defined(JSON_HEDLEY_VERSION_DECODE_REVISION) + #undef JSON_HEDLEY_VERSION_DECODE_REVISION +#endif +#define JSON_HEDLEY_VERSION_DECODE_REVISION(version) ((version) % 1000) + +#if defined(JSON_HEDLEY_GNUC_VERSION) + #undef JSON_HEDLEY_GNUC_VERSION +#endif +#if defined(__GNUC__) && defined(__GNUC_PATCHLEVEL__) + #define JSON_HEDLEY_GNUC_VERSION JSON_HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__) +#elif defined(__GNUC__) + #define JSON_HEDLEY_GNUC_VERSION JSON_HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, 0) +#endif + +#if defined(JSON_HEDLEY_GNUC_VERSION_CHECK) + #undef JSON_HEDLEY_GNUC_VERSION_CHECK +#endif +#if defined(JSON_HEDLEY_GNUC_VERSION) + #define JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_GNUC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(JSON_HEDLEY_MSVC_VERSION) + #undef JSON_HEDLEY_MSVC_VERSION +#endif +#if defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 140000000) + #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 10000000, (_MSC_FULL_VER % 10000000) / 100000, (_MSC_FULL_VER % 100000) / 100) +#elif defined(_MSC_FULL_VER) + #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 1000000, (_MSC_FULL_VER % 1000000) / 10000, (_MSC_FULL_VER % 10000) / 10) +#elif defined(_MSC_VER) + #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_VER / 100, _MSC_VER % 100, 0) +#endif + +#if defined(JSON_HEDLEY_MSVC_VERSION_CHECK) + #undef JSON_HEDLEY_MSVC_VERSION_CHECK +#endif +#if !defined(_MSC_VER) + #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (0) +#elif defined(_MSC_VER) && (_MSC_VER >= 1400) + #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 10000000) + (minor * 100000) + (patch))) +#elif defined(_MSC_VER) && (_MSC_VER >= 1200) + #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 1000000) + (minor * 10000) + (patch))) +#else + #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_VER >= ((major * 100) + (minor))) +#endif + +#if defined(JSON_HEDLEY_INTEL_VERSION) + #undef JSON_HEDLEY_INTEL_VERSION +#endif +#if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE) + #define JSON_HEDLEY_INTEL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, __INTEL_COMPILER_UPDATE) +#elif defined(__INTEL_COMPILER) + #define JSON_HEDLEY_INTEL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, 0) +#endif + +#if defined(JSON_HEDLEY_INTEL_VERSION_CHECK) + #undef JSON_HEDLEY_INTEL_VERSION_CHECK +#endif +#if defined(JSON_HEDLEY_INTEL_VERSION) + #define JSON_HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_INTEL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define JSON_HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(JSON_HEDLEY_PGI_VERSION) + #undef JSON_HEDLEY_PGI_VERSION +#endif +#if defined(__PGI) && defined(__PGIC__) && defined(__PGIC_MINOR__) && defined(__PGIC_PATCHLEVEL__) + #define JSON_HEDLEY_PGI_VERSION JSON_HEDLEY_VERSION_ENCODE(__PGIC__, __PGIC_MINOR__, __PGIC_PATCHLEVEL__) +#endif + +#if defined(JSON_HEDLEY_PGI_VERSION_CHECK) + #undef JSON_HEDLEY_PGI_VERSION_CHECK +#endif +#if defined(JSON_HEDLEY_PGI_VERSION) + #define JSON_HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_PGI_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define JSON_HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(JSON_HEDLEY_SUNPRO_VERSION) + #undef JSON_HEDLEY_SUNPRO_VERSION +#endif +#if defined(__SUNPRO_C) && (__SUNPRO_C > 0x1000) + #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((((__SUNPRO_C >> 16) & 0xf) * 10) + ((__SUNPRO_C >> 12) & 0xf), (((__SUNPRO_C >> 8) & 0xf) * 10) + ((__SUNPRO_C >> 4) & 0xf), (__SUNPRO_C & 0xf) * 10) +#elif defined(__SUNPRO_C) + #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((__SUNPRO_C >> 8) & 0xf, (__SUNPRO_C >> 4) & 0xf, (__SUNPRO_C) & 0xf) +#elif defined(__SUNPRO_CC) && (__SUNPRO_CC > 0x1000) + #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((((__SUNPRO_CC >> 16) & 0xf) * 10) + ((__SUNPRO_CC >> 12) & 0xf), (((__SUNPRO_CC >> 8) & 0xf) * 10) + ((__SUNPRO_CC >> 4) & 0xf), (__SUNPRO_CC & 0xf) * 10) +#elif defined(__SUNPRO_CC) + #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((__SUNPRO_CC >> 8) & 0xf, (__SUNPRO_CC >> 4) & 0xf, (__SUNPRO_CC) & 0xf) +#endif + +#if defined(JSON_HEDLEY_SUNPRO_VERSION_CHECK) + #undef JSON_HEDLEY_SUNPRO_VERSION_CHECK +#endif +#if defined(JSON_HEDLEY_SUNPRO_VERSION) + #define JSON_HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_SUNPRO_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define JSON_HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION) + #undef JSON_HEDLEY_EMSCRIPTEN_VERSION +#endif +#if defined(__EMSCRIPTEN__) + #define JSON_HEDLEY_EMSCRIPTEN_VERSION JSON_HEDLEY_VERSION_ENCODE(__EMSCRIPTEN_major__, __EMSCRIPTEN_minor__, __EMSCRIPTEN_tiny__) +#endif + +#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK) + #undef JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK +#endif +#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION) + #define JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_EMSCRIPTEN_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(JSON_HEDLEY_ARM_VERSION) + #undef JSON_HEDLEY_ARM_VERSION +#endif +#if defined(__CC_ARM) && defined(__ARMCOMPILER_VERSION) + #define JSON_HEDLEY_ARM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ARMCOMPILER_VERSION / 1000000, (__ARMCOMPILER_VERSION % 1000000) / 10000, (__ARMCOMPILER_VERSION % 10000) / 100) +#elif defined(__CC_ARM) && defined(__ARMCC_VERSION) + #define JSON_HEDLEY_ARM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ARMCC_VERSION / 1000000, (__ARMCC_VERSION % 1000000) / 10000, (__ARMCC_VERSION % 10000) / 100) +#endif + +#if defined(JSON_HEDLEY_ARM_VERSION_CHECK) + #undef JSON_HEDLEY_ARM_VERSION_CHECK +#endif +#if defined(JSON_HEDLEY_ARM_VERSION) + #define JSON_HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_ARM_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define JSON_HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(JSON_HEDLEY_IBM_VERSION) + #undef JSON_HEDLEY_IBM_VERSION +#endif +#if defined(__ibmxl__) + #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ibmxl_version__, __ibmxl_release__, __ibmxl_modification__) +#elif defined(__xlC__) && defined(__xlC_ver__) + #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, (__xlC_ver__ >> 8) & 0xff) +#elif defined(__xlC__) + #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, 0) +#endif + +#if defined(JSON_HEDLEY_IBM_VERSION_CHECK) + #undef JSON_HEDLEY_IBM_VERSION_CHECK +#endif +#if defined(JSON_HEDLEY_IBM_VERSION) + #define JSON_HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_IBM_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define JSON_HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(JSON_HEDLEY_TI_VERSION) + #undef JSON_HEDLEY_TI_VERSION +#endif +#if \ + defined(__TI_COMPILER_VERSION__) && \ + ( \ + defined(__TMS470__) || defined(__TI_ARM__) || \ + defined(__MSP430__) || \ + defined(__TMS320C2000__) \ + ) +#if (__TI_COMPILER_VERSION__ >= 16000000) + #define JSON_HEDLEY_TI_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) +#endif +#endif + +#if defined(JSON_HEDLEY_TI_VERSION_CHECK) + #undef JSON_HEDLEY_TI_VERSION_CHECK +#endif +#if defined(JSON_HEDLEY_TI_VERSION) + #define JSON_HEDLEY_TI_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define JSON_HEDLEY_TI_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(JSON_HEDLEY_TI_CL2000_VERSION) + #undef JSON_HEDLEY_TI_CL2000_VERSION +#endif +#if defined(__TI_COMPILER_VERSION__) && defined(__TMS320C2000__) + #define JSON_HEDLEY_TI_CL2000_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) +#endif + +#if defined(JSON_HEDLEY_TI_CL2000_VERSION_CHECK) + #undef JSON_HEDLEY_TI_CL2000_VERSION_CHECK +#endif +#if defined(JSON_HEDLEY_TI_CL2000_VERSION) + #define JSON_HEDLEY_TI_CL2000_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL2000_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define JSON_HEDLEY_TI_CL2000_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(JSON_HEDLEY_TI_CL430_VERSION) + #undef JSON_HEDLEY_TI_CL430_VERSION +#endif +#if defined(__TI_COMPILER_VERSION__) && defined(__MSP430__) + #define JSON_HEDLEY_TI_CL430_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) +#endif + +#if defined(JSON_HEDLEY_TI_CL430_VERSION_CHECK) + #undef JSON_HEDLEY_TI_CL430_VERSION_CHECK +#endif +#if defined(JSON_HEDLEY_TI_CL430_VERSION) + #define JSON_HEDLEY_TI_CL430_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL430_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define JSON_HEDLEY_TI_CL430_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(JSON_HEDLEY_TI_ARMCL_VERSION) + #undef JSON_HEDLEY_TI_ARMCL_VERSION +#endif +#if defined(__TI_COMPILER_VERSION__) && (defined(__TMS470__) || defined(__TI_ARM__)) + #define JSON_HEDLEY_TI_ARMCL_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) +#endif + +#if defined(JSON_HEDLEY_TI_ARMCL_VERSION_CHECK) + #undef JSON_HEDLEY_TI_ARMCL_VERSION_CHECK +#endif +#if defined(JSON_HEDLEY_TI_ARMCL_VERSION) + #define JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_ARMCL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(JSON_HEDLEY_TI_CL6X_VERSION) + #undef JSON_HEDLEY_TI_CL6X_VERSION +#endif +#if defined(__TI_COMPILER_VERSION__) && defined(__TMS320C6X__) + #define JSON_HEDLEY_TI_CL6X_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) +#endif + +#if defined(JSON_HEDLEY_TI_CL6X_VERSION_CHECK) + #undef JSON_HEDLEY_TI_CL6X_VERSION_CHECK +#endif +#if defined(JSON_HEDLEY_TI_CL6X_VERSION) + #define JSON_HEDLEY_TI_CL6X_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL6X_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define JSON_HEDLEY_TI_CL6X_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(JSON_HEDLEY_TI_CL7X_VERSION) + #undef JSON_HEDLEY_TI_CL7X_VERSION +#endif +#if defined(__TI_COMPILER_VERSION__) && defined(__C7000__) + #define JSON_HEDLEY_TI_CL7X_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) +#endif + +#if defined(JSON_HEDLEY_TI_CL7X_VERSION_CHECK) + #undef JSON_HEDLEY_TI_CL7X_VERSION_CHECK +#endif +#if defined(JSON_HEDLEY_TI_CL7X_VERSION) + #define JSON_HEDLEY_TI_CL7X_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL7X_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define JSON_HEDLEY_TI_CL7X_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(JSON_HEDLEY_TI_CLPRU_VERSION) + #undef JSON_HEDLEY_TI_CLPRU_VERSION +#endif +#if defined(__TI_COMPILER_VERSION__) && defined(__PRU__) + #define JSON_HEDLEY_TI_CLPRU_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) +#endif + +#if defined(JSON_HEDLEY_TI_CLPRU_VERSION_CHECK) + #undef JSON_HEDLEY_TI_CLPRU_VERSION_CHECK +#endif +#if defined(JSON_HEDLEY_TI_CLPRU_VERSION) + #define JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CLPRU_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(JSON_HEDLEY_CRAY_VERSION) + #undef JSON_HEDLEY_CRAY_VERSION +#endif +#if defined(_CRAYC) + #if defined(_RELEASE_PATCHLEVEL) + #define JSON_HEDLEY_CRAY_VERSION JSON_HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, _RELEASE_PATCHLEVEL) + #else + #define JSON_HEDLEY_CRAY_VERSION JSON_HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, 0) + #endif +#endif + +#if defined(JSON_HEDLEY_CRAY_VERSION_CHECK) + #undef JSON_HEDLEY_CRAY_VERSION_CHECK +#endif +#if defined(JSON_HEDLEY_CRAY_VERSION) + #define JSON_HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_CRAY_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define JSON_HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(JSON_HEDLEY_IAR_VERSION) + #undef JSON_HEDLEY_IAR_VERSION +#endif +#if defined(__IAR_SYSTEMS_ICC__) + #if __VER__ > 1000 + #define JSON_HEDLEY_IAR_VERSION JSON_HEDLEY_VERSION_ENCODE((__VER__ / 1000000), ((__VER__ / 1000) % 1000), (__VER__ % 1000)) + #else + #define JSON_HEDLEY_IAR_VERSION JSON_HEDLEY_VERSION_ENCODE(VER / 100, __VER__ % 100, 0) + #endif +#endif + +#if defined(JSON_HEDLEY_IAR_VERSION_CHECK) + #undef JSON_HEDLEY_IAR_VERSION_CHECK +#endif +#if defined(JSON_HEDLEY_IAR_VERSION) + #define JSON_HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_IAR_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define JSON_HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(JSON_HEDLEY_TINYC_VERSION) + #undef JSON_HEDLEY_TINYC_VERSION +#endif +#if defined(__TINYC__) + #define JSON_HEDLEY_TINYC_VERSION JSON_HEDLEY_VERSION_ENCODE(__TINYC__ / 1000, (__TINYC__ / 100) % 10, __TINYC__ % 100) +#endif + +#if defined(JSON_HEDLEY_TINYC_VERSION_CHECK) + #undef JSON_HEDLEY_TINYC_VERSION_CHECK +#endif +#if defined(JSON_HEDLEY_TINYC_VERSION) + #define JSON_HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TINYC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define JSON_HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(JSON_HEDLEY_DMC_VERSION) + #undef JSON_HEDLEY_DMC_VERSION +#endif +#if defined(__DMC__) + #define JSON_HEDLEY_DMC_VERSION JSON_HEDLEY_VERSION_ENCODE(__DMC__ >> 8, (__DMC__ >> 4) & 0xf, __DMC__ & 0xf) +#endif + +#if defined(JSON_HEDLEY_DMC_VERSION_CHECK) + #undef JSON_HEDLEY_DMC_VERSION_CHECK +#endif +#if defined(JSON_HEDLEY_DMC_VERSION) + #define JSON_HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_DMC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define JSON_HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(JSON_HEDLEY_COMPCERT_VERSION) + #undef JSON_HEDLEY_COMPCERT_VERSION +#endif +#if defined(__COMPCERT_VERSION__) + #define JSON_HEDLEY_COMPCERT_VERSION JSON_HEDLEY_VERSION_ENCODE(__COMPCERT_VERSION__ / 10000, (__COMPCERT_VERSION__ / 100) % 100, __COMPCERT_VERSION__ % 100) +#endif + +#if defined(JSON_HEDLEY_COMPCERT_VERSION_CHECK) + #undef JSON_HEDLEY_COMPCERT_VERSION_CHECK +#endif +#if defined(JSON_HEDLEY_COMPCERT_VERSION) + #define JSON_HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_COMPCERT_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define JSON_HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(JSON_HEDLEY_PELLES_VERSION) + #undef JSON_HEDLEY_PELLES_VERSION +#endif +#if defined(__POCC__) + #define JSON_HEDLEY_PELLES_VERSION JSON_HEDLEY_VERSION_ENCODE(__POCC__ / 100, __POCC__ % 100, 0) +#endif + +#if defined(JSON_HEDLEY_PELLES_VERSION_CHECK) + #undef JSON_HEDLEY_PELLES_VERSION_CHECK +#endif +#if defined(JSON_HEDLEY_PELLES_VERSION) + #define JSON_HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_PELLES_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define JSON_HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(JSON_HEDLEY_GCC_VERSION) + #undef JSON_HEDLEY_GCC_VERSION +#endif +#if \ + defined(JSON_HEDLEY_GNUC_VERSION) && \ + !defined(__clang__) && \ + !defined(JSON_HEDLEY_INTEL_VERSION) && \ + !defined(JSON_HEDLEY_PGI_VERSION) && \ + !defined(JSON_HEDLEY_ARM_VERSION) && \ + !defined(JSON_HEDLEY_TI_VERSION) && \ + !defined(JSON_HEDLEY_TI_ARMCL_VERSION) && \ + !defined(JSON_HEDLEY_TI_CL430_VERSION) && \ + !defined(JSON_HEDLEY_TI_CL2000_VERSION) && \ + !defined(JSON_HEDLEY_TI_CL6X_VERSION) && \ + !defined(JSON_HEDLEY_TI_CL7X_VERSION) && \ + !defined(JSON_HEDLEY_TI_CLPRU_VERSION) && \ + !defined(__COMPCERT__) + #define JSON_HEDLEY_GCC_VERSION JSON_HEDLEY_GNUC_VERSION +#endif + +#if defined(JSON_HEDLEY_GCC_VERSION_CHECK) + #undef JSON_HEDLEY_GCC_VERSION_CHECK +#endif +#if defined(JSON_HEDLEY_GCC_VERSION) + #define JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_GCC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(JSON_HEDLEY_HAS_ATTRIBUTE) + #undef JSON_HEDLEY_HAS_ATTRIBUTE +#endif +#if defined(__has_attribute) + #define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) __has_attribute(attribute) +#else + #define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) (0) +#endif + +#if defined(JSON_HEDLEY_GNUC_HAS_ATTRIBUTE) + #undef JSON_HEDLEY_GNUC_HAS_ATTRIBUTE +#endif +#if defined(__has_attribute) + #define JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) __has_attribute(attribute) +#else + #define JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) +#endif + +#if defined(JSON_HEDLEY_GCC_HAS_ATTRIBUTE) + #undef JSON_HEDLEY_GCC_HAS_ATTRIBUTE +#endif +#if defined(__has_attribute) + #define JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) __has_attribute(attribute) +#else + #define JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) +#endif + +#if defined(JSON_HEDLEY_HAS_CPP_ATTRIBUTE) + #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE +#endif +#if \ + defined(__has_cpp_attribute) && \ + defined(__cplusplus) && \ + (!defined(JSON_HEDLEY_SUNPRO_VERSION) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0)) + #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) __has_cpp_attribute(attribute) +#else + #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) (0) +#endif + +#if defined(JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS) + #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS +#endif +#if !defined(__cplusplus) || !defined(__has_cpp_attribute) + #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) (0) +#elif \ + !defined(JSON_HEDLEY_PGI_VERSION) && \ + !defined(JSON_HEDLEY_IAR_VERSION) && \ + (!defined(JSON_HEDLEY_SUNPRO_VERSION) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0)) && \ + (!defined(JSON_HEDLEY_MSVC_VERSION) || JSON_HEDLEY_MSVC_VERSION_CHECK(19,20,0)) + #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) JSON_HEDLEY_HAS_CPP_ATTRIBUTE(ns::attribute) +#else + #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) (0) +#endif + +#if defined(JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE) + #undef JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE +#endif +#if defined(__has_cpp_attribute) && defined(__cplusplus) + #define JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute) +#else + #define JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) +#endif + +#if defined(JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE) + #undef JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE +#endif +#if defined(__has_cpp_attribute) && defined(__cplusplus) + #define JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute) +#else + #define JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) +#endif + +#if defined(JSON_HEDLEY_HAS_BUILTIN) + #undef JSON_HEDLEY_HAS_BUILTIN +#endif +#if defined(__has_builtin) + #define JSON_HEDLEY_HAS_BUILTIN(builtin) __has_builtin(builtin) +#else + #define JSON_HEDLEY_HAS_BUILTIN(builtin) (0) +#endif + +#if defined(JSON_HEDLEY_GNUC_HAS_BUILTIN) + #undef JSON_HEDLEY_GNUC_HAS_BUILTIN +#endif +#if defined(__has_builtin) + #define JSON_HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin) +#else + #define JSON_HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) +#endif + +#if defined(JSON_HEDLEY_GCC_HAS_BUILTIN) + #undef JSON_HEDLEY_GCC_HAS_BUILTIN +#endif +#if defined(__has_builtin) + #define JSON_HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin) +#else + #define JSON_HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) +#endif + +#if defined(JSON_HEDLEY_HAS_FEATURE) + #undef JSON_HEDLEY_HAS_FEATURE +#endif +#if defined(__has_feature) + #define JSON_HEDLEY_HAS_FEATURE(feature) __has_feature(feature) +#else + #define JSON_HEDLEY_HAS_FEATURE(feature) (0) +#endif + +#if defined(JSON_HEDLEY_GNUC_HAS_FEATURE) + #undef JSON_HEDLEY_GNUC_HAS_FEATURE +#endif +#if defined(__has_feature) + #define JSON_HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature) +#else + #define JSON_HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) +#endif + +#if defined(JSON_HEDLEY_GCC_HAS_FEATURE) + #undef JSON_HEDLEY_GCC_HAS_FEATURE +#endif +#if defined(__has_feature) + #define JSON_HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature) +#else + #define JSON_HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) +#endif + +#if defined(JSON_HEDLEY_HAS_EXTENSION) + #undef JSON_HEDLEY_HAS_EXTENSION +#endif +#if defined(__has_extension) + #define JSON_HEDLEY_HAS_EXTENSION(extension) __has_extension(extension) +#else + #define JSON_HEDLEY_HAS_EXTENSION(extension) (0) +#endif + +#if defined(JSON_HEDLEY_GNUC_HAS_EXTENSION) + #undef JSON_HEDLEY_GNUC_HAS_EXTENSION +#endif +#if defined(__has_extension) + #define JSON_HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension) +#else + #define JSON_HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) +#endif + +#if defined(JSON_HEDLEY_GCC_HAS_EXTENSION) + #undef JSON_HEDLEY_GCC_HAS_EXTENSION +#endif +#if defined(__has_extension) + #define JSON_HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension) +#else + #define JSON_HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) +#endif + +#if defined(JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE) + #undef JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE +#endif +#if defined(__has_declspec_attribute) + #define JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) __has_declspec_attribute(attribute) +#else + #define JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) (0) +#endif + +#if defined(JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE) + #undef JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE +#endif +#if defined(__has_declspec_attribute) + #define JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute) +#else + #define JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) +#endif + +#if defined(JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE) + #undef JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE +#endif +#if defined(__has_declspec_attribute) + #define JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute) +#else + #define JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) +#endif + +#if defined(JSON_HEDLEY_HAS_WARNING) + #undef JSON_HEDLEY_HAS_WARNING +#endif +#if defined(__has_warning) + #define JSON_HEDLEY_HAS_WARNING(warning) __has_warning(warning) +#else + #define JSON_HEDLEY_HAS_WARNING(warning) (0) +#endif + +#if defined(JSON_HEDLEY_GNUC_HAS_WARNING) + #undef JSON_HEDLEY_GNUC_HAS_WARNING +#endif +#if defined(__has_warning) + #define JSON_HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning) +#else + #define JSON_HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) +#endif + +#if defined(JSON_HEDLEY_GCC_HAS_WARNING) + #undef JSON_HEDLEY_GCC_HAS_WARNING +#endif +#if defined(__has_warning) + #define JSON_HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning) +#else + #define JSON_HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) +#endif + +/* JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_ is for + HEDLEY INTERNAL USE ONLY. API subject to change without notice. */ +#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_) + #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_ +#endif +#if defined(__cplusplus) +# if JSON_HEDLEY_HAS_WARNING("-Wc++98-compat") +# if JSON_HEDLEY_HAS_WARNING("-Wc++17-extensions") +# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \ + JSON_HEDLEY_DIAGNOSTIC_PUSH \ + _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \ + _Pragma("clang diagnostic ignored \"-Wc++17-extensions\"") \ + xpr \ + JSON_HEDLEY_DIAGNOSTIC_POP +# else +# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \ + JSON_HEDLEY_DIAGNOSTIC_PUSH \ + _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \ + xpr \ + JSON_HEDLEY_DIAGNOSTIC_POP +# endif +# endif +#endif +#if !defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(x) x +#endif + +#if defined(JSON_HEDLEY_CONST_CAST) + #undef JSON_HEDLEY_CONST_CAST +#endif +#if defined(__cplusplus) +# define JSON_HEDLEY_CONST_CAST(T, expr) (const_cast(expr)) +#elif \ + JSON_HEDLEY_HAS_WARNING("-Wcast-qual") || \ + JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) +# define JSON_HEDLEY_CONST_CAST(T, expr) (__extension__ ({ \ + JSON_HEDLEY_DIAGNOSTIC_PUSH \ + JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL \ + ((T) (expr)); \ + JSON_HEDLEY_DIAGNOSTIC_POP \ + })) +#else +# define JSON_HEDLEY_CONST_CAST(T, expr) ((T) (expr)) +#endif + +#if defined(JSON_HEDLEY_REINTERPRET_CAST) + #undef JSON_HEDLEY_REINTERPRET_CAST +#endif +#if defined(__cplusplus) + #define JSON_HEDLEY_REINTERPRET_CAST(T, expr) (reinterpret_cast(expr)) +#else + #define JSON_HEDLEY_REINTERPRET_CAST(T, expr) ((T) (expr)) +#endif + +#if defined(JSON_HEDLEY_STATIC_CAST) + #undef JSON_HEDLEY_STATIC_CAST +#endif +#if defined(__cplusplus) + #define JSON_HEDLEY_STATIC_CAST(T, expr) (static_cast(expr)) +#else + #define JSON_HEDLEY_STATIC_CAST(T, expr) ((T) (expr)) +#endif + +#if defined(JSON_HEDLEY_CPP_CAST) + #undef JSON_HEDLEY_CPP_CAST +#endif +#if defined(__cplusplus) +# if JSON_HEDLEY_HAS_WARNING("-Wold-style-cast") +# define JSON_HEDLEY_CPP_CAST(T, expr) \ + JSON_HEDLEY_DIAGNOSTIC_PUSH \ + _Pragma("clang diagnostic ignored \"-Wold-style-cast\"") \ + ((T) (expr)) \ + JSON_HEDLEY_DIAGNOSTIC_POP +# elif JSON_HEDLEY_IAR_VERSION_CHECK(8,3,0) +# define JSON_HEDLEY_CPP_CAST(T, expr) \ + JSON_HEDLEY_DIAGNOSTIC_PUSH \ + _Pragma("diag_suppress=Pe137") \ + JSON_HEDLEY_DIAGNOSTIC_POP \ +# else +# define JSON_HEDLEY_CPP_CAST(T, expr) ((T) (expr)) +# endif +#else +# define JSON_HEDLEY_CPP_CAST(T, expr) (expr) +#endif + +#if \ + (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \ + defined(__clang__) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \ + JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ + JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,7,0) || \ + JSON_HEDLEY_TI_CL430_VERSION_CHECK(2,0,1) || \ + JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,1,0) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,0,0) || \ + JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ + JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ + JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0) || \ + JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,17) || \ + JSON_HEDLEY_SUNPRO_VERSION_CHECK(8,0,0) || \ + (JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) && defined(__C99_PRAGMA_OPERATOR)) + #define JSON_HEDLEY_PRAGMA(value) _Pragma(#value) +#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) + #define JSON_HEDLEY_PRAGMA(value) __pragma(value) +#else + #define JSON_HEDLEY_PRAGMA(value) +#endif + +#if defined(JSON_HEDLEY_DIAGNOSTIC_PUSH) + #undef JSON_HEDLEY_DIAGNOSTIC_PUSH +#endif +#if defined(JSON_HEDLEY_DIAGNOSTIC_POP) + #undef JSON_HEDLEY_DIAGNOSTIC_POP +#endif +#if defined(__clang__) + #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push") + #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("clang diagnostic pop") +#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) + #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)") + #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)") +#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0) + #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push") + #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop") +#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) + #define JSON_HEDLEY_DIAGNOSTIC_PUSH __pragma(warning(push)) + #define JSON_HEDLEY_DIAGNOSTIC_POP __pragma(warning(pop)) +#elif JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) + #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("push") + #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("pop") +#elif \ + JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ + JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ + JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,4,0) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,1,0) || \ + JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ + JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) + #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("diag_push") + #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("diag_pop") +#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0) + #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)") + #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)") +#else + #define JSON_HEDLEY_DIAGNOSTIC_PUSH + #define JSON_HEDLEY_DIAGNOSTIC_POP +#endif + +#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED) + #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED +#endif +#if JSON_HEDLEY_HAS_WARNING("-Wdeprecated-declarations") + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"") +#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warning(disable:1478 1786)") +#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444") +#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") +#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:4996)) +#elif \ + JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ + (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ + (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ + (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ + (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ + JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ + JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1291,1718") +#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && !defined(__cplusplus) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,E_DEPRECATED_ATT,E_DEPRECATED_ATT_MESS)") +#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && defined(__cplusplus) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,symdeprecated,symdeprecated2)") +#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress=Pe1444,Pe1215") +#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warn(disable:2241)") +#else + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED +#endif + +#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS) + #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS +#endif +#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas") + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("clang diagnostic ignored \"-Wunknown-pragmas\"") +#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("warning(disable:161)") +#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 1675") +#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("GCC diagnostic ignored \"-Wunknown-pragmas\"") +#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable:4068)) +#elif \ + JSON_HEDLEY_TI_VERSION_CHECK(16,9,0) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) || \ + JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ + JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,3,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163") +#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163") +#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress=Pe161") +#else + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS +#endif + +#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES) + #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES +#endif +#if JSON_HEDLEY_HAS_WARNING("-Wunknown-attributes") + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("clang diagnostic ignored \"-Wunknown-attributes\"") +#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") +#elif JSON_HEDLEY_INTEL_VERSION_CHECK(17,0,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("warning(disable:1292)") +#elif JSON_HEDLEY_MSVC_VERSION_CHECK(19,0,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES __pragma(warning(disable:5030)) +#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097") +#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("error_messages(off,attrskipunsup)") +#elif \ + JSON_HEDLEY_TI_VERSION_CHECK(18,1,0) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,3,0) || \ + JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1173") +#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress=Pe1097") +#else + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES +#endif + +#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL) + #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL +#endif +#if JSON_HEDLEY_HAS_WARNING("-Wcast-qual") + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("clang diagnostic ignored \"-Wcast-qual\"") +#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("warning(disable:2203 2331)") +#elif JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("GCC diagnostic ignored \"-Wcast-qual\"") +#else + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL +#endif + +#if defined(JSON_HEDLEY_DEPRECATED) + #undef JSON_HEDLEY_DEPRECATED +#endif +#if defined(JSON_HEDLEY_DEPRECATED_FOR) + #undef JSON_HEDLEY_DEPRECATED_FOR +#endif +#if JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) + #define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated("Since " # since)) + #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated("Since " #since "; use " #replacement)) +#elif defined(__cplusplus) && (__cplusplus >= 201402L) + #define JSON_HEDLEY_DEPRECATED(since) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since)]]) + #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since "; use " #replacement)]]) +#elif \ + JSON_HEDLEY_HAS_EXTENSION(attribute_deprecated_with_message) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \ + JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) || \ + JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \ + JSON_HEDLEY_TI_VERSION_CHECK(18,1,0) || \ + JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(18,1,0) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,3,0) || \ + JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ + JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,3,0) + #define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__("Since " #since))) + #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__("Since " #since "; use " #replacement))) +#elif \ + JSON_HEDLEY_HAS_ATTRIBUTE(deprecated) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ + (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ + (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ + (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ + (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ + JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ + JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) + #define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__)) + #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__)) +#elif \ + JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \ + JSON_HEDLEY_PELLES_VERSION_CHECK(6,50,0) + #define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated) + #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated) +#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) + #define JSON_HEDLEY_DEPRECATED(since) _Pragma("deprecated") + #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) _Pragma("deprecated") +#else + #define JSON_HEDLEY_DEPRECATED(since) + #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) +#endif + +#if defined(JSON_HEDLEY_UNAVAILABLE) + #undef JSON_HEDLEY_UNAVAILABLE +#endif +#if \ + JSON_HEDLEY_HAS_ATTRIBUTE(warning) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) + #define JSON_HEDLEY_UNAVAILABLE(available_since) __attribute__((__warning__("Not available until " #available_since))) +#else + #define JSON_HEDLEY_UNAVAILABLE(available_since) +#endif + +#if defined(JSON_HEDLEY_WARN_UNUSED_RESULT) + #undef JSON_HEDLEY_WARN_UNUSED_RESULT +#endif +#if defined(JSON_HEDLEY_WARN_UNUSED_RESULT_MSG) + #undef JSON_HEDLEY_WARN_UNUSED_RESULT_MSG +#endif +#if (JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard) >= 201907L) + #define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]]) + #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard(msg)]]) +#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard) + #define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]]) + #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]]) +#elif \ + JSON_HEDLEY_HAS_ATTRIBUTE(warn_unused_result) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ + (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ + (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ + (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ + (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ + JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ + JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ + (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \ + JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) + #define JSON_HEDLEY_WARN_UNUSED_RESULT __attribute__((__warn_unused_result__)) + #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) __attribute__((__warn_unused_result__)) +#elif defined(_Check_return_) /* SAL */ + #define JSON_HEDLEY_WARN_UNUSED_RESULT _Check_return_ + #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) _Check_return_ +#else + #define JSON_HEDLEY_WARN_UNUSED_RESULT + #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) +#endif + +#if defined(JSON_HEDLEY_SENTINEL) + #undef JSON_HEDLEY_SENTINEL +#endif +#if \ + JSON_HEDLEY_HAS_ATTRIBUTE(sentinel) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(5,4,0) + #define JSON_HEDLEY_SENTINEL(position) __attribute__((__sentinel__(position))) +#else + #define JSON_HEDLEY_SENTINEL(position) +#endif + +#if defined(JSON_HEDLEY_NO_RETURN) + #undef JSON_HEDLEY_NO_RETURN +#endif +#if JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) + #define JSON_HEDLEY_NO_RETURN __noreturn +#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) + #define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__)) +#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L + #define JSON_HEDLEY_NO_RETURN _Noreturn +#elif defined(__cplusplus) && (__cplusplus >= 201103L) + #define JSON_HEDLEY_NO_RETURN JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[noreturn]]) +#elif \ + JSON_HEDLEY_HAS_ATTRIBUTE(noreturn) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(3,2,0) || \ + JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ + JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ + (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ + (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ + (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ + (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ + JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ + JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) + #define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__)) +#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) + #define JSON_HEDLEY_NO_RETURN _Pragma("does_not_return") +#elif JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) + #define JSON_HEDLEY_NO_RETURN __declspec(noreturn) +#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,0,0) && defined(__cplusplus) + #define JSON_HEDLEY_NO_RETURN _Pragma("FUNC_NEVER_RETURNS;") +#elif JSON_HEDLEY_COMPCERT_VERSION_CHECK(3,2,0) + #define JSON_HEDLEY_NO_RETURN __attribute((noreturn)) +#elif JSON_HEDLEY_PELLES_VERSION_CHECK(9,0,0) + #define JSON_HEDLEY_NO_RETURN __declspec(noreturn) +#else + #define JSON_HEDLEY_NO_RETURN +#endif + +#if defined(JSON_HEDLEY_NO_ESCAPE) + #undef JSON_HEDLEY_NO_ESCAPE +#endif +#if JSON_HEDLEY_HAS_ATTRIBUTE(noescape) + #define JSON_HEDLEY_NO_ESCAPE __attribute__((__noescape__)) +#else + #define JSON_HEDLEY_NO_ESCAPE +#endif + +#if defined(JSON_HEDLEY_UNREACHABLE) + #undef JSON_HEDLEY_UNREACHABLE +#endif +#if defined(JSON_HEDLEY_UNREACHABLE_RETURN) + #undef JSON_HEDLEY_UNREACHABLE_RETURN +#endif +#if defined(JSON_HEDLEY_ASSUME) + #undef JSON_HEDLEY_ASSUME +#endif +#if \ + JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) + #define JSON_HEDLEY_ASSUME(expr) __assume(expr) +#elif JSON_HEDLEY_HAS_BUILTIN(__builtin_assume) + #define JSON_HEDLEY_ASSUME(expr) __builtin_assume(expr) +#elif \ + JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0) + #if defined(__cplusplus) + #define JSON_HEDLEY_ASSUME(expr) std::_nassert(expr) + #else + #define JSON_HEDLEY_ASSUME(expr) _nassert(expr) + #endif +#endif +#if \ + (JSON_HEDLEY_HAS_BUILTIN(__builtin_unreachable) && (!defined(JSON_HEDLEY_ARM_VERSION))) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \ + JSON_HEDLEY_PGI_VERSION_CHECK(18,10,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_IBM_VERSION_CHECK(13,1,5) + #define JSON_HEDLEY_UNREACHABLE() __builtin_unreachable() +#elif defined(JSON_HEDLEY_ASSUME) + #define JSON_HEDLEY_UNREACHABLE() JSON_HEDLEY_ASSUME(0) +#endif +#if !defined(JSON_HEDLEY_ASSUME) + #if defined(JSON_HEDLEY_UNREACHABLE) + #define JSON_HEDLEY_ASSUME(expr) JSON_HEDLEY_STATIC_CAST(void, ((expr) ? 1 : (JSON_HEDLEY_UNREACHABLE(), 1))) + #else + #define JSON_HEDLEY_ASSUME(expr) JSON_HEDLEY_STATIC_CAST(void, expr) + #endif +#endif +#if defined(JSON_HEDLEY_UNREACHABLE) + #if \ + JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0) + #define JSON_HEDLEY_UNREACHABLE_RETURN(value) return (JSON_HEDLEY_STATIC_CAST(void, JSON_HEDLEY_ASSUME(0)), (value)) + #else + #define JSON_HEDLEY_UNREACHABLE_RETURN(value) JSON_HEDLEY_UNREACHABLE() + #endif +#else + #define JSON_HEDLEY_UNREACHABLE_RETURN(value) return (value) +#endif +#if !defined(JSON_HEDLEY_UNREACHABLE) + #define JSON_HEDLEY_UNREACHABLE() JSON_HEDLEY_ASSUME(0) +#endif + +JSON_HEDLEY_DIAGNOSTIC_PUSH +#if JSON_HEDLEY_HAS_WARNING("-Wpedantic") + #pragma clang diagnostic ignored "-Wpedantic" +#endif +#if JSON_HEDLEY_HAS_WARNING("-Wc++98-compat-pedantic") && defined(__cplusplus) + #pragma clang diagnostic ignored "-Wc++98-compat-pedantic" +#endif +#if JSON_HEDLEY_GCC_HAS_WARNING("-Wvariadic-macros",4,0,0) + #if defined(__clang__) + #pragma clang diagnostic ignored "-Wvariadic-macros" + #elif defined(JSON_HEDLEY_GCC_VERSION) + #pragma GCC diagnostic ignored "-Wvariadic-macros" + #endif +#endif +#if defined(JSON_HEDLEY_NON_NULL) + #undef JSON_HEDLEY_NON_NULL +#endif +#if \ + JSON_HEDLEY_HAS_ATTRIBUTE(nonnull) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) + #define JSON_HEDLEY_NON_NULL(...) __attribute__((__nonnull__(__VA_ARGS__))) +#else + #define JSON_HEDLEY_NON_NULL(...) +#endif +JSON_HEDLEY_DIAGNOSTIC_POP + +#if defined(JSON_HEDLEY_PRINTF_FORMAT) + #undef JSON_HEDLEY_PRINTF_FORMAT +#endif +#if defined(__MINGW32__) && JSON_HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && !defined(__USE_MINGW_ANSI_STDIO) + #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(ms_printf, string_idx, first_to_check))) +#elif defined(__MINGW32__) && JSON_HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && defined(__USE_MINGW_ANSI_STDIO) + #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(gnu_printf, string_idx, first_to_check))) +#elif \ + JSON_HEDLEY_HAS_ATTRIBUTE(format) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \ + JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ + JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ + (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ + (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ + (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ + (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ + JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ + JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) + #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(__printf__, string_idx, first_to_check))) +#elif JSON_HEDLEY_PELLES_VERSION_CHECK(6,0,0) + #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __declspec(vaformat(printf,string_idx,first_to_check)) +#else + #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) +#endif + +#if defined(JSON_HEDLEY_CONSTEXPR) + #undef JSON_HEDLEY_CONSTEXPR +#endif +#if defined(__cplusplus) + #if __cplusplus >= 201103L + #define JSON_HEDLEY_CONSTEXPR JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(constexpr) + #endif +#endif +#if !defined(JSON_HEDLEY_CONSTEXPR) + #define JSON_HEDLEY_CONSTEXPR +#endif + +#if defined(JSON_HEDLEY_PREDICT) + #undef JSON_HEDLEY_PREDICT +#endif +#if defined(JSON_HEDLEY_LIKELY) + #undef JSON_HEDLEY_LIKELY +#endif +#if defined(JSON_HEDLEY_UNLIKELY) + #undef JSON_HEDLEY_UNLIKELY +#endif +#if defined(JSON_HEDLEY_UNPREDICTABLE) + #undef JSON_HEDLEY_UNPREDICTABLE +#endif +#if JSON_HEDLEY_HAS_BUILTIN(__builtin_unpredictable) + #define JSON_HEDLEY_UNPREDICTABLE(expr) __builtin_unpredictable((expr)) +#endif +#if \ + JSON_HEDLEY_HAS_BUILTIN(__builtin_expect_with_probability) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(9,0,0) +# define JSON_HEDLEY_PREDICT(expr, value, probability) __builtin_expect_with_probability( (expr), (value), (probability)) +# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) __builtin_expect_with_probability(!!(expr), 1 , (probability)) +# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) __builtin_expect_with_probability(!!(expr), 0 , (probability)) +# define JSON_HEDLEY_LIKELY(expr) __builtin_expect (!!(expr), 1 ) +# define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect (!!(expr), 0 ) +#elif \ + JSON_HEDLEY_HAS_BUILTIN(__builtin_expect) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ + JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ + JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,7,0) || \ + JSON_HEDLEY_TI_CL430_VERSION_CHECK(3,1,0) || \ + JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,1,0) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \ + JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ + JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ + JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,27) || \ + JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) +# define JSON_HEDLEY_PREDICT(expr, expected, probability) \ + (((probability) >= 0.9) ? __builtin_expect((expr), (expected)) : (JSON_HEDLEY_STATIC_CAST(void, expected), (expr))) +# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) \ + (__extension__ ({ \ + double hedley_probability_ = (probability); \ + ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 1) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 0) : !!(expr))); \ + })) +# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) \ + (__extension__ ({ \ + double hedley_probability_ = (probability); \ + ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 0) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 1) : !!(expr))); \ + })) +# define JSON_HEDLEY_LIKELY(expr) __builtin_expect(!!(expr), 1) +# define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect(!!(expr), 0) +#else +# define JSON_HEDLEY_PREDICT(expr, expected, probability) (JSON_HEDLEY_STATIC_CAST(void, expected), (expr)) +# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) (!!(expr)) +# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) (!!(expr)) +# define JSON_HEDLEY_LIKELY(expr) (!!(expr)) +# define JSON_HEDLEY_UNLIKELY(expr) (!!(expr)) +#endif +#if !defined(JSON_HEDLEY_UNPREDICTABLE) + #define JSON_HEDLEY_UNPREDICTABLE(expr) JSON_HEDLEY_PREDICT(expr, 1, 0.5) +#endif + +#if defined(JSON_HEDLEY_MALLOC) + #undef JSON_HEDLEY_MALLOC +#endif +#if \ + JSON_HEDLEY_HAS_ATTRIBUTE(malloc) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \ + JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ + (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ + (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ + (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ + (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ + JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ + JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) + #define JSON_HEDLEY_MALLOC __attribute__((__malloc__)) +#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) + #define JSON_HEDLEY_MALLOC _Pragma("returns_new_memory") +#elif JSON_HEDLEY_MSVC_VERSION_CHECK(14, 0, 0) + #define JSON_HEDLEY_MALLOC __declspec(restrict) +#else + #define JSON_HEDLEY_MALLOC +#endif + +#if defined(JSON_HEDLEY_PURE) + #undef JSON_HEDLEY_PURE +#endif +#if \ + JSON_HEDLEY_HAS_ATTRIBUTE(pure) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(2,96,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ + JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ + (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ + (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ + (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ + (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ + JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ + JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ + JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) +# define JSON_HEDLEY_PURE __attribute__((__pure__)) +#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) +# define JSON_HEDLEY_PURE _Pragma("does_not_write_global_data") +#elif defined(__cplusplus) && \ + ( \ + JSON_HEDLEY_TI_CL430_VERSION_CHECK(2,0,1) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0) || \ + JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) \ + ) +# define JSON_HEDLEY_PURE _Pragma("FUNC_IS_PURE;") +#else +# define JSON_HEDLEY_PURE +#endif + +#if defined(JSON_HEDLEY_CONST) + #undef JSON_HEDLEY_CONST +#endif +#if \ + JSON_HEDLEY_HAS_ATTRIBUTE(const) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(2,5,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ + JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ + (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ + (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ + (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ + (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ + JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ + JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ + JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) + #define JSON_HEDLEY_CONST __attribute__((__const__)) +#elif \ + JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) + #define JSON_HEDLEY_CONST _Pragma("no_side_effect") +#else + #define JSON_HEDLEY_CONST JSON_HEDLEY_PURE +#endif + +#if defined(JSON_HEDLEY_RESTRICT) + #undef JSON_HEDLEY_RESTRICT +#endif +#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && !defined(__cplusplus) + #define JSON_HEDLEY_RESTRICT restrict +#elif \ + JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ + JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ + JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \ + JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ + JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,4) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,1,0) || \ + JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ + (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus)) || \ + JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \ + defined(__clang__) + #define JSON_HEDLEY_RESTRICT __restrict +#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,3,0) && !defined(__cplusplus) + #define JSON_HEDLEY_RESTRICT _Restrict +#else + #define JSON_HEDLEY_RESTRICT +#endif + +#if defined(JSON_HEDLEY_INLINE) + #undef JSON_HEDLEY_INLINE +#endif +#if \ + (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \ + (defined(__cplusplus) && (__cplusplus >= 199711L)) + #define JSON_HEDLEY_INLINE inline +#elif \ + defined(JSON_HEDLEY_GCC_VERSION) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(6,2,0) + #define JSON_HEDLEY_INLINE __inline__ +#elif \ + JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,1,0) || \ + JSON_HEDLEY_TI_CL430_VERSION_CHECK(3,1,0) || \ + JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) || \ + JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ + JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) + #define JSON_HEDLEY_INLINE __inline +#else + #define JSON_HEDLEY_INLINE +#endif + +#if defined(JSON_HEDLEY_ALWAYS_INLINE) + #undef JSON_HEDLEY_ALWAYS_INLINE +#endif +#if \ + JSON_HEDLEY_HAS_ATTRIBUTE(always_inline) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ + JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ + (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ + (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ + (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ + (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ + JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ + JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) +# define JSON_HEDLEY_ALWAYS_INLINE __attribute__((__always_inline__)) JSON_HEDLEY_INLINE +#elif JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) +# define JSON_HEDLEY_ALWAYS_INLINE __forceinline +#elif defined(__cplusplus) && \ + ( \ + JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ + JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ + JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \ + JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ + JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) \ + ) +# define JSON_HEDLEY_ALWAYS_INLINE _Pragma("FUNC_ALWAYS_INLINE;") +#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) +# define JSON_HEDLEY_ALWAYS_INLINE _Pragma("inline=forced") +#else +# define JSON_HEDLEY_ALWAYS_INLINE JSON_HEDLEY_INLINE +#endif + +#if defined(JSON_HEDLEY_NEVER_INLINE) + #undef JSON_HEDLEY_NEVER_INLINE +#endif +#if \ + JSON_HEDLEY_HAS_ATTRIBUTE(noinline) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ + JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ + (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ + (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ + (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ + (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ + JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ + JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) + #define JSON_HEDLEY_NEVER_INLINE __attribute__((__noinline__)) +#elif JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) + #define JSON_HEDLEY_NEVER_INLINE __declspec(noinline) +#elif JSON_HEDLEY_PGI_VERSION_CHECK(10,2,0) + #define JSON_HEDLEY_NEVER_INLINE _Pragma("noinline") +#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,0,0) && defined(__cplusplus) + #define JSON_HEDLEY_NEVER_INLINE _Pragma("FUNC_CANNOT_INLINE;") +#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) + #define JSON_HEDLEY_NEVER_INLINE _Pragma("inline=never") +#elif JSON_HEDLEY_COMPCERT_VERSION_CHECK(3,2,0) + #define JSON_HEDLEY_NEVER_INLINE __attribute((noinline)) +#elif JSON_HEDLEY_PELLES_VERSION_CHECK(9,0,0) + #define JSON_HEDLEY_NEVER_INLINE __declspec(noinline) +#else + #define JSON_HEDLEY_NEVER_INLINE +#endif + +#if defined(JSON_HEDLEY_PRIVATE) + #undef JSON_HEDLEY_PRIVATE +#endif +#if defined(JSON_HEDLEY_PUBLIC) + #undef JSON_HEDLEY_PUBLIC +#endif +#if defined(JSON_HEDLEY_IMPORT) + #undef JSON_HEDLEY_IMPORT +#endif +#if defined(_WIN32) || defined(__CYGWIN__) +# define JSON_HEDLEY_PRIVATE +# define JSON_HEDLEY_PUBLIC __declspec(dllexport) +# define JSON_HEDLEY_IMPORT __declspec(dllimport) +#else +# if \ + JSON_HEDLEY_HAS_ATTRIBUTE(visibility) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \ + JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \ + ( \ + defined(__TI_EABI__) && \ + ( \ + (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) \ + ) \ + ) +# define JSON_HEDLEY_PRIVATE __attribute__((__visibility__("hidden"))) +# define JSON_HEDLEY_PUBLIC __attribute__((__visibility__("default"))) +# else +# define JSON_HEDLEY_PRIVATE +# define JSON_HEDLEY_PUBLIC +# endif +# define JSON_HEDLEY_IMPORT extern +#endif + +#if defined(JSON_HEDLEY_NO_THROW) + #undef JSON_HEDLEY_NO_THROW +#endif +#if \ + JSON_HEDLEY_HAS_ATTRIBUTE(nothrow) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) + #define JSON_HEDLEY_NO_THROW __attribute__((__nothrow__)) +#elif \ + JSON_HEDLEY_MSVC_VERSION_CHECK(13,1,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) + #define JSON_HEDLEY_NO_THROW __declspec(nothrow) +#else + #define JSON_HEDLEY_NO_THROW +#endif + +#if defined(JSON_HEDLEY_FALL_THROUGH) + #undef JSON_HEDLEY_FALL_THROUGH +#endif +#if \ + JSON_HEDLEY_HAS_ATTRIBUTE(fallthrough) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(7,0,0) + #define JSON_HEDLEY_FALL_THROUGH __attribute__((__fallthrough__)) +#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(clang,fallthrough) + #define JSON_HEDLEY_FALL_THROUGH JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[clang::fallthrough]]) +#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE(fallthrough) + #define JSON_HEDLEY_FALL_THROUGH JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[fallthrough]]) +#elif defined(__fallthrough) /* SAL */ + #define JSON_HEDLEY_FALL_THROUGH __fallthrough +#else + #define JSON_HEDLEY_FALL_THROUGH +#endif + +#if defined(JSON_HEDLEY_RETURNS_NON_NULL) + #undef JSON_HEDLEY_RETURNS_NON_NULL +#endif +#if \ + JSON_HEDLEY_HAS_ATTRIBUTE(returns_nonnull) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) + #define JSON_HEDLEY_RETURNS_NON_NULL __attribute__((__returns_nonnull__)) +#elif defined(_Ret_notnull_) /* SAL */ + #define JSON_HEDLEY_RETURNS_NON_NULL _Ret_notnull_ +#else + #define JSON_HEDLEY_RETURNS_NON_NULL +#endif + +#if defined(JSON_HEDLEY_ARRAY_PARAM) + #undef JSON_HEDLEY_ARRAY_PARAM +#endif +#if \ + defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && \ + !defined(__STDC_NO_VLA__) && \ + !defined(__cplusplus) && \ + !defined(JSON_HEDLEY_PGI_VERSION) && \ + !defined(JSON_HEDLEY_TINYC_VERSION) + #define JSON_HEDLEY_ARRAY_PARAM(name) (name) +#else + #define JSON_HEDLEY_ARRAY_PARAM(name) +#endif + +#if defined(JSON_HEDLEY_IS_CONSTANT) + #undef JSON_HEDLEY_IS_CONSTANT +#endif +#if defined(JSON_HEDLEY_REQUIRE_CONSTEXPR) + #undef JSON_HEDLEY_REQUIRE_CONSTEXPR +#endif +/* JSON_HEDLEY_IS_CONSTEXPR_ is for + HEDLEY INTERNAL USE ONLY. API subject to change without notice. */ +#if defined(JSON_HEDLEY_IS_CONSTEXPR_) + #undef JSON_HEDLEY_IS_CONSTEXPR_ +#endif +#if \ + JSON_HEDLEY_HAS_BUILTIN(__builtin_constant_p) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,19) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \ + (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) && !defined(__cplusplus)) || \ + JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) + #define JSON_HEDLEY_IS_CONSTANT(expr) __builtin_constant_p(expr) +#endif +#if !defined(__cplusplus) +# if \ + JSON_HEDLEY_HAS_BUILTIN(__builtin_types_compatible_p) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \ + JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(5,4,0) || \ + JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,24) +#if defined(__INTPTR_TYPE__) + #define JSON_HEDLEY_IS_CONSTEXPR_(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0)), int*) +#else + #include + #define JSON_HEDLEY_IS_CONSTEXPR_(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((intptr_t) ((expr) * 0)) : (int*) 0)), int*) +#endif +# elif \ + ( \ + defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) && \ + !defined(JSON_HEDLEY_SUNPRO_VERSION) && \ + !defined(JSON_HEDLEY_PGI_VERSION) && \ + !defined(JSON_HEDLEY_IAR_VERSION)) || \ + JSON_HEDLEY_HAS_EXTENSION(c_generic_selections) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(17,0,0) || \ + JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(5,3,0) +#if defined(__INTPTR_TYPE__) + #define JSON_HEDLEY_IS_CONSTEXPR_(expr) _Generic((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0), int*: 1, void*: 0) +#else + #include + #define JSON_HEDLEY_IS_CONSTEXPR_(expr) _Generic((1 ? (void*) ((intptr_t) * 0) : (int*) 0), int*: 1, void*: 0) +#endif +# elif \ + defined(JSON_HEDLEY_GCC_VERSION) || \ + defined(JSON_HEDLEY_INTEL_VERSION) || \ + defined(JSON_HEDLEY_TINYC_VERSION) || \ + defined(JSON_HEDLEY_TI_ARMCL_VERSION) || \ + JSON_HEDLEY_TI_CL430_VERSION_CHECK(18,12,0) || \ + defined(JSON_HEDLEY_TI_CL2000_VERSION) || \ + defined(JSON_HEDLEY_TI_CL6X_VERSION) || \ + defined(JSON_HEDLEY_TI_CL7X_VERSION) || \ + defined(JSON_HEDLEY_TI_CLPRU_VERSION) || \ + defined(__clang__) +# define JSON_HEDLEY_IS_CONSTEXPR_(expr) ( \ + sizeof(void) != \ + sizeof(*( \ + 1 ? \ + ((void*) ((expr) * 0L) ) : \ +((struct { char v[sizeof(void) * 2]; } *) 1) \ + ) \ + ) \ + ) +# endif +#endif +#if defined(JSON_HEDLEY_IS_CONSTEXPR_) + #if !defined(JSON_HEDLEY_IS_CONSTANT) + #define JSON_HEDLEY_IS_CONSTANT(expr) JSON_HEDLEY_IS_CONSTEXPR_(expr) + #endif + #define JSON_HEDLEY_REQUIRE_CONSTEXPR(expr) (JSON_HEDLEY_IS_CONSTEXPR_(expr) ? (expr) : (-1)) +#else + #if !defined(JSON_HEDLEY_IS_CONSTANT) + #define JSON_HEDLEY_IS_CONSTANT(expr) (0) + #endif + #define JSON_HEDLEY_REQUIRE_CONSTEXPR(expr) (expr) +#endif + +#if defined(JSON_HEDLEY_BEGIN_C_DECLS) + #undef JSON_HEDLEY_BEGIN_C_DECLS +#endif +#if defined(JSON_HEDLEY_END_C_DECLS) + #undef JSON_HEDLEY_END_C_DECLS +#endif +#if defined(JSON_HEDLEY_C_DECL) + #undef JSON_HEDLEY_C_DECL +#endif +#if defined(__cplusplus) + #define JSON_HEDLEY_BEGIN_C_DECLS extern "C" { + #define JSON_HEDLEY_END_C_DECLS } + #define JSON_HEDLEY_C_DECL extern "C" +#else + #define JSON_HEDLEY_BEGIN_C_DECLS + #define JSON_HEDLEY_END_C_DECLS + #define JSON_HEDLEY_C_DECL +#endif + +#if defined(JSON_HEDLEY_STATIC_ASSERT) + #undef JSON_HEDLEY_STATIC_ASSERT +#endif +#if \ + !defined(__cplusplus) && ( \ + (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)) || \ + JSON_HEDLEY_HAS_FEATURE(c_static_assert) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(6,0,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + defined(_Static_assert) \ + ) +# define JSON_HEDLEY_STATIC_ASSERT(expr, message) _Static_assert(expr, message) +#elif \ + (defined(__cplusplus) && (__cplusplus >= 201103L)) || \ + JSON_HEDLEY_MSVC_VERSION_CHECK(16,0,0) +# define JSON_HEDLEY_STATIC_ASSERT(expr, message) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(static_assert(expr, message)) +#else +# define JSON_HEDLEY_STATIC_ASSERT(expr, message) +#endif + +#if defined(JSON_HEDLEY_NULL) + #undef JSON_HEDLEY_NULL +#endif +#if defined(__cplusplus) + #if __cplusplus >= 201103L + #define JSON_HEDLEY_NULL JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(nullptr) + #elif defined(NULL) + #define JSON_HEDLEY_NULL NULL + #else + #define JSON_HEDLEY_NULL JSON_HEDLEY_STATIC_CAST(void*, 0) + #endif +#elif defined(NULL) + #define JSON_HEDLEY_NULL NULL +#else + #define JSON_HEDLEY_NULL ((void*) 0) +#endif + +#if defined(JSON_HEDLEY_MESSAGE) + #undef JSON_HEDLEY_MESSAGE +#endif +#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas") +# define JSON_HEDLEY_MESSAGE(msg) \ + JSON_HEDLEY_DIAGNOSTIC_PUSH \ + JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \ + JSON_HEDLEY_PRAGMA(message msg) \ + JSON_HEDLEY_DIAGNOSTIC_POP +#elif \ + JSON_HEDLEY_GCC_VERSION_CHECK(4,4,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) +# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message msg) +#elif JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0) +# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(_CRI message msg) +#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) +# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message(msg)) +#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,0,0) +# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message(msg)) +#else +# define JSON_HEDLEY_MESSAGE(msg) +#endif + +#if defined(JSON_HEDLEY_WARNING) + #undef JSON_HEDLEY_WARNING +#endif +#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas") +# define JSON_HEDLEY_WARNING(msg) \ + JSON_HEDLEY_DIAGNOSTIC_PUSH \ + JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \ + JSON_HEDLEY_PRAGMA(clang warning msg) \ + JSON_HEDLEY_DIAGNOSTIC_POP +#elif \ + JSON_HEDLEY_GCC_VERSION_CHECK(4,8,0) || \ + JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) +# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(GCC warning msg) +#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) +# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(message(msg)) +#else +# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_MESSAGE(msg) +#endif + +#if defined(JSON_HEDLEY_REQUIRE) + #undef JSON_HEDLEY_REQUIRE +#endif +#if defined(JSON_HEDLEY_REQUIRE_MSG) + #undef JSON_HEDLEY_REQUIRE_MSG +#endif +#if JSON_HEDLEY_HAS_ATTRIBUTE(diagnose_if) +# if JSON_HEDLEY_HAS_WARNING("-Wgcc-compat") +# define JSON_HEDLEY_REQUIRE(expr) \ + JSON_HEDLEY_DIAGNOSTIC_PUSH \ + _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \ + __attribute__((diagnose_if(!(expr), #expr, "error"))) \ + JSON_HEDLEY_DIAGNOSTIC_POP +# define JSON_HEDLEY_REQUIRE_MSG(expr,msg) \ + JSON_HEDLEY_DIAGNOSTIC_PUSH \ + _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \ + __attribute__((diagnose_if(!(expr), msg, "error"))) \ + JSON_HEDLEY_DIAGNOSTIC_POP +# else +# define JSON_HEDLEY_REQUIRE(expr) __attribute__((diagnose_if(!(expr), #expr, "error"))) +# define JSON_HEDLEY_REQUIRE_MSG(expr,msg) __attribute__((diagnose_if(!(expr), msg, "error"))) +# endif +#else +# define JSON_HEDLEY_REQUIRE(expr) +# define JSON_HEDLEY_REQUIRE_MSG(expr,msg) +#endif + +#if defined(JSON_HEDLEY_FLAGS) + #undef JSON_HEDLEY_FLAGS +#endif +#if JSON_HEDLEY_HAS_ATTRIBUTE(flag_enum) + #define JSON_HEDLEY_FLAGS __attribute__((__flag_enum__)) +#endif + +#if defined(JSON_HEDLEY_FLAGS_CAST) + #undef JSON_HEDLEY_FLAGS_CAST +#endif +#if JSON_HEDLEY_INTEL_VERSION_CHECK(19,0,0) +# define JSON_HEDLEY_FLAGS_CAST(T, expr) (__extension__ ({ \ + JSON_HEDLEY_DIAGNOSTIC_PUSH \ + _Pragma("warning(disable:188)") \ + ((T) (expr)); \ + JSON_HEDLEY_DIAGNOSTIC_POP \ + })) +#else +# define JSON_HEDLEY_FLAGS_CAST(T, expr) JSON_HEDLEY_STATIC_CAST(T, expr) +#endif + +#if defined(JSON_HEDLEY_EMPTY_BASES) + #undef JSON_HEDLEY_EMPTY_BASES +#endif +#if JSON_HEDLEY_MSVC_VERSION_CHECK(19,0,23918) && !JSON_HEDLEY_MSVC_VERSION_CHECK(20,0,0) + #define JSON_HEDLEY_EMPTY_BASES __declspec(empty_bases) +#else + #define JSON_HEDLEY_EMPTY_BASES +#endif + +/* Remaining macros are deprecated. */ + +#if defined(JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK) + #undef JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK +#endif +#if defined(__clang__) + #define JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) (0) +#else + #define JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) +#endif + +#if defined(JSON_HEDLEY_CLANG_HAS_ATTRIBUTE) + #undef JSON_HEDLEY_CLANG_HAS_ATTRIBUTE +#endif +#define JSON_HEDLEY_CLANG_HAS_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_ATTRIBUTE(attribute) + +#if defined(JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE) + #undef JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE +#endif +#define JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) + +#if defined(JSON_HEDLEY_CLANG_HAS_BUILTIN) + #undef JSON_HEDLEY_CLANG_HAS_BUILTIN +#endif +#define JSON_HEDLEY_CLANG_HAS_BUILTIN(builtin) JSON_HEDLEY_HAS_BUILTIN(builtin) + +#if defined(JSON_HEDLEY_CLANG_HAS_FEATURE) + #undef JSON_HEDLEY_CLANG_HAS_FEATURE +#endif +#define JSON_HEDLEY_CLANG_HAS_FEATURE(feature) JSON_HEDLEY_HAS_FEATURE(feature) + +#if defined(JSON_HEDLEY_CLANG_HAS_EXTENSION) + #undef JSON_HEDLEY_CLANG_HAS_EXTENSION +#endif +#define JSON_HEDLEY_CLANG_HAS_EXTENSION(extension) JSON_HEDLEY_HAS_EXTENSION(extension) + +#if defined(JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE) + #undef JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE +#endif +#define JSON_HEDLEY_CLANG_HAS_DECLSPEC_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) + +#if defined(JSON_HEDLEY_CLANG_HAS_WARNING) + #undef JSON_HEDLEY_CLANG_HAS_WARNING +#endif +#define JSON_HEDLEY_CLANG_HAS_WARNING(warning) JSON_HEDLEY_HAS_WARNING(warning) + +#endif /* !defined(JSON_HEDLEY_VERSION) || (JSON_HEDLEY_VERSION < X) */ + + +// This file contains all internal macro definitions +// You MUST include macro_unscope.hpp at the end of json.hpp to undef all of them + +// exclude unsupported compilers +#if !defined(JSON_SKIP_UNSUPPORTED_COMPILER_CHECK) + #if defined(__clang__) + #if (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__) < 30400 + #error "unsupported Clang version - see https://github.com/nlohmann/json#supported-compilers" + #endif + #elif defined(__GNUC__) && !(defined(__ICC) || defined(__INTEL_COMPILER)) + #if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) < 40800 + #error "unsupported GCC version - see https://github.com/nlohmann/json#supported-compilers" + #endif + #endif +#endif + +// C++ language standard detection +#if (defined(__cplusplus) && __cplusplus >= 201703L) || (defined(_HAS_CXX17) && _HAS_CXX17 == 1) // fix for issue #464 + #define JSON_HAS_CPP_17 + #define JSON_HAS_CPP_14 +#elif (defined(__cplusplus) && __cplusplus >= 201402L) || (defined(_HAS_CXX14) && _HAS_CXX14 == 1) + #define JSON_HAS_CPP_14 +#endif + +// disable float-equal warnings on GCC/clang +#if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__) + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wfloat-equal" +#endif + +// disable documentation warnings on clang +#if defined(__clang__) + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wdocumentation" +#endif + +// allow to disable exceptions +#if (defined(__cpp_exceptions) || defined(__EXCEPTIONS) || defined(_CPPUNWIND)) && !defined(JSON_NOEXCEPTION) + #define JSON_THROW(exception) throw exception + #define JSON_TRY try + #define JSON_CATCH(exception) catch(exception) + #define JSON_INTERNAL_CATCH(exception) catch(exception) +#else + #include + #define JSON_THROW(exception) std::abort() + #define JSON_TRY if(true) + #define JSON_CATCH(exception) if(false) + #define JSON_INTERNAL_CATCH(exception) if(false) +#endif + +// override exception macros +#if defined(JSON_THROW_USER) + #undef JSON_THROW + #define JSON_THROW JSON_THROW_USER +#endif +#if defined(JSON_TRY_USER) + #undef JSON_TRY + #define JSON_TRY JSON_TRY_USER +#endif +#if defined(JSON_CATCH_USER) + #undef JSON_CATCH + #define JSON_CATCH JSON_CATCH_USER + #undef JSON_INTERNAL_CATCH + #define JSON_INTERNAL_CATCH JSON_CATCH_USER +#endif +#if defined(JSON_INTERNAL_CATCH_USER) + #undef JSON_INTERNAL_CATCH + #define JSON_INTERNAL_CATCH JSON_INTERNAL_CATCH_USER +#endif + +/*! +@brief macro to briefly define a mapping between an enum and JSON +@def NLOHMANN_JSON_SERIALIZE_ENUM +@since version 3.4.0 +*/ +#define NLOHMANN_JSON_SERIALIZE_ENUM(ENUM_TYPE, ...) \ + template \ + inline void to_json(BasicJsonType& j, const ENUM_TYPE& e) \ + { \ + static_assert(std::is_enum::value, #ENUM_TYPE " must be an enum!"); \ + static const std::pair m[] = __VA_ARGS__; \ + auto it = std::find_if(std::begin(m), std::end(m), \ + [e](const std::pair& ej_pair) -> bool \ + { \ + return ej_pair.first == e; \ + }); \ + j = ((it != std::end(m)) ? it : std::begin(m))->second; \ + } \ + template \ + inline void from_json(const BasicJsonType& j, ENUM_TYPE& e) \ + { \ + static_assert(std::is_enum::value, #ENUM_TYPE " must be an enum!"); \ + static const std::pair m[] = __VA_ARGS__; \ + auto it = std::find_if(std::begin(m), std::end(m), \ + [&j](const std::pair& ej_pair) -> bool \ + { \ + return ej_pair.second == j; \ + }); \ + e = ((it != std::end(m)) ? it : std::begin(m))->first; \ + } + +// Ugly macros to avoid uglier copy-paste when specializing basic_json. They +// may be removed in the future once the class is split. + +#define NLOHMANN_BASIC_JSON_TPL_DECLARATION \ + template class ObjectType, \ + template class ArrayType, \ + class StringType, class BooleanType, class NumberIntegerType, \ + class NumberUnsignedType, class NumberFloatType, \ + template class AllocatorType, \ + template class JSONSerializer, \ + class BinaryType> + +#define NLOHMANN_BASIC_JSON_TPL \ + basic_json + + +namespace nlohmann +{ +namespace detail +{ +//////////////// +// exceptions // +//////////////// + +/*! +@brief general exception of the @ref basic_json class + +This class is an extension of `std::exception` objects with a member @a id for +exception ids. It is used as the base class for all exceptions thrown by the +@ref basic_json class. This class can hence be used as "wildcard" to catch +exceptions. + +Subclasses: +- @ref parse_error for exceptions indicating a parse error +- @ref invalid_iterator for exceptions indicating errors with iterators +- @ref type_error for exceptions indicating executing a member function with + a wrong type +- @ref out_of_range for exceptions indicating access out of the defined range +- @ref other_error for exceptions indicating other library errors + +@internal +@note To have nothrow-copy-constructible exceptions, we internally use + `std::runtime_error` which can cope with arbitrary-length error messages. + Intermediate strings are built with static functions and then passed to + the actual constructor. +@endinternal + +@liveexample{The following code shows how arbitrary library exceptions can be +caught.,exception} + +@since version 3.0.0 +*/ +class exception : public std::exception +{ + public: + /// returns the explanatory string + JSON_HEDLEY_RETURNS_NON_NULL + const char* what() const noexcept override + { + return m.what(); + } + + /// the id of the exception + const int id; + + protected: + JSON_HEDLEY_NON_NULL(3) + exception(int id_, const char* what_arg) : id(id_), m(what_arg) {} + + static std::string name(const std::string& ename, int id_) + { + return "[json.exception." + ename + "." + std::to_string(id_) + "] "; + } + + private: + /// an exception object as storage for error messages + std::runtime_error m; +}; + +/*! +@brief exception indicating a parse error + +This exception is thrown by the library when a parse error occurs. Parse errors +can occur during the deserialization of JSON text, CBOR, MessagePack, as well +as when using JSON Patch. + +Member @a byte holds the byte index of the last read character in the input +file. + +Exceptions have ids 1xx. + +name / id | example message | description +------------------------------ | --------------- | ------------------------- +json.exception.parse_error.101 | parse error at 2: unexpected end of input; expected string literal | This error indicates a syntax error while deserializing a JSON text. The error message describes that an unexpected token (character) was encountered, and the member @a byte indicates the error position. +json.exception.parse_error.102 | parse error at 14: missing or wrong low surrogate | JSON uses the `\uxxxx` format to describe Unicode characters. Code points above above 0xFFFF are split into two `\uxxxx` entries ("surrogate pairs"). This error indicates that the surrogate pair is incomplete or contains an invalid code point. +json.exception.parse_error.103 | parse error: code points above 0x10FFFF are invalid | Unicode supports code points up to 0x10FFFF. Code points above 0x10FFFF are invalid. +json.exception.parse_error.104 | parse error: JSON patch must be an array of objects | [RFC 6902](https://tools.ietf.org/html/rfc6902) requires a JSON Patch document to be a JSON document that represents an array of objects. +json.exception.parse_error.105 | parse error: operation must have string member 'op' | An operation of a JSON Patch document must contain exactly one "op" member, whose value indicates the operation to perform. Its value must be one of "add", "remove", "replace", "move", "copy", or "test"; other values are errors. +json.exception.parse_error.106 | parse error: array index '01' must not begin with '0' | An array index in a JSON Pointer ([RFC 6901](https://tools.ietf.org/html/rfc6901)) may be `0` or any number without a leading `0`. +json.exception.parse_error.107 | parse error: JSON pointer must be empty or begin with '/' - was: 'foo' | A JSON Pointer must be a Unicode string containing a sequence of zero or more reference tokens, each prefixed by a `/` character. +json.exception.parse_error.108 | parse error: escape character '~' must be followed with '0' or '1' | In a JSON Pointer, only `~0` and `~1` are valid escape sequences. +json.exception.parse_error.109 | parse error: array index 'one' is not a number | A JSON Pointer array index must be a number. +json.exception.parse_error.110 | parse error at 1: cannot read 2 bytes from vector | When parsing CBOR or MessagePack, the byte vector ends before the complete value has been read. +json.exception.parse_error.112 | parse error at 1: error reading CBOR; last byte: 0xF8 | Not all types of CBOR or MessagePack are supported. This exception occurs if an unsupported byte was read. +json.exception.parse_error.113 | parse error at 2: expected a CBOR string; last byte: 0x98 | While parsing a map key, a value that is not a string has been read. +json.exception.parse_error.114 | parse error: Unsupported BSON record type 0x0F | The parsing of the corresponding BSON record type is not implemented (yet). + +@note For an input with n bytes, 1 is the index of the first character and n+1 + is the index of the terminating null byte or the end of file. This also + holds true when reading a byte vector (CBOR or MessagePack). + +@liveexample{The following code shows how a `parse_error` exception can be +caught.,parse_error} + +@sa - @ref exception for the base class of the library exceptions +@sa - @ref invalid_iterator for exceptions indicating errors with iterators +@sa - @ref type_error for exceptions indicating executing a member function with + a wrong type +@sa - @ref out_of_range for exceptions indicating access out of the defined range +@sa - @ref other_error for exceptions indicating other library errors + +@since version 3.0.0 +*/ +class parse_error : public exception +{ + public: + /*! + @brief create a parse error exception + @param[in] id_ the id of the exception + @param[in] pos the position where the error occurred (or with + chars_read_total=0 if the position cannot be + determined) + @param[in] what_arg the explanatory string + @return parse_error object + */ + static parse_error create(int id_, const position_t& pos, const std::string& what_arg) + { + std::string w = exception::name("parse_error", id_) + "parse error" + + position_string(pos) + ": " + what_arg; + return parse_error(id_, pos.chars_read_total, w.c_str()); + } + + static parse_error create(int id_, std::size_t byte_, const std::string& what_arg) + { + std::string w = exception::name("parse_error", id_) + "parse error" + + (byte_ != 0 ? (" at byte " + std::to_string(byte_)) : "") + + ": " + what_arg; + return parse_error(id_, byte_, w.c_str()); + } + + /*! + @brief byte index of the parse error + + The byte index of the last read character in the input file. + + @note For an input with n bytes, 1 is the index of the first character and + n+1 is the index of the terminating null byte or the end of file. + This also holds true when reading a byte vector (CBOR or MessagePack). + */ + const std::size_t byte; + + private: + parse_error(int id_, std::size_t byte_, const char* what_arg) + : exception(id_, what_arg), byte(byte_) {} + + static std::string position_string(const position_t& pos) + { + return " at line " + std::to_string(pos.lines_read + 1) + + ", column " + std::to_string(pos.chars_read_current_line); + } +}; + +/*! +@brief exception indicating errors with iterators + +This exception is thrown if iterators passed to a library function do not match +the expected semantics. + +Exceptions have ids 2xx. + +name / id | example message | description +----------------------------------- | --------------- | ------------------------- +json.exception.invalid_iterator.201 | iterators are not compatible | The iterators passed to constructor @ref basic_json(InputIT first, InputIT last) are not compatible, meaning they do not belong to the same container. Therefore, the range (@a first, @a last) is invalid. +json.exception.invalid_iterator.202 | iterator does not fit current value | In an erase or insert function, the passed iterator @a pos does not belong to the JSON value for which the function was called. It hence does not define a valid position for the deletion/insertion. +json.exception.invalid_iterator.203 | iterators do not fit current value | Either iterator passed to function @ref erase(IteratorType first, IteratorType last) does not belong to the JSON value from which values shall be erased. It hence does not define a valid range to delete values from. +json.exception.invalid_iterator.204 | iterators out of range | When an iterator range for a primitive type (number, boolean, or string) is passed to a constructor or an erase function, this range has to be exactly (@ref begin(), @ref end()), because this is the only way the single stored value is expressed. All other ranges are invalid. +json.exception.invalid_iterator.205 | iterator out of range | When an iterator for a primitive type (number, boolean, or string) is passed to an erase function, the iterator has to be the @ref begin() iterator, because it is the only way to address the stored value. All other iterators are invalid. +json.exception.invalid_iterator.206 | cannot construct with iterators from null | The iterators passed to constructor @ref basic_json(InputIT first, InputIT last) belong to a JSON null value and hence to not define a valid range. +json.exception.invalid_iterator.207 | cannot use key() for non-object iterators | The key() member function can only be used on iterators belonging to a JSON object, because other types do not have a concept of a key. +json.exception.invalid_iterator.208 | cannot use operator[] for object iterators | The operator[] to specify a concrete offset cannot be used on iterators belonging to a JSON object, because JSON objects are unordered. +json.exception.invalid_iterator.209 | cannot use offsets with object iterators | The offset operators (+, -, +=, -=) cannot be used on iterators belonging to a JSON object, because JSON objects are unordered. +json.exception.invalid_iterator.210 | iterators do not fit | The iterator range passed to the insert function are not compatible, meaning they do not belong to the same container. Therefore, the range (@a first, @a last) is invalid. +json.exception.invalid_iterator.211 | passed iterators may not belong to container | The iterator range passed to the insert function must not be a subrange of the container to insert to. +json.exception.invalid_iterator.212 | cannot compare iterators of different containers | When two iterators are compared, they must belong to the same container. +json.exception.invalid_iterator.213 | cannot compare order of object iterators | The order of object iterators cannot be compared, because JSON objects are unordered. +json.exception.invalid_iterator.214 | cannot get value | Cannot get value for iterator: Either the iterator belongs to a null value or it is an iterator to a primitive type (number, boolean, or string), but the iterator is different to @ref begin(). + +@liveexample{The following code shows how an `invalid_iterator` exception can be +caught.,invalid_iterator} + +@sa - @ref exception for the base class of the library exceptions +@sa - @ref parse_error for exceptions indicating a parse error +@sa - @ref type_error for exceptions indicating executing a member function with + a wrong type +@sa - @ref out_of_range for exceptions indicating access out of the defined range +@sa - @ref other_error for exceptions indicating other library errors + +@since version 3.0.0 +*/ +class invalid_iterator : public exception +{ + public: + static invalid_iterator create(int id_, const std::string& what_arg) + { + std::string w = exception::name("invalid_iterator", id_) + what_arg; + return invalid_iterator(id_, w.c_str()); + } + + private: + JSON_HEDLEY_NON_NULL(3) + invalid_iterator(int id_, const char* what_arg) + : exception(id_, what_arg) {} +}; + +/*! +@brief exception indicating executing a member function with a wrong type + +This exception is thrown in case of a type error; that is, a library function is +executed on a JSON value whose type does not match the expected semantics. + +Exceptions have ids 3xx. + +name / id | example message | description +----------------------------- | --------------- | ------------------------- +json.exception.type_error.301 | cannot create object from initializer list | To create an object from an initializer list, the initializer list must consist only of a list of pairs whose first element is a string. When this constraint is violated, an array is created instead. +json.exception.type_error.302 | type must be object, but is array | During implicit or explicit value conversion, the JSON type must be compatible to the target type. For instance, a JSON string can only be converted into string types, but not into numbers or boolean types. +json.exception.type_error.303 | incompatible ReferenceType for get_ref, actual type is object | To retrieve a reference to a value stored in a @ref basic_json object with @ref get_ref, the type of the reference must match the value type. For instance, for a JSON array, the @a ReferenceType must be @ref array_t &. +json.exception.type_error.304 | cannot use at() with string | The @ref at() member functions can only be executed for certain JSON types. +json.exception.type_error.305 | cannot use operator[] with string | The @ref operator[] member functions can only be executed for certain JSON types. +json.exception.type_error.306 | cannot use value() with string | The @ref value() member functions can only be executed for certain JSON types. +json.exception.type_error.307 | cannot use erase() with string | The @ref erase() member functions can only be executed for certain JSON types. +json.exception.type_error.308 | cannot use push_back() with string | The @ref push_back() and @ref operator+= member functions can only be executed for certain JSON types. +json.exception.type_error.309 | cannot use insert() with | The @ref insert() member functions can only be executed for certain JSON types. +json.exception.type_error.310 | cannot use swap() with number | The @ref swap() member functions can only be executed for certain JSON types. +json.exception.type_error.311 | cannot use emplace_back() with string | The @ref emplace_back() member function can only be executed for certain JSON types. +json.exception.type_error.312 | cannot use update() with string | The @ref update() member functions can only be executed for certain JSON types. +json.exception.type_error.313 | invalid value to unflatten | The @ref unflatten function converts an object whose keys are JSON Pointers back into an arbitrary nested JSON value. The JSON Pointers must not overlap, because then the resulting value would not be well defined. +json.exception.type_error.314 | only objects can be unflattened | The @ref unflatten function only works for an object whose keys are JSON Pointers. +json.exception.type_error.315 | values in object must be primitive | The @ref unflatten function only works for an object whose keys are JSON Pointers and whose values are primitive. +json.exception.type_error.316 | invalid UTF-8 byte at index 10: 0x7E | The @ref dump function only works with UTF-8 encoded strings; that is, if you assign a `std::string` to a JSON value, make sure it is UTF-8 encoded. | +json.exception.type_error.317 | JSON value cannot be serialized to requested format | The dynamic type of the object cannot be represented in the requested serialization format (e.g. a raw `true` or `null` JSON object cannot be serialized to BSON) | + +@liveexample{The following code shows how a `type_error` exception can be +caught.,type_error} + +@sa - @ref exception for the base class of the library exceptions +@sa - @ref parse_error for exceptions indicating a parse error +@sa - @ref invalid_iterator for exceptions indicating errors with iterators +@sa - @ref out_of_range for exceptions indicating access out of the defined range +@sa - @ref other_error for exceptions indicating other library errors + +@since version 3.0.0 +*/ +class type_error : public exception +{ + public: + static type_error create(int id_, const std::string& what_arg) + { + std::string w = exception::name("type_error", id_) + what_arg; + return type_error(id_, w.c_str()); + } + + private: + JSON_HEDLEY_NON_NULL(3) + type_error(int id_, const char* what_arg) : exception(id_, what_arg) {} +}; + +/*! +@brief exception indicating access out of the defined range + +This exception is thrown in case a library function is called on an input +parameter that exceeds the expected range, for instance in case of array +indices or nonexisting object keys. + +Exceptions have ids 4xx. + +name / id | example message | description +------------------------------- | --------------- | ------------------------- +json.exception.out_of_range.401 | array index 3 is out of range | The provided array index @a i is larger than @a size-1. +json.exception.out_of_range.402 | array index '-' (3) is out of range | The special array index `-` in a JSON Pointer never describes a valid element of the array, but the index past the end. That is, it can only be used to add elements at this position, but not to read it. +json.exception.out_of_range.403 | key 'foo' not found | The provided key was not found in the JSON object. +json.exception.out_of_range.404 | unresolved reference token 'foo' | A reference token in a JSON Pointer could not be resolved. +json.exception.out_of_range.405 | JSON pointer has no parent | The JSON Patch operations 'remove' and 'add' can not be applied to the root element of the JSON value. +json.exception.out_of_range.406 | number overflow parsing '10E1000' | A parsed number could not be stored as without changing it to NaN or INF. +json.exception.out_of_range.407 | number overflow serializing '9223372036854775808' | UBJSON and BSON only support integer numbers up to 9223372036854775807. | +json.exception.out_of_range.408 | excessive array size: 8658170730974374167 | The size (following `#`) of an UBJSON array or object exceeds the maximal capacity. | +json.exception.out_of_range.409 | BSON key cannot contain code point U+0000 (at byte 2) | Key identifiers to be serialized to BSON cannot contain code point U+0000, since the key is stored as zero-terminated c-string | + +@liveexample{The following code shows how an `out_of_range` exception can be +caught.,out_of_range} + +@sa - @ref exception for the base class of the library exceptions +@sa - @ref parse_error for exceptions indicating a parse error +@sa - @ref invalid_iterator for exceptions indicating errors with iterators +@sa - @ref type_error for exceptions indicating executing a member function with + a wrong type +@sa - @ref other_error for exceptions indicating other library errors + +@since version 3.0.0 +*/ +class out_of_range : public exception +{ + public: + static out_of_range create(int id_, const std::string& what_arg) + { + std::string w = exception::name("out_of_range", id_) + what_arg; + return out_of_range(id_, w.c_str()); + } + + private: + JSON_HEDLEY_NON_NULL(3) + out_of_range(int id_, const char* what_arg) : exception(id_, what_arg) {} +}; + +/*! +@brief exception indicating other library errors + +This exception is thrown in case of errors that cannot be classified with the +other exception types. + +Exceptions have ids 5xx. + +name / id | example message | description +------------------------------ | --------------- | ------------------------- +json.exception.other_error.501 | unsuccessful: {"op":"test","path":"/baz", "value":"bar"} | A JSON Patch operation 'test' failed. The unsuccessful operation is also printed. + +@sa - @ref exception for the base class of the library exceptions +@sa - @ref parse_error for exceptions indicating a parse error +@sa - @ref invalid_iterator for exceptions indicating errors with iterators +@sa - @ref type_error for exceptions indicating executing a member function with + a wrong type +@sa - @ref out_of_range for exceptions indicating access out of the defined range + +@liveexample{The following code shows how an `other_error` exception can be +caught.,other_error} + +@since version 3.0.0 +*/ +class other_error : public exception +{ + public: + static other_error create(int id_, const std::string& what_arg) + { + std::string w = exception::name("other_error", id_) + what_arg; + return other_error(id_, w.c_str()); + } + + private: + JSON_HEDLEY_NON_NULL(3) + other_error(int id_, const char* what_arg) : exception(id_, what_arg) {} +}; +} // namespace detail +} // namespace nlohmann + +// #include + +// #include + + +#include // size_t +#include // conditional, enable_if, false_type, integral_constant, is_constructible, is_integral, is_same, remove_cv, remove_reference, true_type + +// #include + + +namespace nlohmann +{ +namespace detail +{ +// alias templates to reduce boilerplate +template +using enable_if_t = typename std::enable_if::type; + +template +using uncvref_t = typename std::remove_cv::type>::type; + +// implementation of C++14 index_sequence and affiliates +// source: https://stackoverflow.com/a/32223343 +template +struct index_sequence +{ + using type = index_sequence; + using value_type = std::size_t; + static constexpr std::size_t size() noexcept + { + return sizeof...(Ints); + } +}; + +template +struct merge_and_renumber; + +template +struct merge_and_renumber, index_sequence> + : index_sequence < I1..., (sizeof...(I1) + I2)... > {}; + +template +struct make_index_sequence + : merge_and_renumber < typename make_index_sequence < N / 2 >::type, + typename make_index_sequence < N - N / 2 >::type > {}; + +template<> struct make_index_sequence<0> : index_sequence<> {}; +template<> struct make_index_sequence<1> : index_sequence<0> {}; + +template +using index_sequence_for = make_index_sequence; + +// dispatch utility (taken from ranges-v3) +template struct priority_tag : priority_tag < N - 1 > {}; +template<> struct priority_tag<0> {}; + +// taken from ranges-v3 +template +struct static_const +{ + static constexpr T value{}; +}; + +template +constexpr T static_const::value; +} // namespace detail +} // namespace nlohmann + +// #include + + +#include // numeric_limits +#include // false_type, is_constructible, is_integral, is_same, true_type +#include // declval + +// #include + +// #include + + +#include // random_access_iterator_tag + +// #include + + +namespace nlohmann +{ +namespace detail +{ +template struct make_void +{ + using type = void; +}; +template using void_t = typename make_void::type; +} // namespace detail +} // namespace nlohmann + +// #include + + +namespace nlohmann +{ +namespace detail +{ +template +struct iterator_types {}; + +template +struct iterator_types < + It, + void_t> +{ + using difference_type = typename It::difference_type; + using value_type = typename It::value_type; + using pointer = typename It::pointer; + using reference = typename It::reference; + using iterator_category = typename It::iterator_category; +}; + +// This is required as some compilers implement std::iterator_traits in a way that +// doesn't work with SFINAE. See https://github.com/nlohmann/json/issues/1341. +template +struct iterator_traits +{ +}; + +template +struct iterator_traits < T, enable_if_t < !std::is_pointer::value >> + : iterator_types +{ +}; + +template +struct iterator_traits::value>> +{ + using iterator_category = std::random_access_iterator_tag; + using value_type = T; + using difference_type = ptrdiff_t; + using pointer = T*; + using reference = T&; +}; +} // namespace detail +} // namespace nlohmann + +// #include + +// #include + +// #include + + +#include + +// #include + + +// https://en.cppreference.com/w/cpp/experimental/is_detected +namespace nlohmann +{ +namespace detail +{ +struct nonesuch +{ + nonesuch() = delete; + ~nonesuch() = delete; + nonesuch(nonesuch const&) = delete; + nonesuch(nonesuch const&&) = delete; + void operator=(nonesuch const&) = delete; + void operator=(nonesuch&&) = delete; +}; + +template class Op, + class... Args> +struct detector +{ + using value_t = std::false_type; + using type = Default; +}; + +template class Op, class... Args> +struct detector>, Op, Args...> +{ + using value_t = std::true_type; + using type = Op; +}; + +template