添加opus,还不能正常启动
authorsnickersun <snickersun@163.com>
Tue, 2 Jun 2026 15:05:24 +0000 (23:05 +0800)
committersnickersun <snickersun@163.com>
Tue, 2 Jun 2026 15:05:24 +0000 (23:05 +0800)
43 files changed:
.cursor/rules/project.mdc
2.sdk/Helios_SDK/comp_info_tell.mk
2.sdk/Helios_SDK/compile.py
2.sdk/Helios_SDK/compilerules.mk
2.sdk/Helios_SDK/link.mk
2.sdk/Helios_SDK/services/microPython/microPython.mk
2.sdk/new_clean.bat
2.sdk/project/7PIN_1_5/new.bat
2.sdk/project/7PIN_1_5/sdk/services/microPython/microPython_opus.mk [new file with mode: 0644]
2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/Makefile
2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/default_config.py
2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/opus_codec.py [new file with mode: 0644]
2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/products/configs/k8v3/default_config.py
2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/source/OPUS_BUILD.txt [new file with mode: 0644]
2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/source/libopus_min.a [new file with mode: 0644]
2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/source/modopus.c [new file with mode: 0644]
2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/source/opus/opus.h [new file with mode: 0644]
2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/source/opus/opus_custom.h [new file with mode: 0644]
2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/source/opus/opus_defines.h [new file with mode: 0644]
2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/source/opus/opus_multistream.h [new file with mode: 0644]
2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/source/opus/opus_projection.h [new file with mode: 0644]
2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/source/opus/opus_types.h [new file with mode: 0644]
2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/vc_buttons.py
2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/vc_interrupt.py
2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/vc_media_arb.py
2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/vc_mode_strategy.py
2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/vc_notify.py
2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/vc_ota.py
2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/vc_present.py
2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/vc_session.py
2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/vc_session_imports.py
2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/vc_session_media.py
2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/vc_ux.py
2.sdk/project/7PIN_1_5/sdk/system/platform/ASR_1606/boards/EG810MCN_GA_VOLTE/config/autoconf.h
2.sdk/project/7PIN_1_5/sdk/system/platform/ASR_1606/boards/EG810MCN_GA_VOLTE/config/config.mk
2.sdk/project/7PIN_1_5/sdk/system/platform/ASR_1606/boards/EG810MCN_GA_VOLTE/images/firmware_base_release_pack/README.md [new file with mode: 0644]
2.sdk/project/7PIN_1_5/sdk/system/platform/ASR_1606/boards/EG810MCN_GA_VOLTE/images/firmware_base_release_pack/config/partition/CRANEL_SINGLE_QUEC_FLASH_LAYOUT_8M_GNSS_OPEN_VOLTE.json [new file with mode: 0644]
2.sdk/project/7PIN_1_5/sdk/system/platform/ASR_1606/boards/EG810MCN_GA_VOLTE/include/app_link_start_addr.h
2.sdk/project/7PIN_1_5/tools/build_opus_min.bat [new file with mode: 0644]
2.sdk/project/7PIN_1_5/tools/build_opus_min.ps1 [new file with mode: 0644]
2.sdk/project/7PIN_1_5/tools/ensure_helios_opus_mk.ps1 [new file with mode: 0644]
2.sdk/project/7PIN_1_5/tools/sync_base_pack_config.bat [new file with mode: 0644]
2.sdk/project/7PIN_1_5/tools/sync_base_pack_config.ps1 [new file with mode: 0644]

index 914588d..6a12572 100644 (file)
@@ -6,7 +6,8 @@ alwaysApply: true
 - 你是高级嵌入式工程师,代码必须遵循最佳实践和最佳设计原则\r
 - 本工程是micropython工程,\r
 - 2.sdk/Helios_SDK是编译路径,2.sdk/project/7PIN_1_5是项目路径 ,代码优先在项目路径里找,没有的通用代码才在编译路径里。\r
-- 2.sdk\project\7PIN_1_5\sdk\services\microPython\ports\quectel\core\products\configs\k8\default_config.py 是默认k8 的配置参数。\r
-- 编译指令是 new_clean.bat k8 1 \r
+- 2.sdk\project\7PIN_1_5\sdk\services\microPython\ports\quectel\core\products\configs\k8v3\default_config.py 是默认k8v3 的配置参数。\r
+- 编译指令是 new_clean.bat k8v3 1 \r
 - 分析日志解决问题时,要考虑根因,不要只是靠简单判断条件进行兜底修复。\r
-- 每次修改都要考虑副作用,不能拆东墙补西墙
\ No newline at end of file
+- 每次修改都要考虑副作用,不能拆东墙补西墙\r
+- 2.sdk\Helios_SDK\opt\log\build.log 是编译日志,有编译问题,可以直接搜索这个文件
\ No newline at end of file
index e53ef18..3ff4bb4 100644 (file)
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+.DEFAULT_GOAL := all
+
 include $(COMP_MK)
 
 all:
-       @echo "NAME: $(NAME)"
-       @echo "GLOBAL_INCS: $(GLOBAL_INCS)"
-       @echo "GLOBAL_DEFINE: $(GLOBAL_DEFINE)"
-       @echo "LOCAL_CFLAGS: $($(NAME)_CFLAGS)"
-       @echo "LOCAL_ARCHIVES: $($(NAME)_ARCHIVES)"
-       @echo "LOCAL_SRCS: $($(NAME)_SRCS)"
-       @echo "LOCAL_SRCS_2: $($(NAME)_SRCS_2)"
-       @echo "LOCAL_SRCS_3: $($(NAME)_SRCS_3)"
-       @echo "LOCAL_INCS: $($(NAME)_INCS)"
-       @echo "LOCAL_DEFINE: $($(NAME)_DEFINE)"
-       @echo "COMP_DEPS: $($(NAME)_COMPONENTS)"
+       @echo NAME: $(NAME)
+       @echo GLOBAL_INCS: $(GLOBAL_INCS)
+       @echo GLOBAL_DEFINE: $(GLOBAL_DEFINE)
+       @echo LOCAL_CFLAGS: $($(NAME)_CFLAGS)
+       @echo LOCAL_ARCHIVES: $($(NAME)_ARCHIVES)
+       @echo LOCAL_SRCS:
+       @echo LOCAL_SRCS_2:
+       @echo LOCAL_SRCS_3:
+       @echo LOCAL_INCS: $($(NAME)_INCS)
+       @echo LOCAL_DEFINE: $($(NAME)_DEFINE)
+       @echo COMP_DEPS: $($(NAME)_COMPONENTS)
index 06d3a35..8088340 100644 (file)
@@ -14,6 +14,7 @@
 
 import json, os, re, sys, shutil, subprocess
 
+HELIOS_ROOT = os.path.dirname(os.path.abspath(__file__))
 dep_dict = {}
 SYSTEMROOT = os.environ.get('SystemRoot', r'C:\Windows')
 # 不信任 COMSPEC/ComSpec(批处理/工具链可能把它设成相对路径 cmd.exe),直接固定用系统 cmd.exe 绝对路径
@@ -56,11 +57,104 @@ def path_optimizer(comp_path):
     app_path_split = comp_path.replace('\\', '/').split('/')
     return '/'.join(list(filter(not_empty, app_path_split)))
 
+def _comp_info_cmd(comp_mk):
+    kcfg = os.environ.get('KCONFIG_CONFIG') or 'config.mk'
+    # comp_info_tell.mk 会 include 组件 mk;有些组件 mk 自己定义了“第一个目标”,
+    # 不显式指定目标时 make 会默认构建错误目标(常见表现:尝试构建 `config/` 目录)。
+    # 这里强制指定目标 `all`,只输出组件信息。
+    return 'make --no-print-directory -f comp_info_tell.mk COMP_MK=' + comp_mk + ' KCONFIG_CONFIG=' + kcfg + ' all'
+
+def _read_src_file(rel_path):
+    if not rel_path:
+        return []
+    path = rel_path if os.path.isabs(rel_path) else os.path.join(HELIOS_ROOT, rel_path.replace('/', os.sep))
+    if not os.path.isfile(path):
+        return []
+    with open(path, 'r', encoding='utf-8', errors='ignore') as f:
+        return list(filter(not_empty, f.read().split()))
+
+def _parse_comp_info(ret):
+    fields = {}
+    src_files = {}
+    for line in ret.splitlines():
+        if not line or ':' not in line:
+            continue
+        key, val = line.split(':', 1)
+        key = key.strip()
+        val = val.lstrip()
+        if key == 'LOCAL_SRCS_FILE':
+            src_files['LOCAL_SRCS'] = val.strip()
+        elif key == 'LOCAL_SRCS_2_FILE':
+            src_files['LOCAL_SRCS_2'] = val.strip()
+        elif key == 'LOCAL_SRCS_3_FILE':
+            src_files['LOCAL_SRCS_3'] = val.strip()
+        else:
+            fields[key] = val.strip()
+
+    if 'NAME' in fields and 'LOCAL_SRCS' in src_files:
+        local_srcs = _read_src_file(src_files.get('LOCAL_SRCS'))
+        local_srcs_2 = _read_src_file(src_files.get('LOCAL_SRCS_2'))
+        local_srcs_3 = _read_src_file(src_files.get('LOCAL_SRCS_3'))
+        return {
+            'name_list': fields.get('NAME', '').split(),
+            'global_incs': fields.get('GLOBAL_INCS', '').split(),
+            'global_define': fields.get('GLOBAL_DEFINE', '').split(),
+            'local_cflags': fields.get('LOCAL_CFLAGS', '').split(),
+            'local_archives': fields.get('LOCAL_ARCHIVES', '').split(),
+            'local_srcs': local_srcs,
+            'local_srcs_2': local_srcs_2,
+            'local_srcs_3': local_srcs_3,
+            'local_incs': fields.get('LOCAL_INCS', '').split(),
+            'local_define': fields.get('LOCAL_DEFINE', '').split(),
+            'comp_deps': [path_optimizer(x) for x in fields.get('COMP_DEPS', '').split()],
+        }
+
+    # 兼容:comp_info_tell.mk 直接输出 LOCAL_SRCS/LOCAL_SRCS_2/LOCAL_SRCS_3(可能为空),
+    # 不再强制要求 *_FILE 形式。
+    if 'NAME' in fields:
+        return {
+            'name_list': fields.get('NAME', '').split(),
+            'global_incs': fields.get('GLOBAL_INCS', '').split(),
+            'global_define': fields.get('GLOBAL_DEFINE', '').split(),
+            'local_cflags': fields.get('LOCAL_CFLAGS', '').split(),
+            'local_archives': fields.get('LOCAL_ARCHIVES', '').split(),
+            'local_srcs': fields.get('LOCAL_SRCS', '').split(),
+            'local_srcs_2': fields.get('LOCAL_SRCS_2', '').split(),
+            'local_srcs_3': fields.get('LOCAL_SRCS_3', '').split(),
+            'local_incs': fields.get('LOCAL_INCS', '').split(),
+            'local_define': fields.get('LOCAL_DEFINE', '').split(),
+            'comp_deps': [path_optimizer(x) for x in fields.get('COMP_DEPS', '').split()],
+        }
+
+    regex = re.compile(r'NAME: (.*)\nGLOBAL_INCS: (.*)\nGLOBAL_DEFINE: (.*)\nLOCAL_CFLAGS: (.*)\nLOCAL_ARCHIVES: (.*)\nLOCAL_SRCS: (.*)\nLOCAL_SRCS_2: (.*)\nLOCAL_SRCS_3: (.*)\nLOCAL_INCS: (.*)\nLOCAL_DEFINE: (.*)\nCOMP_DEPS: (.*)\n')
+    mo = regex.findall(ret)
+    if not mo:
+        return None
+    row = mo[0]
+    return {
+        'name_list': row[0].split(),
+        'global_incs': row[1].split(),
+        'global_define': row[2].split(),
+        'local_cflags': row[3].split(),
+        'local_archives': row[4].split(),
+        'local_srcs': row[5].split(),
+        'local_srcs_2': row[6].split(),
+        'local_srcs_3': row[7].split(),
+        'local_incs': row[8].split(),
+        'local_define': row[9].split(),
+        'comp_deps': [path_optimizer(x) for x in row[10].split()],
+    }
+
 animation_idx = 0
+# Windows/cmd 写 build.log 或非 TTY 时 \b 无法原地覆盖,会刷出一长串 |/-\ 像乱码
+_animation_enabled = sys.platform != 'win32' and getattr(sys.stdout, 'isatty', lambda: False)()
+
 def wait_animation():
     global animation_idx
+    if not _animation_enabled:
+        return
     animation = "|/-\\"
-    if(animation_idx >= 4):
+    if animation_idx >= 4:
         animation_idx = 0
     print('\b\b' + animation[animation_idx] + ' ', end='', flush=True)
     animation_idx += 1
@@ -73,24 +167,26 @@ def search_for_deps(comp_path):
         return
     
     comp_mk = comp_path + '/' + comp_path.split('/')[-1] + '.mk'
-    cmd = 'make --no-print-directory -f comp_info_tell.mk' + ' COMP_MK=' + comp_mk
+    cmd = _comp_info_cmd(comp_mk)
     ret = run_cmd_capture(cmd).decode(encoding='utf-8', errors='ignore')
     if not ret:
         raise RuntimeError('cmd [%s] execution error' % cmd)
-    regex = re.compile(r'NAME: (.*)\nGLOBAL_INCS: (.*)\nGLOBAL_DEFINE: (.*)\nLOCAL_CFLAGS: (.*)\nLOCAL_ARCHIVES: (.*)\nLOCAL_SRCS: (.*)\nLOCAL_SRCS_2: (.*)\nLOCAL_SRCS_3: (.*)\nLOCAL_INCS: (.*)\nLOCAL_DEFINE: (.*)\nCOMP_DEPS: (.*)\n')
-    mo = regex.findall(ret)
-    
-    name_list = mo[0][0].split(' ')
-    global_incs = mo[0][1].split(' ')
-    global_define = mo[0][2].split(' ')
-    local_cflags = mo[0][3].split(' ')
-    local_archives = mo[0][4].split(' ')
-    local_srcs = mo[0][5].split(' ')
-    local_srcs_2 = mo[0][6].split(' ')
-    local_srcs_3 = mo[0][7].split(' ')
-    local_incs = mo[0][8].split(' ')
-    local_define = mo[0][9].split(' ')
-    comp_deps = mo[0][10].split(' ')
+    parsed = _parse_comp_info(ret)
+    if not parsed:
+        snippet = ret.strip()[:1500]
+        raise RuntimeError('comp_info parse failed for %s (cwd=%s); make output:\n%s' % (comp_mk, os.getcwd(), snippet))
+
+    name_list = parsed['name_list']
+    global_incs = parsed['global_incs']
+    global_define = parsed['global_define']
+    local_cflags = parsed['local_cflags']
+    local_archives = parsed['local_archives']
+    local_srcs = parsed['local_srcs']
+    local_srcs_2 = parsed['local_srcs_2']
+    local_srcs_3 = parsed['local_srcs_3']
+    local_incs = parsed['local_incs']
+    local_define = parsed['local_define']
+    comp_deps = parsed['comp_deps']
 
     '''
     print('', flush=True)
@@ -146,23 +242,38 @@ def search_for_deps(comp_path):
 
     if 'COMP_DEPS' in dep_dict[comp_path]:
         for comp in dep_dict[comp_path]['COMP_DEPS']:
-            search_for_deps(comp)
+            search_for_deps(path_optimizer(comp))
+
+def _iter_comp_deps(component):
+    if 'COMP_DEPS' not in dep_dict[component]:
+        return
+    for comp in dep_dict[component]['COMP_DEPS']:
+        comp = path_optimizer(comp)
+        if comp and comp != component and comp in dep_dict:
+            yield comp
 
 def dependency_proc(component, last = None):
     global dep_dict
+    component = path_optimizer(component)
     wait_animation()
+    if component not in dep_dict:
+        return
     if 'COMP_DEPS' in dep_dict[component]:
-        if last:
+        if last and last in dep_dict:
             last_dep = dep_dict[last]['COMP_DEPS']
             for dep in dep_dict[component]['COMP_DEPS']:
-                if dep not in last_dep:
+                dep = path_optimizer(dep)
+                if dep and dep not in last_dep:
                     last_dep.append(dep)
-        for comp in dep_dict[component]['COMP_DEPS']:
+        for comp in _iter_comp_deps(component):
             dependency_proc(comp, component)
 
 def compile_option_proc(component, last = []):
     wait_animation()
     global dep_dict
+    component = path_optimizer(component)
+    if component not in dep_dict:
+        return
     if 'LOCAL_INCS' in dep_dict[component]:
         for inc in dep_dict[component]['LOCAL_INCS']:
             if 'INC_COLLECT' not in dep_dict[component]:
@@ -195,15 +306,11 @@ def compile_option_proc(component, last = []):
                 if 'DEF_COLLECT' in dep_dict[lst] and define not in dep_dict[lst]['DEF_COLLECT']:
                     if 'COMP_DEPS' in dep_dict[lst] and component in dep_dict[lst]['COMP_DEPS']:
                         dep_dict[lst]['DEF_COLLECT'].append(define)
-    if 'LOCAL_DEFINE' in dep_dict[component]:
-        for define in dep_dict[component]['LOCAL_DEFINE']:
-            if 'DEF_COLLECT' not in dep_dict[component]:
-                dep_dict[component]['DEF_COLLECT'] = []
-            if define not in dep_dict[component]['DEF_COLLECT']:
-                dep_dict[component]['DEF_COLLECT'].append(define)
+    # LOCAL_DEFINE 不写入 DEF_COLLECT:compilerules.mk 已 include 组件 mk,
+    # 直接读 $($(NAME)_DEFINE),避免 Windows 下 echo/env 往返时引号被截断(MICROPY_BUILD_DATE)。
     if 'COMP_DEPS' in dep_dict[component]:
         last.append(component)
-        for comp in dep_dict[component]['COMP_DEPS']:
+        for comp in _iter_comp_deps(component):
             compile_option_proc(comp, last)
         last = []
 
@@ -211,19 +318,28 @@ def compile_proc():
     comp_archive_list = []
     user_archive_list = []
     for k,v in dep_dict.items():
-        if 'LOCAL_SRCS' in v and v['LOCAL_SRCS']:
-            archive = os.environ['OUTPUT_OBJ_PATH'] + '/' + k + '/lib' + k.split('/')[-1] + '.a'
+        # 说明:
+        # - 早期做法依赖 comp_info_tell.mk 打印完整 LOCAL_SRCS,用于判断“是否需要编译该组件”;
+        #   但在 Windows 环境下 LOCAL_SRCS 过长会导致 Make 输出被截断/解析失败。
+        # - 实际上 compilerules.mk 会直接 include 组件 mk 并读取 $(NAME)_SRCS 来决定要编译哪些源文件。
+        #   因此这里改为:对 dep_dict 中的组件都尝试构建 archive,构建后仅在文件存在时加入链接列表。
+        archive = os.environ['OUTPUT_OBJ_PATH'] + '/' + k + '/lib' + k.split('/')[-1] + '.a'
+        cmd = 'make --no-print-directory -j12 -f compilerules.mk %s' % archive
+        os.environ['COMP_PATH'] = k
+        if 'INC_COLLECT' in v and v['INC_COLLECT']:
+            comp_iflags = ' '.join(v['INC_COLLECT'])
+            os.environ['COMP_IFLAGS'] = comp_iflags
+        else:
+            os.environ.pop('COMP_IFLAGS', None)
+        if 'DEF_COLLECT' in v and v['DEF_COLLECT']:
+            comp_dflags = ' '.join(v['DEF_COLLECT'])
+            os.environ['COMP_DFLAGS'] = comp_dflags
+        else:
+            os.environ.pop('COMP_DFLAGS', None)
+        if system_cmd(cmd):
+            raise RuntimeError('cmd [%s] execution error' % cmd)
+        if os.path.exists(archive):
             comp_archive_list.append(archive)
-            cmd = 'make --no-print-directory -j12 -f compilerules.mk'
-            os.environ['COMP_PATH'] = k
-            if 'INC_COLLECT' in v and v['INC_COLLECT']:
-                comp_iflags = ' '.join(v['INC_COLLECT'])
-                os.environ['COMP_IFLAGS'] = comp_iflags
-            if 'DEF_COLLECT' in v and v['DEF_COLLECT']:
-                comp_dflags = ' '.join(v['DEF_COLLECT'])
-                os.environ['COMP_DFLAGS'] = comp_dflags
-            if system_cmd(cmd):
-                raise RuntimeError('cmd [%s] execution error' % cmd)
         if 'LOCAL_ARCHIVES' in v and v['LOCAL_ARCHIVES']:
             user_archive_list.extend(list(map(lambda x : k + '/' + x, v['LOCAL_ARCHIVES'])))
     
@@ -243,6 +359,8 @@ def compile_proc():
             raise RuntimeError('cmd [make -f link.mk] execution error')
 
 def build_proc(app):
+    os.chdir(HELIOS_ROOT)
+    os.environ.setdefault('KCONFIG_CONFIG', 'config.mk')
     print('\n[searching for all components ...]   ', end = '', flush=True)
     search_for_deps(app)
     print('')
index 77858b2..a5f250c 100644 (file)
@@ -19,14 +19,22 @@ make_dep_fnc = $(OUTPUT_OBJ_PATH)/$(strip $(1)).d
 COMP_MK = $(call make_mk_fnc,$(COMP_PATH))
 include $(COMP_MK)
 
-OBJECTS_1 := $(foreach n, $(addprefix $(COMP_PATH)/,$(strip $($(NAME)_SRCS))), $(call make_obj_fnc, $(n)))
-DEPENDS   := $(foreach n, $(addprefix $(COMP_PATH)/,$(strip $($(NAME)_SRCS))), $(call make_dep_fnc, $(n)))
-OBJECTS_2 := $(foreach n, $(addprefix $(COMP_PATH)/,$(strip $($(NAME)_SRCS_2))), $(call make_obj_fnc, $(n)))
-DEPENDS   += $(foreach n, $(addprefix $(COMP_PATH)/,$(strip $($(NAME)_SRCS_2))), $(call make_dep_fnc, $(n)))
-OBJECTS_3 := $(foreach n, $(addprefix $(COMP_PATH)/,$(strip $($(NAME)_SRCS_3))), $(call make_obj_fnc, $(n)))
-DEPENDS   += $(foreach n, $(addprefix $(COMP_PATH)/,$(strip $($(NAME)_SRCS_3))), $(call make_dep_fnc, $(n)))
+OBJECTS_1 := $(foreach n, $(addprefix $(COMP_PATH)/,$(sort $(strip $($(NAME)_SRCS)))), $(call make_obj_fnc, $(n)))
+DEPENDS   := $(foreach n, $(addprefix $(COMP_PATH)/,$(sort $(strip $($(NAME)_SRCS)))), $(call make_dep_fnc, $(n)))
+OBJECTS_2 := $(foreach n, $(addprefix $(COMP_PATH)/,$(sort $(strip $($(NAME)_SRCS_2)))), $(call make_obj_fnc, $(n)))
+DEPENDS   += $(foreach n, $(addprefix $(COMP_PATH)/,$(sort $(strip $($(NAME)_SRCS_2)))), $(call make_dep_fnc, $(n)))
+OBJECTS_3 := $(foreach n, $(addprefix $(COMP_PATH)/,$(sort $(strip $($(NAME)_SRCS_3)))), $(call make_obj_fnc, $(n)))
+DEPENDS   += $(foreach n, $(addprefix $(COMP_PATH)/,$(sort $(strip $($(NAME)_SRCS_3)))), $(call make_dep_fnc, $(n)))
 ARCHIVE   := $(OUTPUT_OBJ_PATH)/$(COMP_PATH)/lib$(notdir $(COMP_PATH)).a
 
+# 说明:宏参数里如果包含双引号,Windows 下 make 常通过 /usr/bin/bash 执行命令行,
+# 会把双引号当作 shell 语法吞掉,导致 gcc 看到的 -D 宏丢失引号(进而报 undeclared / missing terminating)。
+# 这里对 MICROPY_BUILD_DATE 做特殊处理:把值包成 C 字符串,并用反斜杠转义双引号,使其穿透到 gcc。
+DFLAGS_EXPANDED := $(foreach d,$(DFLAGS) $(COMP_DFLAGS) $($(NAME)_DEFINE),\
+  $(if $(filter MICROPY_BUILD_DATE=%,$(d)),\
+    -DMICROPY_BUILD_DATE='"$(patsubst MICROPY_BUILD_DATE=%,%,$(d))"',\
+    -D$(d)))
+
 $(ARCHIVE): $(OBJECTS_1) $(OBJECTS_2) $(OBJECTS_3)
        @echo ----- archiving $@
        @-rm -f $@
@@ -43,7 +51,7 @@ endif
 $(OBJECTS_1) $(OBJECTS_2) $(OBJECTS_3):$(OUTPUT_OBJ_PATH)/%.o:%
        @echo ----- compiling $<
        @mkdir -p $(OUTPUT_OBJ_PATH)/$(dir $<)
-       $(Q)$(cc) $($(NAME)_CFLAGS) -c $< $(foreach i, $(COMP_IFLAGS) $(IFLAGS), -I$(i)) $(foreach d, $(DFLAGS) $(COMP_DFLAGS), -D$(d)) -o $@ -MMD -MF $(OUTPUT_OBJ_PATH)/$<.d.tmp -MP || (rm -f $(ARCHIVE); exit 1)
+       $(Q)$(cc) $($(NAME)_CFLAGS) -c $< $(foreach i, $(COMP_IFLAGS) $(IFLAGS), -I$(i)) $(DFLAGS_EXPANDED) -o $@ -MMD -MF $(OUTPUT_OBJ_PATH)/$<.d.tmp -MP || (rm -f $(ARCHIVE); exit 1)
        $(Q)sed -i '/\\:\\/s/\\:\\/:\\/g' $(OUTPUT_OBJ_PATH)/$<.d.tmp
        $(Q)mv $(OUTPUT_OBJ_PATH)/$<.d.tmp $(OUTPUT_OBJ_PATH)/$<.d
 
index 854c0b3..b1440cc 100644 (file)
 
 USE_WHOLE_ARCHIVE ?= y
 
+# 与 compilerules.mk 保持一致:对 MICROPY_BUILD_DATE 做引号穿透,避免 bash/cmd 吞引号
+DFLAGS_EXPANDED := $(foreach d,$(DFLAGS) $(COMP_DFLAGS),\
+  $(if $(filter MICROPY_BUILD_DATE=%,$(d)),\
+    -DMICROPY_BUILD_DATE='"$(patsubst MICROPY_BUILD_DATE=%,%,$(d))"',\
+    -D$(d)))
+
 $(TARGET_BIN): $(TARGET_ELF)
 ifeq ($(strip $(PLAT)),Qualcomm)
        $(Q)$(OBJCOPY_PY) --bin $^ --output $@
@@ -32,7 +38,7 @@ $(TARGET_HEX): $(TARGET_ELF)
 
 $(OUTPUT_LD_FILE): $(LD_FILE)
        @echo
-       $(Q)$(CC) $(foreach inc, $(OUTPUT_SCRIPTS_INCS), -I$(inc)) $(CFLAGS) $(foreach d, $(DFLAGS) $(COMP_DFLAGS), -D$(d)) -E -P -x c -MD -MT $@ -MF $@.d -o $@ -c $<
+       $(Q)$(CC) $(foreach inc, $(OUTPUT_SCRIPTS_INCS), -I$(inc)) $(CFLAGS) $(DFLAGS_EXPANDED) -E -P -x c -MD -MT $@ -MF $@.d -o $@ -c $<
        @echo ----- $@ updated
 
 $(TARGET_ELF): $(OUTPUT_LD_FILE) $(COMP_ARCHIVES) $(USER_ARCHIVES) $(STD_LIBS)
index 6a3e7bc..afe5b14 100644 (file)
-
-NAME := MICROPYTHON
-
-include config/$(KCONFIG_CONFIG)
-
-PY_SRCS = \
-        py/argcheck.c \
-        py/asmarm.c \
-        py/asmbase.c \
-        py/asmthumb.c \
-        py/asmx64.c \
-        py/asmx86.c \
-        py/asmxtensa.c \
-        py/bc.c \
-        py/binary.c \
-        py/builtinevex.c \
-        py/builtinhelp.c \
-        py/builtinimport.c \
-        py/compile.c \
-        py/emitbc.c \
-        py/emitcommon.c \
-        py/emitglue.c \
-        py/emitinlinethumb.c \
-        py/emitinlinextensa.c \
-        py/emitnarm.c \
-        py/emitnthumb.c \
-        py/emitnx64.c \
-        py/emitnx86.c \
-        py/emitnxtensa.c \
-        py/emitnxtensawin.c \
-        py/formatfloat.c \
-        py/frozenmod.c \
-        py/gc.c \
-        py/lexer.c \
-        py/malloc.c \
-        py/map.c \
-        py/modarray.c \
-        py/modbuiltins.c \
-        py/modcmath.c \
-        py/modcollections.c \
-        py/modgc.c \
-        py/modio.c \
-        py/modmath.c \
-        py/modmicropython.c \
-        py/modstruct.c \
-        py/modsys.c \
-        py/modthread.c \
-        py/moduerrno.c \
-        py/mpprint.c \
-        py/mpstate.c \
-        py/mpz.c \
-        py/nativeglue.c \
-        py/nlr.c \
-        py/nlrpowerpc.c \
-        py/nlrsetjmp.c \
-        py/nlrthumb.c \
-        py/nlrx64.c \
-        py/nlrx86.c \
-        py/nlrxtensa.c \
-        py/obj.c \
-        py/objarray.c \
-        py/objattrtuple.c \
-        py/objbool.c \
-        py/objboundmeth.c \
-        py/objcell.c \
-        py/objclosure.c \
-        py/objcomplex.c \
-        py/objdeque.c \
-        py/objdict.c \
-        py/objenumerate.c \
-        py/objexcept.c \
-        py/objfilter.c \
-        py/objfloat.c \
-        py/objfun.c \
-        py/objgenerator.c \
-        py/objgetitemiter.c \
-        py/objint.c \
-        py/objint_longlong.c \
-        py/objint_mpz.c \
-        py/objlist.c \
-        py/objmap.c \
-        py/objmodule.c \
-        py/objnamedtuple.c \
-        py/objnone.c \
-        py/objobject.c \
-        py/objpolyiter.c \
-        py/objproperty.c \
-        py/objrange.c \
-        py/objreversed.c \
-        py/objset.c \
-        py/objsingleton.c \
-        py/objslice.c \
-        py/objstr.c \
-        py/objstringio.c \
-        py/objstrunicode.c \
-        py/objtuple.c \
-        py/objtype.c \
-        py/objzip.c \
-        py/opmethods.c \
-        py/pairheap.c \
-        py/parse.c \
-        py/parsenum.c \
-        py/parsenumbase.c \
-        py/persistentcode.c \
-        py/profile.c \
-        py/pystack.c \
-        py/qstr.c \
-        py/reader.c \
-        py/repl.c \
-        py/ringbuf.c \
-        py/runtime.c \
-        py/runtime_utils.c \
-        py/scheduler.c \
-        py/scope.c \
-        py/sequence.c \
-        py/showbc.c \
-        py/smallint.c \
-        py/stackctrl.c \
-        py/stream.c \
-        py/unicode.c \
-        py/vm.c \
-        py/vstr.c \
-        py/warning.c
-        
-        
-EXTMOD_SRCS = \
-        extmod/mb_ussl_error.c \
-        extmod/modaes.c \
-        extmod/modhash.c  \
-        extmod/moduasyncio.c \
-               extmod/moduwebsocket.c \
-        extmod/modubinascii.c \
-        extmod/moducryptolib.c \
-        extmod/moductypes.c \
-        extmod/moduhashlib.c  \
-        extmod/modujson.c \
-        extmod/modurandom.c \
-        extmod/modure.c \
-        extmod/moduselect.c \
-        extmod/modussl_mbedtls.c \
-        extmod/moduzlib.c \
-        extmod/utime_mphal.c \
-        extmod/vfs.c \
-        extmod/vfs_blockdev.c \
-        extmod/vfs_efs.c \
-        extmod/vfs_efs_file.c \
-        extmod/vfs_fat.c \
-        extmod/vfs_fat_file.c \
-        extmod/vfs_lfs.c \
-        extmod/vfs_reader.c \
-        extmod/vfs_temp.c \
-        extmod/vfs_temp_file.c \
-        extmod/vfs_fat_sdio.c \
-        extmod/vfs_fat_sdio_file.c \
-        lib/littlefs/lfs1.c \
-        lib/littlefs/lfs1_util.c \
-        lib/littlefs/lfs2.c \
-        lib/littlefs/lfs2_util.c \
-        lib/mp-readline/readline.c \
-        lib/netutils/netutils.c \
-        lib/timeutils/timeutils.c \
-        lib/utils/interrupt_char.c \
-        lib/utils/pyexec.c \
-        lib/utils/stdout_helpers.c \
-        lib/utils/sys_stdio_mphal.c
-
-
-QPY_SRCS = \
-        ports/quectel/core/build/_frozen_mpy.c \
-               ports/quectel/core/source/random.c \
-        ports/quectel/core/source/audio_audio.c \
-        ports/quectel/core/source/audio_handle.c \
-        ports/quectel/core/source/audio_queue.c \
-        ports/quectel/core/source/audio_record.c \
-        ports/quectel/core/source/audio_tts.c \
-        ports/quectel/core/source/audiocodec_rt5616.c \
-        ports/quectel/core/source/callbackdeal.c \
-        ports/quectel/core/source/camera_capture.c \
-        ports/quectel/core/source/camera_preview.c \
-        ports/quectel/core/source/camera_scandecode.c \
-        ports/quectel/core/source/devreport.c \
-        ports/quectel/core/source/gccollect.c \
-        ports/quectel/core/source/help.c \
-        ports/quectel/core/source/linklist.c \
-        ports/quectel/core/source/machine_extint.c \
-        ports/quectel/core/source/machine_hw_spi.c \
-        ports/quectel/core/source/machine_iic.c \
-        ports/quectel/core/source/machine_iic_simulation.c \
-        ports/quectel/core/source/machine_keypad.c \
-        ports/quectel/core/source/machine_lcd.c \
-        ports/quectel/core/source/machine_nandflash.c \
-        ports/quectel/core/source/machine_pin.c \
-        ports/quectel/core/source/machine_rtc.c \
-        ports/quectel/core/source/machine_timer.c \
-        ports/quectel/core/source/machine_uart.c \
-        ports/quectel/core/source/machine_wdt.c \
-        ports/quectel/core/source/misc_adc.c \
-        ports/quectel/core/source/misc_power.c \
-        ports/quectel/core/source/misc_powerkey.c \
-        ports/quectel/core/source/misc_pwm.c \
-        ports/quectel/core/source/misc_temperature.c \
-        ports/quectel/core/source/misc_usb.c \
-        ports/quectel/core/source/misc_usbnet.c \
-        ports/quectel/core/source/modatcmd.c \
-        ports/quectel/core/source/modaudio.c \
-        ports/quectel/core/source/modaudiocodec.c \
-        ports/quectel/core/source/modble.c \
-        ports/quectel/core/source/modbt.c \
-        ports/quectel/core/source/modcamera.c \
-        ports/quectel/core/source/modcelllocator.c \
-        ports/quectel/core/source/modcelllocator_qpy.c \
-               ports/quectel/core/source/locator.c \
-        ports/quectel/core/source/modcsd.c \
-        ports/quectel/core/source/moddatacall.c \
-        ports/quectel/core/source/moddev.c \
-        ports/quectel/core/source/modethernet.c \
-        ports/quectel/core/source/modethernet_dm9051.c \
-        ports/quectel/core/source/modethernet_w5500.c \
-        ports/quectel/core/source/modethernet_ch395.c \
-        ports/quectel/core/source/modexample.c \
-        ports/quectel/core/source/modfota.c \
-        ports/quectel/core/source/modgnss.c \
-        ports/quectel/core/source/modlpm.c \
-        ports/quectel/core/source/modlvgl.c \
-        ports/quectel/core/source/modlvgl_other_hander.c \
-        ports/quectel/core/source/modlwm2m.c \
-        ports/quectel/core/source/modmachine.c \
-        ports/quectel/core/source/modmisc.c \
-        ports/quectel/core/source/modnb.c \
-        ports/quectel/core/source/modnet.c \
-        ports/quectel/core/source/modostimer.c \
-        ports/quectel/core/source/modpoc.c \
-        ports/quectel/core/source/modqrcode.c \
-        ports/quectel/core/source/modrtmp.c \
-        ports/quectel/core/source/modsecuredata.c \
-        ports/quectel/core/source/modsensor.c \
-        ports/quectel/core/source/modsha1.c \
-        ports/quectel/core/source/modsim.c \
-        ports/quectel/core/source/modslipif.c \
-        ports/quectel/core/source/modsms.c \
-        ports/quectel/core/source/modussd.c \
-        ports/quectel/core/source/modsocket.c \
-        ports/quectel/core/source/modwifi.c \
-        ports/quectel/core/source/modtp.c \
-        ports/quectel/core/source/moduos.c \
-        ports/quectel/core/source/modutils.c \
-        ports/quectel/core/source/modutime.c \
-        ports/quectel/core/source/modvoicecall.c \
-        ports/quectel/core/source/modwifilocator.c \
-        ports/quectel/core/source/modwifiscan.c \
-        ports/quectel/core/source/mphalport.c \
-        ports/quectel/core/source/mpthreadport.c \
-        ports/quectel/core/source/nb_aep.c \
-        ports/quectel/core/source/nb_oc.c \
-        ports/quectel/core/source/nb_onenet.c \
-        ports/quectel/core/source/quecpython.c \
-        ports/quectel/core/source/sensor_sn95500.c \
-        ports/quectel/core/source/sensor_icckey.c \
-        ports/quectel/core/source/sensor_gnss.c \
-        ports/quectel/core/source/sensor_handmic_key.c \
-        ports/quectel/core/source/tp_gt9xx.c \
-        ports/quectel/core/source/tp_xpt2046.c \
-        ports/quectel/core/source/tp_cst816.c \
-       ports/quectel/core/source/tp_ft6x36.c \
-        ports/quectel/core/source/tp_st1615.c \
-        ports/quectel/core/source/modGsensor.c \
-        ports/quectel/core/source/modGsensor_SC7A20.c \
-        ports/quectel/core/source/modHsensor.c \
-        ports/quectel/core/source/modHsensor_GH3018.c \
-        ports/quectel/core/source/modHsensor_HX3918.c \
-        ports/quectel/core/source/modgpio_encoder.c \
-        ports/quectel/core/source/modVideoCall.c \
-        ports/quectel/core/source/modVideoCall_juphoon.c \
-        ports/quectel/core/source/modrsa.c \
-        ports/quectel/core/source/modsftp.c \
-        ports/quectel/core/source/utils_crc32.c \
-        ports/quectel/core/source/modwebserver.c \
-        ports/quectel/core/source/http_parser.c \
-        ports/quectel/core/source/modethernet_yt8512h.c \
-        ports/quectel/core/source/sim_esim.c \
-        ports/quectel/core/source/modG711.c \
-        ports/quectel/core/source/modG729.c \
-        ports/quectel/core/source/modG722.c \
-        ports/quectel/core/source/modcan_mcp2515.c \
-        ports/quectel/core/source/modextuart_wk2114.c \
-        ports/quectel/core/source/modgpio_encoder.c \
-        ports/quectel/core/source/modextgpio_aw9523.c \
-        ports/quectel/core/source/modalipay.c \
-        ports/quectel/core/source/machine_key.c \
-        ports/quectel/core/source/lpm_wakeup.c \
-        ports/quectel/core/source/modnetwork.c \
-        ports/quectel/core/source/modwlan_ASR5803.c \
-        ports/quectel/core/source/machine_soft_spi.c \
-        ports/quectel/core/source/modwlan.c\
-        ports/quectel/core/source/code128_p.c \
-        ports/quectel/core/source/modmask.c \
-        ports/quectel/core/source/modVad.c \
-        ports/quectel/core/source/machine_one_wire.c\
-       ports/quectel/core/source/modalipay_collection.c \
-        ports/quectel/core/source/modsif.c\
-        ports/quectel/core/source/jrtc.c \
-        ports/quectel/core/source/modnfc.c \
-        ports/quectel/core/source/nfc_sl6320.c \
-       ports/quectel/core/source/modstk.c \
-        ports/quectel/core/source/modalipay_se.c \
-        ports/quectel/core/source/modvoip.c \
-        ports/quectel/core/source/modipsec.c \
-        ports/quectel/core/source/modecdsa.c \
-        ports/quectel/core/source/modecdh.c \
-        ports/quectel/core/source/moddlms.c    \
-        ports/quectel/core/source/modai_rtc.c
-        
-ifeq ($(CONFIG_QUECTHING), y)
-ifeq ($(strip $(PLAT)),RDA)
-QPY_SRCS += ../../components/quecsdk/cloud/python/modquecIot-BC25old.c
-else
-QPY_SRCS += ../../components/quecsdk/cloud/python/modquecIot.c
-endif
-endif
-
-
-$(NAME)_ARCHIVES = \
-       ports/quectel/core/source/libimslvad.a
-
-ifeq ($(CONFIG_USQLITE), y)
-EXTMOD_SRCS += lib/usqlite/usqlite_connection.c \
-                       lib/usqlite/usqlite_cursor.c \
-                       lib/usqlite/usqlite_row.c \
-                       lib/usqlite/usqlite_file.c \
-                       lib/usqlite/usqlite_mem.c \
-                       lib/usqlite/usqlite_vfs.c \
-                       lib/usqlite/usqlite_utils.c \
-                       lib/usqlite/usqlite.c \
-                       lib/usqlite/usqlite_module.c
-$(NAME)_INCS += lib/usqlite
-endif
-
-
-ifeq ($(CONFIG_LVGL), y)
-
-LVGL_SRCS_1  += \
-lib/lvgl/src/extra/layouts/flex/lv_flex.c \
-lib/lvgl/src/extra/layouts/grid/lv_grid.c \
-lib/lvgl/src/extra/libs/bmp/lv_bmp.c \
-lib/lvgl/src/extra/libs/ffmpeg/lv_ffmpeg.c \
-lib/lvgl/src/extra/libs/freetype/lv_freetype.c \
-lib/lvgl/src/extra/libs/fsdrv/lv_fs_fatfs.c \
-lib/lvgl/src/extra/libs/fsdrv/lv_fs_posix.c \
-lib/lvgl/src/extra/libs/fsdrv/lv_fs_helios.c \
-lib/lvgl/src/extra/libs/fsdrv/lv_fs_stdio.c \
-lib/lvgl/src/extra/libs/fsdrv/lv_fs_win32.c \
-lib/lvgl/src/extra/libs/gif/gifdec.c \
-lib/lvgl/src/extra/libs/gif/lv_gif.c \
-lib/lvgl/src/extra/libs/png/lodepng.c \
-lib/lvgl/src/extra/libs/png/lv_png.c \
-lib/lvgl/src/extra/libs/qrcode/lv_qrcode.c \
-lib/lvgl/src/extra/libs/qrcode/qrcodegen.c \
-lib/lvgl/src/extra/libs/rlottie/lv_rlottie.c \
-lib/lvgl/src/extra/libs/sjpg/lv_sjpg.c \
-lib/lvgl/src/extra/libs/sjpg/tjpgd.c \
-lib/lvgl/src/extra/lv_extra.c \
-lib/lvgl/src/extra/others/gridnav/lv_gridnav.c \
-lib/lvgl/src/extra/others/monkey/lv_monkey.c \
-lib/lvgl/src/extra/others/snapshot/lv_snapshot.c \
-lib/lvgl/src/extra/themes/basic/lv_theme_basic.c \
-lib/lvgl/src/extra/themes/default/lv_theme_default.c \
-lib/lvgl/src/extra/themes/mono/lv_theme_mono.c \
-lib/lvgl/src/extra/widgets/animimg/lv_animimg.c \
-lib/lvgl/src/extra/widgets/calendar/lv_calendar.c \
-lib/lvgl/src/extra/widgets/calendar/lv_calendar_header_arrow.c \
-lib/lvgl/src/extra/widgets/calendar/lv_calendar_header_dropdown.c \
-lib/lvgl/src/extra/widgets/chart/lv_chart.c \
-lib/lvgl/src/extra/widgets/colorwheel/lv_colorwheel.c \
-lib/lvgl/src/extra/widgets/imgbtn/lv_imgbtn.c \
-lib/lvgl/src/extra/widgets/keyboard/lv_keyboard.c \
-lib/lvgl/src/extra/widgets/led/lv_led.c \
-lib/lvgl/src/extra/widgets/list/lv_list.c \
-lib/lvgl/src/extra/widgets/menu/lv_menu.c \
-lib/lvgl/src/extra/widgets/meter/lv_meter.c \
-lib/lvgl/src/extra/widgets/msgbox/lv_msgbox.c \
-lib/lvgl/src/extra/widgets/span/lv_span.c \
-lib/lvgl/src/extra/widgets/spinbox/lv_spinbox.c \
-lib/lvgl/src/extra/widgets/spinner/lv_spinner.c \
-lib/lvgl/src/extra/widgets/tabview/lv_tabview.c \
-lib/lvgl/src/extra/widgets/tileview/lv_tileview.c \
-lib/lvgl/src/extra/widgets/win/lv_win.c \
-lib/lvgl/src/extra/others/ime/lv_ime_pinyin.c \
-lib/lvgl/src/core/lv_disp.c \
-lib/lvgl/src/core/lv_group.c \
-lib/lvgl/src/core/lv_indev.c \
-lib/lvgl/src/core/lv_indev_scroll.c \
-lib/lvgl/src/core/lv_obj.c \
-lib/lvgl/src/core/lv_obj_class.c \
-lib/lvgl/src/core/lv_obj_draw.c \
-lib/lvgl/src/core/lv_obj_pos.c \
-lib/lvgl/src/core/lv_obj_scroll.c \
-lib/lvgl/src/core/lv_obj_style.c \
-lib/lvgl/src/core/lv_obj_style_gen.c \
-lib/lvgl/src/core/lv_obj_tree.c \
-lib/lvgl/src/core/lv_event.c \
-lib/lvgl/src/core/lv_refr.c \
-lib/lvgl/src/core/lv_theme.c \
-lib/lvgl/src/draw/lv_draw_arc.c \
-lib/lvgl/src/draw/lv_draw.c \
-lib/lvgl/src/draw/lv_draw_img.c \
-lib/lvgl/src/draw/lv_draw_label.c \
-lib/lvgl/src/draw/lv_draw_layer.c \
-lib/lvgl/src/draw/lv_draw_line.c \
-lib/lvgl/src/draw/lv_draw_mask.c \
-lib/lvgl/src/draw/lv_draw_rect.c \
-lib/lvgl/src/draw/lv_draw_transform.c \
-lib/lvgl/src/draw/lv_draw_triangle.c \
-lib/lvgl/src/draw/lv_img_buf.c \
-lib/lvgl/src/draw/lv_img_cache.c \
-lib/lvgl/src/draw/lv_img_decoder.c \
-lib/lvgl/src/draw/sdl/lv_draw_sdl.c \
-lib/lvgl/src/draw/sdl/lv_draw_sdl_arc.c \
-lib/lvgl/src/draw/sdl/lv_draw_sdl_bg.c \
-lib/lvgl/src/draw/sdl/lv_draw_sdl_composite.c \
-lib/lvgl/src/draw/sdl/lv_draw_sdl_img.c \
-lib/lvgl/src/draw/sdl/lv_draw_sdl_label.c \
-lib/lvgl/src/draw/sdl/lv_draw_sdl_line.c \
-lib/lvgl/src/draw/sdl/lv_draw_sdl_mask.c \
-lib/lvgl/src/draw/sdl/lv_draw_sdl_polygon.c \
-lib/lvgl/src/draw/sdl/lv_draw_sdl_rect.c \
-lib/lvgl/src/draw/sdl/lv_draw_sdl_stack_blur.c \
-lib/lvgl/src/draw/sdl/lv_draw_sdl_texture_cache.c \
-lib/lvgl/src/draw/sdl/lv_draw_sdl_utils.c \
-lib/lvgl/src/draw/sw/lv_draw_sw.c \
-lib/lvgl/src/draw/sw/lv_draw_sw_arc.c \
-lib/lvgl/src/draw/sw/lv_draw_sw_blend.c \
-lib/lvgl/src/draw/sw/lv_draw_sw_img.c \
-lib/lvgl/src/draw/sw/lv_draw_sw_letter.c \
-lib/lvgl/src/draw/sw/lv_draw_sw_line.c \
-lib/lvgl/src/draw/sw/lv_draw_sw_rect.c \
-lib/lvgl/src/draw/sw/lv_draw_sw_polygon.c \
-lib/lvgl/src/draw/sw/lv_draw_sw_gradient.c \
-lib/lvgl/src/draw/sw/lv_draw_sw_dither.c \
-lib/lvgl/src/draw/sw/lv_draw_sw_transform.c \
-lib/lvgl/src/draw/sw/lv_draw_sw_layer.c \
-lib/lvgl/src/font/lv_font.c \
-lib/lvgl/src/font/lv_font_fmt_txt.c \
-lib/lvgl/src/font/lv_font_loader.c \
-lib/lvgl/src/font/lv_font_dejavu_16_persian_hebrew.c \
-lib/lvgl/src/font/lv_font_montserrat_8.c \
-lib/lvgl/src/font/lv_font_montserrat_10.c \
-lib/lvgl/src/font/lv_font_montserrat_12.c \
-lib/lvgl/src/font/lv_font_montserrat_12_subpx.c \
-lib/lvgl/src/font/lv_font_montserrat_14.c \
-lib/lvgl/src/font/lv_font_montserrat_16.c \
-lib/lvgl/src/font/lv_font_montserrat_18.c \
-lib/lvgl/src/font/lv_font_montserrat_20.c \
-lib/lvgl/src/font/lv_font_montserrat_22.c \
-lib/lvgl/src/font/lv_font_montserrat_24.c \
-lib/lvgl/src/font/lv_font_montserrat_26.c \
-lib/lvgl/src/font/lv_font_montserrat_28.c \
-lib/lvgl/src/font/lv_font_montserrat_28_compressed.c \
-lib/lvgl/src/font/lv_font_montserrat_30.c \
-lib/lvgl/src/font/lv_font_montserrat_32.c \
-lib/lvgl/src/font/lv_font_montserrat_34.c \
-lib/lvgl/src/font/lv_font_montserrat_36.c \
-lib/lvgl/src/font/lv_font_montserrat_38.c \
-lib/lvgl/src/font/lv_font_montserrat_40.c \
-lib/lvgl/src/font/lv_font_montserrat_42.c \
-lib/lvgl/src/font/lv_font_montserrat_44.c \
-lib/lvgl/src/font/lv_font_montserrat_46.c \
-lib/lvgl/src/font/lv_font_montserrat_48.c \
-lib/lvgl/src/font/lv_font_simsun_16_cjk.c \
-lib/lvgl/src/font/lv_font_unscii_8.c \
-lib/lvgl/src/font/lv_font_unscii_16.c \
-lib/lvgl/src/font/lv_font_siyun_18.c \
-lib/lvgl/src/font/lv_font_arial_54.c \
-lib/lvgl/src/font/lv_font_siyuan_32.c \
-lib/lvgl/src/font/lv_font_sdSiyuan16.c \
-lib/lvgl/src/font/lv_font_SDsiyuan_8.c \
-lib/lvgl/src/font/lv_font_SDsiyuan_10.c \
-lib/lvgl/src/font/lv_font_SDsiyuan_12.c \
-lib/lvgl/src/font/lv_font_SDsiyuan_14.c \
-lib/lvgl/src/font/lv_font_SDsiyuan_16.c \
-lib/lvgl/src/font/lv_font_SDsiyuan_18.c \
-lib/lvgl/src/font/lv_font_SDsiyuan_20.c \
-lib/lvgl/src/font/lv_font_SDsiyuan_22.c \
-lib/lvgl/src/font/lv_font_SDsiyuan_24.c \
-lib/lvgl/src/font/lv_font_SDsiyuan_26.c \
-lib/lvgl/src/font/lv_font_SDsiyuan_28.c \
-lib/lvgl/src/font/lv_font_SDsiyuan_30.c \
-lib/lvgl/src/font/lv_font_SDsiyuan_32.c \
-lib/lvgl/src/font/lv_font_SDsiyuan_34.c \
-lib/lvgl/src/font/lv_font_SDsiyuan_36.c \
-lib/lvgl/src/font/lv_font_SDsiyuan_38.c \
-lib/lvgl/src/font/lv_font_SDsiyuan_40.c \
-lib/lvgl/src/font/lv_font_SDsiyuan_42.c \
-lib/lvgl/src/font/lv_font_SDsiyuan_44.c \
-lib/lvgl/src/font/lv_font_SDsiyuan_46.c \
-lib/lvgl/src/font/lv_font_SDsiyuan_48.c \
-lib/lvgl/src/font/lv_11_siyuan_light.c \
-
-LVGL_SRCS_2 = \
-lib/lvgl/src/font/lv_14_ali.c \
-lib/lvgl/src/font/lv_font_HarmonyOS_Bold_60.c \
-lib/lvgl/src/font/lv_font_HarmonyOS_Bold_100.c \
-lib/lvgl/src/font/lv_font_HarmonyOS_Regular_28.c \
-lib/lvgl/src/font/lv_font_HarmonyOS_Regular_48.c \
-lib/lvgl/src/font/lv_font_HarmonyOS_Regular_20.c \
-lib/lvgl/src/font/lv_font_siyuan_Bold_26.c \
-lib/lvgl/src/font/lv_font_siyuan_Regular_12.c \
-lib/lvgl/src/font/lv_font_siyuan_Regular_14.c \
-lib/lvgl/src/font/lv_font_siyuan_Regular_16.c \
-lib/lvgl/src/font/lv_font_siyuan_Regular_18.c \
-lib/lvgl/src/font/lv_font_siyuan_Regular_20.c \
-lib/lvgl/src/font/lv_font_siyuan_Regular_22.c \
-lib/lvgl/src/font/lv_bold_18.c \
-lib/lvgl/src/font/lv_bold_34.c \
-lib/lvgl/src/font/lv_bold_48.c \
-lib/lvgl/src/font/lv_regular_12.c \
-lib/lvgl/src/font/lv_regular_14.c \
-lib/lvgl/src/font/lv_regular_18.c \
-lib/lvgl/src/font/lv_regular_20.c \
-lib/lvgl/src/font/lv_regular_22.c \
-lib/lvgl/src/font/lv_regular_24.c \
-lib/lvgl/src/font/lv_regular_29.c \
-lib/lvgl/src/font/lv_font_tianbo_10.c \
-lib/lvgl/src/font/lv_font_tianbo_12.c \
-lib/lvgl/src/font/lv_font_tianbo_14.c \
-lib/lvgl/src/font/lv_font_tianbo_16.c \
-lib/lvgl/src/font/lv_font_12_qs.c \
-lib/lvgl/src/font/lv_font_12.c \
-lib/lvgl/src/font/lv_font_21_light.c \
-lib/lvgl/src/font/lv_font_30_light.c \
-lib/lvgl/src/font/lv_font_14_simsum.c \
-lib/lvgl/src/font/lv_font_16_simsum.c \
-lib/lvgl/src/font/lv_font_18_simsum.c \
-lib/lvgl/src/font/lv_font_70_bold.c \
-lib/lvgl/src/font/lv_font_28_dial.c \
-lib/lvgl/src/font/lv_font_60_main_menu.c \
-lib/lvgl/src/font/lv_font_50_main_menu_e.c \
-lib/lvgl/src/font/K01_font_16_ALL.c \
-lib/lvgl/src/font/K01_font_30_DIAL.c \
-lib/lvgl/src/hal/lv_hal_disp.c \
-lib/lvgl/src/hal/lv_hal_indev.c \
-lib/lvgl/src/hal/lv_hal_tick.c \
-lib/lvgl/src/misc/lv_anim.c \
-lib/lvgl/src/misc/lv_anim_timeline.c \
-lib/lvgl/src/misc/lv_area.c \
-lib/lvgl/src/misc/lv_async.c \
-lib/lvgl/src/misc/lv_bidi.c \
-lib/lvgl/src/misc/lv_color.c \
-lib/lvgl/src/misc/lv_fs.c \
-lib/lvgl/src/misc/lv_gc.c \
-lib/lvgl/src/misc/lv_ll.c \
-lib/lvgl/src/misc/lv_log.c \
-lib/lvgl/src/misc/lv_lru.c \
-lib/lvgl/src/misc/lv_math.c \
-lib/lvgl/src/misc/lv_mem.c \
-lib/lvgl/src/misc/lv_printf.c \
-lib/lvgl/src/misc/lv_style.c \
-lib/lvgl/src/misc/lv_style_gen.c \
-lib/lvgl/src/misc/lv_timer.c \
-lib/lvgl/src/misc/lv_tlsf.c \
-lib/lvgl/src/misc/lv_txt.c \
-lib/lvgl/src/misc/lv_txt_ap.c \
-lib/lvgl/src/misc/lv_utils.c \
-lib/lvgl/src/widgets/lv_arc.c \
-lib/lvgl/src/widgets/lv_bar.c \
-lib/lvgl/src/widgets/lv_btn.c \
-lib/lvgl/src/widgets/lv_btnmatrix.c \
-lib/lvgl/src/widgets/lv_canvas.c \
-lib/lvgl/src/widgets/lv_checkbox.c \
-lib/lvgl/src/widgets/lv_dropdown.c \
-lib/lvgl/src/widgets/lv_img.c \
-lib/lvgl/src/widgets/lv_label.c \
-lib/lvgl/src/widgets/lv_line.c \
-lib/lvgl/src/widgets/lv_roller.c \
-lib/lvgl/src/widgets/lv_slider.c \
-lib/lvgl/src/widgets/lv_switch.c \
-lib/lvgl/src/widgets/lv_table.c \
-lib/lvgl/src/widgets/lv_textarea.c \
-lib/lvgl/freetype-2.11.1/src/autofit/autofit.c \
-lib/lvgl/freetype-2.11.1/src/base/ftbase.c \
-lib/lvgl/freetype-2.11.1/src/base/ftbbox.c \
-lib/lvgl/freetype-2.11.1/src/base/ftbdf.c \
-lib/lvgl/freetype-2.11.1/src/base/ftbitmap.c \
-lib/lvgl/freetype-2.11.1/src/base/ftcid.c \
-lib/lvgl/freetype-2.11.1/src/base/ftfstype.c \
-lib/lvgl/freetype-2.11.1/src/base/ftgasp.c \
-lib/lvgl/freetype-2.11.1/src/base/ftglyph.c \
-lib/lvgl/freetype-2.11.1/src/base/ftgxval.c \
-lib/lvgl/freetype-2.11.1/src/base/ftinit.c \
-lib/lvgl/freetype-2.11.1/src/base/ftmm.c \
-lib/lvgl/freetype-2.11.1/src/base/ftotval.c \
-lib/lvgl/freetype-2.11.1/src/base/ftpatent.c \
-lib/lvgl/freetype-2.11.1/src/base/ftpfr.c \
-lib/lvgl/freetype-2.11.1/src/base/ftstroke.c \
-lib/lvgl/freetype-2.11.1/src/base/ftsynth.c \
-lib/lvgl/freetype-2.11.1/src/base/fttype1.c \
-lib/lvgl/freetype-2.11.1/src/base/ftwinfnt.c \
-lib/lvgl/freetype-2.11.1/src/bdf/bdf.c \
-lib/lvgl/freetype-2.11.1/src/bzip2/ftbzip2.c \
-lib/lvgl/freetype-2.11.1/src/cache/ftcache.c \
-lib/lvgl/freetype-2.11.1/src/cff/cff.c \
-lib/lvgl/freetype-2.11.1/src/cid/type1cid.c \
-lib/lvgl/freetype-2.11.1/src/gzip/ftgzip.c \
-lib/lvgl/freetype-2.11.1/src/lzw/ftlzw.c \
-lib/lvgl/freetype-2.11.1/src/pcf/pcf.c \
-lib/lvgl/freetype-2.11.1/src/pfr/pfr.c \
-lib/lvgl/freetype-2.11.1/src/psaux/psaux.c \
-lib/lvgl/freetype-2.11.1/src/pshinter/pshinter.c \
-lib/lvgl/freetype-2.11.1/src/psnames/psnames.c \
-lib/lvgl/freetype-2.11.1/src/raster/raster.c \
-lib/lvgl/freetype-2.11.1/src/sdf/sdf.c \
-lib/lvgl/freetype-2.11.1/src/sfnt/sfnt.c \
-lib/lvgl/freetype-2.11.1/src/smooth/smooth.c \
-lib/lvgl/freetype-2.11.1/src/truetype/truetype.c \
-lib/lvgl/freetype-2.11.1/src/type1/type1.c \
-lib/lvgl/freetype-2.11.1/src/type42/type42.c \
-lib/lvgl/freetype-2.11.1/src/winfonts/winfnt.c \
-lib/lvgl/freetype-2.11.1/src/base/ftsystem.c \
-lib/lvgl/freetype-2.11.1/src/base/ftdebug.c
-endif
-
-
-
-$(NAME)_SRCS += $(PY_SRCS) $(EXTMOD_SRCS) $(QPY_SRCS)
-ifeq ($(CONFIG_LVGL), y)
-$(NAME)_SRCS_2 = $(LVGL_SRCS_1)
-$(NAME)_SRCS_3 = $(LVGL_SRCS_2)
-endif
-
-$(NAME)_INCS = \
-       . \
-       extmod \
-       genhdr \
-       lib \
-       lib/littlefs \
-       lib/mp-readline \
-       lib/netutils \
-       lib/timeutils \
-       lib/utils \
-       ports/quectel/core/source \
-       py 
-       
-ifeq ($(CONFIG_LVGL), y)
-$(NAME)_INCS += \
-       lib/lvgl \
-       lib/lvgl        \
-       lib/lvgl/src    \
-       lib/lvgl/src/core       \
-       lib/lvgl/src/draw       \
-       lib/lvgl/src/extra      \
-       lib/lvgl/src/font       \
-       lib/lvgl/src/gpu        \
-       lib/lvgl/src/hal        \
-       lib/lvgl/src/misc       \
-       lib/lvgl/src/widgts \
-    lib/lvgl/freetype-2.11.1/include \
-    lib/lvgl/freetype-2.11.1/include/dlg \
-    lib/lvgl/freetype-2.11.1/include/freetype \
-    lib/lvgl/freetype-2.11.1/include/freetype/config \
-    lib/lvgl/freetype-2.11.1/include/freetype/internal \
-    lib/lvgl/freetype-2.11.1/include/freetype/internal/services \
-    lib/lvgl/freetype-2.11.1/src/base \
-    lib/lvgl/freetype-2.11.1/src/autofit \
-    lib/lvgl/freetype-2.11.1/src/bdf    \
-    lib/lvgl/freetype-2.11.1/src/bzip2  \
-    lib/lvgl/freetype-2.11.1/src/cache  \
-    lib/lvgl/freetype-2.11.1/src/cff    \
-    lib/lvgl/freetype-2.11.1/src/cid    \
-    lib/lvgl/freetype-2.11.1/src/gzip   \
-    lib/lvgl/freetype-2.11.1/src/lzw    \
-    lib/lvgl/freetype-2.11.1/src/pcf    \
-    lib/lvgl/freetype-2.11.1/src/pfr    \
-    lib/lvgl/freetype-2.11.1/src/psaux  \
-    lib/lvgl/freetype-2.11.1/src/pshinter   \
-    lib/lvgl/freetype-2.11.1/src/psnames    \
-    lib/lvgl/freetype-2.11.1/src/raster \
-    lib/lvgl/freetype-2.11.1/src/sdf    \
-    lib/lvgl/freetype-2.11.1/src/sfnt   \
-    lib/lvgl/freetype-2.11.1/src/smooth \
-    lib/lvgl/freetype-2.11.1/src/truetype   \
-    lib/lvgl/freetype-2.11.1/src/type1  \
-    lib/lvgl/freetype-2.11.1/src/type42 \
-    lib/lvgl/freetype-2.11.1/src/winfonts
-endif
-
-EMPTY=
-SPACE=$(EMPTY) $(EMPTY)
-COMMA=$(EMPTY),$(EMPTY)
-BUILD_TIMESTAMP=\\\"$(subst $(SPACE),_,$(subst $(COMMA),,$(shell echo $$(env LANG=en_US.UTF-8 date))))\\\"
-$(NAME)_DEFINE = \
-       MP_ENDIANNESS_LITTLE \
-       MICROPY_BUILD_DATE=${BUILD_TIMESTAMP}
-
-
-
-ifneq ($(strip $(PLAT)),Qualcomm)
-$(NAME)_CFLAGS = \
-       -Wno-error=unused-parameter \
-       -Wno-error=format-truncation \
-       -Wno-error=unused-variable \
-       -Wno-error=unused-function \
-       -Wno-error=format=
-else
-$(NAME)_CFLAGS = -Wno-error=tautological-constant-out-of-range-compare \
-                                -Wno-error=missing-field-initializers \
-                                -Wno-error=unused-parameter \
-                                -Wno-error=unused-variable \
-                                -Wno-error=unused-function \
-                                -Wno-error=missing-braces \
-                                -Wno-error=sometimes-uninitialized
-endif
-
-
-ifeq ($(CONFIG_LVGL), y)
-$(NAME)_CFLAGS += \
-       -Wno-error=incompatible-pointer-types \
-       -Wno-error=sign-compare \
-       -Wno-error=unused-but-set-variable \
-       -Wno-error=switch-unreachable \
-       -Wno-error=unused-function \
-       -Wno-error=implicit-function-declaration \
-       -Wno-error=missing-field-initializers \
-       -Wno-error=unused-parameter \
-       -Wno-error=unused-variable \
-       -Wno-error=type-limits \
-       -Wno-error=format= \
-       -Wno-error=discarded-qualifiers \
-       -Wno-error=maybe-uninitialized \
-       -Wno-error=int-conversion
-endif
-
-ifeq ($(CONFIG_SPINAND), y)
-$(NAME)_CFLAGS += \
-       -Wno-error=restrict \
-       -Wno-error=format-overflow=
-endif
-
-$(NAME)_COMPONENTS = peripheral
-
-$(NAME)_COMPONENTS += driver
-
-ifeq ($(CONFIG_DECODE_QUECTEL), y)
-$(NAME)_COMPONENTS += components/decode/quectel
-endif
-
-ifeq ($(CONFIG_DECODE_QINGYA), y)
-ifneq ($(strip $(PLAT)),ASR)
-ifneq ($(strip $(PLAT)),ASR_1606)
-$(NAME)_COMPONENTS += components/decode/qingya
-endif
-endif
-endif
-
-ifeq ($(CONFIG_JPEG), y)
-$(NAME)_COMPONENTS += components/jpeg
-endif
-
-$(NAME)_COMPONENTS += utilities
-
-
-$(NAME)_COMPONENTS += components/audio
-
-ifneq (,$(filter y,$(CONFIG_SPINAND) $(CONFIG_SPI_SDCARD)))
-$(NAME)_COMPONENTS += components/fs
-endif
-
-ifeq ($(CONFIG_RTMP), y)
-$(NAME)_COMPONENTS += components/rtmpdump
-endif
-ifeq ($(CONFIG_JRTC), y)
-$(NAME)_COMPONENTS += components/jpeg
-$(NAME)_COMPONENTS += components/jrtc
-$(NAME)_INCS += ../../components/jrtc/inc
-
-endif
-
-ifeq ($(CONFIG_SENSOR_VC9202), y)
-$(NAME)_COMPONENTS += components/sensor/VC9202
-$(NAME)_INCS += ../../components/sensor/VS9202/inc
-$(NAME)_INCS += ../../components/sensor/VS9202/algo/inc
-endif
-
-ifeq ($(CONFIG_POC), y)
-$(NAME)_CFLAGS += \
-       -Wno-error=incompatible-pointer-types \
-       -Wno-error=ignored-qualifiers \
-       -Wno-error=int-conversion \
-       -Wno-error=implicit-function-declaration \
-       -Wno-error=discarded-qualifiers \
-       -Wno-error=unused-const-variable=
-
-$(NAME)_COMPONENTS += components/poc
-endif
-
-ifeq ($(CONFIG_QRCODE), y)
-$(NAME)_COMPONENTS += components/qrcode
-endif
-
-ifeq ($(CONFIG_HX3918), y)
-$(NAME)_COMPONENTS += components/HX3918
-endif
-ifeq ($(CONFIG_GH301x), y)
-$(NAME)_COMPONENTS += components/GH301X
-endif
-ifeq ($(CONFIG_SC7A20), y)
-$(NAME)_COMPONENTS += components/SC7A20
-endif
-ifeq ($(CONFIG_juphoon), y)
-$(NAME)_COMPONENTS += components/juphoon
-endif
-
-ifeq ($(CONFIG_LIBSSH2), y)
-$(NAME)_INCS += ../../components/ssh2/include \
-                ../../components/ssh2/src
-$(NAME)_COMPONENTS += components/ssh2
-endif
-
-ifeq ($(CONFIG_QUECTHING), y)
-$(NAME)_INCS += ../../components/quecsdk
-$(NAME)_COMPONENTS += components/quecsdk
-endif
-
-ifeq ($(CONFIG_GMSSL), y)
-$(NAME)_COMPONENTS += components/GMSSL
-endif
-
-ifeq ($(CONFIG_GB2312), y)
-$(NAME)_COMPONENTS += components/decode/gb2312
-endif
-
-ifeq ($(CONFIG_ESIMSDK), y)
-$(NAME)_COMPONENTS += components/esim
-endif
-
-ifeq ($(CONFIG_NFC_SL6320), y)
-$(NAME)_COMPONENTS += components/NFC/SL6320
-endif
-
-ifeq ($(CONFIG_VOIP), y)
-$(NAME)_INCS += ../../components/voip/libexosip2/include  \
-                ../../components/voip/libosip2/include  \
-                ../../components/voip/rtp
-$(NAME)_COMPONENTS += components/voip
-endif
-
-ifeq ($(CONFIG_ETHERNET_W5500), y)
-$(NAME)_COMPONENTS += components/ethernet
-$(NAME)_INCS += ../../components/ethernet/wiznet
-endif
-
-ifeq ($(CONFIG_SLIP), y)
-$(NAME)_COMPONENTS += components/slip
-$(NAME)_INCS += ../../components/slip
-endif
-
-ifeq ($(CONFIG_DLMS), y)
-$(NAME)_COMPONENTS += components/dlms
-endif
-
-ifeq ($(CONFIG_MICROPYTHON_EXTENSION_PERF), y)
-$(NAME)_COMPONENTS += components/micropython_extension
-$(NAME)_INCS += ../../components/micropython_extension/perf
-endif
-
-ifeq ($(CONFIG_MICROPYTHON_EXTENSION_SECURE_APP), y)
-$(NAME)_COMPONENTS += components/micropython_extension
-$(NAME)_INCS += ../../components/micropython_extension/secure_app
-endif
-
-$(NAME)_CFLAGS += -Wno-error=implicit-fallthrough
-
-$(NAME)_PRIVATE_SCRIPT = private.mk
-
-$(NAME)_PRIVATE_SCRIPT_TARGETS = construct clean
+\r
+NAME := MICROPYTHON\r
+\r
+include config/$(KCONFIG_CONFIG)\r
+\r
+PY_SRCS = \\r
+        py/argcheck.c \\r
+        py/asmarm.c \\r
+        py/asmbase.c \\r
+        py/asmthumb.c \\r
+        py/asmx64.c \\r
+        py/asmx86.c \\r
+        py/asmxtensa.c \\r
+        py/bc.c \\r
+        py/binary.c \\r
+        py/builtinevex.c \\r
+        py/builtinhelp.c \\r
+        py/builtinimport.c \\r
+        py/compile.c \\r
+        py/emitbc.c \\r
+        py/emitcommon.c \\r
+        py/emitglue.c \\r
+        py/emitinlinethumb.c \\r
+        py/emitinlinextensa.c \\r
+        py/emitnarm.c \\r
+        py/emitnthumb.c \\r
+        py/emitnx64.c \\r
+        py/emitnx86.c \\r
+        py/emitnxtensa.c \\r
+        py/emitnxtensawin.c \\r
+        py/formatfloat.c \\r
+        py/frozenmod.c \\r
+        py/gc.c \\r
+        py/lexer.c \\r
+        py/malloc.c \\r
+        py/map.c \\r
+        py/modarray.c \\r
+        py/modbuiltins.c \\r
+        py/modcmath.c \\r
+        py/modcollections.c \\r
+        py/modgc.c \\r
+        py/modio.c \\r
+        py/modmath.c \\r
+        py/modmicropython.c \\r
+        py/modstruct.c \\r
+        py/modsys.c \\r
+        py/modthread.c \\r
+        py/moduerrno.c \\r
+        py/mpprint.c \\r
+        py/mpstate.c \\r
+        py/mpz.c \\r
+        py/nativeglue.c \\r
+        py/nlr.c \\r
+        py/nlrpowerpc.c \\r
+        py/nlrsetjmp.c \\r
+        py/nlrthumb.c \\r
+        py/nlrx64.c \\r
+        py/nlrx86.c \\r
+        py/nlrxtensa.c \\r
+        py/obj.c \\r
+        py/objarray.c \\r
+        py/objattrtuple.c \\r
+        py/objbool.c \\r
+        py/objboundmeth.c \\r
+        py/objcell.c \\r
+        py/objclosure.c \\r
+        py/objcomplex.c \\r
+        py/objdeque.c \\r
+        py/objdict.c \\r
+        py/objenumerate.c \\r
+        py/objexcept.c \\r
+        py/objfilter.c \\r
+        py/objfloat.c \\r
+        py/objfun.c \\r
+        py/objgenerator.c \\r
+        py/objgetitemiter.c \\r
+        py/objint.c \\r
+        py/objint_longlong.c \\r
+        py/objint_mpz.c \\r
+        py/objlist.c \\r
+        py/objmap.c \\r
+        py/objmodule.c \\r
+        py/objnamedtuple.c \\r
+        py/objnone.c \\r
+        py/objobject.c \\r
+        py/objpolyiter.c \\r
+        py/objproperty.c \\r
+        py/objrange.c \\r
+        py/objreversed.c \\r
+        py/objset.c \\r
+        py/objsingleton.c \\r
+        py/objslice.c \\r
+        py/objstr.c \\r
+        py/objstringio.c \\r
+        py/objstrunicode.c \\r
+        py/objtuple.c \\r
+        py/objtype.c \\r
+        py/objzip.c \\r
+        py/opmethods.c \\r
+        py/pairheap.c \\r
+        py/parse.c \\r
+        py/parsenum.c \\r
+        py/parsenumbase.c \\r
+        py/persistentcode.c \\r
+        py/profile.c \\r
+        py/pystack.c \\r
+        py/qstr.c \\r
+        py/reader.c \\r
+        py/repl.c \\r
+        py/ringbuf.c \\r
+        py/runtime.c \\r
+        py/runtime_utils.c \\r
+        py/scheduler.c \\r
+        py/scope.c \\r
+        py/sequence.c \\r
+        py/showbc.c \\r
+        py/smallint.c \\r
+        py/stackctrl.c \\r
+        py/stream.c \\r
+        py/unicode.c \\r
+        py/vm.c \\r
+        py/vstr.c \\r
+        py/warning.c\r
+        \r
+        \r
+EXTMOD_SRCS = \\r
+        extmod/mb_ussl_error.c \\r
+        extmod/modaes.c \\r
+        extmod/modhash.c  \\r
+        extmod/moduasyncio.c \\r
+               extmod/moduwebsocket.c \\r
+        extmod/modubinascii.c \\r
+        extmod/moducryptolib.c \\r
+        extmod/moductypes.c \\r
+        extmod/moduhashlib.c  \\r
+        extmod/modujson.c \\r
+        extmod/modurandom.c \\r
+        extmod/modure.c \\r
+        extmod/moduselect.c \\r
+        extmod/modussl_mbedtls.c \\r
+        extmod/moduzlib.c \\r
+        extmod/utime_mphal.c \\r
+        extmod/vfs.c \\r
+        extmod/vfs_blockdev.c \\r
+        extmod/vfs_efs.c \\r
+        extmod/vfs_efs_file.c \\r
+        extmod/vfs_fat.c \\r
+        extmod/vfs_fat_file.c \\r
+        extmod/vfs_lfs.c \\r
+        extmod/vfs_reader.c \\r
+        extmod/vfs_temp.c \\r
+        extmod/vfs_temp_file.c \\r
+        extmod/vfs_fat_sdio.c \\r
+        extmod/vfs_fat_sdio_file.c \\r
+        lib/littlefs/lfs1.c \\r
+        lib/littlefs/lfs1_util.c \\r
+        lib/littlefs/lfs2.c \\r
+        lib/littlefs/lfs2_util.c \\r
+        lib/mp-readline/readline.c \\r
+        lib/netutils/netutils.c \\r
+        lib/timeutils/timeutils.c \\r
+        lib/utils/interrupt_char.c \\r
+        lib/utils/pyexec.c \\r
+        lib/utils/stdout_helpers.c \\r
+        lib/utils/sys_stdio_mphal.c\r
+\r
+\r
+QPY_SRCS = \\r
+        ports/quectel/core/build/_frozen_mpy.c \\r
+               ports/quectel/core/source/random.c \\r
+        ports/quectel/core/source/audio_audio.c \\r
+        ports/quectel/core/source/audio_handle.c \\r
+        ports/quectel/core/source/audio_queue.c \\r
+        ports/quectel/core/source/audio_record.c \\r
+        ports/quectel/core/source/audio_tts.c \\r
+        ports/quectel/core/source/audiocodec_rt5616.c \\r
+        ports/quectel/core/source/callbackdeal.c \\r
+        ports/quectel/core/source/camera_capture.c \\r
+        ports/quectel/core/source/camera_preview.c \\r
+        ports/quectel/core/source/camera_scandecode.c \\r
+        ports/quectel/core/source/devreport.c \\r
+        ports/quectel/core/source/gccollect.c \\r
+        ports/quectel/core/source/help.c \\r
+        ports/quectel/core/source/linklist.c \\r
+        ports/quectel/core/source/machine_extint.c \\r
+        ports/quectel/core/source/machine_hw_spi.c \\r
+        ports/quectel/core/source/machine_iic.c \\r
+        ports/quectel/core/source/machine_iic_simulation.c \\r
+        ports/quectel/core/source/machine_keypad.c \\r
+        ports/quectel/core/source/machine_lcd.c \\r
+        ports/quectel/core/source/machine_nandflash.c \\r
+        ports/quectel/core/source/machine_pin.c \\r
+        ports/quectel/core/source/machine_rtc.c \\r
+        ports/quectel/core/source/machine_timer.c \\r
+        ports/quectel/core/source/machine_uart.c \\r
+        ports/quectel/core/source/machine_wdt.c \\r
+        ports/quectel/core/source/misc_adc.c \\r
+        ports/quectel/core/source/misc_power.c \\r
+        ports/quectel/core/source/misc_powerkey.c \\r
+        ports/quectel/core/source/misc_pwm.c \\r
+        ports/quectel/core/source/misc_temperature.c \\r
+        ports/quectel/core/source/misc_usb.c \\r
+        ports/quectel/core/source/misc_usbnet.c \\r
+        ports/quectel/core/source/modatcmd.c \\r
+        ports/quectel/core/source/modaudio.c \\r
+        ports/quectel/core/source/modaudiocodec.c \\r
+        ports/quectel/core/source/modble.c \\r
+        ports/quectel/core/source/modbt.c \\r
+        ports/quectel/core/source/modcamera.c \\r
+        ports/quectel/core/source/modcelllocator.c \\r
+        ports/quectel/core/source/modcelllocator_qpy.c \\r
+               ports/quectel/core/source/locator.c \\r
+        ports/quectel/core/source/modcsd.c \\r
+        ports/quectel/core/source/moddatacall.c \\r
+        ports/quectel/core/source/moddev.c \\r
+        ports/quectel/core/source/modethernet.c \\r
+        ports/quectel/core/source/modethernet_dm9051.c \\r
+        ports/quectel/core/source/modethernet_w5500.c \\r
+        ports/quectel/core/source/modethernet_ch395.c \\r
+        ports/quectel/core/source/modexample.c \\r
+        ports/quectel/core/source/modfota.c \\r
+        ports/quectel/core/source/modgnss.c \\r
+        ports/quectel/core/source/modlpm.c \\r
+        ports/quectel/core/source/modlvgl.c \\r
+        ports/quectel/core/source/modlvgl_other_hander.c \\r
+        ports/quectel/core/source/modlwm2m.c \\r
+        ports/quectel/core/source/modmachine.c \\r
+        ports/quectel/core/source/modmisc.c \\r
+        ports/quectel/core/source/modnb.c \\r
+        ports/quectel/core/source/modnet.c \\r
+        ports/quectel/core/source/modostimer.c \\r
+        ports/quectel/core/source/modpoc.c \\r
+        ports/quectel/core/source/modqrcode.c \\r
+        ports/quectel/core/source/modrtmp.c \\r
+        ports/quectel/core/source/modsecuredata.c \\r
+        ports/quectel/core/source/modsensor.c \\r
+        ports/quectel/core/source/modsha1.c \\r
+        ports/quectel/core/source/modsim.c \\r
+        ports/quectel/core/source/modslipif.c \\r
+        ports/quectel/core/source/modsms.c \\r
+        ports/quectel/core/source/modussd.c \\r
+        ports/quectel/core/source/modsocket.c \\r
+        ports/quectel/core/source/modwifi.c \\r
+        ports/quectel/core/source/modtp.c \\r
+        ports/quectel/core/source/moduos.c \\r
+        ports/quectel/core/source/modutils.c \\r
+        ports/quectel/core/source/modutime.c \\r
+        ports/quectel/core/source/modvoicecall.c \\r
+        ports/quectel/core/source/modwifilocator.c \\r
+        ports/quectel/core/source/modwifiscan.c \\r
+        ports/quectel/core/source/mphalport.c \\r
+        ports/quectel/core/source/mpthreadport.c \\r
+        ports/quectel/core/source/nb_aep.c \\r
+        ports/quectel/core/source/nb_oc.c \\r
+        ports/quectel/core/source/nb_onenet.c \\r
+        ports/quectel/core/source/quecpython.c \\r
+        ports/quectel/core/source/sensor_sn95500.c \\r
+        ports/quectel/core/source/sensor_icckey.c \\r
+        ports/quectel/core/source/sensor_gnss.c \\r
+        ports/quectel/core/source/sensor_handmic_key.c \\r
+        ports/quectel/core/source/tp_gt9xx.c \\r
+        ports/quectel/core/source/tp_xpt2046.c \\r
+        ports/quectel/core/source/tp_cst816.c \\r
+       ports/quectel/core/source/tp_ft6x36.c \\r
+        ports/quectel/core/source/tp_st1615.c \\r
+        ports/quectel/core/source/modGsensor.c \\r
+        ports/quectel/core/source/modGsensor_SC7A20.c \\r
+        ports/quectel/core/source/modHsensor.c \\r
+        ports/quectel/core/source/modHsensor_GH3018.c \\r
+        ports/quectel/core/source/modHsensor_HX3918.c \\r
+        ports/quectel/core/source/modgpio_encoder.c \\r
+        ports/quectel/core/source/modVideoCall.c \\r
+        ports/quectel/core/source/modVideoCall_juphoon.c \\r
+        ports/quectel/core/source/modrsa.c \\r
+        ports/quectel/core/source/modsftp.c \\r
+        ports/quectel/core/source/utils_crc32.c \\r
+        ports/quectel/core/source/modwebserver.c \\r
+        ports/quectel/core/source/http_parser.c \\r
+        ports/quectel/core/source/modethernet_yt8512h.c \\r
+        ports/quectel/core/source/sim_esim.c \\r
+        ports/quectel/core/source/modG711.c \\r
+        ports/quectel/core/source/modG729.c \\r
+        ports/quectel/core/source/modG722.c \\r
+        ports/quectel/core/source/modcan_mcp2515.c \\r
+        ports/quectel/core/source/modextuart_wk2114.c \\r
+        ports/quectel/core/source/modgpio_encoder.c \\r
+        ports/quectel/core/source/modextgpio_aw9523.c \\r
+        ports/quectel/core/source/modalipay.c \\r
+        ports/quectel/core/source/machine_key.c \\r
+        ports/quectel/core/source/lpm_wakeup.c \\r
+        ports/quectel/core/source/modnetwork.c \\r
+        ports/quectel/core/source/modwlan_ASR5803.c \\r
+        ports/quectel/core/source/machine_soft_spi.c \\r
+        ports/quectel/core/source/modwlan.c\\r
+        ports/quectel/core/source/code128_p.c \\r
+        ports/quectel/core/source/modmask.c \\r
+        ports/quectel/core/source/modVad.c \\r
+        ports/quectel/core/source/machine_one_wire.c\\r
+       ports/quectel/core/source/modalipay_collection.c \\r
+        ports/quectel/core/source/modsif.c\\r
+        ports/quectel/core/source/jrtc.c \\r
+        ports/quectel/core/source/modnfc.c \\r
+        ports/quectel/core/source/nfc_sl6320.c \\r
+       ports/quectel/core/source/modstk.c \\r
+        ports/quectel/core/source/modalipay_se.c \\r
+        ports/quectel/core/source/modvoip.c \\r
+        ports/quectel/core/source/modipsec.c \\r
+        ports/quectel/core/source/modecdsa.c \\r
+        ports/quectel/core/source/modecdh.c \\r
+        ports/quectel/core/source/moddlms.c    \\r
+        ports/quectel/core/source/modai_rtc.c\r
+        \r
+ifeq ($(CONFIG_QUECTHING), y)\r
+ifeq ($(strip $(PLAT)),RDA)\r
+QPY_SRCS += ../../components/quecsdk/cloud/python/modquecIot-BC25old.c\r
+else\r
+QPY_SRCS += ../../components/quecsdk/cloud/python/modquecIot.c\r
+endif\r
+endif\r
+\r
+\r
+$(NAME)_ARCHIVES = \\r
+       ports/quectel/core/source/libimslvad.a\r
+# Opus:须在 $(NAME)_SRCS)+= 之前;路径相对 Helios 根(勿用 lastword,config.mk include 后会指错目录)\r
+-include services/microPython/microPython_opus.mk\r
+\r
+ifeq ($(CONFIG_USQLITE), y)\r
+EXTMOD_SRCS += lib/usqlite/usqlite_connection.c \\r
+                       lib/usqlite/usqlite_cursor.c \\r
+                       lib/usqlite/usqlite_row.c \\r
+                       lib/usqlite/usqlite_file.c \\r
+                       lib/usqlite/usqlite_mem.c \\r
+                       lib/usqlite/usqlite_vfs.c \\r
+                       lib/usqlite/usqlite_utils.c \\r
+                       lib/usqlite/usqlite.c \\r
+                       lib/usqlite/usqlite_module.c\r
+$(NAME)_INCS += lib/usqlite\r
+endif\r
+\r
+\r
+ifeq ($(CONFIG_LVGL), y)\r
+\r
+LVGL_SRCS_1  += \\r
+lib/lvgl/src/extra/layouts/flex/lv_flex.c \\r
+lib/lvgl/src/extra/layouts/grid/lv_grid.c \\r
+lib/lvgl/src/extra/libs/bmp/lv_bmp.c \\r
+lib/lvgl/src/extra/libs/ffmpeg/lv_ffmpeg.c \\r
+lib/lvgl/src/extra/libs/freetype/lv_freetype.c \\r
+lib/lvgl/src/extra/libs/fsdrv/lv_fs_fatfs.c \\r
+lib/lvgl/src/extra/libs/fsdrv/lv_fs_posix.c \\r
+lib/lvgl/src/extra/libs/fsdrv/lv_fs_helios.c \\r
+lib/lvgl/src/extra/libs/fsdrv/lv_fs_stdio.c \\r
+lib/lvgl/src/extra/libs/fsdrv/lv_fs_win32.c \\r
+lib/lvgl/src/extra/libs/gif/gifdec.c \\r
+lib/lvgl/src/extra/libs/gif/lv_gif.c \\r
+lib/lvgl/src/extra/libs/png/lodepng.c \\r
+lib/lvgl/src/extra/libs/png/lv_png.c \\r
+lib/lvgl/src/extra/libs/qrcode/lv_qrcode.c \\r
+lib/lvgl/src/extra/libs/qrcode/qrcodegen.c \\r
+lib/lvgl/src/extra/libs/rlottie/lv_rlottie.c \\r
+lib/lvgl/src/extra/libs/sjpg/lv_sjpg.c \\r
+lib/lvgl/src/extra/libs/sjpg/tjpgd.c \\r
+lib/lvgl/src/extra/lv_extra.c \\r
+lib/lvgl/src/extra/others/gridnav/lv_gridnav.c \\r
+lib/lvgl/src/extra/others/monkey/lv_monkey.c \\r
+lib/lvgl/src/extra/others/snapshot/lv_snapshot.c \\r
+lib/lvgl/src/extra/themes/basic/lv_theme_basic.c \\r
+lib/lvgl/src/extra/themes/default/lv_theme_default.c \\r
+lib/lvgl/src/extra/themes/mono/lv_theme_mono.c \\r
+lib/lvgl/src/extra/widgets/animimg/lv_animimg.c \\r
+lib/lvgl/src/extra/widgets/calendar/lv_calendar.c \\r
+lib/lvgl/src/extra/widgets/calendar/lv_calendar_header_arrow.c \\r
+lib/lvgl/src/extra/widgets/calendar/lv_calendar_header_dropdown.c \\r
+lib/lvgl/src/extra/widgets/chart/lv_chart.c \\r
+lib/lvgl/src/extra/widgets/colorwheel/lv_colorwheel.c \\r
+lib/lvgl/src/extra/widgets/imgbtn/lv_imgbtn.c \\r
+lib/lvgl/src/extra/widgets/keyboard/lv_keyboard.c \\r
+lib/lvgl/src/extra/widgets/led/lv_led.c \\r
+lib/lvgl/src/extra/widgets/list/lv_list.c \\r
+lib/lvgl/src/extra/widgets/menu/lv_menu.c \\r
+lib/lvgl/src/extra/widgets/meter/lv_meter.c \\r
+lib/lvgl/src/extra/widgets/msgbox/lv_msgbox.c \\r
+lib/lvgl/src/extra/widgets/span/lv_span.c \\r
+lib/lvgl/src/extra/widgets/spinbox/lv_spinbox.c \\r
+lib/lvgl/src/extra/widgets/spinner/lv_spinner.c \\r
+lib/lvgl/src/extra/widgets/tabview/lv_tabview.c \\r
+lib/lvgl/src/extra/widgets/tileview/lv_tileview.c \\r
+lib/lvgl/src/extra/widgets/win/lv_win.c \\r
+lib/lvgl/src/extra/others/ime/lv_ime_pinyin.c \\r
+lib/lvgl/src/core/lv_disp.c \\r
+lib/lvgl/src/core/lv_group.c \\r
+lib/lvgl/src/core/lv_indev.c \\r
+lib/lvgl/src/core/lv_indev_scroll.c \\r
+lib/lvgl/src/core/lv_obj.c \\r
+lib/lvgl/src/core/lv_obj_class.c \\r
+lib/lvgl/src/core/lv_obj_draw.c \\r
+lib/lvgl/src/core/lv_obj_pos.c \\r
+lib/lvgl/src/core/lv_obj_scroll.c \\r
+lib/lvgl/src/core/lv_obj_style.c \\r
+lib/lvgl/src/core/lv_obj_style_gen.c \\r
+lib/lvgl/src/core/lv_obj_tree.c \\r
+lib/lvgl/src/core/lv_event.c \\r
+lib/lvgl/src/core/lv_refr.c \\r
+lib/lvgl/src/core/lv_theme.c \\r
+lib/lvgl/src/draw/lv_draw_arc.c \\r
+lib/lvgl/src/draw/lv_draw.c \\r
+lib/lvgl/src/draw/lv_draw_img.c \\r
+lib/lvgl/src/draw/lv_draw_label.c \\r
+lib/lvgl/src/draw/lv_draw_layer.c \\r
+lib/lvgl/src/draw/lv_draw_line.c \\r
+lib/lvgl/src/draw/lv_draw_mask.c \\r
+lib/lvgl/src/draw/lv_draw_rect.c \\r
+lib/lvgl/src/draw/lv_draw_transform.c \\r
+lib/lvgl/src/draw/lv_draw_triangle.c \\r
+lib/lvgl/src/draw/lv_img_buf.c \\r
+lib/lvgl/src/draw/lv_img_cache.c \\r
+lib/lvgl/src/draw/lv_img_decoder.c \\r
+lib/lvgl/src/draw/sdl/lv_draw_sdl.c \\r
+lib/lvgl/src/draw/sdl/lv_draw_sdl_arc.c \\r
+lib/lvgl/src/draw/sdl/lv_draw_sdl_bg.c \\r
+lib/lvgl/src/draw/sdl/lv_draw_sdl_composite.c \\r
+lib/lvgl/src/draw/sdl/lv_draw_sdl_img.c \\r
+lib/lvgl/src/draw/sdl/lv_draw_sdl_label.c \\r
+lib/lvgl/src/draw/sdl/lv_draw_sdl_line.c \\r
+lib/lvgl/src/draw/sdl/lv_draw_sdl_mask.c \\r
+lib/lvgl/src/draw/sdl/lv_draw_sdl_polygon.c \\r
+lib/lvgl/src/draw/sdl/lv_draw_sdl_rect.c \\r
+lib/lvgl/src/draw/sdl/lv_draw_sdl_stack_blur.c \\r
+lib/lvgl/src/draw/sdl/lv_draw_sdl_texture_cache.c \\r
+lib/lvgl/src/draw/sdl/lv_draw_sdl_utils.c \\r
+lib/lvgl/src/draw/sw/lv_draw_sw.c \\r
+lib/lvgl/src/draw/sw/lv_draw_sw_arc.c \\r
+lib/lvgl/src/draw/sw/lv_draw_sw_blend.c \\r
+lib/lvgl/src/draw/sw/lv_draw_sw_img.c \\r
+lib/lvgl/src/draw/sw/lv_draw_sw_letter.c \\r
+lib/lvgl/src/draw/sw/lv_draw_sw_line.c \\r
+lib/lvgl/src/draw/sw/lv_draw_sw_rect.c \\r
+lib/lvgl/src/draw/sw/lv_draw_sw_polygon.c \\r
+lib/lvgl/src/draw/sw/lv_draw_sw_gradient.c \\r
+lib/lvgl/src/draw/sw/lv_draw_sw_dither.c \\r
+lib/lvgl/src/draw/sw/lv_draw_sw_transform.c \\r
+lib/lvgl/src/draw/sw/lv_draw_sw_layer.c \\r
+lib/lvgl/src/font/lv_font.c \\r
+lib/lvgl/src/font/lv_font_fmt_txt.c \\r
+lib/lvgl/src/font/lv_font_loader.c \\r
+lib/lvgl/src/font/lv_font_dejavu_16_persian_hebrew.c \\r
+lib/lvgl/src/font/lv_font_montserrat_8.c \\r
+lib/lvgl/src/font/lv_font_montserrat_10.c \\r
+lib/lvgl/src/font/lv_font_montserrat_12.c \\r
+lib/lvgl/src/font/lv_font_montserrat_12_subpx.c \\r
+lib/lvgl/src/font/lv_font_montserrat_14.c \\r
+lib/lvgl/src/font/lv_font_montserrat_16.c \\r
+lib/lvgl/src/font/lv_font_montserrat_18.c \\r
+lib/lvgl/src/font/lv_font_montserrat_20.c \\r
+lib/lvgl/src/font/lv_font_montserrat_22.c \\r
+lib/lvgl/src/font/lv_font_montserrat_24.c \\r
+lib/lvgl/src/font/lv_font_montserrat_26.c \\r
+lib/lvgl/src/font/lv_font_montserrat_28.c \\r
+lib/lvgl/src/font/lv_font_montserrat_28_compressed.c \\r
+lib/lvgl/src/font/lv_font_montserrat_30.c \\r
+lib/lvgl/src/font/lv_font_montserrat_32.c \\r
+lib/lvgl/src/font/lv_font_montserrat_34.c \\r
+lib/lvgl/src/font/lv_font_montserrat_36.c \\r
+lib/lvgl/src/font/lv_font_montserrat_38.c \\r
+lib/lvgl/src/font/lv_font_montserrat_40.c \\r
+lib/lvgl/src/font/lv_font_montserrat_42.c \\r
+lib/lvgl/src/font/lv_font_montserrat_44.c \\r
+lib/lvgl/src/font/lv_font_montserrat_46.c \\r
+lib/lvgl/src/font/lv_font_montserrat_48.c \\r
+lib/lvgl/src/font/lv_font_simsun_16_cjk.c \\r
+lib/lvgl/src/font/lv_font_unscii_8.c \\r
+lib/lvgl/src/font/lv_font_unscii_16.c \\r
+lib/lvgl/src/font/lv_font_siyun_18.c \\r
+lib/lvgl/src/font/lv_font_arial_54.c \\r
+lib/lvgl/src/font/lv_font_siyuan_32.c \\r
+lib/lvgl/src/font/lv_font_sdSiyuan16.c \\r
+lib/lvgl/src/font/lv_font_SDsiyuan_8.c \\r
+lib/lvgl/src/font/lv_font_SDsiyuan_10.c \\r
+lib/lvgl/src/font/lv_font_SDsiyuan_12.c \\r
+lib/lvgl/src/font/lv_font_SDsiyuan_14.c \\r
+lib/lvgl/src/font/lv_font_SDsiyuan_16.c \\r
+lib/lvgl/src/font/lv_font_SDsiyuan_18.c \\r
+lib/lvgl/src/font/lv_font_SDsiyuan_20.c \\r
+lib/lvgl/src/font/lv_font_SDsiyuan_22.c \\r
+lib/lvgl/src/font/lv_font_SDsiyuan_24.c \\r
+lib/lvgl/src/font/lv_font_SDsiyuan_26.c \\r
+lib/lvgl/src/font/lv_font_SDsiyuan_28.c \\r
+lib/lvgl/src/font/lv_font_SDsiyuan_30.c \\r
+lib/lvgl/src/font/lv_font_SDsiyuan_32.c \\r
+lib/lvgl/src/font/lv_font_SDsiyuan_34.c \\r
+lib/lvgl/src/font/lv_font_SDsiyuan_36.c \\r
+lib/lvgl/src/font/lv_font_SDsiyuan_38.c \\r
+lib/lvgl/src/font/lv_font_SDsiyuan_40.c \\r
+lib/lvgl/src/font/lv_font_SDsiyuan_42.c \\r
+lib/lvgl/src/font/lv_font_SDsiyuan_44.c \\r
+lib/lvgl/src/font/lv_font_SDsiyuan_46.c \\r
+lib/lvgl/src/font/lv_font_SDsiyuan_48.c \\r
+lib/lvgl/src/font/lv_11_siyuan_light.c \\r
+\r
+LVGL_SRCS_2 = \\r
+lib/lvgl/src/font/lv_14_ali.c \\r
+lib/lvgl/src/font/lv_font_HarmonyOS_Bold_60.c \\r
+lib/lvgl/src/font/lv_font_HarmonyOS_Bold_100.c \\r
+lib/lvgl/src/font/lv_font_HarmonyOS_Regular_28.c \\r
+lib/lvgl/src/font/lv_font_HarmonyOS_Regular_48.c \\r
+lib/lvgl/src/font/lv_font_HarmonyOS_Regular_20.c \\r
+lib/lvgl/src/font/lv_font_siyuan_Bold_26.c \\r
+lib/lvgl/src/font/lv_font_siyuan_Regular_12.c \\r
+lib/lvgl/src/font/lv_font_siyuan_Regular_14.c \\r
+lib/lvgl/src/font/lv_font_siyuan_Regular_16.c \\r
+lib/lvgl/src/font/lv_font_siyuan_Regular_18.c \\r
+lib/lvgl/src/font/lv_font_siyuan_Regular_20.c \\r
+lib/lvgl/src/font/lv_font_siyuan_Regular_22.c \\r
+lib/lvgl/src/font/lv_bold_18.c \\r
+lib/lvgl/src/font/lv_bold_34.c \\r
+lib/lvgl/src/font/lv_bold_48.c \\r
+lib/lvgl/src/font/lv_regular_12.c \\r
+lib/lvgl/src/font/lv_regular_14.c \\r
+lib/lvgl/src/font/lv_regular_18.c \\r
+lib/lvgl/src/font/lv_regular_20.c \\r
+lib/lvgl/src/font/lv_regular_22.c \\r
+lib/lvgl/src/font/lv_regular_24.c \\r
+lib/lvgl/src/font/lv_regular_29.c \\r
+lib/lvgl/src/font/lv_font_tianbo_10.c \\r
+lib/lvgl/src/font/lv_font_tianbo_12.c \\r
+lib/lvgl/src/font/lv_font_tianbo_14.c \\r
+lib/lvgl/src/font/lv_font_tianbo_16.c \\r
+lib/lvgl/src/font/lv_font_12_qs.c \\r
+lib/lvgl/src/font/lv_font_12.c \\r
+lib/lvgl/src/font/lv_font_21_light.c \\r
+lib/lvgl/src/font/lv_font_30_light.c \\r
+lib/lvgl/src/font/lv_font_14_simsum.c \\r
+lib/lvgl/src/font/lv_font_16_simsum.c \\r
+lib/lvgl/src/font/lv_font_18_simsum.c \\r
+lib/lvgl/src/font/lv_font_70_bold.c \\r
+lib/lvgl/src/font/lv_font_28_dial.c \\r
+lib/lvgl/src/font/lv_font_60_main_menu.c \\r
+lib/lvgl/src/font/lv_font_50_main_menu_e.c \\r
+lib/lvgl/src/font/K01_font_16_ALL.c \\r
+lib/lvgl/src/font/K01_font_30_DIAL.c \\r
+lib/lvgl/src/hal/lv_hal_disp.c \\r
+lib/lvgl/src/hal/lv_hal_indev.c \\r
+lib/lvgl/src/hal/lv_hal_tick.c \\r
+lib/lvgl/src/misc/lv_anim.c \\r
+lib/lvgl/src/misc/lv_anim_timeline.c \\r
+lib/lvgl/src/misc/lv_area.c \\r
+lib/lvgl/src/misc/lv_async.c \\r
+lib/lvgl/src/misc/lv_bidi.c \\r
+lib/lvgl/src/misc/lv_color.c \\r
+lib/lvgl/src/misc/lv_fs.c \\r
+lib/lvgl/src/misc/lv_gc.c \\r
+lib/lvgl/src/misc/lv_ll.c \\r
+lib/lvgl/src/misc/lv_log.c \\r
+lib/lvgl/src/misc/lv_lru.c \\r
+lib/lvgl/src/misc/lv_math.c \\r
+lib/lvgl/src/misc/lv_mem.c \\r
+lib/lvgl/src/misc/lv_printf.c \\r
+lib/lvgl/src/misc/lv_style.c \\r
+lib/lvgl/src/misc/lv_style_gen.c \\r
+lib/lvgl/src/misc/lv_timer.c \\r
+lib/lvgl/src/misc/lv_tlsf.c \\r
+lib/lvgl/src/misc/lv_txt.c \\r
+lib/lvgl/src/misc/lv_txt_ap.c \\r
+lib/lvgl/src/misc/lv_utils.c \\r
+lib/lvgl/src/widgets/lv_arc.c \\r
+lib/lvgl/src/widgets/lv_bar.c \\r
+lib/lvgl/src/widgets/lv_btn.c \\r
+lib/lvgl/src/widgets/lv_btnmatrix.c \\r
+lib/lvgl/src/widgets/lv_canvas.c \\r
+lib/lvgl/src/widgets/lv_checkbox.c \\r
+lib/lvgl/src/widgets/lv_dropdown.c \\r
+lib/lvgl/src/widgets/lv_img.c \\r
+lib/lvgl/src/widgets/lv_label.c \\r
+lib/lvgl/src/widgets/lv_line.c \\r
+lib/lvgl/src/widgets/lv_roller.c \\r
+lib/lvgl/src/widgets/lv_slider.c \\r
+lib/lvgl/src/widgets/lv_switch.c \\r
+lib/lvgl/src/widgets/lv_table.c \\r
+lib/lvgl/src/widgets/lv_textarea.c \\r
+lib/lvgl/freetype-2.11.1/src/autofit/autofit.c \\r
+lib/lvgl/freetype-2.11.1/src/base/ftbase.c \\r
+lib/lvgl/freetype-2.11.1/src/base/ftbbox.c \\r
+lib/lvgl/freetype-2.11.1/src/base/ftbdf.c \\r
+lib/lvgl/freetype-2.11.1/src/base/ftbitmap.c \\r
+lib/lvgl/freetype-2.11.1/src/base/ftcid.c \\r
+lib/lvgl/freetype-2.11.1/src/base/ftfstype.c \\r
+lib/lvgl/freetype-2.11.1/src/base/ftgasp.c \\r
+lib/lvgl/freetype-2.11.1/src/base/ftglyph.c \\r
+lib/lvgl/freetype-2.11.1/src/base/ftgxval.c \\r
+lib/lvgl/freetype-2.11.1/src/base/ftinit.c \\r
+lib/lvgl/freetype-2.11.1/src/base/ftmm.c \\r
+lib/lvgl/freetype-2.11.1/src/base/ftotval.c \\r
+lib/lvgl/freetype-2.11.1/src/base/ftpatent.c \\r
+lib/lvgl/freetype-2.11.1/src/base/ftpfr.c \\r
+lib/lvgl/freetype-2.11.1/src/base/ftstroke.c \\r
+lib/lvgl/freetype-2.11.1/src/base/ftsynth.c \\r
+lib/lvgl/freetype-2.11.1/src/base/fttype1.c \\r
+lib/lvgl/freetype-2.11.1/src/base/ftwinfnt.c \\r
+lib/lvgl/freetype-2.11.1/src/bdf/bdf.c \\r
+lib/lvgl/freetype-2.11.1/src/bzip2/ftbzip2.c \\r
+lib/lvgl/freetype-2.11.1/src/cache/ftcache.c \\r
+lib/lvgl/freetype-2.11.1/src/cff/cff.c \\r
+lib/lvgl/freetype-2.11.1/src/cid/type1cid.c \\r
+lib/lvgl/freetype-2.11.1/src/gzip/ftgzip.c \\r
+lib/lvgl/freetype-2.11.1/src/lzw/ftlzw.c \\r
+lib/lvgl/freetype-2.11.1/src/pcf/pcf.c \\r
+lib/lvgl/freetype-2.11.1/src/pfr/pfr.c \\r
+lib/lvgl/freetype-2.11.1/src/psaux/psaux.c \\r
+lib/lvgl/freetype-2.11.1/src/pshinter/pshinter.c \\r
+lib/lvgl/freetype-2.11.1/src/psnames/psnames.c \\r
+lib/lvgl/freetype-2.11.1/src/raster/raster.c \\r
+lib/lvgl/freetype-2.11.1/src/sdf/sdf.c \\r
+lib/lvgl/freetype-2.11.1/src/sfnt/sfnt.c \\r
+lib/lvgl/freetype-2.11.1/src/smooth/smooth.c \\r
+lib/lvgl/freetype-2.11.1/src/truetype/truetype.c \\r
+lib/lvgl/freetype-2.11.1/src/type1/type1.c \\r
+lib/lvgl/freetype-2.11.1/src/type42/type42.c \\r
+lib/lvgl/freetype-2.11.1/src/winfonts/winfnt.c \\r
+lib/lvgl/freetype-2.11.1/src/base/ftsystem.c \\r
+lib/lvgl/freetype-2.11.1/src/base/ftdebug.c\r
+endif\r
+\r
+\r
+\r
+$(NAME)_SRCS += $(PY_SRCS) $(EXTMOD_SRCS) $(QPY_SRCS)\r
+ifeq ($(CONFIG_LVGL), y)\r
+$(NAME)_SRCS_2 = $(LVGL_SRCS_1)\r
+$(NAME)_SRCS_3 = $(LVGL_SRCS_2)\r
+endif\r
+\r
+$(NAME)_INCS = \\r
+       . \\r
+       extmod \\r
+       genhdr \\r
+       lib \\r
+       lib/littlefs \\r
+       lib/mp-readline \\r
+       lib/netutils \\r
+       lib/timeutils \\r
+       lib/utils \\r
+       ports/quectel/core/source \\r
+       py \r
+       \r
+ifeq ($(CONFIG_LVGL), y)\r
+$(NAME)_INCS += \\r
+       lib/lvgl \\r
+       lib/lvgl        \\r
+       lib/lvgl/src    \\r
+       lib/lvgl/src/core       \\r
+       lib/lvgl/src/draw       \\r
+       lib/lvgl/src/extra      \\r
+       lib/lvgl/src/font       \\r
+       lib/lvgl/src/gpu        \\r
+       lib/lvgl/src/hal        \\r
+       lib/lvgl/src/misc       \\r
+       lib/lvgl/src/widgts \\r
+    lib/lvgl/freetype-2.11.1/include \\r
+    lib/lvgl/freetype-2.11.1/include/dlg \\r
+    lib/lvgl/freetype-2.11.1/include/freetype \\r
+    lib/lvgl/freetype-2.11.1/include/freetype/config \\r
+    lib/lvgl/freetype-2.11.1/include/freetype/internal \\r
+    lib/lvgl/freetype-2.11.1/include/freetype/internal/services \\r
+    lib/lvgl/freetype-2.11.1/src/base \\r
+    lib/lvgl/freetype-2.11.1/src/autofit \\r
+    lib/lvgl/freetype-2.11.1/src/bdf    \\r
+    lib/lvgl/freetype-2.11.1/src/bzip2  \\r
+    lib/lvgl/freetype-2.11.1/src/cache  \\r
+    lib/lvgl/freetype-2.11.1/src/cff    \\r
+    lib/lvgl/freetype-2.11.1/src/cid    \\r
+    lib/lvgl/freetype-2.11.1/src/gzip   \\r
+    lib/lvgl/freetype-2.11.1/src/lzw    \\r
+    lib/lvgl/freetype-2.11.1/src/pcf    \\r
+    lib/lvgl/freetype-2.11.1/src/pfr    \\r
+    lib/lvgl/freetype-2.11.1/src/psaux  \\r
+    lib/lvgl/freetype-2.11.1/src/pshinter   \\r
+    lib/lvgl/freetype-2.11.1/src/psnames    \\r
+    lib/lvgl/freetype-2.11.1/src/raster \\r
+    lib/lvgl/freetype-2.11.1/src/sdf    \\r
+    lib/lvgl/freetype-2.11.1/src/sfnt   \\r
+    lib/lvgl/freetype-2.11.1/src/smooth \\r
+    lib/lvgl/freetype-2.11.1/src/truetype   \\r
+    lib/lvgl/freetype-2.11.1/src/type1  \\r
+    lib/lvgl/freetype-2.11.1/src/type42 \\r
+    lib/lvgl/freetype-2.11.1/src/winfonts\r
+endif\r
+\r
+EMPTY=\r
+SPACE=$(EMPTY) $(EMPTY)\r
+COMMA=$(EMPTY),$(EMPTY)\r
+BUILD_TIMESTAMP=\\\"$(subst $(SPACE),_,$(subst $(COMMA),,$(shell echo $$(env LANG=en_US.UTF-8 date))))\\\"\r
+$(NAME)_DEFINE = \\r
+       MP_ENDIANNESS_LITTLE \\r
+       MICROPY_BUILD_DATE=${BUILD_TIMESTAMP}\r
+\r
+\r
+\r
+ifneq ($(strip $(PLAT)),Qualcomm)\r
+$(NAME)_CFLAGS = \\r
+       -Wno-error=unused-parameter \\r
+       -Wno-error=format-truncation \\r
+       -Wno-error=unused-variable \\r
+       -Wno-error=unused-function \\r
+       -Wno-error=format=\r
+else\r
+$(NAME)_CFLAGS = -Wno-error=tautological-constant-out-of-range-compare \\r
+                                -Wno-error=missing-field-initializers \\r
+                                -Wno-error=unused-parameter \\r
+                                -Wno-error=unused-variable \\r
+                                -Wno-error=unused-function \\r
+                                -Wno-error=missing-braces \\r
+                                -Wno-error=sometimes-uninitialized\r
+endif\r
+\r
+\r
+ifeq ($(CONFIG_LVGL), y)\r
+$(NAME)_CFLAGS += \\r
+       -Wno-error=incompatible-pointer-types \\r
+       -Wno-error=sign-compare \\r
+       -Wno-error=unused-but-set-variable \\r
+       -Wno-error=switch-unreachable \\r
+       -Wno-error=unused-function \\r
+       -Wno-error=implicit-function-declaration \\r
+       -Wno-error=missing-field-initializers \\r
+       -Wno-error=unused-parameter \\r
+       -Wno-error=unused-variable \\r
+       -Wno-error=type-limits \\r
+       -Wno-error=format= \\r
+       -Wno-error=discarded-qualifiers \\r
+       -Wno-error=maybe-uninitialized \\r
+       -Wno-error=int-conversion\r
+endif\r
+\r
+ifeq ($(CONFIG_SPINAND), y)\r
+$(NAME)_CFLAGS += \\r
+       -Wno-error=restrict \\r
+       -Wno-error=format-overflow=\r
+endif\r
+\r
+$(NAME)_COMPONENTS = peripheral\r
+\r
+$(NAME)_COMPONENTS += driver\r
+\r
+ifeq ($(CONFIG_DECODE_QUECTEL), y)\r
+$(NAME)_COMPONENTS += components/decode/quectel\r
+endif\r
+\r
+ifeq ($(CONFIG_DECODE_QINGYA), y)\r
+ifneq ($(strip $(PLAT)),ASR)\r
+ifneq ($(strip $(PLAT)),ASR_1606)\r
+$(NAME)_COMPONENTS += components/decode/qingya\r
+endif\r
+endif\r
+endif\r
+\r
+ifeq ($(CONFIG_JPEG), y)\r
+$(NAME)_COMPONENTS += components/jpeg\r
+endif\r
+\r
+$(NAME)_COMPONENTS += utilities\r
+\r
+\r
+$(NAME)_COMPONENTS += components/audio\r
+\r
+ifneq (,$(filter y,$(CONFIG_SPINAND) $(CONFIG_SPI_SDCARD)))\r
+$(NAME)_COMPONENTS += components/fs\r
+endif\r
+\r
+ifeq ($(CONFIG_RTMP), y)\r
+$(NAME)_COMPONENTS += components/rtmpdump\r
+endif\r
+ifeq ($(CONFIG_JRTC), y)\r
+$(NAME)_COMPONENTS += components/jpeg\r
+$(NAME)_COMPONENTS += components/jrtc\r
+$(NAME)_INCS += ../../components/jrtc/inc\r
+\r
+endif\r
+\r
+ifeq ($(CONFIG_SENSOR_VC9202), y)\r
+$(NAME)_COMPONENTS += components/sensor/VC9202\r
+$(NAME)_INCS += ../../components/sensor/VS9202/inc\r
+$(NAME)_INCS += ../../components/sensor/VS9202/algo/inc\r
+endif\r
+\r
+ifeq ($(CONFIG_POC), y)\r
+$(NAME)_CFLAGS += \\r
+       -Wno-error=incompatible-pointer-types \\r
+       -Wno-error=ignored-qualifiers \\r
+       -Wno-error=int-conversion \\r
+       -Wno-error=implicit-function-declaration \\r
+       -Wno-error=discarded-qualifiers \\r
+       -Wno-error=unused-const-variable=\r
+\r
+$(NAME)_COMPONENTS += components/poc\r
+endif\r
+\r
+ifeq ($(CONFIG_QRCODE), y)\r
+$(NAME)_COMPONENTS += components/qrcode\r
+endif\r
+\r
+ifeq ($(CONFIG_HX3918), y)\r
+$(NAME)_COMPONENTS += components/HX3918\r
+endif\r
+ifeq ($(CONFIG_GH301x), y)\r
+$(NAME)_COMPONENTS += components/GH301X\r
+endif\r
+ifeq ($(CONFIG_SC7A20), y)\r
+$(NAME)_COMPONENTS += components/SC7A20\r
+endif\r
+ifeq ($(CONFIG_juphoon), y)\r
+$(NAME)_COMPONENTS += components/juphoon\r
+endif\r
+\r
+ifeq ($(CONFIG_LIBSSH2), y)\r
+$(NAME)_INCS += ../../components/ssh2/include \\r
+                ../../components/ssh2/src\r
+$(NAME)_COMPONENTS += components/ssh2\r
+endif\r
+\r
+ifeq ($(CONFIG_QUECTHING), y)\r
+$(NAME)_INCS += ../../components/quecsdk\r
+$(NAME)_COMPONENTS += components/quecsdk\r
+endif\r
+\r
+ifeq ($(CONFIG_GMSSL), y)\r
+$(NAME)_COMPONENTS += components/GMSSL\r
+endif\r
+\r
+ifeq ($(CONFIG_GB2312), y)\r
+$(NAME)_COMPONENTS += components/decode/gb2312\r
+endif\r
+\r
+ifeq ($(CONFIG_ESIMSDK), y)\r
+$(NAME)_COMPONENTS += components/esim\r
+endif\r
+\r
+ifeq ($(CONFIG_NFC_SL6320), y)\r
+$(NAME)_COMPONENTS += components/NFC/SL6320\r
+endif\r
+\r
+ifeq ($(CONFIG_VOIP), y)\r
+$(NAME)_INCS += ../../components/voip/libexosip2/include  \\r
+                ../../components/voip/libosip2/include  \\r
+                ../../components/voip/rtp\r
+$(NAME)_COMPONENTS += components/voip\r
+endif\r
+\r
+ifeq ($(CONFIG_ETHERNET_W5500), y)\r
+$(NAME)_COMPONENTS += components/ethernet\r
+$(NAME)_INCS += ../../components/ethernet/wiznet\r
+endif\r
+\r
+ifeq ($(CONFIG_SLIP), y)\r
+$(NAME)_COMPONENTS += components/slip\r
+$(NAME)_INCS += ../../components/slip\r
+endif\r
+\r
+ifeq ($(CONFIG_DLMS), y)\r
+$(NAME)_COMPONENTS += components/dlms\r
+endif\r
+\r
+ifeq ($(CONFIG_MICROPYTHON_EXTENSION_PERF), y)\r
+$(NAME)_COMPONENTS += components/micropython_extension\r
+$(NAME)_INCS += ../../components/micropython_extension/perf\r
+endif\r
+\r
+ifeq ($(CONFIG_MICROPYTHON_EXTENSION_SECURE_APP), y)\r
+$(NAME)_COMPONENTS += components/micropython_extension\r
+$(NAME)_INCS += ../../components/micropython_extension/secure_app\r
+endif\r
+\r
+$(NAME)_CFLAGS += -Wno-error=implicit-fallthrough\r
+\r
+$(NAME)_PRIVATE_SCRIPT = private.mk\r
+\r
+$(NAME)_PRIVATE_SCRIPT_TARGETS = construct clean\r
index 1c0c996..331534a 100644 (file)
@@ -111,6 +111,13 @@ if errorlevel 1 (
 )\r
 cd ..\r
 \r
+rem sync base release pack config from unpacked source dir\r
+powershell -NoProfile -ExecutionPolicy Bypass -File "%~dp0project\!PROJ!\tools\sync_base_pack_config.ps1" -Root:"%CD%" -Project:"!PROJ!" -Board:"!BOARD!"\r
+if errorlevel 1 (\r
+  echo [´íÎó] Í¬²½ firmware_base_release_pack ÅäÖÃʧ°Ü\r
+  exit /b 1\r
+)\r
+\r
 rem versions.py: generated once inside new.bat (before xcopy/compile)\r
 call new.bat !PROJ! !PRODUCT_NAME!\r
 if errorlevel 1 (\r
index ed2c4a1..37eabed 100644 (file)
@@ -1,59 +1,74 @@
-@echo off\r
-setlocal EnableDelayedExpansion\r
-rem arg1=project  arg2=PRODUCT_NAME (product_%2%.ini)\r
-set "PROJ=%~1"\r
-set "PRODUCT_NAME=%~2"\r
-if "!PROJ!"=="" set "PROJ=7PIN_1_5"\r
-if "!PRODUCT_NAME!"=="" (\r
-  echo [ERROR] usage: new.bat ^<project^> ^<PRODUCT_NAME^>\r
-  goto exit\r
-)\r
-\r
-md images\r
-del images /q\r
-\r
-:: 确保 7PIN_1_5 的 customer_fs(/usr) 内包含音频 NVM(增益/语音增强表)\r
-:: 这两份文件会影响录音/通话的场景增益与 VE 参数;缺失时可能回退到默认表导致录音幅度异常。\r
-if exist "sdk\services\microPython\ports\quectel\core\audio_gain.nvm" (\r
-    copy /y "sdk\services\microPython\ports\quectel\core\audio_gain.nvm" "usr\audio_gain.nvm" >nul\r
-)\r
-if exist "sdk\services\microPython\ports\quectel\core\audio_ve.nvm" (\r
-    copy /y "sdk\services\microPython\ports\quectel\core\audio_ve.nvm" "usr\audio_ve.nvm" >nul\r
-)\r
-\r
-@GOTO :STEP1\r
-..\..\Helios_SDK\tools\ASR_1606\win32\mklfs.exe -c ext -b 4096 -r 4096 -p 4096 -s 1048576 -i .\images\ext_fs.bin\r
-if errorlevel 1 (\r
-    echo "ext_fs.bin生成失败 !!!!!!!!!!!!!!! "\r
-    goto exit\r
-)\r
-if errorlevel 0 (\r
-    echo "ext_fs.bin生成成功 !!!!!!!!!!!!!!! "\r
-)\r
-:STEP1\r
-\r
-..\..\Helios_SDK\tools\ASR_1606\win32\mklfs.exe -c usr -b 4096 -r 4096 -p 4096 -s 1376256 -i .\images\customer_fs.bin\r
-if errorlevel 1 (\r
-    echo "customer_fs.bin生成失败 请检查usr目录是否大于316K!!!!!!!!!!!!!!!"\r
-    goto exit\r
-)\r
-if errorlevel 0 (\r
-    echo "customer_fs.bin生成成功 !!!!!!!!!!!!!!! "\r
-)\r
-\r
-%copy font\ext_font.bin images\ext_font.bin%\r
-\r
-..\..\Helios_SDK\tools\common\win32\7z\7z a sdk\system\platform\ASR_1606\boards\EG810MCN_GA_VOLTE\images\firmware_base_release_pack.zip .\images\\r
-if errorlevel 0 (\r
-    echo images压缩成功!!!!!!!!!!!!!!\r
-)\r
-if errorlevel 1 (\r
-    echo images压缩失败!!!!!!!!!!!!!!!!!!\r
-    goto exit\r
-)\r
-xcopy  sdk\ ..\..\Helios_SDK\ /e/h/y\r
-cd ..\..\Helios_SDK\r
-helios.exe make services/microPython @EG810MCN_GA_VOLTE EG810MCN_GA_VOLTE\r
-cd ..\r
-:exit\r
-endlocal\r
+@echo off
+setlocal EnableDelayedExpansion
+rem arg1=project  arg2=PRODUCT_NAME (product_%2%.ini)
+cd /d "%~dp0"
+set "PROJ=%~1"
+set "PRODUCT_NAME=%~2"
+if "!PROJ!"=="" set "PROJ=7PIN_1_5"
+if "!PRODUCT_NAME!"=="" (
+  echo [ERROR] usage: new.bat ^<project^> ^<PRODUCT_NAME^>
+  exit /b 1
+)
+
+md images 2>nul
+del /q images\* 2>nul
+
+rem sync audio NVM into usr for customer_fs (gain / VE tables)
+if exist "sdk\services\microPython\ports\quectel\core\audio_gain.nvm" (
+    copy /y "sdk\services\microPython\ports\quectel\core\audio_gain.nvm" "usr\audio_gain.nvm" >nul
+)
+if exist "sdk\services\microPython\ports\quectel\core\audio_ve.nvm" (
+    copy /y "sdk\services\microPython\ports\quectel\core\audio_ve.nvm" "usr\audio_ve.nvm" >nul
+)
+
+..\..\Helios_SDK\tools\ASR_1606\win32\mklfs.exe -c ext -b 4096 -r 4096 -p 4096 -s 1048576 -i .\images\ext_fs.bin
+if errorlevel 1 (
+    echo [ERROR] ext_fs.bin failed
+    exit /b 1
+)
+echo [OK] ext_fs.bin
+
+..\..\Helios_SDK\tools\ASR_1606\win32\mklfs.exe -c usr -b 4096 -r 4096 -p 4096 -s 1007616 -i .\images\customer_fs.bin
+if errorlevel 1 (
+    echo [ERROR] customer_fs.bin failed - check usr size
+    exit /b 1
+)
+echo [OK] customer_fs.bin
+
+if exist "font\ext_font.bin" copy /y "font\ext_font.bin" "images\ext_font.bin" >nul
+
+..\..\Helios_SDK\tools\common\win32\7z\7z a sdk\system\platform\ASR_1606\boards\EG810MCN_GA_VOLTE\images\firmware_base_release_pack.zip .\images\
+if errorlevel 1 (
+    echo [ERROR] firmware_base_release_pack.zip failed
+    exit /b 1
+)
+echo [OK] images zip
+
+rem run sync again before xcopy to avoid stale zip entries
+powershell -NoProfile -ExecutionPolicy Bypass -File "%~dp0tools\sync_base_pack_config.ps1" -Root:"%~dp0..\.." -Project:"!PROJ!" -Board:"EG810MCN_GA_VOLTE"
+if errorlevel 1 (
+    echo [ERROR] sync_base_pack_config.ps1 failed
+    exit /b 1
+)
+
+xcopy sdk\ ..\..\Helios_SDK\ /e/h/y
+if errorlevel 1 (
+    echo [ERROR] xcopy to Helios_SDK failed
+    exit /b 1
+)
+
+powershell -NoProfile -ExecutionPolicy Bypass -File "%~dp0tools\ensure_helios_opus_mk.ps1" -HeliosRoot:"%~dp0..\..\Helios_SDK"
+if errorlevel 1 (
+    echo [ERROR] ensure_helios_opus_mk.ps1 failed
+    exit /b 1
+)
+
+cd /d "%~dp0..\..\Helios_SDK"
+helios.exe make services/microPython @EG810MCN_GA_VOLTE EG810MCN_GA_VOLTE
+if errorlevel 1 (
+    cd /d "%~dp0"
+    exit /b 1
+)
+cd /d "%~dp0"
+exit /b 0
+
diff --git a/2.sdk/project/7PIN_1_5/sdk/services/microPython/microPython_opus.mk b/2.sdk/project/7PIN_1_5/sdk/services/microPython/microPython_opus.mk
new file mode 100644 (file)
index 0000000..f5aab70
--- /dev/null
@@ -0,0 +1,7 @@
+# 7PIN_1_5 Opus(xcopy -> Helios_SDK/services/microPython/microPython_opus.mk)\r
+# 由 microPython.mk 在 $(NAME)_SRCS)+= 之前 -include(目录用 _MP_MK_DIR)\r
+ifeq ($(CONFIG_OPUS), y)\r
+QPY_SRCS += ports/quectel/core/source/modopus.c\r
+$(NAME)_SRCS += ports/quectel/core/source/modopus.c\r
+$(NAME)_ARCHIVES += ports/quectel/core/source/libopus_min.a\r
+endif\r
index cb3ec6a..26456dd 100644 (file)
@@ -404,6 +404,11 @@ SRC_QSTR += lib/usqlite/usqlite_connection.c \
 INC += -Ilib/usqlite
 endif
 
+ifeq ($(CONFIG_OPUS), y)
+SRC_QSTR += source/modopus.c
+INC += -Isource/opus
+endif
+
 $(BUILD)/%.pp: %.c
        @$(ECHO) "PreProcess $<"
        $(Q)$(CPP) $(C_FLAGS) -Wp,-C,-dD,-dI -o $@ $<
index 8ed229c..89fb28c 100644 (file)
@@ -133,6 +133,12 @@ KEY_RELEASE_DEBOUNCE_COUNT = 5
 AI_LONG_PRESS_POWER_OFF_ENABLED = False  # AI 键长按 8s 关机
 SOS_ENABLED = False                      # AI 长按 3s SOS、板载 SOS 入口
 
+# =============================================================================
+# 6.1 看门狗(WDT)
+# =============================================================================
+WDT_ENABLED = False
+WDT_TIMEOUT_S = 30  # 需大于喂狗周期(默认 10s),建议 >= 15
+
 # =============================================================================
 # 7. VC 会话 / WebSocket / 空闲与休眠
 # =============================================================================
diff --git a/2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/opus_codec.py b/2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/opus_codec.py
new file mode 100644 (file)
index 0000000..c4a2228
--- /dev/null
@@ -0,0 +1,29 @@
+# -*- coding: utf-8 -*-\r
+"""Opus 编解码薄封装(16kHz 单声道,20ms 帧 = 320 字节 PCM)。"""\r
+try:\r
+    from qp_log import qp_print as print\r
+except Exception:\r
+    pass\r
+\r
+import opus\r
+\r
+FRAME_PCM_BYTES = opus.FRAME_PCM_BYTES\r
+SAMPLE_RATE = opus.SAMPLE_RATE\r
+\r
+\r
+class OpusCodec:\r
+    """上行编码 / 下行解码可独立开关。"""\r
+\r
+    def __init__(self, encoder=True, decoder=True):\r
+        self._c = opus.OpusCodec(encoder=encoder, decoder=decoder)\r
+\r
+    def encode(self, pcm):\r
+        if len(pcm) != FRAME_PCM_BYTES:\r
+            raise ValueError("pcm must be %d bytes" % FRAME_PCM_BYTES)\r
+        return self._c.encode(pcm)\r
+\r
+    def decode(self, pkt):\r
+        return self._c.decode(pkt)\r
+\r
+    def close(self):\r
+        self._c.close()\r
index 8ed229c..89fb28c 100644 (file)
@@ -133,6 +133,12 @@ KEY_RELEASE_DEBOUNCE_COUNT = 5
 AI_LONG_PRESS_POWER_OFF_ENABLED = False  # AI 键长按 8s 关机
 SOS_ENABLED = False                      # AI 长按 3s SOS、板载 SOS 入口
 
+# =============================================================================
+# 6.1 看门狗(WDT)
+# =============================================================================
+WDT_ENABLED = False
+WDT_TIMEOUT_S = 30  # 需大于喂狗周期(默认 10s),建议 >= 15
+
 # =============================================================================
 # 7. VC 会话 / WebSocket / 空闲与休眠
 # =============================================================================
diff --git a/2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/source/OPUS_BUILD.txt b/2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/source/OPUS_BUILD.txt
new file mode 100644 (file)
index 0000000..7cf0a68
--- /dev/null
@@ -0,0 +1,37 @@
+Opus 集成说明(7PIN_1_5 / EG810MCN_GA_VOLTE)\r
+==========================================\r
+\r
+1. 扩大 APP 分区\r
+   project/.../app_link_start_addr.h 中 APP_FLASH_MAX_SIZE=0x1F8000(对齐 K8)\r
+\r
+2. 头文件与静态库(与 imsl_vad 相同,均在 source/ 下)\r
+   source/opus/*.h     — 从 opus 官方 include 拷贝的公开头(固件编译用)\r
+   source/libopus_min.a — 预编译 Opus 库\r
+\r
+3. 重新生成 libopus_min.a(可选)\r
+   将 opus-1.4 源码解压到 project/7PIN_1_5/tools/opus_src/\r
+   cd 2.sdk\project\7PIN_1_5\tools\r
+   build_opus_min.bat\r
+\r
+4. 配置开关\r
+   config.mk / autoconf.h: CONFIG_OPUS=y\r
+\r
+5. 固件编译\r
+   cd 2.sdk\r
+   new_clean.bat k8v3\r
+   xcopy 后 Helios_SDK/services/microPython/microPython_opus.mk 由本工程提供;\r
+   new.bat 会 ensure Helios microPython.mk 在 libimslvad 后 -include microPython_opus.mk;\r
+   modopus.c 使用 MP_REGISTER_MODULE 注册 import opus(无需改 mpconfigport.h)\r
+\r
+6. REPL 自测\r
+   import opus\r
+   print(opus.version())\r
+   c = opus.OpusCodec(encoder=True, decoder=True)\r
+   pkt = c.encode(bytes(320))\r
+   pcm = c.decode(pkt)\r
+   c.close()\r
+\r
+7. 接入 VC 上行(未默认开启)\r
+   在 vc_session_media.VC_record_thread 中 AI_client_VC_send 前调用 OpusCodec.encode\r
+\r
+注意: 未生成 libopus_min.a 时链接会失败;可临时 CONFIG_OPUS=n。\r
diff --git a/2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/source/libopus_min.a b/2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/source/libopus_min.a
new file mode 100644 (file)
index 0000000..5fa3751
Binary files /dev/null and b/2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/source/libopus_min.a differ
diff --git a/2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/source/modopus.c b/2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/source/modopus.c
new file mode 100644 (file)
index 0000000..2c7f718
--- /dev/null
@@ -0,0 +1,185 @@
+/*\r
+ * MicroPython Opus 编解码(最简 API,16kHz 单声道 VOIP)\r
+ * 依赖 libopus_min.a 与 source/opus 下头文件(同 imsl_vad 目录习惯)\r
+ */\r
+#include <string.h>\r
+#include "py/runtime.h"\r
+#include "py/binary.h"\r
+#include "mperrno.h"\r
+#include "helios_debug.h"\r
+#include "autoconf.h"\r
+\r
+#if CONFIG_OPUS\r
+\r
+#include "opus.h"\r
+\r
+#define MOD_OPUS_LOG(msg, ...) custom_log("modopus", msg, ##__VA_ARGS__)\r
+\r
+#define OPUS_CODEC_SR_HZ     16000\r
+#define OPUS_CODEC_CHANNELS  1\r
+#define OPUS_CODEC_FRAME_PCM 320\r
+#define OPUS_CODEC_MAX_PKT   400\r
+\r
+typedef struct _mp_obj_OpusCodec_t {\r
+    mp_obj_base_t base;\r
+    OpusEncoder *enc;\r
+    OpusDecoder *dec;\r
+    int has_enc;\r
+    int has_dec;\r
+} mp_obj_OpusCodec_t;\r
+\r
+static const mp_obj_type_t OpusCodec_type;\r
+\r
+static int opus_codec_check_pcm_len(mp_uint_t len)\r
+{\r
+    if (len != OPUS_CODEC_FRAME_PCM) {\r
+        MOD_OPUS_LOG("pcm len=%u expect=%d", (unsigned)len, OPUS_CODEC_FRAME_PCM);\r
+        return -1;\r
+    }\r
+    return 0;\r
+}\r
+\r
+STATIC mp_obj_t OpusCodec_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args)\r
+{\r
+    static const mp_arg_t allowed[] = {\r
+        { MP_QSTR_encoder, MP_ARG_KW_ONLY | MP_ARG_BOOL, { .u_bool = true } },\r
+        { MP_QSTR_decoder, MP_ARG_KW_ONLY | MP_ARG_BOOL, { .u_bool = true } },\r
+    };\r
+    mp_arg_val_t parsed[2];\r
+    mp_arg_parse_all_kw_array(n_args, n_kw, all_args, 2, allowed, parsed);\r
+\r
+    mp_obj_OpusCodec_t *self = m_new_obj(mp_obj_OpusCodec_t);\r
+    self->base.type = &OpusCodec_type;\r
+    self->enc = NULL;\r
+    self->dec = NULL;\r
+    self->has_enc = 0;\r
+    self->has_dec = 0;\r
+\r
+    int err = 0;\r
+    if (parsed[0].u_bool) {\r
+        self->enc = opus_encoder_create(OPUS_CODEC_SR_HZ, OPUS_CODEC_CHANNELS,\r
+                                        OPUS_APPLICATION_VOIP, &err);\r
+        if (err != OPUS_OK || self->enc == NULL) {\r
+            mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("opus_encoder_create failed"));\r
+        }\r
+        opus_encoder_ctl(self->enc, OPUS_SET_COMPLEXITY(5));\r
+        opus_encoder_ctl(self->enc, OPUS_SET_BITRATE(24000));\r
+        self->has_enc = 1;\r
+    }\r
+    if (parsed[1].u_bool) {\r
+        self->dec = opus_decoder_create(OPUS_CODEC_SR_HZ, OPUS_CODEC_CHANNELS, &err);\r
+        if (err != OPUS_OK || self->dec == NULL) {\r
+            if (self->enc) {\r
+                opus_encoder_destroy(self->enc);\r
+                self->enc = NULL;\r
+            }\r
+            mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("opus_decoder_create failed"));\r
+        }\r
+        self->has_dec = 1;\r
+    }\r
+    if (!self->has_enc && !self->has_dec) {\r
+        mp_raise_ValueError(MP_ERROR_TEXT("encoder or decoder required"));\r
+    }\r
+    return MP_OBJ_FROM_PTR(self);\r
+}\r
+\r
+STATIC mp_obj_t opus_codec_encode(mp_obj_t self_in, mp_obj_t pcm_in)\r
+{\r
+    mp_obj_OpusCodec_t *self = MP_OBJ_TO_PTR(self_in);\r
+    if (!self->has_enc || self->enc == NULL) {\r
+        mp_raise_msg(&mp_type_OSError, MP_ERROR_TEXT("encoder not open"));\r
+    }\r
+    mp_buffer_info_t pcm;\r
+    mp_get_buffer_raise(pcm_in, &pcm, MP_BUFFER_READ);\r
+    if (opus_codec_check_pcm_len(pcm.len) != 0) {\r
+        mp_raise_ValueError(MP_ERROR_TEXT("pcm frame must be 320 bytes"));\r
+    }\r
+    uint8_t out[OPUS_CODEC_MAX_PKT];\r
+    mp_int_t n = opus_encode(self->enc, (const opus_int16 *)pcm.buf, OPUS_CODEC_FRAME_PCM / 2,\r
+                             out, OPUS_CODEC_MAX_PKT);\r
+    if (n < 0) {\r
+        mp_raise_msg_varg(&mp_type_OSError, MP_ERROR_TEXT("opus_encode %d"), (int)n);\r
+    }\r
+    return mp_obj_new_bytes(out, (mp_uint_t)n);\r
+}\r
+STATIC MP_DEFINE_CONST_FUN_OBJ_2(opus_encode_obj, opus_codec_encode);\r
+\r
+STATIC mp_obj_t opus_codec_decode(mp_obj_t self_in, mp_obj_t pkt_in)\r
+{\r
+    mp_obj_OpusCodec_t *self = MP_OBJ_TO_PTR(self_in);\r
+    if (!self->has_dec || self->dec == NULL) {\r
+        mp_raise_msg(&mp_type_OSError, MP_ERROR_TEXT("decoder not open"));\r
+    }\r
+    mp_buffer_info_t pkt;\r
+    mp_get_buffer_raise(pkt_in, &pkt, MP_BUFFER_READ);\r
+    if (pkt.len == 0 || pkt.len > OPUS_CODEC_MAX_PKT) {\r
+        mp_raise_ValueError(MP_ERROR_TEXT("invalid opus packet"));\r
+    }\r
+    opus_int16 pcm[OPUS_CODEC_FRAME_PCM / 2];\r
+    mp_int_t n = opus_decode(self->dec, pkt.buf, (opus_int32)pkt.len, pcm,\r
+                             OPUS_CODEC_FRAME_PCM / 2, 0);\r
+    if (n < 0) {\r
+        mp_raise_msg_varg(&mp_type_OSError, MP_ERROR_TEXT("opus_decode %d"), (int)n);\r
+    }\r
+    if (n != OPUS_CODEC_FRAME_PCM / 2) {\r
+        mp_raise_msg(&mp_type_OSError, MP_ERROR_TEXT("opus_decode short frame"));\r
+    }\r
+    return mp_obj_new_bytes((const byte *)pcm, OPUS_CODEC_FRAME_PCM);\r
+}\r
+STATIC MP_DEFINE_CONST_FUN_OBJ_2(opus_decode_obj, opus_codec_decode);\r
+\r
+STATIC mp_obj_t opus_close(mp_obj_t self_in)\r
+{\r
+    mp_obj_OpusCodec_t *self = MP_OBJ_TO_PTR(self_in);\r
+    if (self->enc) {\r
+        opus_encoder_destroy(self->enc);\r
+        self->enc = NULL;\r
+    }\r
+    if (self->dec) {\r
+        opus_decoder_destroy(self->dec);\r
+        self->dec = NULL;\r
+    }\r
+    self->has_enc = 0;\r
+    self->has_dec = 0;\r
+    return mp_const_none;\r
+}\r
+STATIC MP_DEFINE_CONST_FUN_OBJ_1(opus_close_obj, opus_close);\r
+\r
+STATIC mp_obj_t opus_version(mp_obj_t cls_in)\r
+{\r
+    (void)cls_in;\r
+    return mp_obj_new_str(opus_get_version_string(), strlen(opus_get_version_string()));\r
+}\r
+STATIC MP_DEFINE_CONST_FUN_OBJ_1(opus_version_obj, opus_version);\r
+\r
+STATIC const mp_rom_map_elem_t OpusCodec_locals[] = {\r
+    { MP_ROM_QSTR(MP_QSTR_encode), MP_ROM_PTR(&opus_encode_obj) },\r
+    { MP_ROM_QSTR(MP_QSTR_decode), MP_ROM_PTR(&opus_decode_obj) },\r
+    { MP_ROM_QSTR(MP_QSTR_close), MP_ROM_PTR(&opus_close_obj) },\r
+};\r
+STATIC MP_DEFINE_CONST_DICT(OpusCodec_locals_dict, OpusCodec_locals);\r
+\r
+STATIC const mp_obj_type_t OpusCodec_type = {\r
+    { &mp_type_type },\r
+    .name = MP_QSTR_OpusCodec,\r
+    .make_new = OpusCodec_make_new,\r
+    .locals_dict = (void *)&OpusCodec_locals_dict,\r
+};\r
+\r
+STATIC const mp_rom_map_elem_t opus_module_globals[] = {\r
+    { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_opus) },\r
+    { MP_ROM_QSTR(MP_QSTR_OpusCodec), MP_ROM_PTR(&OpusCodec_type) },\r
+    { MP_ROM_QSTR(MP_QSTR_version), MP_ROM_PTR(&opus_version_obj) },\r
+    { MP_ROM_QSTR(MP_QSTR_FRAME_PCM_BYTES), MP_ROM_INT(OPUS_CODEC_FRAME_PCM) },\r
+    { MP_ROM_QSTR(MP_QSTR_SAMPLE_RATE), MP_ROM_INT(OPUS_CODEC_SR_HZ) },\r
+};\r
+STATIC MP_DEFINE_CONST_DICT(opus_module_globals_dict, opus_module_globals);\r
+\r
+const mp_obj_module_t mp_module_opus = {\r
+    .base = { &mp_type_module },\r
+    .globals = (mp_obj_dict_t *)&opus_module_globals_dict,\r
+};\r
+\r
+MP_REGISTER_MODULE(MP_QSTR_opus, mp_module_opus, CONFIG_OPUS);\r
+\r
+#endif /* CONFIG_OPUS */\r
diff --git a/2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/source/opus/opus.h b/2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/source/opus/opus.h
new file mode 100644 (file)
index 0000000..0c69c62
--- /dev/null
@@ -0,0 +1,981 @@
+/* Copyright (c) 2010-2011 Xiph.Org Foundation, Skype Limited
+   Written by Jean-Marc Valin and Koen Vos */
+/*
+   Redistribution and use in source and binary forms, with or without
+   modification, are permitted provided that the following conditions
+   are met:
+
+   - Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+
+   - Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+
+   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+   ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
+   OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+   PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+   LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+/**
+ * @file opus.h
+ * @brief Opus reference implementation API
+ */
+
+#ifndef OPUS_H
+#define OPUS_H
+
+#include "opus_types.h"
+#include "opus_defines.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @mainpage Opus
+ *
+ * The Opus codec is designed for interactive speech and audio transmission over the Internet.
+ * It is designed by the IETF Codec Working Group and incorporates technology from
+ * Skype's SILK codec and Xiph.Org's CELT codec.
+ *
+ * The Opus codec is designed to handle a wide range of interactive audio applications,
+ * including Voice over IP, videoconferencing, in-game chat, and even remote live music
+ * performances. It can scale from low bit-rate narrowband speech to very high quality
+ * stereo music. Its main features are:
+
+ * @li Sampling rates from 8 to 48 kHz
+ * @li Bit-rates from 6 kb/s to 510 kb/s
+ * @li Support for both constant bit-rate (CBR) and variable bit-rate (VBR)
+ * @li Audio bandwidth from narrowband to full-band
+ * @li Support for speech and music
+ * @li Support for mono and stereo
+ * @li Support for multichannel (up to 255 channels)
+ * @li Frame sizes from 2.5 ms to 60 ms
+ * @li Good loss robustness and packet loss concealment (PLC)
+ * @li Floating point and fixed-point implementation
+ *
+ * Documentation sections:
+ * @li @ref opus_encoder
+ * @li @ref opus_decoder
+ * @li @ref opus_repacketizer
+ * @li @ref opus_multistream
+ * @li @ref opus_libinfo
+ * @li @ref opus_custom
+ */
+
+/** @defgroup opus_encoder Opus Encoder
+  * @{
+  *
+  * @brief This page describes the process and functions used to encode Opus.
+  *
+  * Since Opus is a stateful codec, the encoding process starts with creating an encoder
+  * state. This can be done with:
+  *
+  * @code
+  * int          error;
+  * OpusEncoder *enc;
+  * enc = opus_encoder_create(Fs, channels, application, &error);
+  * @endcode
+  *
+  * From this point, @c enc can be used for encoding an audio stream. An encoder state
+  * @b must @b not be used for more than one stream at the same time. Similarly, the encoder
+  * state @b must @b not be re-initialized for each frame.
+  *
+  * While opus_encoder_create() allocates memory for the state, it's also possible
+  * to initialize pre-allocated memory:
+  *
+  * @code
+  * int          size;
+  * int          error;
+  * OpusEncoder *enc;
+  * size = opus_encoder_get_size(channels);
+  * enc = malloc(size);
+  * error = opus_encoder_init(enc, Fs, channels, application);
+  * @endcode
+  *
+  * where opus_encoder_get_size() returns the required size for the encoder state. Note that
+  * future versions of this code may change the size, so no assuptions should be made about it.
+  *
+  * The encoder state is always continuous in memory and only a shallow copy is sufficient
+  * to copy it (e.g. memcpy())
+  *
+  * It is possible to change some of the encoder's settings using the opus_encoder_ctl()
+  * interface. All these settings already default to the recommended value, so they should
+  * only be changed when necessary. The most common settings one may want to change are:
+  *
+  * @code
+  * opus_encoder_ctl(enc, OPUS_SET_BITRATE(bitrate));
+  * opus_encoder_ctl(enc, OPUS_SET_COMPLEXITY(complexity));
+  * opus_encoder_ctl(enc, OPUS_SET_SIGNAL(signal_type));
+  * @endcode
+  *
+  * where
+  *
+  * @arg bitrate is in bits per second (b/s)
+  * @arg complexity is a value from 1 to 10, where 1 is the lowest complexity and 10 is the highest
+  * @arg signal_type is either OPUS_AUTO (default), OPUS_SIGNAL_VOICE, or OPUS_SIGNAL_MUSIC
+  *
+  * See @ref opus_encoderctls and @ref opus_genericctls for a complete list of parameters that can be set or queried. Most parameters can be set or changed at any time during a stream.
+  *
+  * To encode a frame, opus_encode() or opus_encode_float() must be called with exactly one frame (2.5, 5, 10, 20, 40 or 60 ms) of audio data:
+  * @code
+  * len = opus_encode(enc, audio_frame, frame_size, packet, max_packet);
+  * @endcode
+  *
+  * where
+  * <ul>
+  * <li>audio_frame is the audio data in opus_int16 (or float for opus_encode_float())</li>
+  * <li>frame_size is the duration of the frame in samples (per channel)</li>
+  * <li>packet is the byte array to which the compressed data is written</li>
+  * <li>max_packet is the maximum number of bytes that can be written in the packet (4000 bytes is recommended).
+  *     Do not use max_packet to control VBR target bitrate, instead use the #OPUS_SET_BITRATE CTL.</li>
+  * </ul>
+  *
+  * opus_encode() and opus_encode_float() return the number of bytes actually written to the packet.
+  * The return value <b>can be negative</b>, which indicates that an error has occurred. If the return value
+  * is 2 bytes or less, then the packet does not need to be transmitted (DTX).
+  *
+  * Once the encoder state if no longer needed, it can be destroyed with
+  *
+  * @code
+  * opus_encoder_destroy(enc);
+  * @endcode
+  *
+  * If the encoder was created with opus_encoder_init() rather than opus_encoder_create(),
+  * then no action is required aside from potentially freeing the memory that was manually
+  * allocated for it (calling free(enc) for the example above)
+  *
+  */
+
+/** Opus encoder state.
+  * This contains the complete state of an Opus encoder.
+  * It is position independent and can be freely copied.
+  * @see opus_encoder_create,opus_encoder_init
+  */
+typedef struct OpusEncoder OpusEncoder;
+
+/** Gets the size of an <code>OpusEncoder</code> structure.
+  * @param[in] channels <tt>int</tt>: Number of channels.
+  *                                   This must be 1 or 2.
+  * @returns The size in bytes.
+  */
+OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_encoder_get_size(int channels);
+
+/**
+ */
+
+/** Allocates and initializes an encoder state.
+ * There are three coding modes:
+ *
+ * @ref OPUS_APPLICATION_VOIP gives best quality at a given bitrate for voice
+ *    signals. It enhances the  input signal by high-pass filtering and
+ *    emphasizing formants and harmonics. Optionally  it includes in-band
+ *    forward error correction to protect against packet loss. Use this
+ *    mode for typical VoIP applications. Because of the enhancement,
+ *    even at high bitrates the output may sound different from the input.
+ *
+ * @ref OPUS_APPLICATION_AUDIO gives best quality at a given bitrate for most
+ *    non-voice signals like music. Use this mode for music and mixed
+ *    (music/voice) content, broadcast, and applications requiring less
+ *    than 15 ms of coding delay.
+ *
+ * @ref OPUS_APPLICATION_RESTRICTED_LOWDELAY configures low-delay mode that
+ *    disables the speech-optimized mode in exchange for slightly reduced delay.
+ *    This mode can only be set on an newly initialized or freshly reset encoder
+ *    because it changes the codec delay.
+ *
+ * This is useful when the caller knows that the speech-optimized modes will not be needed (use with caution).
+ * @param [in] Fs <tt>opus_int32</tt>: Sampling rate of input signal (Hz)
+ *                                     This must be one of 8000, 12000, 16000,
+ *                                     24000, or 48000.
+ * @param [in] channels <tt>int</tt>: Number of channels (1 or 2) in input signal
+ * @param [in] application <tt>int</tt>: Coding mode (one of @ref OPUS_APPLICATION_VOIP, @ref OPUS_APPLICATION_AUDIO, or @ref OPUS_APPLICATION_RESTRICTED_LOWDELAY)
+ * @param [out] error <tt>int*</tt>: @ref opus_errorcodes
+ * @note Regardless of the sampling rate and number channels selected, the Opus encoder
+ * can switch to a lower audio bandwidth or number of channels if the bitrate
+ * selected is too low. This also means that it is safe to always use 48 kHz stereo input
+ * and let the encoder optimize the encoding.
+ */
+OPUS_EXPORT OPUS_WARN_UNUSED_RESULT OpusEncoder *opus_encoder_create(
+    opus_int32 Fs,
+    int channels,
+    int application,
+    int *error
+);
+
+/** Initializes a previously allocated encoder state
+  * The memory pointed to by st must be at least the size returned by opus_encoder_get_size().
+  * This is intended for applications which use their own allocator instead of malloc.
+  * @see opus_encoder_create(),opus_encoder_get_size()
+  * To reset a previously initialized state, use the #OPUS_RESET_STATE CTL.
+  * @param [in] st <tt>OpusEncoder*</tt>: Encoder state
+  * @param [in] Fs <tt>opus_int32</tt>: Sampling rate of input signal (Hz)
+ *                                      This must be one of 8000, 12000, 16000,
+ *                                      24000, or 48000.
+  * @param [in] channels <tt>int</tt>: Number of channels (1 or 2) in input signal
+  * @param [in] application <tt>int</tt>: Coding mode (one of OPUS_APPLICATION_VOIP, OPUS_APPLICATION_AUDIO, or OPUS_APPLICATION_RESTRICTED_LOWDELAY)
+  * @retval #OPUS_OK Success or @ref opus_errorcodes
+  */
+OPUS_EXPORT int opus_encoder_init(
+    OpusEncoder *st,
+    opus_int32 Fs,
+    int channels,
+    int application
+) OPUS_ARG_NONNULL(1);
+
+/** Encodes an Opus frame.
+  * @param [in] st <tt>OpusEncoder*</tt>: Encoder state
+  * @param [in] pcm <tt>opus_int16*</tt>: Input signal (interleaved if 2 channels). length is frame_size*channels*sizeof(opus_int16)
+  * @param [in] frame_size <tt>int</tt>: Number of samples per channel in the
+  *                                      input signal.
+  *                                      This must be an Opus frame size for
+  *                                      the encoder's sampling rate.
+  *                                      For example, at 48 kHz the permitted
+  *                                      values are 120, 240, 480, 960, 1920,
+  *                                      and 2880.
+  *                                      Passing in a duration of less than
+  *                                      10 ms (480 samples at 48 kHz) will
+  *                                      prevent the encoder from using the LPC
+  *                                      or hybrid modes.
+  * @param [out] data <tt>unsigned char*</tt>: Output payload.
+  *                                            This must contain storage for at
+  *                                            least \a max_data_bytes.
+  * @param [in] max_data_bytes <tt>opus_int32</tt>: Size of the allocated
+  *                                                 memory for the output
+  *                                                 payload. This may be
+  *                                                 used to impose an upper limit on
+  *                                                 the instant bitrate, but should
+  *                                                 not be used as the only bitrate
+  *                                                 control. Use #OPUS_SET_BITRATE to
+  *                                                 control the bitrate.
+  * @returns The length of the encoded packet (in bytes) on success or a
+  *          negative error code (see @ref opus_errorcodes) on failure.
+  */
+OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_encode(
+    OpusEncoder *st,
+    const opus_int16 *pcm,
+    int frame_size,
+    unsigned char *data,
+    opus_int32 max_data_bytes
+) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2) OPUS_ARG_NONNULL(4);
+
+/** Encodes an Opus frame from floating point input.
+  * @param [in] st <tt>OpusEncoder*</tt>: Encoder state
+  * @param [in] pcm <tt>float*</tt>: Input in float format (interleaved if 2 channels), with a normal range of +/-1.0.
+  *          Samples with a range beyond +/-1.0 are supported but will
+  *          be clipped by decoders using the integer API and should
+  *          only be used if it is known that the far end supports
+  *          extended dynamic range.
+  *          length is frame_size*channels*sizeof(float)
+  * @param [in] frame_size <tt>int</tt>: Number of samples per channel in the
+  *                                      input signal.
+  *                                      This must be an Opus frame size for
+  *                                      the encoder's sampling rate.
+  *                                      For example, at 48 kHz the permitted
+  *                                      values are 120, 240, 480, 960, 1920,
+  *                                      and 2880.
+  *                                      Passing in a duration of less than
+  *                                      10 ms (480 samples at 48 kHz) will
+  *                                      prevent the encoder from using the LPC
+  *                                      or hybrid modes.
+  * @param [out] data <tt>unsigned char*</tt>: Output payload.
+  *                                            This must contain storage for at
+  *                                            least \a max_data_bytes.
+  * @param [in] max_data_bytes <tt>opus_int32</tt>: Size of the allocated
+  *                                                 memory for the output
+  *                                                 payload. This may be
+  *                                                 used to impose an upper limit on
+  *                                                 the instant bitrate, but should
+  *                                                 not be used as the only bitrate
+  *                                                 control. Use #OPUS_SET_BITRATE to
+  *                                                 control the bitrate.
+  * @returns The length of the encoded packet (in bytes) on success or a
+  *          negative error code (see @ref opus_errorcodes) on failure.
+  */
+OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_encode_float(
+    OpusEncoder *st,
+    const float *pcm,
+    int frame_size,
+    unsigned char *data,
+    opus_int32 max_data_bytes
+) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2) OPUS_ARG_NONNULL(4);
+
+/** Frees an <code>OpusEncoder</code> allocated by opus_encoder_create().
+  * @param[in] st <tt>OpusEncoder*</tt>: State to be freed.
+  */
+OPUS_EXPORT void opus_encoder_destroy(OpusEncoder *st);
+
+/** Perform a CTL function on an Opus encoder.
+  *
+  * Generally the request and subsequent arguments are generated
+  * by a convenience macro.
+  * @param st <tt>OpusEncoder*</tt>: Encoder state.
+  * @param request This and all remaining parameters should be replaced by one
+  *                of the convenience macros in @ref opus_genericctls or
+  *                @ref opus_encoderctls.
+  * @see opus_genericctls
+  * @see opus_encoderctls
+  */
+OPUS_EXPORT int opus_encoder_ctl(OpusEncoder *st, int request, ...) OPUS_ARG_NONNULL(1);
+/**@}*/
+
+/** @defgroup opus_decoder Opus Decoder
+  * @{
+  *
+  * @brief This page describes the process and functions used to decode Opus.
+  *
+  * The decoding process also starts with creating a decoder
+  * state. This can be done with:
+  * @code
+  * int          error;
+  * OpusDecoder *dec;
+  * dec = opus_decoder_create(Fs, channels, &error);
+  * @endcode
+  * where
+  * @li Fs is the sampling rate and must be 8000, 12000, 16000, 24000, or 48000
+  * @li channels is the number of channels (1 or 2)
+  * @li error will hold the error code in case of failure (or #OPUS_OK on success)
+  * @li the return value is a newly created decoder state to be used for decoding
+  *
+  * While opus_decoder_create() allocates memory for the state, it's also possible
+  * to initialize pre-allocated memory:
+  * @code
+  * int          size;
+  * int          error;
+  * OpusDecoder *dec;
+  * size = opus_decoder_get_size(channels);
+  * dec = malloc(size);
+  * error = opus_decoder_init(dec, Fs, channels);
+  * @endcode
+  * where opus_decoder_get_size() returns the required size for the decoder state. Note that
+  * future versions of this code may change the size, so no assuptions should be made about it.
+  *
+  * The decoder state is always continuous in memory and only a shallow copy is sufficient
+  * to copy it (e.g. memcpy())
+  *
+  * To decode a frame, opus_decode() or opus_decode_float() must be called with a packet of compressed audio data:
+  * @code
+  * frame_size = opus_decode(dec, packet, len, decoded, max_size, 0);
+  * @endcode
+  * where
+  *
+  * @li packet is the byte array containing the compressed data
+  * @li len is the exact number of bytes contained in the packet
+  * @li decoded is the decoded audio data in opus_int16 (or float for opus_decode_float())
+  * @li max_size is the max duration of the frame in samples (per channel) that can fit into the decoded_frame array
+  *
+  * opus_decode() and opus_decode_float() return the number of samples (per channel) decoded from the packet.
+  * If that value is negative, then an error has occurred. This can occur if the packet is corrupted or if the audio
+  * buffer is too small to hold the decoded audio.
+  *
+  * Opus is a stateful codec with overlapping blocks and as a result Opus
+  * packets are not coded independently of each other. Packets must be
+  * passed into the decoder serially and in the correct order for a correct
+  * decode. Lost packets can be replaced with loss concealment by calling
+  * the decoder with a null pointer and zero length for the missing packet.
+  *
+  * A single codec state may only be accessed from a single thread at
+  * a time and any required locking must be performed by the caller. Separate
+  * streams must be decoded with separate decoder states and can be decoded
+  * in parallel unless the library was compiled with NONTHREADSAFE_PSEUDOSTACK
+  * defined.
+  *
+  */
+
+/** Opus decoder state.
+  * This contains the complete state of an Opus decoder.
+  * It is position independent and can be freely copied.
+  * @see opus_decoder_create,opus_decoder_init
+  */
+typedef struct OpusDecoder OpusDecoder;
+
+/** Gets the size of an <code>OpusDecoder</code> structure.
+  * @param [in] channels <tt>int</tt>: Number of channels.
+  *                                    This must be 1 or 2.
+  * @returns The size in bytes.
+  */
+OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_decoder_get_size(int channels);
+
+/** Allocates and initializes a decoder state.
+  * @param [in] Fs <tt>opus_int32</tt>: Sample rate to decode at (Hz).
+  *                                     This must be one of 8000, 12000, 16000,
+  *                                     24000, or 48000.
+  * @param [in] channels <tt>int</tt>: Number of channels (1 or 2) to decode
+  * @param [out] error <tt>int*</tt>: #OPUS_OK Success or @ref opus_errorcodes
+  *
+  * Internally Opus stores data at 48000 Hz, so that should be the default
+  * value for Fs. However, the decoder can efficiently decode to buffers
+  * at 8, 12, 16, and 24 kHz so if for some reason the caller cannot use
+  * data at the full sample rate, or knows the compressed data doesn't
+  * use the full frequency range, it can request decoding at a reduced
+  * rate. Likewise, the decoder is capable of filling in either mono or
+  * interleaved stereo pcm buffers, at the caller's request.
+  */
+OPUS_EXPORT OPUS_WARN_UNUSED_RESULT OpusDecoder *opus_decoder_create(
+    opus_int32 Fs,
+    int channels,
+    int *error
+);
+
+/** Initializes a previously allocated decoder state.
+  * The state must be at least the size returned by opus_decoder_get_size().
+  * This is intended for applications which use their own allocator instead of malloc. @see opus_decoder_create,opus_decoder_get_size
+  * To reset a previously initialized state, use the #OPUS_RESET_STATE CTL.
+  * @param [in] st <tt>OpusDecoder*</tt>: Decoder state.
+  * @param [in] Fs <tt>opus_int32</tt>: Sampling rate to decode to (Hz).
+  *                                     This must be one of 8000, 12000, 16000,
+  *                                     24000, or 48000.
+  * @param [in] channels <tt>int</tt>: Number of channels (1 or 2) to decode
+  * @retval #OPUS_OK Success or @ref opus_errorcodes
+  */
+OPUS_EXPORT int opus_decoder_init(
+    OpusDecoder *st,
+    opus_int32 Fs,
+    int channels
+) OPUS_ARG_NONNULL(1);
+
+/** Decode an Opus packet.
+  * @param [in] st <tt>OpusDecoder*</tt>: Decoder state
+  * @param [in] data <tt>char*</tt>: Input payload. Use a NULL pointer to indicate packet loss
+  * @param [in] len <tt>opus_int32</tt>: Number of bytes in payload*
+  * @param [out] pcm <tt>opus_int16*</tt>: Output signal (interleaved if 2 channels). length
+  *  is frame_size*channels*sizeof(opus_int16)
+  * @param [in] frame_size Number of samples per channel of available space in \a pcm.
+  *  If this is less than the maximum packet duration (120ms; 5760 for 48kHz), this function will
+  *  not be capable of decoding some packets. In the case of PLC (data==NULL) or FEC (decode_fec=1),
+  *  then frame_size needs to be exactly the duration of audio that is missing, otherwise the
+  *  decoder will not be in the optimal state to decode the next incoming packet. For the PLC and
+  *  FEC cases, frame_size <b>must</b> be a multiple of 2.5 ms.
+  * @param [in] decode_fec <tt>int</tt>: Flag (0 or 1) to request that any in-band forward error correction data be
+  *  decoded. If no such data is available, the frame is decoded as if it were lost.
+  * @returns Number of decoded samples or @ref opus_errorcodes
+  */
+OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_decode(
+    OpusDecoder *st,
+    const unsigned char *data,
+    opus_int32 len,
+    opus_int16 *pcm,
+    int frame_size,
+    int decode_fec
+) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(4);
+
+/** Decode an Opus packet with floating point output.
+  * @param [in] st <tt>OpusDecoder*</tt>: Decoder state
+  * @param [in] data <tt>char*</tt>: Input payload. Use a NULL pointer to indicate packet loss
+  * @param [in] len <tt>opus_int32</tt>: Number of bytes in payload
+  * @param [out] pcm <tt>float*</tt>: Output signal (interleaved if 2 channels). length
+  *  is frame_size*channels*sizeof(float)
+  * @param [in] frame_size Number of samples per channel of available space in \a pcm.
+  *  If this is less than the maximum packet duration (120ms; 5760 for 48kHz), this function will
+  *  not be capable of decoding some packets. In the case of PLC (data==NULL) or FEC (decode_fec=1),
+  *  then frame_size needs to be exactly the duration of audio that is missing, otherwise the
+  *  decoder will not be in the optimal state to decode the next incoming packet. For the PLC and
+  *  FEC cases, frame_size <b>must</b> be a multiple of 2.5 ms.
+  * @param [in] decode_fec <tt>int</tt>: Flag (0 or 1) to request that any in-band forward error correction data be
+  *  decoded. If no such data is available the frame is decoded as if it were lost.
+  * @returns Number of decoded samples or @ref opus_errorcodes
+  */
+OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_decode_float(
+    OpusDecoder *st,
+    const unsigned char *data,
+    opus_int32 len,
+    float *pcm,
+    int frame_size,
+    int decode_fec
+) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(4);
+
+/** Perform a CTL function on an Opus decoder.
+  *
+  * Generally the request and subsequent arguments are generated
+  * by a convenience macro.
+  * @param st <tt>OpusDecoder*</tt>: Decoder state.
+  * @param request This and all remaining parameters should be replaced by one
+  *                of the convenience macros in @ref opus_genericctls or
+  *                @ref opus_decoderctls.
+  * @see opus_genericctls
+  * @see opus_decoderctls
+  */
+OPUS_EXPORT int opus_decoder_ctl(OpusDecoder *st, int request, ...) OPUS_ARG_NONNULL(1);
+
+/** Frees an <code>OpusDecoder</code> allocated by opus_decoder_create().
+  * @param[in] st <tt>OpusDecoder*</tt>: State to be freed.
+  */
+OPUS_EXPORT void opus_decoder_destroy(OpusDecoder *st);
+
+/** Parse an opus packet into one or more frames.
+  * Opus_decode will perform this operation internally so most applications do
+  * not need to use this function.
+  * This function does not copy the frames, the returned pointers are pointers into
+  * the input packet.
+  * @param [in] data <tt>char*</tt>: Opus packet to be parsed
+  * @param [in] len <tt>opus_int32</tt>: size of data
+  * @param [out] out_toc <tt>char*</tt>: TOC pointer
+  * @param [out] frames <tt>char*[48]</tt> encapsulated frames
+  * @param [out] size <tt>opus_int16[48]</tt> sizes of the encapsulated frames
+  * @param [out] payload_offset <tt>int*</tt>: returns the position of the payload within the packet (in bytes)
+  * @returns number of frames
+  */
+OPUS_EXPORT int opus_packet_parse(
+   const unsigned char *data,
+   opus_int32 len,
+   unsigned char *out_toc,
+   const unsigned char *frames[48],
+   opus_int16 size[48],
+   int *payload_offset
+) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(5);
+
+/** Gets the bandwidth of an Opus packet.
+  * @param [in] data <tt>char*</tt>: Opus packet
+  * @retval OPUS_BANDWIDTH_NARROWBAND Narrowband (4kHz bandpass)
+  * @retval OPUS_BANDWIDTH_MEDIUMBAND Mediumband (6kHz bandpass)
+  * @retval OPUS_BANDWIDTH_WIDEBAND Wideband (8kHz bandpass)
+  * @retval OPUS_BANDWIDTH_SUPERWIDEBAND Superwideband (12kHz bandpass)
+  * @retval OPUS_BANDWIDTH_FULLBAND Fullband (20kHz bandpass)
+  * @retval OPUS_INVALID_PACKET The compressed data passed is corrupted or of an unsupported type
+  */
+OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_packet_get_bandwidth(const unsigned char *data) OPUS_ARG_NONNULL(1);
+
+/** Gets the number of samples per frame from an Opus packet.
+  * @param [in] data <tt>char*</tt>: Opus packet.
+  *                                  This must contain at least one byte of
+  *                                  data.
+  * @param [in] Fs <tt>opus_int32</tt>: Sampling rate in Hz.
+  *                                     This must be a multiple of 400, or
+  *                                     inaccurate results will be returned.
+  * @returns Number of samples per frame.
+  */
+OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_packet_get_samples_per_frame(const unsigned char *data, opus_int32 Fs) OPUS_ARG_NONNULL(1);
+
+/** Gets the number of channels from an Opus packet.
+  * @param [in] data <tt>char*</tt>: Opus packet
+  * @returns Number of channels
+  * @retval OPUS_INVALID_PACKET The compressed data passed is corrupted or of an unsupported type
+  */
+OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_packet_get_nb_channels(const unsigned char *data) OPUS_ARG_NONNULL(1);
+
+/** Gets the number of frames in an Opus packet.
+  * @param [in] packet <tt>char*</tt>: Opus packet
+  * @param [in] len <tt>opus_int32</tt>: Length of packet
+  * @returns Number of frames
+  * @retval OPUS_BAD_ARG Insufficient data was passed to the function
+  * @retval OPUS_INVALID_PACKET The compressed data passed is corrupted or of an unsupported type
+  */
+OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_packet_get_nb_frames(const unsigned char packet[], opus_int32 len) OPUS_ARG_NONNULL(1);
+
+/** Gets the number of samples of an Opus packet.
+  * @param [in] packet <tt>char*</tt>: Opus packet
+  * @param [in] len <tt>opus_int32</tt>: Length of packet
+  * @param [in] Fs <tt>opus_int32</tt>: Sampling rate in Hz.
+  *                                     This must be a multiple of 400, or
+  *                                     inaccurate results will be returned.
+  * @returns Number of samples
+  * @retval OPUS_BAD_ARG Insufficient data was passed to the function
+  * @retval OPUS_INVALID_PACKET The compressed data passed is corrupted or of an unsupported type
+  */
+OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_packet_get_nb_samples(const unsigned char packet[], opus_int32 len, opus_int32 Fs) OPUS_ARG_NONNULL(1);
+
+/** Gets the number of samples of an Opus packet.
+  * @param [in] dec <tt>OpusDecoder*</tt>: Decoder state
+  * @param [in] packet <tt>char*</tt>: Opus packet
+  * @param [in] len <tt>opus_int32</tt>: Length of packet
+  * @returns Number of samples
+  * @retval OPUS_BAD_ARG Insufficient data was passed to the function
+  * @retval OPUS_INVALID_PACKET The compressed data passed is corrupted or of an unsupported type
+  */
+OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_decoder_get_nb_samples(const OpusDecoder *dec, const unsigned char packet[], opus_int32 len) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2);
+
+/** Applies soft-clipping to bring a float signal within the [-1,1] range. If
+  * the signal is already in that range, nothing is done. If there are values
+  * outside of [-1,1], then the signal is clipped as smoothly as possible to
+  * both fit in the range and avoid creating excessive distortion in the
+  * process.
+  * @param [in,out] pcm <tt>float*</tt>: Input PCM and modified PCM
+  * @param [in] frame_size <tt>int</tt> Number of samples per channel to process
+  * @param [in] channels <tt>int</tt>: Number of channels
+  * @param [in,out] softclip_mem <tt>float*</tt>: State memory for the soft clipping process (one float per channel, initialized to zero)
+  */
+OPUS_EXPORT void opus_pcm_soft_clip(float *pcm, int frame_size, int channels, float *softclip_mem);
+
+
+/**@}*/
+
+/** @defgroup opus_repacketizer Repacketizer
+  * @{
+  *
+  * The repacketizer can be used to merge multiple Opus packets into a single
+  * packet or alternatively to split Opus packets that have previously been
+  * merged. Splitting valid Opus packets is always guaranteed to succeed,
+  * whereas merging valid packets only succeeds if all frames have the same
+  * mode, bandwidth, and frame size, and when the total duration of the merged
+  * packet is no more than 120 ms. The 120 ms limit comes from the
+  * specification and limits decoder memory requirements at a point where
+  * framing overhead becomes negligible.
+  *
+  * The repacketizer currently only operates on elementary Opus
+  * streams. It will not manipualte multistream packets successfully, except in
+  * the degenerate case where they consist of data from a single stream.
+  *
+  * The repacketizing process starts with creating a repacketizer state, either
+  * by calling opus_repacketizer_create() or by allocating the memory yourself,
+  * e.g.,
+  * @code
+  * OpusRepacketizer *rp;
+  * rp = (OpusRepacketizer*)malloc(opus_repacketizer_get_size());
+  * if (rp != NULL)
+  *     opus_repacketizer_init(rp);
+  * @endcode
+  *
+  * Then the application should submit packets with opus_repacketizer_cat(),
+  * extract new packets with opus_repacketizer_out() or
+  * opus_repacketizer_out_range(), and then reset the state for the next set of
+  * input packets via opus_repacketizer_init().
+  *
+  * For example, to split a sequence of packets into individual frames:
+  * @code
+  * unsigned char *data;
+  * int len;
+  * while (get_next_packet(&data, &len))
+  * {
+  *   unsigned char out[1276];
+  *   opus_int32 out_len;
+  *   int nb_frames;
+  *   int err;
+  *   int i;
+  *   err = opus_repacketizer_cat(rp, data, len);
+  *   if (err != OPUS_OK)
+  *   {
+  *     release_packet(data);
+  *     return err;
+  *   }
+  *   nb_frames = opus_repacketizer_get_nb_frames(rp);
+  *   for (i = 0; i < nb_frames; i++)
+  *   {
+  *     out_len = opus_repacketizer_out_range(rp, i, i+1, out, sizeof(out));
+  *     if (out_len < 0)
+  *     {
+  *        release_packet(data);
+  *        return (int)out_len;
+  *     }
+  *     output_next_packet(out, out_len);
+  *   }
+  *   opus_repacketizer_init(rp);
+  *   release_packet(data);
+  * }
+  * @endcode
+  *
+  * Alternatively, to combine a sequence of frames into packets that each
+  * contain up to <code>TARGET_DURATION_MS</code> milliseconds of data:
+  * @code
+  * // The maximum number of packets with duration TARGET_DURATION_MS occurs
+  * // when the frame size is 2.5 ms, for a total of (TARGET_DURATION_MS*2/5)
+  * // packets.
+  * unsigned char *data[(TARGET_DURATION_MS*2/5)+1];
+  * opus_int32 len[(TARGET_DURATION_MS*2/5)+1];
+  * int nb_packets;
+  * unsigned char out[1277*(TARGET_DURATION_MS*2/2)];
+  * opus_int32 out_len;
+  * int prev_toc;
+  * nb_packets = 0;
+  * while (get_next_packet(data+nb_packets, len+nb_packets))
+  * {
+  *   int nb_frames;
+  *   int err;
+  *   nb_frames = opus_packet_get_nb_frames(data[nb_packets], len[nb_packets]);
+  *   if (nb_frames < 1)
+  *   {
+  *     release_packets(data, nb_packets+1);
+  *     return nb_frames;
+  *   }
+  *   nb_frames += opus_repacketizer_get_nb_frames(rp);
+  *   // If adding the next packet would exceed our target, or it has an
+  *   // incompatible TOC sequence, output the packets we already have before
+  *   // submitting it.
+  *   // N.B., The nb_packets > 0 check ensures we've submitted at least one
+  *   // packet since the last call to opus_repacketizer_init(). Otherwise a
+  *   // single packet longer than TARGET_DURATION_MS would cause us to try to
+  *   // output an (invalid) empty packet. It also ensures that prev_toc has
+  *   // been set to a valid value. Additionally, len[nb_packets] > 0 is
+  *   // guaranteed by the call to opus_packet_get_nb_frames() above, so the
+  *   // reference to data[nb_packets][0] should be valid.
+  *   if (nb_packets > 0 && (
+  *       ((prev_toc & 0xFC) != (data[nb_packets][0] & 0xFC)) ||
+  *       opus_packet_get_samples_per_frame(data[nb_packets], 48000)*nb_frames >
+  *       TARGET_DURATION_MS*48))
+  *   {
+  *     out_len = opus_repacketizer_out(rp, out, sizeof(out));
+  *     if (out_len < 0)
+  *     {
+  *        release_packets(data, nb_packets+1);
+  *        return (int)out_len;
+  *     }
+  *     output_next_packet(out, out_len);
+  *     opus_repacketizer_init(rp);
+  *     release_packets(data, nb_packets);
+  *     data[0] = data[nb_packets];
+  *     len[0] = len[nb_packets];
+  *     nb_packets = 0;
+  *   }
+  *   err = opus_repacketizer_cat(rp, data[nb_packets], len[nb_packets]);
+  *   if (err != OPUS_OK)
+  *   {
+  *     release_packets(data, nb_packets+1);
+  *     return err;
+  *   }
+  *   prev_toc = data[nb_packets][0];
+  *   nb_packets++;
+  * }
+  * // Output the final, partial packet.
+  * if (nb_packets > 0)
+  * {
+  *   out_len = opus_repacketizer_out(rp, out, sizeof(out));
+  *   release_packets(data, nb_packets);
+  *   if (out_len < 0)
+  *     return (int)out_len;
+  *   output_next_packet(out, out_len);
+  * }
+  * @endcode
+  *
+  * An alternate way of merging packets is to simply call opus_repacketizer_cat()
+  * unconditionally until it fails. At that point, the merged packet can be
+  * obtained with opus_repacketizer_out() and the input packet for which
+  * opus_repacketizer_cat() needs to be re-added to a newly reinitialized
+  * repacketizer state.
+  */
+
+typedef struct OpusRepacketizer OpusRepacketizer;
+
+/** Gets the size of an <code>OpusRepacketizer</code> structure.
+  * @returns The size in bytes.
+  */
+OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_repacketizer_get_size(void);
+
+/** (Re)initializes a previously allocated repacketizer state.
+  * The state must be at least the size returned by opus_repacketizer_get_size().
+  * This can be used for applications which use their own allocator instead of
+  * malloc().
+  * It must also be called to reset the queue of packets waiting to be
+  * repacketized, which is necessary if the maximum packet duration of 120 ms
+  * is reached or if you wish to submit packets with a different Opus
+  * configuration (coding mode, audio bandwidth, frame size, or channel count).
+  * Failure to do so will prevent a new packet from being added with
+  * opus_repacketizer_cat().
+  * @see opus_repacketizer_create
+  * @see opus_repacketizer_get_size
+  * @see opus_repacketizer_cat
+  * @param rp <tt>OpusRepacketizer*</tt>: The repacketizer state to
+  *                                       (re)initialize.
+  * @returns A pointer to the same repacketizer state that was passed in.
+  */
+OPUS_EXPORT OpusRepacketizer *opus_repacketizer_init(OpusRepacketizer *rp) OPUS_ARG_NONNULL(1);
+
+/** Allocates memory and initializes the new repacketizer with
+ * opus_repacketizer_init().
+  */
+OPUS_EXPORT OPUS_WARN_UNUSED_RESULT OpusRepacketizer *opus_repacketizer_create(void);
+
+/** Frees an <code>OpusRepacketizer</code> allocated by
+  * opus_repacketizer_create().
+  * @param[in] rp <tt>OpusRepacketizer*</tt>: State to be freed.
+  */
+OPUS_EXPORT void opus_repacketizer_destroy(OpusRepacketizer *rp);
+
+/** Add a packet to the current repacketizer state.
+  * This packet must match the configuration of any packets already submitted
+  * for repacketization since the last call to opus_repacketizer_init().
+  * This means that it must have the same coding mode, audio bandwidth, frame
+  * size, and channel count.
+  * This can be checked in advance by examining the top 6 bits of the first
+  * byte of the packet, and ensuring they match the top 6 bits of the first
+  * byte of any previously submitted packet.
+  * The total duration of audio in the repacketizer state also must not exceed
+  * 120 ms, the maximum duration of a single packet, after adding this packet.
+  *
+  * The contents of the current repacketizer state can be extracted into new
+  * packets using opus_repacketizer_out() or opus_repacketizer_out_range().
+  *
+  * In order to add a packet with a different configuration or to add more
+  * audio beyond 120 ms, you must clear the repacketizer state by calling
+  * opus_repacketizer_init().
+  * If a packet is too large to add to the current repacketizer state, no part
+  * of it is added, even if it contains multiple frames, some of which might
+  * fit.
+  * If you wish to be able to add parts of such packets, you should first use
+  * another repacketizer to split the packet into pieces and add them
+  * individually.
+  * @see opus_repacketizer_out_range
+  * @see opus_repacketizer_out
+  * @see opus_repacketizer_init
+  * @param rp <tt>OpusRepacketizer*</tt>: The repacketizer state to which to
+  *                                       add the packet.
+  * @param[in] data <tt>const unsigned char*</tt>: The packet data.
+  *                                                The application must ensure
+  *                                                this pointer remains valid
+  *                                                until the next call to
+  *                                                opus_repacketizer_init() or
+  *                                                opus_repacketizer_destroy().
+  * @param len <tt>opus_int32</tt>: The number of bytes in the packet data.
+  * @returns An error code indicating whether or not the operation succeeded.
+  * @retval #OPUS_OK The packet's contents have been added to the repacketizer
+  *                  state.
+  * @retval #OPUS_INVALID_PACKET The packet did not have a valid TOC sequence,
+  *                              the packet's TOC sequence was not compatible
+  *                              with previously submitted packets (because
+  *                              the coding mode, audio bandwidth, frame size,
+  *                              or channel count did not match), or adding
+  *                              this packet would increase the total amount of
+  *                              audio stored in the repacketizer state to more
+  *                              than 120 ms.
+  */
+OPUS_EXPORT int opus_repacketizer_cat(OpusRepacketizer *rp, const unsigned char *data, opus_int32 len) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2);
+
+
+/** Construct a new packet from data previously submitted to the repacketizer
+  * state via opus_repacketizer_cat().
+  * @param rp <tt>OpusRepacketizer*</tt>: The repacketizer state from which to
+  *                                       construct the new packet.
+  * @param begin <tt>int</tt>: The index of the first frame in the current
+  *                            repacketizer state to include in the output.
+  * @param end <tt>int</tt>: One past the index of the last frame in the
+  *                          current repacketizer state to include in the
+  *                          output.
+  * @param[out] data <tt>const unsigned char*</tt>: The buffer in which to
+  *                                                 store the output packet.
+  * @param maxlen <tt>opus_int32</tt>: The maximum number of bytes to store in
+  *                                    the output buffer. In order to guarantee
+  *                                    success, this should be at least
+  *                                    <code>1276</code> for a single frame,
+  *                                    or for multiple frames,
+  *                                    <code>1277*(end-begin)</code>.
+  *                                    However, <code>1*(end-begin)</code> plus
+  *                                    the size of all packet data submitted to
+  *                                    the repacketizer since the last call to
+  *                                    opus_repacketizer_init() or
+  *                                    opus_repacketizer_create() is also
+  *                                    sufficient, and possibly much smaller.
+  * @returns The total size of the output packet on success, or an error code
+  *          on failure.
+  * @retval #OPUS_BAD_ARG <code>[begin,end)</code> was an invalid range of
+  *                       frames (begin < 0, begin >= end, or end >
+  *                       opus_repacketizer_get_nb_frames()).
+  * @retval #OPUS_BUFFER_TOO_SMALL \a maxlen was insufficient to contain the
+  *                                complete output packet.
+  */
+OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_repacketizer_out_range(OpusRepacketizer *rp, int begin, int end, unsigned char *data, opus_int32 maxlen) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(4);
+
+/** Return the total number of frames contained in packet data submitted to
+  * the repacketizer state so far via opus_repacketizer_cat() since the last
+  * call to opus_repacketizer_init() or opus_repacketizer_create().
+  * This defines the valid range of packets that can be extracted with
+  * opus_repacketizer_out_range() or opus_repacketizer_out().
+  * @param rp <tt>OpusRepacketizer*</tt>: The repacketizer state containing the
+  *                                       frames.
+  * @returns The total number of frames contained in the packet data submitted
+  *          to the repacketizer state.
+  */
+OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_repacketizer_get_nb_frames(OpusRepacketizer *rp) OPUS_ARG_NONNULL(1);
+
+/** Construct a new packet from data previously submitted to the repacketizer
+  * state via opus_repacketizer_cat().
+  * This is a convenience routine that returns all the data submitted so far
+  * in a single packet.
+  * It is equivalent to calling
+  * @code
+  * opus_repacketizer_out_range(rp, 0, opus_repacketizer_get_nb_frames(rp),
+  *                             data, maxlen)
+  * @endcode
+  * @param rp <tt>OpusRepacketizer*</tt>: The repacketizer state from which to
+  *                                       construct the new packet.
+  * @param[out] data <tt>const unsigned char*</tt>: The buffer in which to
+  *                                                 store the output packet.
+  * @param maxlen <tt>opus_int32</tt>: The maximum number of bytes to store in
+  *                                    the output buffer. In order to guarantee
+  *                                    success, this should be at least
+  *                                    <code>1277*opus_repacketizer_get_nb_frames(rp)</code>.
+  *                                    However,
+  *                                    <code>1*opus_repacketizer_get_nb_frames(rp)</code>
+  *                                    plus the size of all packet data
+  *                                    submitted to the repacketizer since the
+  *                                    last call to opus_repacketizer_init() or
+  *                                    opus_repacketizer_create() is also
+  *                                    sufficient, and possibly much smaller.
+  * @returns The total size of the output packet on success, or an error code
+  *          on failure.
+  * @retval #OPUS_BUFFER_TOO_SMALL \a maxlen was insufficient to contain the
+  *                                complete output packet.
+  */
+OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_repacketizer_out(OpusRepacketizer *rp, unsigned char *data, opus_int32 maxlen) OPUS_ARG_NONNULL(1);
+
+/** Pads a given Opus packet to a larger size (possibly changing the TOC sequence).
+  * @param[in,out] data <tt>const unsigned char*</tt>: The buffer containing the
+  *                                                   packet to pad.
+  * @param len <tt>opus_int32</tt>: The size of the packet.
+  *                                 This must be at least 1.
+  * @param new_len <tt>opus_int32</tt>: The desired size of the packet after padding.
+  *                                 This must be at least as large as len.
+  * @returns an error code
+  * @retval #OPUS_OK \a on success.
+  * @retval #OPUS_BAD_ARG \a len was less than 1 or new_len was less than len.
+  * @retval #OPUS_INVALID_PACKET \a data did not contain a valid Opus packet.
+  */
+OPUS_EXPORT int opus_packet_pad(unsigned char *data, opus_int32 len, opus_int32 new_len);
+
+/** Remove all padding from a given Opus packet and rewrite the TOC sequence to
+  * minimize space usage.
+  * @param[in,out] data <tt>const unsigned char*</tt>: The buffer containing the
+  *                                                   packet to strip.
+  * @param len <tt>opus_int32</tt>: The size of the packet.
+  *                                 This must be at least 1.
+  * @returns The new size of the output packet on success, or an error code
+  *          on failure.
+  * @retval #OPUS_BAD_ARG \a len was less than 1.
+  * @retval #OPUS_INVALID_PACKET \a data did not contain a valid Opus packet.
+  */
+OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_packet_unpad(unsigned char *data, opus_int32 len);
+
+/** Pads a given Opus multi-stream packet to a larger size (possibly changing the TOC sequence).
+  * @param[in,out] data <tt>const unsigned char*</tt>: The buffer containing the
+  *                                                   packet to pad.
+  * @param len <tt>opus_int32</tt>: The size of the packet.
+  *                                 This must be at least 1.
+  * @param new_len <tt>opus_int32</tt>: The desired size of the packet after padding.
+  *                                 This must be at least 1.
+  * @param nb_streams <tt>opus_int32</tt>: The number of streams (not channels) in the packet.
+  *                                 This must be at least as large as len.
+  * @returns an error code
+  * @retval #OPUS_OK \a on success.
+  * @retval #OPUS_BAD_ARG \a len was less than 1.
+  * @retval #OPUS_INVALID_PACKET \a data did not contain a valid Opus packet.
+  */
+OPUS_EXPORT int opus_multistream_packet_pad(unsigned char *data, opus_int32 len, opus_int32 new_len, int nb_streams);
+
+/** Remove all padding from a given Opus multi-stream packet and rewrite the TOC sequence to
+  * minimize space usage.
+  * @param[in,out] data <tt>const unsigned char*</tt>: The buffer containing the
+  *                                                   packet to strip.
+  * @param len <tt>opus_int32</tt>: The size of the packet.
+  *                                 This must be at least 1.
+  * @param nb_streams <tt>opus_int32</tt>: The number of streams (not channels) in the packet.
+  *                                 This must be at least 1.
+  * @returns The new size of the output packet on success, or an error code
+  *          on failure.
+  * @retval #OPUS_BAD_ARG \a len was less than 1 or new_len was less than len.
+  * @retval #OPUS_INVALID_PACKET \a data did not contain a valid Opus packet.
+  */
+OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_multistream_packet_unpad(unsigned char *data, opus_int32 len, int nb_streams);
+
+/**@}*/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* OPUS_H */
diff --git a/2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/source/opus/opus_custom.h b/2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/source/opus/opus_custom.h
new file mode 100644 (file)
index 0000000..2f22d4b
--- /dev/null
@@ -0,0 +1,343 @@
+/* Copyright (c) 2007-2008 CSIRO
+   Copyright (c) 2007-2009 Xiph.Org Foundation
+   Copyright (c) 2008-2012 Gregory Maxwell
+   Written by Jean-Marc Valin and Gregory Maxwell */
+/*
+   Redistribution and use in source and binary forms, with or without
+   modification, are permitted provided that the following conditions
+   are met:
+
+   - Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+
+   - Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+
+   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+   ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
+   OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+   PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+   LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+/**
+  @file opus_custom.h
+  @brief Opus-Custom reference implementation API
+ */
+
+#ifndef OPUS_CUSTOM_H
+#define OPUS_CUSTOM_H
+
+#include "opus_defines.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef CUSTOM_MODES
+# define OPUS_CUSTOM_EXPORT OPUS_EXPORT
+# define OPUS_CUSTOM_EXPORT_STATIC OPUS_EXPORT
+#else
+# define OPUS_CUSTOM_EXPORT
+# ifdef OPUS_BUILD
+#  define OPUS_CUSTOM_EXPORT_STATIC static OPUS_INLINE
+# else
+#  define OPUS_CUSTOM_EXPORT_STATIC
+# endif
+#endif
+
+/** @defgroup opus_custom Opus Custom
+  * @{
+  *  Opus Custom is an optional part of the Opus specification and
+  * reference implementation which uses a distinct API from the regular
+  * API and supports frame sizes that are not normally supported.\ Use
+  * of Opus Custom is discouraged for all but very special applications
+  * for which a frame size different from 2.5, 5, 10, or 20 ms is needed
+  * (for either complexity or latency reasons) and where interoperability
+  * is less important.
+  *
+  * In addition to the interoperability limitations the use of Opus custom
+  * disables a substantial chunk of the codec and generally lowers the
+  * quality available at a given bitrate. Normally when an application needs
+  * a different frame size from the codec it should buffer to match the
+  * sizes but this adds a small amount of delay which may be important
+  * in some very low latency applications. Some transports (especially
+  * constant rate RF transports) may also work best with frames of
+  * particular durations.
+  *
+  * Libopus only supports custom modes if they are enabled at compile time.
+  *
+  * The Opus Custom API is similar to the regular API but the
+  * @ref opus_encoder_create and @ref opus_decoder_create calls take
+  * an additional mode parameter which is a structure produced by
+  * a call to @ref opus_custom_mode_create. Both the encoder and decoder
+  * must create a mode using the same sample rate (fs) and frame size
+  * (frame size) so these parameters must either be signaled out of band
+  * or fixed in a particular implementation.
+  *
+  * Similar to regular Opus the custom modes support on the fly frame size
+  * switching, but the sizes available depend on the particular frame size in
+  * use. For some initial frame sizes on a single on the fly size is available.
+  */
+
+/** Contains the state of an encoder. One encoder state is needed
+    for each stream. It is initialized once at the beginning of the
+    stream. Do *not* re-initialize the state for every frame.
+   @brief Encoder state
+ */
+typedef struct OpusCustomEncoder OpusCustomEncoder;
+
+/** State of the decoder. One decoder state is needed for each stream.
+    It is initialized once at the beginning of the stream. Do *not*
+    re-initialize the state for every frame.
+   @brief Decoder state
+ */
+typedef struct OpusCustomDecoder OpusCustomDecoder;
+
+/** The mode contains all the information necessary to create an
+    encoder. Both the encoder and decoder need to be initialized
+    with exactly the same mode, otherwise the output will be
+    corrupted. The mode MUST NOT BE DESTROYED until the encoders and
+    decoders that use it are destroyed as well.
+   @brief Mode configuration
+ */
+typedef struct OpusCustomMode OpusCustomMode;
+
+/** Creates a new mode struct. This will be passed to an encoder or
+  * decoder. The mode MUST NOT BE DESTROYED until the encoders and
+  * decoders that use it are destroyed as well.
+  * @param [in] Fs <tt>int</tt>: Sampling rate (8000 to 96000 Hz)
+  * @param [in] frame_size <tt>int</tt>: Number of samples (per channel) to encode in each
+  *        packet (64 - 1024, prime factorization must contain zero or more 2s, 3s, or 5s and no other primes)
+  * @param [out] error <tt>int*</tt>: Returned error code (if NULL, no error will be returned)
+  * @return A newly created mode
+  */
+OPUS_CUSTOM_EXPORT OPUS_WARN_UNUSED_RESULT OpusCustomMode *opus_custom_mode_create(opus_int32 Fs, int frame_size, int *error);
+
+/** Destroys a mode struct. Only call this after all encoders and
+  * decoders using this mode are destroyed as well.
+  * @param [in] mode <tt>OpusCustomMode*</tt>: Mode to be freed.
+  */
+OPUS_CUSTOM_EXPORT void opus_custom_mode_destroy(OpusCustomMode *mode);
+
+
+#if !defined(OPUS_BUILD) || defined(CELT_ENCODER_C)
+
+/* Encoder */
+/** Gets the size of an OpusCustomEncoder structure.
+  * @param [in] mode <tt>OpusCustomMode *</tt>: Mode configuration
+  * @param [in] channels <tt>int</tt>: Number of channels
+  * @returns size
+  */
+OPUS_CUSTOM_EXPORT_STATIC OPUS_WARN_UNUSED_RESULT int opus_custom_encoder_get_size(
+    const OpusCustomMode *mode,
+    int channels
+) OPUS_ARG_NONNULL(1);
+
+# ifdef CUSTOM_MODES
+/** Initializes a previously allocated encoder state
+  * The memory pointed to by st must be the size returned by opus_custom_encoder_get_size.
+  * This is intended for applications which use their own allocator instead of malloc.
+  * @see opus_custom_encoder_create(),opus_custom_encoder_get_size()
+  * To reset a previously initialized state use the OPUS_RESET_STATE CTL.
+  * @param [in] st <tt>OpusCustomEncoder*</tt>: Encoder state
+  * @param [in] mode <tt>OpusCustomMode *</tt>: Contains all the information about the characteristics of
+  *  the stream (must be the same characteristics as used for the
+  *  decoder)
+  * @param [in] channels <tt>int</tt>: Number of channels
+  * @return OPUS_OK Success or @ref opus_errorcodes
+  */
+OPUS_CUSTOM_EXPORT int opus_custom_encoder_init(
+    OpusCustomEncoder *st,
+    const OpusCustomMode *mode,
+    int channels
+) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2);
+# endif
+#endif
+
+
+/** Creates a new encoder state. Each stream needs its own encoder
+  * state (can't be shared across simultaneous streams).
+  * @param [in] mode <tt>OpusCustomMode*</tt>: Contains all the information about the characteristics of
+  *  the stream (must be the same characteristics as used for the
+  *  decoder)
+  * @param [in] channels <tt>int</tt>: Number of channels
+  * @param [out] error <tt>int*</tt>: Returns an error code
+  * @return Newly created encoder state.
+*/
+OPUS_CUSTOM_EXPORT OPUS_WARN_UNUSED_RESULT OpusCustomEncoder *opus_custom_encoder_create(
+    const OpusCustomMode *mode,
+    int channels,
+    int *error
+) OPUS_ARG_NONNULL(1);
+
+
+/** Destroys an encoder state.
+  * @param[in] st <tt>OpusCustomEncoder*</tt>: State to be freed.
+  */
+OPUS_CUSTOM_EXPORT void opus_custom_encoder_destroy(OpusCustomEncoder *st);
+
+/** Encodes a frame of audio.
+  * @param [in] st <tt>OpusCustomEncoder*</tt>: Encoder state
+  * @param [in] pcm <tt>float*</tt>: PCM audio in float format, with a normal range of +/-1.0.
+  *          Samples with a range beyond +/-1.0 are supported but will
+  *          be clipped by decoders using the integer API and should
+  *          only be used if it is known that the far end supports
+  *          extended dynamic range. There must be exactly
+  *          frame_size samples per channel.
+  * @param [in] frame_size <tt>int</tt>: Number of samples per frame of input signal
+  * @param [out] compressed <tt>char *</tt>: The compressed data is written here. This may not alias pcm and must be at least maxCompressedBytes long.
+  * @param [in] maxCompressedBytes <tt>int</tt>: Maximum number of bytes to use for compressing the frame
+  *          (can change from one frame to another)
+  * @return Number of bytes written to "compressed".
+  *       If negative, an error has occurred (see error codes). It is IMPORTANT that
+  *       the length returned be somehow transmitted to the decoder. Otherwise, no
+  *       decoding is possible.
+  */
+OPUS_CUSTOM_EXPORT OPUS_WARN_UNUSED_RESULT int opus_custom_encode_float(
+    OpusCustomEncoder *st,
+    const float *pcm,
+    int frame_size,
+    unsigned char *compressed,
+    int maxCompressedBytes
+) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2) OPUS_ARG_NONNULL(4);
+
+/** Encodes a frame of audio.
+  * @param [in] st <tt>OpusCustomEncoder*</tt>: Encoder state
+  * @param [in] pcm <tt>opus_int16*</tt>: PCM audio in signed 16-bit format (native endian).
+  *          There must be exactly frame_size samples per channel.
+  * @param [in] frame_size <tt>int</tt>: Number of samples per frame of input signal
+  * @param [out] compressed <tt>char *</tt>: The compressed data is written here. This may not alias pcm and must be at least maxCompressedBytes long.
+  * @param [in] maxCompressedBytes <tt>int</tt>: Maximum number of bytes to use for compressing the frame
+  *          (can change from one frame to another)
+  * @return Number of bytes written to "compressed".
+  *       If negative, an error has occurred (see error codes). It is IMPORTANT that
+  *       the length returned be somehow transmitted to the decoder. Otherwise, no
+  *       decoding is possible.
+ */
+OPUS_CUSTOM_EXPORT OPUS_WARN_UNUSED_RESULT int opus_custom_encode(
+    OpusCustomEncoder *st,
+    const opus_int16 *pcm,
+    int frame_size,
+    unsigned char *compressed,
+    int maxCompressedBytes
+) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2) OPUS_ARG_NONNULL(4);
+
+/** Perform a CTL function on an Opus custom encoder.
+  *
+  * Generally the request and subsequent arguments are generated
+  * by a convenience macro.
+  * @see opus_encoderctls
+  */
+OPUS_CUSTOM_EXPORT int opus_custom_encoder_ctl(OpusCustomEncoder * OPUS_RESTRICT st, int request, ...) OPUS_ARG_NONNULL(1);
+
+
+#if !defined(OPUS_BUILD) || defined(CELT_DECODER_C)
+/* Decoder */
+
+/** Gets the size of an OpusCustomDecoder structure.
+  * @param [in] mode <tt>OpusCustomMode *</tt>: Mode configuration
+  * @param [in] channels <tt>int</tt>: Number of channels
+  * @returns size
+  */
+OPUS_CUSTOM_EXPORT_STATIC OPUS_WARN_UNUSED_RESULT int opus_custom_decoder_get_size(
+    const OpusCustomMode *mode,
+    int channels
+) OPUS_ARG_NONNULL(1);
+
+/** Initializes a previously allocated decoder state
+  * The memory pointed to by st must be the size returned by opus_custom_decoder_get_size.
+  * This is intended for applications which use their own allocator instead of malloc.
+  * @see opus_custom_decoder_create(),opus_custom_decoder_get_size()
+  * To reset a previously initialized state use the OPUS_RESET_STATE CTL.
+  * @param [in] st <tt>OpusCustomDecoder*</tt>: Decoder state
+  * @param [in] mode <tt>OpusCustomMode *</tt>: Contains all the information about the characteristics of
+  *  the stream (must be the same characteristics as used for the
+  *  encoder)
+  * @param [in] channels <tt>int</tt>: Number of channels
+  * @return OPUS_OK Success or @ref opus_errorcodes
+  */
+OPUS_CUSTOM_EXPORT_STATIC int opus_custom_decoder_init(
+    OpusCustomDecoder *st,
+    const OpusCustomMode *mode,
+    int channels
+) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2);
+
+#endif
+
+
+/** Creates a new decoder state. Each stream needs its own decoder state (can't
+  * be shared across simultaneous streams).
+  * @param [in] mode <tt>OpusCustomMode</tt>: Contains all the information about the characteristics of the
+  *          stream (must be the same characteristics as used for the encoder)
+  * @param [in] channels <tt>int</tt>: Number of channels
+  * @param [out] error <tt>int*</tt>: Returns an error code
+  * @return Newly created decoder state.
+  */
+OPUS_CUSTOM_EXPORT OPUS_WARN_UNUSED_RESULT OpusCustomDecoder *opus_custom_decoder_create(
+    const OpusCustomMode *mode,
+    int channels,
+    int *error
+) OPUS_ARG_NONNULL(1);
+
+/** Destroys a decoder state.
+  * @param[in] st <tt>OpusCustomDecoder*</tt>: State to be freed.
+  */
+OPUS_CUSTOM_EXPORT void opus_custom_decoder_destroy(OpusCustomDecoder *st);
+
+/** Decode an opus custom frame with floating point output
+  * @param [in] st <tt>OpusCustomDecoder*</tt>: Decoder state
+  * @param [in] data <tt>char*</tt>: Input payload. Use a NULL pointer to indicate packet loss
+  * @param [in] len <tt>int</tt>: Number of bytes in payload
+  * @param [out] pcm <tt>float*</tt>: Output signal (interleaved if 2 channels). length
+  *  is frame_size*channels*sizeof(float)
+  * @param [in] frame_size Number of samples per channel of available space in *pcm.
+  * @returns Number of decoded samples or @ref opus_errorcodes
+  */
+OPUS_CUSTOM_EXPORT OPUS_WARN_UNUSED_RESULT int opus_custom_decode_float(
+    OpusCustomDecoder *st,
+    const unsigned char *data,
+    int len,
+    float *pcm,
+    int frame_size
+) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(4);
+
+/** Decode an opus custom frame
+  * @param [in] st <tt>OpusCustomDecoder*</tt>: Decoder state
+  * @param [in] data <tt>char*</tt>: Input payload. Use a NULL pointer to indicate packet loss
+  * @param [in] len <tt>int</tt>: Number of bytes in payload
+  * @param [out] pcm <tt>opus_int16*</tt>: Output signal (interleaved if 2 channels). length
+  *  is frame_size*channels*sizeof(opus_int16)
+  * @param [in] frame_size Number of samples per channel of available space in *pcm.
+  * @returns Number of decoded samples or @ref opus_errorcodes
+  */
+OPUS_CUSTOM_EXPORT OPUS_WARN_UNUSED_RESULT int opus_custom_decode(
+    OpusCustomDecoder *st,
+    const unsigned char *data,
+    int len,
+    opus_int16 *pcm,
+    int frame_size
+) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(4);
+
+/** Perform a CTL function on an Opus custom decoder.
+  *
+  * Generally the request and subsequent arguments are generated
+  * by a convenience macro.
+  * @see opus_genericctls
+  */
+OPUS_CUSTOM_EXPORT int opus_custom_decoder_ctl(OpusCustomDecoder * OPUS_RESTRICT st, int request, ...) OPUS_ARG_NONNULL(1);
+
+/**@}*/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* OPUS_CUSTOM_H */
diff --git a/2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/source/opus/opus_defines.h b/2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/source/opus/opus_defines.h
new file mode 100644 (file)
index 0000000..94b9e0d
--- /dev/null
@@ -0,0 +1,801 @@
+/* Copyright (c) 2010-2011 Xiph.Org Foundation, Skype Limited
+   Written by Jean-Marc Valin and Koen Vos */
+/*
+   Redistribution and use in source and binary forms, with or without
+   modification, are permitted provided that the following conditions
+   are met:
+
+   - Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+
+   - Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+
+   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+   ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
+   OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+   PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+   LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+/**
+ * @file opus_defines.h
+ * @brief Opus reference implementation constants
+ */
+
+#ifndef OPUS_DEFINES_H
+#define OPUS_DEFINES_H
+
+#include "opus_types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** @defgroup opus_errorcodes Error codes
+ * @{
+ */
+/** No error @hideinitializer*/
+#define OPUS_OK                0
+/** One or more invalid/out of range arguments @hideinitializer*/
+#define OPUS_BAD_ARG          -1
+/** Not enough bytes allocated in the buffer @hideinitializer*/
+#define OPUS_BUFFER_TOO_SMALL -2
+/** An internal error was detected @hideinitializer*/
+#define OPUS_INTERNAL_ERROR   -3
+/** The compressed data passed is corrupted @hideinitializer*/
+#define OPUS_INVALID_PACKET   -4
+/** Invalid/unsupported request number @hideinitializer*/
+#define OPUS_UNIMPLEMENTED    -5
+/** An encoder or decoder structure is invalid or already freed @hideinitializer*/
+#define OPUS_INVALID_STATE    -6
+/** Memory allocation has failed @hideinitializer*/
+#define OPUS_ALLOC_FAIL       -7
+/**@}*/
+
+/** @cond OPUS_INTERNAL_DOC */
+/**Export control for opus functions */
+
+#ifndef OPUS_EXPORT
+# if defined(_WIN32)
+#  if defined(OPUS_BUILD) && defined(DLL_EXPORT)
+#   define OPUS_EXPORT __declspec(dllexport)
+#  else
+#   define OPUS_EXPORT
+#  endif
+# elif defined(__GNUC__) && defined(OPUS_BUILD)
+#  define OPUS_EXPORT __attribute__ ((visibility ("default")))
+# else
+#  define OPUS_EXPORT
+# endif
+#endif
+
+# if !defined(OPUS_GNUC_PREREQ)
+#  if defined(__GNUC__)&&defined(__GNUC_MINOR__)
+#   define OPUS_GNUC_PREREQ(_maj,_min) \
+ ((__GNUC__<<16)+__GNUC_MINOR__>=((_maj)<<16)+(_min))
+#  else
+#   define OPUS_GNUC_PREREQ(_maj,_min) 0
+#  endif
+# endif
+
+#if (!defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L) )
+# if OPUS_GNUC_PREREQ(3,0)
+#  define OPUS_RESTRICT __restrict__
+# elif (defined(_MSC_VER) && _MSC_VER >= 1400)
+#  define OPUS_RESTRICT __restrict
+# else
+#  define OPUS_RESTRICT
+# endif
+#else
+# define OPUS_RESTRICT restrict
+#endif
+
+#if (!defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L) )
+# if OPUS_GNUC_PREREQ(2,7)
+#  define OPUS_INLINE __inline__
+# elif (defined(_MSC_VER))
+#  define OPUS_INLINE __inline
+# else
+#  define OPUS_INLINE
+# endif
+#else
+# define OPUS_INLINE inline
+#endif
+
+/**Warning attributes for opus functions
+  * NONNULL is not used in OPUS_BUILD to avoid the compiler optimizing out
+  * some paranoid null checks. */
+#if defined(__GNUC__) && OPUS_GNUC_PREREQ(3, 4)
+# define OPUS_WARN_UNUSED_RESULT __attribute__ ((__warn_unused_result__))
+#else
+# define OPUS_WARN_UNUSED_RESULT
+#endif
+#if !defined(OPUS_BUILD) && defined(__GNUC__) && OPUS_GNUC_PREREQ(3, 4)
+# define OPUS_ARG_NONNULL(_x)  __attribute__ ((__nonnull__(_x)))
+#else
+# define OPUS_ARG_NONNULL(_x)
+#endif
+
+/** These are the actual Encoder CTL ID numbers.
+  * They should not be used directly by applications.
+  * In general, SETs should be even and GETs should be odd.*/
+#define OPUS_SET_APPLICATION_REQUEST         4000
+#define OPUS_GET_APPLICATION_REQUEST         4001
+#define OPUS_SET_BITRATE_REQUEST             4002
+#define OPUS_GET_BITRATE_REQUEST             4003
+#define OPUS_SET_MAX_BANDWIDTH_REQUEST       4004
+#define OPUS_GET_MAX_BANDWIDTH_REQUEST       4005
+#define OPUS_SET_VBR_REQUEST                 4006
+#define OPUS_GET_VBR_REQUEST                 4007
+#define OPUS_SET_BANDWIDTH_REQUEST           4008
+#define OPUS_GET_BANDWIDTH_REQUEST           4009
+#define OPUS_SET_COMPLEXITY_REQUEST          4010
+#define OPUS_GET_COMPLEXITY_REQUEST          4011
+#define OPUS_SET_INBAND_FEC_REQUEST          4012
+#define OPUS_GET_INBAND_FEC_REQUEST          4013
+#define OPUS_SET_PACKET_LOSS_PERC_REQUEST    4014
+#define OPUS_GET_PACKET_LOSS_PERC_REQUEST    4015
+#define OPUS_SET_DTX_REQUEST                 4016
+#define OPUS_GET_DTX_REQUEST                 4017
+#define OPUS_SET_VBR_CONSTRAINT_REQUEST      4020
+#define OPUS_GET_VBR_CONSTRAINT_REQUEST      4021
+#define OPUS_SET_FORCE_CHANNELS_REQUEST      4022
+#define OPUS_GET_FORCE_CHANNELS_REQUEST      4023
+#define OPUS_SET_SIGNAL_REQUEST              4024
+#define OPUS_GET_SIGNAL_REQUEST              4025
+#define OPUS_GET_LOOKAHEAD_REQUEST           4027
+/* #define OPUS_RESET_STATE 4028 */
+#define OPUS_GET_SAMPLE_RATE_REQUEST         4029
+#define OPUS_GET_FINAL_RANGE_REQUEST         4031
+#define OPUS_GET_PITCH_REQUEST               4033
+#define OPUS_SET_GAIN_REQUEST                4034
+#define OPUS_GET_GAIN_REQUEST                4045 /* Should have been 4035 */
+#define OPUS_SET_LSB_DEPTH_REQUEST           4036
+#define OPUS_GET_LSB_DEPTH_REQUEST           4037
+#define OPUS_GET_LAST_PACKET_DURATION_REQUEST 4039
+#define OPUS_SET_EXPERT_FRAME_DURATION_REQUEST 4040
+#define OPUS_GET_EXPERT_FRAME_DURATION_REQUEST 4041
+#define OPUS_SET_PREDICTION_DISABLED_REQUEST 4042
+#define OPUS_GET_PREDICTION_DISABLED_REQUEST 4043
+/* Don't use 4045, it's already taken by OPUS_GET_GAIN_REQUEST */
+#define OPUS_SET_PHASE_INVERSION_DISABLED_REQUEST 4046
+#define OPUS_GET_PHASE_INVERSION_DISABLED_REQUEST 4047
+#define OPUS_GET_IN_DTX_REQUEST              4049
+
+/** Defines for the presence of extended APIs. */
+#define OPUS_HAVE_OPUS_PROJECTION_H
+
+/* Macros to trigger compilation errors when the wrong types are provided to a CTL */
+#define __opus_check_int(x) (((void)((x) == (opus_int32)0)), (opus_int32)(x))
+#define __opus_check_int_ptr(ptr) ((ptr) + ((ptr) - (opus_int32*)(ptr)))
+#define __opus_check_uint_ptr(ptr) ((ptr) + ((ptr) - (opus_uint32*)(ptr)))
+#define __opus_check_val16_ptr(ptr) ((ptr) + ((ptr) - (opus_val16*)(ptr)))
+/** @endcond */
+
+/** @defgroup opus_ctlvalues Pre-defined values for CTL interface
+  * @see opus_genericctls, opus_encoderctls
+  * @{
+  */
+/* Values for the various encoder CTLs */
+#define OPUS_AUTO                           -1000 /**<Auto/default setting @hideinitializer*/
+#define OPUS_BITRATE_MAX                       -1 /**<Maximum bitrate @hideinitializer*/
+
+/** Best for most VoIP/videoconference applications where listening quality and intelligibility matter most
+ * @hideinitializer */
+#define OPUS_APPLICATION_VOIP                2048
+/** Best for broadcast/high-fidelity application where the decoded audio should be as close as possible to the input
+ * @hideinitializer */
+#define OPUS_APPLICATION_AUDIO               2049
+/** Only use when lowest-achievable latency is what matters most. Voice-optimized modes cannot be used.
+ * @hideinitializer */
+#define OPUS_APPLICATION_RESTRICTED_LOWDELAY 2051
+
+#define OPUS_SIGNAL_VOICE                    3001 /**< Signal being encoded is voice */
+#define OPUS_SIGNAL_MUSIC                    3002 /**< Signal being encoded is music */
+#define OPUS_BANDWIDTH_NARROWBAND            1101 /**< 4 kHz bandpass @hideinitializer*/
+#define OPUS_BANDWIDTH_MEDIUMBAND            1102 /**< 6 kHz bandpass @hideinitializer*/
+#define OPUS_BANDWIDTH_WIDEBAND              1103 /**< 8 kHz bandpass @hideinitializer*/
+#define OPUS_BANDWIDTH_SUPERWIDEBAND         1104 /**<12 kHz bandpass @hideinitializer*/
+#define OPUS_BANDWIDTH_FULLBAND              1105 /**<20 kHz bandpass @hideinitializer*/
+
+#define OPUS_FRAMESIZE_ARG                   5000 /**< Select frame size from the argument (default) */
+#define OPUS_FRAMESIZE_2_5_MS                5001 /**< Use 2.5 ms frames */
+#define OPUS_FRAMESIZE_5_MS                  5002 /**< Use 5 ms frames */
+#define OPUS_FRAMESIZE_10_MS                 5003 /**< Use 10 ms frames */
+#define OPUS_FRAMESIZE_20_MS                 5004 /**< Use 20 ms frames */
+#define OPUS_FRAMESIZE_40_MS                 5005 /**< Use 40 ms frames */
+#define OPUS_FRAMESIZE_60_MS                 5006 /**< Use 60 ms frames */
+#define OPUS_FRAMESIZE_80_MS                 5007 /**< Use 80 ms frames */
+#define OPUS_FRAMESIZE_100_MS                5008 /**< Use 100 ms frames */
+#define OPUS_FRAMESIZE_120_MS                5009 /**< Use 120 ms frames */
+
+/**@}*/
+
+
+/** @defgroup opus_encoderctls Encoder related CTLs
+  *
+  * These are convenience macros for use with the \c opus_encode_ctl
+  * interface. They are used to generate the appropriate series of
+  * arguments for that call, passing the correct type, size and so
+  * on as expected for each particular request.
+  *
+  * Some usage examples:
+  *
+  * @code
+  * int ret;
+  * ret = opus_encoder_ctl(enc_ctx, OPUS_SET_BANDWIDTH(OPUS_AUTO));
+  * if (ret != OPUS_OK) return ret;
+  *
+  * opus_int32 rate;
+  * opus_encoder_ctl(enc_ctx, OPUS_GET_BANDWIDTH(&rate));
+  *
+  * opus_encoder_ctl(enc_ctx, OPUS_RESET_STATE);
+  * @endcode
+  *
+  * @see opus_genericctls, opus_encoder
+  * @{
+  */
+
+/** Configures the encoder's computational complexity.
+  * The supported range is 0-10 inclusive with 10 representing the highest complexity.
+  * @see OPUS_GET_COMPLEXITY
+  * @param[in] x <tt>opus_int32</tt>: Allowed values: 0-10, inclusive.
+  *
+  * @hideinitializer */
+#define OPUS_SET_COMPLEXITY(x) OPUS_SET_COMPLEXITY_REQUEST, __opus_check_int(x)
+/** Gets the encoder's complexity configuration.
+  * @see OPUS_SET_COMPLEXITY
+  * @param[out] x <tt>opus_int32 *</tt>: Returns a value in the range 0-10,
+  *                                      inclusive.
+  * @hideinitializer */
+#define OPUS_GET_COMPLEXITY(x) OPUS_GET_COMPLEXITY_REQUEST, __opus_check_int_ptr(x)
+
+/** Configures the bitrate in the encoder.
+  * Rates from 500 to 512000 bits per second are meaningful, as well as the
+  * special values #OPUS_AUTO and #OPUS_BITRATE_MAX.
+  * The value #OPUS_BITRATE_MAX can be used to cause the codec to use as much
+  * rate as it can, which is useful for controlling the rate by adjusting the
+  * output buffer size.
+  * @see OPUS_GET_BITRATE
+  * @param[in] x <tt>opus_int32</tt>: Bitrate in bits per second. The default
+  *                                   is determined based on the number of
+  *                                   channels and the input sampling rate.
+  * @hideinitializer */
+#define OPUS_SET_BITRATE(x) OPUS_SET_BITRATE_REQUEST, __opus_check_int(x)
+/** Gets the encoder's bitrate configuration.
+  * @see OPUS_SET_BITRATE
+  * @param[out] x <tt>opus_int32 *</tt>: Returns the bitrate in bits per second.
+  *                                      The default is determined based on the
+  *                                      number of channels and the input
+  *                                      sampling rate.
+  * @hideinitializer */
+#define OPUS_GET_BITRATE(x) OPUS_GET_BITRATE_REQUEST, __opus_check_int_ptr(x)
+
+/** Enables or disables variable bitrate (VBR) in the encoder.
+  * The configured bitrate may not be met exactly because frames must
+  * be an integer number of bytes in length.
+  * @see OPUS_GET_VBR
+  * @see OPUS_SET_VBR_CONSTRAINT
+  * @param[in] x <tt>opus_int32</tt>: Allowed values:
+  * <dl>
+  * <dt>0</dt><dd>Hard CBR. For LPC/hybrid modes at very low bit-rate, this can
+  *               cause noticeable quality degradation.</dd>
+  * <dt>1</dt><dd>VBR (default). The exact type of VBR is controlled by
+  *               #OPUS_SET_VBR_CONSTRAINT.</dd>
+  * </dl>
+  * @hideinitializer */
+#define OPUS_SET_VBR(x) OPUS_SET_VBR_REQUEST, __opus_check_int(x)
+/** Determine if variable bitrate (VBR) is enabled in the encoder.
+  * @see OPUS_SET_VBR
+  * @see OPUS_GET_VBR_CONSTRAINT
+  * @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values:
+  * <dl>
+  * <dt>0</dt><dd>Hard CBR.</dd>
+  * <dt>1</dt><dd>VBR (default). The exact type of VBR may be retrieved via
+  *               #OPUS_GET_VBR_CONSTRAINT.</dd>
+  * </dl>
+  * @hideinitializer */
+#define OPUS_GET_VBR(x) OPUS_GET_VBR_REQUEST, __opus_check_int_ptr(x)
+
+/** Enables or disables constrained VBR in the encoder.
+  * This setting is ignored when the encoder is in CBR mode.
+  * @warning Only the MDCT mode of Opus currently heeds the constraint.
+  *  Speech mode ignores it completely, hybrid mode may fail to obey it
+  *  if the LPC layer uses more bitrate than the constraint would have
+  *  permitted.
+  * @see OPUS_GET_VBR_CONSTRAINT
+  * @see OPUS_SET_VBR
+  * @param[in] x <tt>opus_int32</tt>: Allowed values:
+  * <dl>
+  * <dt>0</dt><dd>Unconstrained VBR.</dd>
+  * <dt>1</dt><dd>Constrained VBR (default). This creates a maximum of one
+  *               frame of buffering delay assuming a transport with a
+  *               serialization speed of the nominal bitrate.</dd>
+  * </dl>
+  * @hideinitializer */
+#define OPUS_SET_VBR_CONSTRAINT(x) OPUS_SET_VBR_CONSTRAINT_REQUEST, __opus_check_int(x)
+/** Determine if constrained VBR is enabled in the encoder.
+  * @see OPUS_SET_VBR_CONSTRAINT
+  * @see OPUS_GET_VBR
+  * @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values:
+  * <dl>
+  * <dt>0</dt><dd>Unconstrained VBR.</dd>
+  * <dt>1</dt><dd>Constrained VBR (default).</dd>
+  * </dl>
+  * @hideinitializer */
+#define OPUS_GET_VBR_CONSTRAINT(x) OPUS_GET_VBR_CONSTRAINT_REQUEST, __opus_check_int_ptr(x)
+
+/** Configures mono/stereo forcing in the encoder.
+  * This can force the encoder to produce packets encoded as either mono or
+  * stereo, regardless of the format of the input audio. This is useful when
+  * the caller knows that the input signal is currently a mono source embedded
+  * in a stereo stream.
+  * @see OPUS_GET_FORCE_CHANNELS
+  * @param[in] x <tt>opus_int32</tt>: Allowed values:
+  * <dl>
+  * <dt>#OPUS_AUTO</dt><dd>Not forced (default)</dd>
+  * <dt>1</dt>         <dd>Forced mono</dd>
+  * <dt>2</dt>         <dd>Forced stereo</dd>
+  * </dl>
+  * @hideinitializer */
+#define OPUS_SET_FORCE_CHANNELS(x) OPUS_SET_FORCE_CHANNELS_REQUEST, __opus_check_int(x)
+/** Gets the encoder's forced channel configuration.
+  * @see OPUS_SET_FORCE_CHANNELS
+  * @param[out] x <tt>opus_int32 *</tt>:
+  * <dl>
+  * <dt>#OPUS_AUTO</dt><dd>Not forced (default)</dd>
+  * <dt>1</dt>         <dd>Forced mono</dd>
+  * <dt>2</dt>         <dd>Forced stereo</dd>
+  * </dl>
+  * @hideinitializer */
+#define OPUS_GET_FORCE_CHANNELS(x) OPUS_GET_FORCE_CHANNELS_REQUEST, __opus_check_int_ptr(x)
+
+/** Configures the maximum bandpass that the encoder will select automatically.
+  * Applications should normally use this instead of #OPUS_SET_BANDWIDTH
+  * (leaving that set to the default, #OPUS_AUTO). This allows the
+  * application to set an upper bound based on the type of input it is
+  * providing, but still gives the encoder the freedom to reduce the bandpass
+  * when the bitrate becomes too low, for better overall quality.
+  * @see OPUS_GET_MAX_BANDWIDTH
+  * @param[in] x <tt>opus_int32</tt>: Allowed values:
+  * <dl>
+  * <dt>OPUS_BANDWIDTH_NARROWBAND</dt>    <dd>4 kHz passband</dd>
+  * <dt>OPUS_BANDWIDTH_MEDIUMBAND</dt>    <dd>6 kHz passband</dd>
+  * <dt>OPUS_BANDWIDTH_WIDEBAND</dt>      <dd>8 kHz passband</dd>
+  * <dt>OPUS_BANDWIDTH_SUPERWIDEBAND</dt><dd>12 kHz passband</dd>
+  * <dt>OPUS_BANDWIDTH_FULLBAND</dt>     <dd>20 kHz passband (default)</dd>
+  * </dl>
+  * @hideinitializer */
+#define OPUS_SET_MAX_BANDWIDTH(x) OPUS_SET_MAX_BANDWIDTH_REQUEST, __opus_check_int(x)
+
+/** Gets the encoder's configured maximum allowed bandpass.
+  * @see OPUS_SET_MAX_BANDWIDTH
+  * @param[out] x <tt>opus_int32 *</tt>: Allowed values:
+  * <dl>
+  * <dt>#OPUS_BANDWIDTH_NARROWBAND</dt>    <dd>4 kHz passband</dd>
+  * <dt>#OPUS_BANDWIDTH_MEDIUMBAND</dt>    <dd>6 kHz passband</dd>
+  * <dt>#OPUS_BANDWIDTH_WIDEBAND</dt>      <dd>8 kHz passband</dd>
+  * <dt>#OPUS_BANDWIDTH_SUPERWIDEBAND</dt><dd>12 kHz passband</dd>
+  * <dt>#OPUS_BANDWIDTH_FULLBAND</dt>     <dd>20 kHz passband (default)</dd>
+  * </dl>
+  * @hideinitializer */
+#define OPUS_GET_MAX_BANDWIDTH(x) OPUS_GET_MAX_BANDWIDTH_REQUEST, __opus_check_int_ptr(x)
+
+/** Sets the encoder's bandpass to a specific value.
+  * This prevents the encoder from automatically selecting the bandpass based
+  * on the available bitrate. If an application knows the bandpass of the input
+  * audio it is providing, it should normally use #OPUS_SET_MAX_BANDWIDTH
+  * instead, which still gives the encoder the freedom to reduce the bandpass
+  * when the bitrate becomes too low, for better overall quality.
+  * @see OPUS_GET_BANDWIDTH
+  * @param[in] x <tt>opus_int32</tt>: Allowed values:
+  * <dl>
+  * <dt>#OPUS_AUTO</dt>                    <dd>(default)</dd>
+  * <dt>#OPUS_BANDWIDTH_NARROWBAND</dt>    <dd>4 kHz passband</dd>
+  * <dt>#OPUS_BANDWIDTH_MEDIUMBAND</dt>    <dd>6 kHz passband</dd>
+  * <dt>#OPUS_BANDWIDTH_WIDEBAND</dt>      <dd>8 kHz passband</dd>
+  * <dt>#OPUS_BANDWIDTH_SUPERWIDEBAND</dt><dd>12 kHz passband</dd>
+  * <dt>#OPUS_BANDWIDTH_FULLBAND</dt>     <dd>20 kHz passband</dd>
+  * </dl>
+  * @hideinitializer */
+#define OPUS_SET_BANDWIDTH(x) OPUS_SET_BANDWIDTH_REQUEST, __opus_check_int(x)
+
+/** Configures the type of signal being encoded.
+  * This is a hint which helps the encoder's mode selection.
+  * @see OPUS_GET_SIGNAL
+  * @param[in] x <tt>opus_int32</tt>: Allowed values:
+  * <dl>
+  * <dt>#OPUS_AUTO</dt>        <dd>(default)</dd>
+  * <dt>#OPUS_SIGNAL_VOICE</dt><dd>Bias thresholds towards choosing LPC or Hybrid modes.</dd>
+  * <dt>#OPUS_SIGNAL_MUSIC</dt><dd>Bias thresholds towards choosing MDCT modes.</dd>
+  * </dl>
+  * @hideinitializer */
+#define OPUS_SET_SIGNAL(x) OPUS_SET_SIGNAL_REQUEST, __opus_check_int(x)
+/** Gets the encoder's configured signal type.
+  * @see OPUS_SET_SIGNAL
+  * @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values:
+  * <dl>
+  * <dt>#OPUS_AUTO</dt>        <dd>(default)</dd>
+  * <dt>#OPUS_SIGNAL_VOICE</dt><dd>Bias thresholds towards choosing LPC or Hybrid modes.</dd>
+  * <dt>#OPUS_SIGNAL_MUSIC</dt><dd>Bias thresholds towards choosing MDCT modes.</dd>
+  * </dl>
+  * @hideinitializer */
+#define OPUS_GET_SIGNAL(x) OPUS_GET_SIGNAL_REQUEST, __opus_check_int_ptr(x)
+
+
+/** Configures the encoder's intended application.
+  * The initial value is a mandatory argument to the encoder_create function.
+  * @see OPUS_GET_APPLICATION
+  * @param[in] x <tt>opus_int32</tt>: Returns one of the following values:
+  * <dl>
+  * <dt>#OPUS_APPLICATION_VOIP</dt>
+  * <dd>Process signal for improved speech intelligibility.</dd>
+  * <dt>#OPUS_APPLICATION_AUDIO</dt>
+  * <dd>Favor faithfulness to the original input.</dd>
+  * <dt>#OPUS_APPLICATION_RESTRICTED_LOWDELAY</dt>
+  * <dd>Configure the minimum possible coding delay by disabling certain modes
+  * of operation.</dd>
+  * </dl>
+  * @hideinitializer */
+#define OPUS_SET_APPLICATION(x) OPUS_SET_APPLICATION_REQUEST, __opus_check_int(x)
+/** Gets the encoder's configured application.
+  * @see OPUS_SET_APPLICATION
+  * @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values:
+  * <dl>
+  * <dt>#OPUS_APPLICATION_VOIP</dt>
+  * <dd>Process signal for improved speech intelligibility.</dd>
+  * <dt>#OPUS_APPLICATION_AUDIO</dt>
+  * <dd>Favor faithfulness to the original input.</dd>
+  * <dt>#OPUS_APPLICATION_RESTRICTED_LOWDELAY</dt>
+  * <dd>Configure the minimum possible coding delay by disabling certain modes
+  * of operation.</dd>
+  * </dl>
+  * @hideinitializer */
+#define OPUS_GET_APPLICATION(x) OPUS_GET_APPLICATION_REQUEST, __opus_check_int_ptr(x)
+
+/** Gets the total samples of delay added by the entire codec.
+  * This can be queried by the encoder and then the provided number of samples can be
+  * skipped on from the start of the decoder's output to provide time aligned input
+  * and output. From the perspective of a decoding application the real data begins this many
+  * samples late.
+  *
+  * The decoder contribution to this delay is identical for all decoders, but the
+  * encoder portion of the delay may vary from implementation to implementation,
+  * version to version, or even depend on the encoder's initial configuration.
+  * Applications needing delay compensation should call this CTL rather than
+  * hard-coding a value.
+  * @param[out] x <tt>opus_int32 *</tt>:   Number of lookahead samples
+  * @hideinitializer */
+#define OPUS_GET_LOOKAHEAD(x) OPUS_GET_LOOKAHEAD_REQUEST, __opus_check_int_ptr(x)
+
+/** Configures the encoder's use of inband forward error correction (FEC).
+  * @note This is only applicable to the LPC layer
+  * @see OPUS_GET_INBAND_FEC
+  * @param[in] x <tt>opus_int32</tt>: Allowed values:
+  * <dl>
+  * <dt>0</dt><dd>Disable inband FEC (default).</dd>
+  * <dt>1</dt><dd>Inband FEC enabled. If the packet loss rate is sufficiently high, Opus will automatically switch to SILK even at high rates to enable use of that FEC.</dd>
+  * <dt>2</dt><dd>Inband FEC enabled, but does not necessarily switch to SILK if we have music.</dd>
+  * </dl>
+  * @hideinitializer */
+#define OPUS_SET_INBAND_FEC(x) OPUS_SET_INBAND_FEC_REQUEST, __opus_check_int(x)
+/** Gets encoder's configured use of inband forward error correction.
+  * @see OPUS_SET_INBAND_FEC
+  * @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values:
+  * <dl>
+  * <dt>0</dt><dd>Inband FEC disabled (default).</dd>
+  * <dt>1</dt><dd>Inband FEC enabled. If the packet loss rate is sufficiently high, Opus will automatically switch to SILK even at high rates to enable use of that FEC.</dd>
+  * <dt>2</dt><dd>Inband FEC enabled, but does not necessarily switch to SILK if we have music.</dd>
+  * </dl>
+  * @hideinitializer */
+#define OPUS_GET_INBAND_FEC(x) OPUS_GET_INBAND_FEC_REQUEST, __opus_check_int_ptr(x)
+
+/** Configures the encoder's expected packet loss percentage.
+  * Higher values trigger progressively more loss resistant behavior in the encoder
+  * at the expense of quality at a given bitrate in the absence of packet loss, but
+  * greater quality under loss.
+  * @see OPUS_GET_PACKET_LOSS_PERC
+  * @param[in] x <tt>opus_int32</tt>:   Loss percentage in the range 0-100, inclusive (default: 0).
+  * @hideinitializer */
+#define OPUS_SET_PACKET_LOSS_PERC(x) OPUS_SET_PACKET_LOSS_PERC_REQUEST, __opus_check_int(x)
+/** Gets the encoder's configured packet loss percentage.
+  * @see OPUS_SET_PACKET_LOSS_PERC
+  * @param[out] x <tt>opus_int32 *</tt>: Returns the configured loss percentage
+  *                                      in the range 0-100, inclusive (default: 0).
+  * @hideinitializer */
+#define OPUS_GET_PACKET_LOSS_PERC(x) OPUS_GET_PACKET_LOSS_PERC_REQUEST, __opus_check_int_ptr(x)
+
+/** Configures the encoder's use of discontinuous transmission (DTX).
+  * @note This is only applicable to the LPC layer
+  * @see OPUS_GET_DTX
+  * @param[in] x <tt>opus_int32</tt>: Allowed values:
+  * <dl>
+  * <dt>0</dt><dd>Disable DTX (default).</dd>
+  * <dt>1</dt><dd>Enabled DTX.</dd>
+  * </dl>
+  * @hideinitializer */
+#define OPUS_SET_DTX(x) OPUS_SET_DTX_REQUEST, __opus_check_int(x)
+/** Gets encoder's configured use of discontinuous transmission.
+  * @see OPUS_SET_DTX
+  * @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values:
+  * <dl>
+  * <dt>0</dt><dd>DTX disabled (default).</dd>
+  * <dt>1</dt><dd>DTX enabled.</dd>
+  * </dl>
+  * @hideinitializer */
+#define OPUS_GET_DTX(x) OPUS_GET_DTX_REQUEST, __opus_check_int_ptr(x)
+/** Configures the depth of signal being encoded.
+  *
+  * This is a hint which helps the encoder identify silence and near-silence.
+  * It represents the number of significant bits of linear intensity below
+  * which the signal contains ignorable quantization or other noise.
+  *
+  * For example, OPUS_SET_LSB_DEPTH(14) would be an appropriate setting
+  * for G.711 u-law input. OPUS_SET_LSB_DEPTH(16) would be appropriate
+  * for 16-bit linear pcm input with opus_encode_float().
+  *
+  * When using opus_encode() instead of opus_encode_float(), or when libopus
+  * is compiled for fixed-point, the encoder uses the minimum of the value
+  * set here and the value 16.
+  *
+  * @see OPUS_GET_LSB_DEPTH
+  * @param[in] x <tt>opus_int32</tt>: Input precision in bits, between 8 and 24
+  *                                   (default: 24).
+  * @hideinitializer */
+#define OPUS_SET_LSB_DEPTH(x) OPUS_SET_LSB_DEPTH_REQUEST, __opus_check_int(x)
+/** Gets the encoder's configured signal depth.
+  * @see OPUS_SET_LSB_DEPTH
+  * @param[out] x <tt>opus_int32 *</tt>: Input precision in bits, between 8 and
+  *                                      24 (default: 24).
+  * @hideinitializer */
+#define OPUS_GET_LSB_DEPTH(x) OPUS_GET_LSB_DEPTH_REQUEST, __opus_check_int_ptr(x)
+
+/** Configures the encoder's use of variable duration frames.
+  * When variable duration is enabled, the encoder is free to use a shorter frame
+  * size than the one requested in the opus_encode*() call.
+  * It is then the user's responsibility
+  * to verify how much audio was encoded by checking the ToC byte of the encoded
+  * packet. The part of the audio that was not encoded needs to be resent to the
+  * encoder for the next call. Do not use this option unless you <b>really</b>
+  * know what you are doing.
+  * @see OPUS_GET_EXPERT_FRAME_DURATION
+  * @param[in] x <tt>opus_int32</tt>: Allowed values:
+  * <dl>
+  * <dt>OPUS_FRAMESIZE_ARG</dt><dd>Select frame size from the argument (default).</dd>
+  * <dt>OPUS_FRAMESIZE_2_5_MS</dt><dd>Use 2.5 ms frames.</dd>
+  * <dt>OPUS_FRAMESIZE_5_MS</dt><dd>Use 5 ms frames.</dd>
+  * <dt>OPUS_FRAMESIZE_10_MS</dt><dd>Use 10 ms frames.</dd>
+  * <dt>OPUS_FRAMESIZE_20_MS</dt><dd>Use 20 ms frames.</dd>
+  * <dt>OPUS_FRAMESIZE_40_MS</dt><dd>Use 40 ms frames.</dd>
+  * <dt>OPUS_FRAMESIZE_60_MS</dt><dd>Use 60 ms frames.</dd>
+  * <dt>OPUS_FRAMESIZE_80_MS</dt><dd>Use 80 ms frames.</dd>
+  * <dt>OPUS_FRAMESIZE_100_MS</dt><dd>Use 100 ms frames.</dd>
+  * <dt>OPUS_FRAMESIZE_120_MS</dt><dd>Use 120 ms frames.</dd>
+  * </dl>
+  * @hideinitializer */
+#define OPUS_SET_EXPERT_FRAME_DURATION(x) OPUS_SET_EXPERT_FRAME_DURATION_REQUEST, __opus_check_int(x)
+/** Gets the encoder's configured use of variable duration frames.
+  * @see OPUS_SET_EXPERT_FRAME_DURATION
+  * @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values:
+  * <dl>
+  * <dt>OPUS_FRAMESIZE_ARG</dt><dd>Select frame size from the argument (default).</dd>
+  * <dt>OPUS_FRAMESIZE_2_5_MS</dt><dd>Use 2.5 ms frames.</dd>
+  * <dt>OPUS_FRAMESIZE_5_MS</dt><dd>Use 5 ms frames.</dd>
+  * <dt>OPUS_FRAMESIZE_10_MS</dt><dd>Use 10 ms frames.</dd>
+  * <dt>OPUS_FRAMESIZE_20_MS</dt><dd>Use 20 ms frames.</dd>
+  * <dt>OPUS_FRAMESIZE_40_MS</dt><dd>Use 40 ms frames.</dd>
+  * <dt>OPUS_FRAMESIZE_60_MS</dt><dd>Use 60 ms frames.</dd>
+  * <dt>OPUS_FRAMESIZE_80_MS</dt><dd>Use 80 ms frames.</dd>
+  * <dt>OPUS_FRAMESIZE_100_MS</dt><dd>Use 100 ms frames.</dd>
+  * <dt>OPUS_FRAMESIZE_120_MS</dt><dd>Use 120 ms frames.</dd>
+  * </dl>
+  * @hideinitializer */
+#define OPUS_GET_EXPERT_FRAME_DURATION(x) OPUS_GET_EXPERT_FRAME_DURATION_REQUEST, __opus_check_int_ptr(x)
+
+/** If set to 1, disables almost all use of prediction, making frames almost
+  * completely independent. This reduces quality.
+  * @see OPUS_GET_PREDICTION_DISABLED
+  * @param[in] x <tt>opus_int32</tt>: Allowed values:
+  * <dl>
+  * <dt>0</dt><dd>Enable prediction (default).</dd>
+  * <dt>1</dt><dd>Disable prediction.</dd>
+  * </dl>
+  * @hideinitializer */
+#define OPUS_SET_PREDICTION_DISABLED(x) OPUS_SET_PREDICTION_DISABLED_REQUEST, __opus_check_int(x)
+/** Gets the encoder's configured prediction status.
+  * @see OPUS_SET_PREDICTION_DISABLED
+  * @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values:
+  * <dl>
+  * <dt>0</dt><dd>Prediction enabled (default).</dd>
+  * <dt>1</dt><dd>Prediction disabled.</dd>
+  * </dl>
+  * @hideinitializer */
+#define OPUS_GET_PREDICTION_DISABLED(x) OPUS_GET_PREDICTION_DISABLED_REQUEST, __opus_check_int_ptr(x)
+
+/**@}*/
+
+/** @defgroup opus_genericctls Generic CTLs
+  *
+  * These macros are used with the \c opus_decoder_ctl and
+  * \c opus_encoder_ctl calls to generate a particular
+  * request.
+  *
+  * When called on an \c OpusDecoder they apply to that
+  * particular decoder instance. When called on an
+  * \c OpusEncoder they apply to the corresponding setting
+  * on that encoder instance, if present.
+  *
+  * Some usage examples:
+  *
+  * @code
+  * int ret;
+  * opus_int32 pitch;
+  * ret = opus_decoder_ctl(dec_ctx, OPUS_GET_PITCH(&pitch));
+  * if (ret == OPUS_OK) return ret;
+  *
+  * opus_encoder_ctl(enc_ctx, OPUS_RESET_STATE);
+  * opus_decoder_ctl(dec_ctx, OPUS_RESET_STATE);
+  *
+  * opus_int32 enc_bw, dec_bw;
+  * opus_encoder_ctl(enc_ctx, OPUS_GET_BANDWIDTH(&enc_bw));
+  * opus_decoder_ctl(dec_ctx, OPUS_GET_BANDWIDTH(&dec_bw));
+  * if (enc_bw != dec_bw) {
+  *   printf("packet bandwidth mismatch!\n");
+  * }
+  * @endcode
+  *
+  * @see opus_encoder, opus_decoder_ctl, opus_encoder_ctl, opus_decoderctls, opus_encoderctls
+  * @{
+  */
+
+/** Resets the codec state to be equivalent to a freshly initialized state.
+  * This should be called when switching streams in order to prevent
+  * the back to back decoding from giving different results from
+  * one at a time decoding.
+  * @hideinitializer */
+#define OPUS_RESET_STATE 4028
+
+/** Gets the final state of the codec's entropy coder.
+  * This is used for testing purposes,
+  * The encoder and decoder state should be identical after coding a payload
+  * (assuming no data corruption or software bugs)
+  *
+  * @param[out] x <tt>opus_uint32 *</tt>: Entropy coder state
+  *
+  * @hideinitializer */
+#define OPUS_GET_FINAL_RANGE(x) OPUS_GET_FINAL_RANGE_REQUEST, __opus_check_uint_ptr(x)
+
+/** Gets the encoder's configured bandpass or the decoder's last bandpass.
+  * @see OPUS_SET_BANDWIDTH
+  * @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values:
+  * <dl>
+  * <dt>#OPUS_AUTO</dt>                    <dd>(default)</dd>
+  * <dt>#OPUS_BANDWIDTH_NARROWBAND</dt>    <dd>4 kHz passband</dd>
+  * <dt>#OPUS_BANDWIDTH_MEDIUMBAND</dt>    <dd>6 kHz passband</dd>
+  * <dt>#OPUS_BANDWIDTH_WIDEBAND</dt>      <dd>8 kHz passband</dd>
+  * <dt>#OPUS_BANDWIDTH_SUPERWIDEBAND</dt><dd>12 kHz passband</dd>
+  * <dt>#OPUS_BANDWIDTH_FULLBAND</dt>     <dd>20 kHz passband</dd>
+  * </dl>
+  * @hideinitializer */
+#define OPUS_GET_BANDWIDTH(x) OPUS_GET_BANDWIDTH_REQUEST, __opus_check_int_ptr(x)
+
+/** Gets the sampling rate the encoder or decoder was initialized with.
+  * This simply returns the <code>Fs</code> value passed to opus_encoder_init()
+  * or opus_decoder_init().
+  * @param[out] x <tt>opus_int32 *</tt>: Sampling rate of encoder or decoder.
+  * @hideinitializer
+  */
+#define OPUS_GET_SAMPLE_RATE(x) OPUS_GET_SAMPLE_RATE_REQUEST, __opus_check_int_ptr(x)
+
+/** If set to 1, disables the use of phase inversion for intensity stereo,
+  * improving the quality of mono downmixes, but slightly reducing normal
+  * stereo quality. Disabling phase inversion in the decoder does not comply
+  * with RFC 6716, although it does not cause any interoperability issue and
+  * is expected to become part of the Opus standard once RFC 6716 is updated
+  * by draft-ietf-codec-opus-update.
+  * @see OPUS_GET_PHASE_INVERSION_DISABLED
+  * @param[in] x <tt>opus_int32</tt>: Allowed values:
+  * <dl>
+  * <dt>0</dt><dd>Enable phase inversion (default).</dd>
+  * <dt>1</dt><dd>Disable phase inversion.</dd>
+  * </dl>
+  * @hideinitializer */
+#define OPUS_SET_PHASE_INVERSION_DISABLED(x) OPUS_SET_PHASE_INVERSION_DISABLED_REQUEST, __opus_check_int(x)
+/** Gets the encoder's configured phase inversion status.
+  * @see OPUS_SET_PHASE_INVERSION_DISABLED
+  * @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values:
+  * <dl>
+  * <dt>0</dt><dd>Stereo phase inversion enabled (default).</dd>
+  * <dt>1</dt><dd>Stereo phase inversion disabled.</dd>
+  * </dl>
+  * @hideinitializer */
+#define OPUS_GET_PHASE_INVERSION_DISABLED(x) OPUS_GET_PHASE_INVERSION_DISABLED_REQUEST, __opus_check_int_ptr(x)
+/** Gets the DTX state of the encoder.
+  * Returns whether the last encoded frame was either a comfort noise update
+  * during DTX or not encoded because of DTX.
+  * @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values:
+  * <dl>
+  * <dt>0</dt><dd>The encoder is not in DTX.</dd>
+  * <dt>1</dt><dd>The encoder is in DTX.</dd>
+  * </dl>
+  * @hideinitializer */
+#define OPUS_GET_IN_DTX(x) OPUS_GET_IN_DTX_REQUEST, __opus_check_int_ptr(x)
+
+/**@}*/
+
+/** @defgroup opus_decoderctls Decoder related CTLs
+  * @see opus_genericctls, opus_encoderctls, opus_decoder
+  * @{
+  */
+
+/** Configures decoder gain adjustment.
+  * Scales the decoded output by a factor specified in Q8 dB units.
+  * This has a maximum range of -32768 to 32767 inclusive, and returns
+  * OPUS_BAD_ARG otherwise. The default is zero indicating no adjustment.
+  * This setting survives decoder reset.
+  *
+  * gain = pow(10, x/(20.0*256))
+  *
+  * @param[in] x <tt>opus_int32</tt>:   Amount to scale PCM signal by in Q8 dB units.
+  * @hideinitializer */
+#define OPUS_SET_GAIN(x) OPUS_SET_GAIN_REQUEST, __opus_check_int(x)
+/** Gets the decoder's configured gain adjustment. @see OPUS_SET_GAIN
+  *
+  * @param[out] x <tt>opus_int32 *</tt>: Amount to scale PCM signal by in Q8 dB units.
+  * @hideinitializer */
+#define OPUS_GET_GAIN(x) OPUS_GET_GAIN_REQUEST, __opus_check_int_ptr(x)
+
+/** Gets the duration (in samples) of the last packet successfully decoded or concealed.
+  * @param[out] x <tt>opus_int32 *</tt>: Number of samples (at current sampling rate).
+  * @hideinitializer */
+#define OPUS_GET_LAST_PACKET_DURATION(x) OPUS_GET_LAST_PACKET_DURATION_REQUEST, __opus_check_int_ptr(x)
+
+/** Gets the pitch of the last decoded frame, if available.
+  * This can be used for any post-processing algorithm requiring the use of pitch,
+  * e.g. time stretching/shortening. If the last frame was not voiced, or if the
+  * pitch was not coded in the frame, then zero is returned.
+  *
+  * This CTL is only implemented for decoder instances.
+  *
+  * @param[out] x <tt>opus_int32 *</tt>: pitch period at 48 kHz (or 0 if not available)
+  *
+  * @hideinitializer */
+#define OPUS_GET_PITCH(x) OPUS_GET_PITCH_REQUEST, __opus_check_int_ptr(x)
+
+/**@}*/
+
+/** @defgroup opus_libinfo Opus library information functions
+  * @{
+  */
+
+/** Converts an opus error code into a human readable string.
+  *
+  * @param[in] error <tt>int</tt>: Error number
+  * @returns Error string
+  */
+OPUS_EXPORT const char *opus_strerror(int error);
+
+/** Gets the libopus version string.
+  *
+  * Applications may look for the substring "-fixed" in the version string to
+  * determine whether they have a fixed-point or floating-point build at
+  * runtime.
+  *
+  * @returns Version string
+  */
+OPUS_EXPORT const char *opus_get_version_string(void);
+/**@}*/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* OPUS_DEFINES_H */
diff --git a/2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/source/opus/opus_multistream.h b/2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/source/opus/opus_multistream.h
new file mode 100644 (file)
index 0000000..babcee6
--- /dev/null
@@ -0,0 +1,660 @@
+/* Copyright (c) 2011 Xiph.Org Foundation
+   Written by Jean-Marc Valin */
+/*
+   Redistribution and use in source and binary forms, with or without
+   modification, are permitted provided that the following conditions
+   are met:
+
+   - Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+
+   - Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+
+   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+   ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
+   OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+   PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+   LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+/**
+ * @file opus_multistream.h
+ * @brief Opus reference implementation multistream API
+ */
+
+#ifndef OPUS_MULTISTREAM_H
+#define OPUS_MULTISTREAM_H
+
+#include "opus.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** @cond OPUS_INTERNAL_DOC */
+
+/** Macros to trigger compilation errors when the wrong types are provided to a
+  * CTL. */
+/**@{*/
+#define __opus_check_encstate_ptr(ptr) ((ptr) + ((ptr) - (OpusEncoder**)(ptr)))
+#define __opus_check_decstate_ptr(ptr) ((ptr) + ((ptr) - (OpusDecoder**)(ptr)))
+/**@}*/
+
+/** These are the actual encoder and decoder CTL ID numbers.
+  * They should not be used directly by applications.
+  * In general, SETs should be even and GETs should be odd.*/
+/**@{*/
+#define OPUS_MULTISTREAM_GET_ENCODER_STATE_REQUEST 5120
+#define OPUS_MULTISTREAM_GET_DECODER_STATE_REQUEST 5122
+/**@}*/
+
+/** @endcond */
+
+/** @defgroup opus_multistream_ctls Multistream specific encoder and decoder CTLs
+  *
+  * These are convenience macros that are specific to the
+  * opus_multistream_encoder_ctl() and opus_multistream_decoder_ctl()
+  * interface.
+  * The CTLs from @ref opus_genericctls, @ref opus_encoderctls, and
+  * @ref opus_decoderctls may be applied to a multistream encoder or decoder as
+  * well.
+  * In addition, you may retrieve the encoder or decoder state for an specific
+  * stream via #OPUS_MULTISTREAM_GET_ENCODER_STATE or
+  * #OPUS_MULTISTREAM_GET_DECODER_STATE and apply CTLs to it individually.
+  */
+/**@{*/
+
+/** Gets the encoder state for an individual stream of a multistream encoder.
+  * @param[in] x <tt>opus_int32</tt>: The index of the stream whose encoder you
+  *                                   wish to retrieve.
+  *                                   This must be non-negative and less than
+  *                                   the <code>streams</code> parameter used
+  *                                   to initialize the encoder.
+  * @param[out] y <tt>OpusEncoder**</tt>: Returns a pointer to the given
+  *                                       encoder state.
+  * @retval OPUS_BAD_ARG The index of the requested stream was out of range.
+  * @hideinitializer
+  */
+#define OPUS_MULTISTREAM_GET_ENCODER_STATE(x,y) OPUS_MULTISTREAM_GET_ENCODER_STATE_REQUEST, __opus_check_int(x), __opus_check_encstate_ptr(y)
+
+/** Gets the decoder state for an individual stream of a multistream decoder.
+  * @param[in] x <tt>opus_int32</tt>: The index of the stream whose decoder you
+  *                                   wish to retrieve.
+  *                                   This must be non-negative and less than
+  *                                   the <code>streams</code> parameter used
+  *                                   to initialize the decoder.
+  * @param[out] y <tt>OpusDecoder**</tt>: Returns a pointer to the given
+  *                                       decoder state.
+  * @retval OPUS_BAD_ARG The index of the requested stream was out of range.
+  * @hideinitializer
+  */
+#define OPUS_MULTISTREAM_GET_DECODER_STATE(x,y) OPUS_MULTISTREAM_GET_DECODER_STATE_REQUEST, __opus_check_int(x), __opus_check_decstate_ptr(y)
+
+/**@}*/
+
+/** @defgroup opus_multistream Opus Multistream API
+  * @{
+  *
+  * The multistream API allows individual Opus streams to be combined into a
+  * single packet, enabling support for up to 255 channels. Unlike an
+  * elementary Opus stream, the encoder and decoder must negotiate the channel
+  * configuration before the decoder can successfully interpret the data in the
+  * packets produced by the encoder. Some basic information, such as packet
+  * duration, can be computed without any special negotiation.
+  *
+  * The format for multistream Opus packets is defined in
+  * <a href="https://tools.ietf.org/html/rfc7845">RFC 7845</a>
+  * and is based on the self-delimited Opus framing described in Appendix B of
+  * <a href="https://tools.ietf.org/html/rfc6716">RFC 6716</a>.
+  * Normal Opus packets are just a degenerate case of multistream Opus packets,
+  * and can be encoded or decoded with the multistream API by setting
+  * <code>streams</code> to <code>1</code> when initializing the encoder or
+  * decoder.
+  *
+  * Multistream Opus streams can contain up to 255 elementary Opus streams.
+  * These may be either "uncoupled" or "coupled", indicating that the decoder
+  * is configured to decode them to either 1 or 2 channels, respectively.
+  * The streams are ordered so that all coupled streams appear at the
+  * beginning.
+  *
+  * A <code>mapping</code> table defines which decoded channel <code>i</code>
+  * should be used for each input/output (I/O) channel <code>j</code>. This table is
+  * typically provided as an unsigned char array.
+  * Let <code>i = mapping[j]</code> be the index for I/O channel <code>j</code>.
+  * If <code>i < 2*coupled_streams</code>, then I/O channel <code>j</code> is
+  * encoded as the left channel of stream <code>(i/2)</code> if <code>i</code>
+  * is even, or  as the right channel of stream <code>(i/2)</code> if
+  * <code>i</code> is odd. Otherwise, I/O channel <code>j</code> is encoded as
+  * mono in stream <code>(i - coupled_streams)</code>, unless it has the special
+  * value 255, in which case it is omitted from the encoding entirely (the
+  * decoder will reproduce it as silence). Each value <code>i</code> must either
+  * be the special value 255 or be less than <code>streams + coupled_streams</code>.
+  *
+  * The output channels specified by the encoder
+  * should use the
+  * <a href="https://www.xiph.org/vorbis/doc/Vorbis_I_spec.html#x1-810004.3.9">Vorbis
+  * channel ordering</a>. A decoder may wish to apply an additional permutation
+  * to the mapping the encoder used to achieve a different output channel
+  * order (e.g. for outputing in WAV order).
+  *
+  * Each multistream packet contains an Opus packet for each stream, and all of
+  * the Opus packets in a single multistream packet must have the same
+  * duration. Therefore the duration of a multistream packet can be extracted
+  * from the TOC sequence of the first stream, which is located at the
+  * beginning of the packet, just like an elementary Opus stream:
+  *
+  * @code
+  * int nb_samples;
+  * int nb_frames;
+  * nb_frames = opus_packet_get_nb_frames(data, len);
+  * if (nb_frames < 1)
+  *   return nb_frames;
+  * nb_samples = opus_packet_get_samples_per_frame(data, 48000) * nb_frames;
+  * @endcode
+  *
+  * The general encoding and decoding process proceeds exactly the same as in
+  * the normal @ref opus_encoder and @ref opus_decoder APIs.
+  * See their documentation for an overview of how to use the corresponding
+  * multistream functions.
+  */
+
+/** Opus multistream encoder state.
+  * This contains the complete state of a multistream Opus encoder.
+  * It is position independent and can be freely copied.
+  * @see opus_multistream_encoder_create
+  * @see opus_multistream_encoder_init
+  */
+typedef struct OpusMSEncoder OpusMSEncoder;
+
+/** Opus multistream decoder state.
+  * This contains the complete state of a multistream Opus decoder.
+  * It is position independent and can be freely copied.
+  * @see opus_multistream_decoder_create
+  * @see opus_multistream_decoder_init
+  */
+typedef struct OpusMSDecoder OpusMSDecoder;
+
+/**\name Multistream encoder functions */
+/**@{*/
+
+/** Gets the size of an OpusMSEncoder structure.
+  * @param streams <tt>int</tt>: The total number of streams to encode from the
+  *                              input.
+  *                              This must be no more than 255.
+  * @param coupled_streams <tt>int</tt>: Number of coupled (2 channel) streams
+  *                                      to encode.
+  *                                      This must be no larger than the total
+  *                                      number of streams.
+  *                                      Additionally, The total number of
+  *                                      encoded channels (<code>streams +
+  *                                      coupled_streams</code>) must be no
+  *                                      more than 255.
+  * @returns The size in bytes on success, or a negative error code
+  *          (see @ref opus_errorcodes) on error.
+  */
+OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_multistream_encoder_get_size(
+      int streams,
+      int coupled_streams
+);
+
+OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_multistream_surround_encoder_get_size(
+      int channels,
+      int mapping_family
+);
+
+
+/** Allocates and initializes a multistream encoder state.
+  * Call opus_multistream_encoder_destroy() to release
+  * this object when finished.
+  * @param Fs <tt>opus_int32</tt>: Sampling rate of the input signal (in Hz).
+  *                                This must be one of 8000, 12000, 16000,
+  *                                24000, or 48000.
+  * @param channels <tt>int</tt>: Number of channels in the input signal.
+  *                               This must be at most 255.
+  *                               It may be greater than the number of
+  *                               coded channels (<code>streams +
+  *                               coupled_streams</code>).
+  * @param streams <tt>int</tt>: The total number of streams to encode from the
+  *                              input.
+  *                              This must be no more than the number of channels.
+  * @param coupled_streams <tt>int</tt>: Number of coupled (2 channel) streams
+  *                                      to encode.
+  *                                      This must be no larger than the total
+  *                                      number of streams.
+  *                                      Additionally, The total number of
+  *                                      encoded channels (<code>streams +
+  *                                      coupled_streams</code>) must be no
+  *                                      more than the number of input channels.
+  * @param[in] mapping <code>const unsigned char[channels]</code>: Mapping from
+  *                    encoded channels to input channels, as described in
+  *                    @ref opus_multistream. As an extra constraint, the
+  *                    multistream encoder does not allow encoding coupled
+  *                    streams for which one channel is unused since this
+  *                    is never a good idea.
+  * @param application <tt>int</tt>: The target encoder application.
+  *                                  This must be one of the following:
+  * <dl>
+  * <dt>#OPUS_APPLICATION_VOIP</dt>
+  * <dd>Process signal for improved speech intelligibility.</dd>
+  * <dt>#OPUS_APPLICATION_AUDIO</dt>
+  * <dd>Favor faithfulness to the original input.</dd>
+  * <dt>#OPUS_APPLICATION_RESTRICTED_LOWDELAY</dt>
+  * <dd>Configure the minimum possible coding delay by disabling certain modes
+  * of operation.</dd>
+  * </dl>
+  * @param[out] error <tt>int *</tt>: Returns #OPUS_OK on success, or an error
+  *                                   code (see @ref opus_errorcodes) on
+  *                                   failure.
+  */
+OPUS_EXPORT OPUS_WARN_UNUSED_RESULT OpusMSEncoder *opus_multistream_encoder_create(
+      opus_int32 Fs,
+      int channels,
+      int streams,
+      int coupled_streams,
+      const unsigned char *mapping,
+      int application,
+      int *error
+) OPUS_ARG_NONNULL(5);
+
+OPUS_EXPORT OPUS_WARN_UNUSED_RESULT OpusMSEncoder *opus_multistream_surround_encoder_create(
+      opus_int32 Fs,
+      int channels,
+      int mapping_family,
+      int *streams,
+      int *coupled_streams,
+      unsigned char *mapping,
+      int application,
+      int *error
+) OPUS_ARG_NONNULL(4) OPUS_ARG_NONNULL(5) OPUS_ARG_NONNULL(6);
+
+/** Initialize a previously allocated multistream encoder state.
+  * The memory pointed to by \a st must be at least the size returned by
+  * opus_multistream_encoder_get_size().
+  * This is intended for applications which use their own allocator instead of
+  * malloc.
+  * To reset a previously initialized state, use the #OPUS_RESET_STATE CTL.
+  * @see opus_multistream_encoder_create
+  * @see opus_multistream_encoder_get_size
+  * @param st <tt>OpusMSEncoder*</tt>: Multistream encoder state to initialize.
+  * @param Fs <tt>opus_int32</tt>: Sampling rate of the input signal (in Hz).
+  *                                This must be one of 8000, 12000, 16000,
+  *                                24000, or 48000.
+  * @param channels <tt>int</tt>: Number of channels in the input signal.
+  *                               This must be at most 255.
+  *                               It may be greater than the number of
+  *                               coded channels (<code>streams +
+  *                               coupled_streams</code>).
+  * @param streams <tt>int</tt>: The total number of streams to encode from the
+  *                              input.
+  *                              This must be no more than the number of channels.
+  * @param coupled_streams <tt>int</tt>: Number of coupled (2 channel) streams
+  *                                      to encode.
+  *                                      This must be no larger than the total
+  *                                      number of streams.
+  *                                      Additionally, The total number of
+  *                                      encoded channels (<code>streams +
+  *                                      coupled_streams</code>) must be no
+  *                                      more than the number of input channels.
+  * @param[in] mapping <code>const unsigned char[channels]</code>: Mapping from
+  *                    encoded channels to input channels, as described in
+  *                    @ref opus_multistream. As an extra constraint, the
+  *                    multistream encoder does not allow encoding coupled
+  *                    streams for which one channel is unused since this
+  *                    is never a good idea.
+  * @param application <tt>int</tt>: The target encoder application.
+  *                                  This must be one of the following:
+  * <dl>
+  * <dt>#OPUS_APPLICATION_VOIP</dt>
+  * <dd>Process signal for improved speech intelligibility.</dd>
+  * <dt>#OPUS_APPLICATION_AUDIO</dt>
+  * <dd>Favor faithfulness to the original input.</dd>
+  * <dt>#OPUS_APPLICATION_RESTRICTED_LOWDELAY</dt>
+  * <dd>Configure the minimum possible coding delay by disabling certain modes
+  * of operation.</dd>
+  * </dl>
+  * @returns #OPUS_OK on success, or an error code (see @ref opus_errorcodes)
+  *          on failure.
+  */
+OPUS_EXPORT int opus_multistream_encoder_init(
+      OpusMSEncoder *st,
+      opus_int32 Fs,
+      int channels,
+      int streams,
+      int coupled_streams,
+      const unsigned char *mapping,
+      int application
+) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(6);
+
+OPUS_EXPORT int opus_multistream_surround_encoder_init(
+      OpusMSEncoder *st,
+      opus_int32 Fs,
+      int channels,
+      int mapping_family,
+      int *streams,
+      int *coupled_streams,
+      unsigned char *mapping,
+      int application
+) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(5) OPUS_ARG_NONNULL(6) OPUS_ARG_NONNULL(7);
+
+/** Encodes a multistream Opus frame.
+  * @param st <tt>OpusMSEncoder*</tt>: Multistream encoder state.
+  * @param[in] pcm <tt>const opus_int16*</tt>: The input signal as interleaved
+  *                                            samples.
+  *                                            This must contain
+  *                                            <code>frame_size*channels</code>
+  *                                            samples.
+  * @param frame_size <tt>int</tt>: Number of samples per channel in the input
+  *                                 signal.
+  *                                 This must be an Opus frame size for the
+  *                                 encoder's sampling rate.
+  *                                 For example, at 48 kHz the permitted values
+  *                                 are 120, 240, 480, 960, 1920, and 2880.
+  *                                 Passing in a duration of less than 10 ms
+  *                                 (480 samples at 48 kHz) will prevent the
+  *                                 encoder from using the LPC or hybrid modes.
+  * @param[out] data <tt>unsigned char*</tt>: Output payload.
+  *                                           This must contain storage for at
+  *                                           least \a max_data_bytes.
+  * @param [in] max_data_bytes <tt>opus_int32</tt>: Size of the allocated
+  *                                                 memory for the output
+  *                                                 payload. This may be
+  *                                                 used to impose an upper limit on
+  *                                                 the instant bitrate, but should
+  *                                                 not be used as the only bitrate
+  *                                                 control. Use #OPUS_SET_BITRATE to
+  *                                                 control the bitrate.
+  * @returns The length of the encoded packet (in bytes) on success or a
+  *          negative error code (see @ref opus_errorcodes) on failure.
+  */
+OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_multistream_encode(
+    OpusMSEncoder *st,
+    const opus_int16 *pcm,
+    int frame_size,
+    unsigned char *data,
+    opus_int32 max_data_bytes
+) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2) OPUS_ARG_NONNULL(4);
+
+/** Encodes a multistream Opus frame from floating point input.
+  * @param st <tt>OpusMSEncoder*</tt>: Multistream encoder state.
+  * @param[in] pcm <tt>const float*</tt>: The input signal as interleaved
+  *                                       samples with a normal range of
+  *                                       +/-1.0.
+  *                                       Samples with a range beyond +/-1.0
+  *                                       are supported but will be clipped by
+  *                                       decoders using the integer API and
+  *                                       should only be used if it is known
+  *                                       that the far end supports extended
+  *                                       dynamic range.
+  *                                       This must contain
+  *                                       <code>frame_size*channels</code>
+  *                                       samples.
+  * @param frame_size <tt>int</tt>: Number of samples per channel in the input
+  *                                 signal.
+  *                                 This must be an Opus frame size for the
+  *                                 encoder's sampling rate.
+  *                                 For example, at 48 kHz the permitted values
+  *                                 are 120, 240, 480, 960, 1920, and 2880.
+  *                                 Passing in a duration of less than 10 ms
+  *                                 (480 samples at 48 kHz) will prevent the
+  *                                 encoder from using the LPC or hybrid modes.
+  * @param[out] data <tt>unsigned char*</tt>: Output payload.
+  *                                           This must contain storage for at
+  *                                           least \a max_data_bytes.
+  * @param [in] max_data_bytes <tt>opus_int32</tt>: Size of the allocated
+  *                                                 memory for the output
+  *                                                 payload. This may be
+  *                                                 used to impose an upper limit on
+  *                                                 the instant bitrate, but should
+  *                                                 not be used as the only bitrate
+  *                                                 control. Use #OPUS_SET_BITRATE to
+  *                                                 control the bitrate.
+  * @returns The length of the encoded packet (in bytes) on success or a
+  *          negative error code (see @ref opus_errorcodes) on failure.
+  */
+OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_multistream_encode_float(
+      OpusMSEncoder *st,
+      const float *pcm,
+      int frame_size,
+      unsigned char *data,
+      opus_int32 max_data_bytes
+) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2) OPUS_ARG_NONNULL(4);
+
+/** Frees an <code>OpusMSEncoder</code> allocated by
+  * opus_multistream_encoder_create().
+  * @param st <tt>OpusMSEncoder*</tt>: Multistream encoder state to be freed.
+  */
+OPUS_EXPORT void opus_multistream_encoder_destroy(OpusMSEncoder *st);
+
+/** Perform a CTL function on a multistream Opus encoder.
+  *
+  * Generally the request and subsequent arguments are generated by a
+  * convenience macro.
+  * @param st <tt>OpusMSEncoder*</tt>: Multistream encoder state.
+  * @param request This and all remaining parameters should be replaced by one
+  *                of the convenience macros in @ref opus_genericctls,
+  *                @ref opus_encoderctls, or @ref opus_multistream_ctls.
+  * @see opus_genericctls
+  * @see opus_encoderctls
+  * @see opus_multistream_ctls
+  */
+OPUS_EXPORT int opus_multistream_encoder_ctl(OpusMSEncoder *st, int request, ...) OPUS_ARG_NONNULL(1);
+
+/**@}*/
+
+/**\name Multistream decoder functions */
+/**@{*/
+
+/** Gets the size of an <code>OpusMSDecoder</code> structure.
+  * @param streams <tt>int</tt>: The total number of streams coded in the
+  *                              input.
+  *                              This must be no more than 255.
+  * @param coupled_streams <tt>int</tt>: Number streams to decode as coupled
+  *                                      (2 channel) streams.
+  *                                      This must be no larger than the total
+  *                                      number of streams.
+  *                                      Additionally, The total number of
+  *                                      coded channels (<code>streams +
+  *                                      coupled_streams</code>) must be no
+  *                                      more than 255.
+  * @returns The size in bytes on success, or a negative error code
+  *          (see @ref opus_errorcodes) on error.
+  */
+OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_multistream_decoder_get_size(
+      int streams,
+      int coupled_streams
+);
+
+/** Allocates and initializes a multistream decoder state.
+  * Call opus_multistream_decoder_destroy() to release
+  * this object when finished.
+  * @param Fs <tt>opus_int32</tt>: Sampling rate to decode at (in Hz).
+  *                                This must be one of 8000, 12000, 16000,
+  *                                24000, or 48000.
+  * @param channels <tt>int</tt>: Number of channels to output.
+  *                               This must be at most 255.
+  *                               It may be different from the number of coded
+  *                               channels (<code>streams +
+  *                               coupled_streams</code>).
+  * @param streams <tt>int</tt>: The total number of streams coded in the
+  *                              input.
+  *                              This must be no more than 255.
+  * @param coupled_streams <tt>int</tt>: Number of streams to decode as coupled
+  *                                      (2 channel) streams.
+  *                                      This must be no larger than the total
+  *                                      number of streams.
+  *                                      Additionally, The total number of
+  *                                      coded channels (<code>streams +
+  *                                      coupled_streams</code>) must be no
+  *                                      more than 255.
+  * @param[in] mapping <code>const unsigned char[channels]</code>: Mapping from
+  *                    coded channels to output channels, as described in
+  *                    @ref opus_multistream.
+  * @param[out] error <tt>int *</tt>: Returns #OPUS_OK on success, or an error
+  *                                   code (see @ref opus_errorcodes) on
+  *                                   failure.
+  */
+OPUS_EXPORT OPUS_WARN_UNUSED_RESULT OpusMSDecoder *opus_multistream_decoder_create(
+      opus_int32 Fs,
+      int channels,
+      int streams,
+      int coupled_streams,
+      const unsigned char *mapping,
+      int *error
+) OPUS_ARG_NONNULL(5);
+
+/** Intialize a previously allocated decoder state object.
+  * The memory pointed to by \a st must be at least the size returned by
+  * opus_multistream_encoder_get_size().
+  * This is intended for applications which use their own allocator instead of
+  * malloc.
+  * To reset a previously initialized state, use the #OPUS_RESET_STATE CTL.
+  * @see opus_multistream_decoder_create
+  * @see opus_multistream_deocder_get_size
+  * @param st <tt>OpusMSEncoder*</tt>: Multistream encoder state to initialize.
+  * @param Fs <tt>opus_int32</tt>: Sampling rate to decode at (in Hz).
+  *                                This must be one of 8000, 12000, 16000,
+  *                                24000, or 48000.
+  * @param channels <tt>int</tt>: Number of channels to output.
+  *                               This must be at most 255.
+  *                               It may be different from the number of coded
+  *                               channels (<code>streams +
+  *                               coupled_streams</code>).
+  * @param streams <tt>int</tt>: The total number of streams coded in the
+  *                              input.
+  *                              This must be no more than 255.
+  * @param coupled_streams <tt>int</tt>: Number of streams to decode as coupled
+  *                                      (2 channel) streams.
+  *                                      This must be no larger than the total
+  *                                      number of streams.
+  *                                      Additionally, The total number of
+  *                                      coded channels (<code>streams +
+  *                                      coupled_streams</code>) must be no
+  *                                      more than 255.
+  * @param[in] mapping <code>const unsigned char[channels]</code>: Mapping from
+  *                    coded channels to output channels, as described in
+  *                    @ref opus_multistream.
+  * @returns #OPUS_OK on success, or an error code (see @ref opus_errorcodes)
+  *          on failure.
+  */
+OPUS_EXPORT int opus_multistream_decoder_init(
+      OpusMSDecoder *st,
+      opus_int32 Fs,
+      int channels,
+      int streams,
+      int coupled_streams,
+      const unsigned char *mapping
+) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(6);
+
+/** Decode a multistream Opus packet.
+  * @param st <tt>OpusMSDecoder*</tt>: Multistream decoder state.
+  * @param[in] data <tt>const unsigned char*</tt>: Input payload.
+  *                                                Use a <code>NULL</code>
+  *                                                pointer to indicate packet
+  *                                                loss.
+  * @param len <tt>opus_int32</tt>: Number of bytes in payload.
+  * @param[out] pcm <tt>opus_int16*</tt>: Output signal, with interleaved
+  *                                       samples.
+  *                                       This must contain room for
+  *                                       <code>frame_size*channels</code>
+  *                                       samples.
+  * @param frame_size <tt>int</tt>: The number of samples per channel of
+  *                                 available space in \a pcm.
+  *                                 If this is less than the maximum packet duration
+  *                                 (120 ms; 5760 for 48kHz), this function will not be capable
+  *                                 of decoding some packets. In the case of PLC (data==NULL)
+  *                                 or FEC (decode_fec=1), then frame_size needs to be exactly
+  *                                 the duration of audio that is missing, otherwise the
+  *                                 decoder will not be in the optimal state to decode the
+  *                                 next incoming packet. For the PLC and FEC cases, frame_size
+  *                                 <b>must</b> be a multiple of 2.5 ms.
+  * @param decode_fec <tt>int</tt>: Flag (0 or 1) to request that any in-band
+  *                                 forward error correction data be decoded.
+  *                                 If no such data is available, the frame is
+  *                                 decoded as if it were lost.
+  * @returns Number of samples decoded on success or a negative error code
+  *          (see @ref opus_errorcodes) on failure.
+  */
+OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_multistream_decode(
+    OpusMSDecoder *st,
+    const unsigned char *data,
+    opus_int32 len,
+    opus_int16 *pcm,
+    int frame_size,
+    int decode_fec
+) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(4);
+
+/** Decode a multistream Opus packet with floating point output.
+  * @param st <tt>OpusMSDecoder*</tt>: Multistream decoder state.
+  * @param[in] data <tt>const unsigned char*</tt>: Input payload.
+  *                                                Use a <code>NULL</code>
+  *                                                pointer to indicate packet
+  *                                                loss.
+  * @param len <tt>opus_int32</tt>: Number of bytes in payload.
+  * @param[out] pcm <tt>opus_int16*</tt>: Output signal, with interleaved
+  *                                       samples.
+  *                                       This must contain room for
+  *                                       <code>frame_size*channels</code>
+  *                                       samples.
+  * @param frame_size <tt>int</tt>: The number of samples per channel of
+  *                                 available space in \a pcm.
+  *                                 If this is less than the maximum packet duration
+  *                                 (120 ms; 5760 for 48kHz), this function will not be capable
+  *                                 of decoding some packets. In the case of PLC (data==NULL)
+  *                                 or FEC (decode_fec=1), then frame_size needs to be exactly
+  *                                 the duration of audio that is missing, otherwise the
+  *                                 decoder will not be in the optimal state to decode the
+  *                                 next incoming packet. For the PLC and FEC cases, frame_size
+  *                                 <b>must</b> be a multiple of 2.5 ms.
+  * @param decode_fec <tt>int</tt>: Flag (0 or 1) to request that any in-band
+  *                                 forward error correction data be decoded.
+  *                                 If no such data is available, the frame is
+  *                                 decoded as if it were lost.
+  * @returns Number of samples decoded on success or a negative error code
+  *          (see @ref opus_errorcodes) on failure.
+  */
+OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_multistream_decode_float(
+    OpusMSDecoder *st,
+    const unsigned char *data,
+    opus_int32 len,
+    float *pcm,
+    int frame_size,
+    int decode_fec
+) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(4);
+
+/** Perform a CTL function on a multistream Opus decoder.
+  *
+  * Generally the request and subsequent arguments are generated by a
+  * convenience macro.
+  * @param st <tt>OpusMSDecoder*</tt>: Multistream decoder state.
+  * @param request This and all remaining parameters should be replaced by one
+  *                of the convenience macros in @ref opus_genericctls,
+  *                @ref opus_decoderctls, or @ref opus_multistream_ctls.
+  * @see opus_genericctls
+  * @see opus_decoderctls
+  * @see opus_multistream_ctls
+  */
+OPUS_EXPORT int opus_multistream_decoder_ctl(OpusMSDecoder *st, int request, ...) OPUS_ARG_NONNULL(1);
+
+/** Frees an <code>OpusMSDecoder</code> allocated by
+  * opus_multistream_decoder_create().
+  * @param st <tt>OpusMSDecoder</tt>: Multistream decoder state to be freed.
+  */
+OPUS_EXPORT void opus_multistream_decoder_destroy(OpusMSDecoder *st);
+
+/**@}*/
+
+/**@}*/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* OPUS_MULTISTREAM_H */
diff --git a/2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/source/opus/opus_projection.h b/2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/source/opus/opus_projection.h
new file mode 100644 (file)
index 0000000..9dabf4e
--- /dev/null
@@ -0,0 +1,568 @@
+/* Copyright (c) 2017 Google Inc.
+   Written by Andrew Allen */
+/*
+   Redistribution and use in source and binary forms, with or without
+   modification, are permitted provided that the following conditions
+   are met:
+
+   - Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+
+   - Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+
+   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+   ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
+   OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+   PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+   LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+/**
+ * @file opus_projection.h
+ * @brief Opus projection reference API
+ */
+
+#ifndef OPUS_PROJECTION_H
+#define OPUS_PROJECTION_H
+
+#include "opus_multistream.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** @cond OPUS_INTERNAL_DOC */
+
+/** These are the actual encoder and decoder CTL ID numbers.
+  * They should not be used directly by applications.c
+  * In general, SETs should be even and GETs should be odd.*/
+/**@{*/
+#define OPUS_PROJECTION_GET_DEMIXING_MATRIX_GAIN_REQUEST    6001
+#define OPUS_PROJECTION_GET_DEMIXING_MATRIX_SIZE_REQUEST    6003
+#define OPUS_PROJECTION_GET_DEMIXING_MATRIX_REQUEST         6005
+/**@}*/
+
+
+/** @endcond */
+
+/** @defgroup opus_projection_ctls Projection specific encoder and decoder CTLs
+  *
+  * These are convenience macros that are specific to the
+  * opus_projection_encoder_ctl() and opus_projection_decoder_ctl()
+  * interface.
+  * The CTLs from @ref opus_genericctls, @ref opus_encoderctls,
+  * @ref opus_decoderctls, and @ref opus_multistream_ctls may be applied to a
+  * projection encoder or decoder as well.
+  */
+/**@{*/
+
+/** Gets the gain (in dB. S7.8-format) of the demixing matrix from the encoder.
+  * @param[out] x <tt>opus_int32 *</tt>: Returns the gain (in dB. S7.8-format)
+  *                                      of the demixing matrix.
+  * @hideinitializer
+  */
+#define OPUS_PROJECTION_GET_DEMIXING_MATRIX_GAIN(x) OPUS_PROJECTION_GET_DEMIXING_MATRIX_GAIN_REQUEST, __opus_check_int_ptr(x)
+
+
+/** Gets the size in bytes of the demixing matrix from the encoder.
+  * @param[out] x <tt>opus_int32 *</tt>: Returns the size in bytes of the
+  *                                      demixing matrix.
+  * @hideinitializer
+  */
+#define OPUS_PROJECTION_GET_DEMIXING_MATRIX_SIZE(x) OPUS_PROJECTION_GET_DEMIXING_MATRIX_SIZE_REQUEST, __opus_check_int_ptr(x)
+
+
+/** Copies the demixing matrix to the supplied pointer location.
+  * @param[out] x <tt>unsigned char *</tt>: Returns the demixing matrix to the
+  *                                         supplied pointer location.
+  * @param y <tt>opus_int32</tt>: The size in bytes of the reserved memory at the
+  *                              pointer location.
+  * @hideinitializer
+  */
+#define OPUS_PROJECTION_GET_DEMIXING_MATRIX(x,y) OPUS_PROJECTION_GET_DEMIXING_MATRIX_REQUEST, x, __opus_check_int(y)
+
+
+/**@}*/
+
+/** Opus projection encoder state.
+ * This contains the complete state of a projection Opus encoder.
+ * It is position independent and can be freely copied.
+ * @see opus_projection_ambisonics_encoder_create
+ */
+typedef struct OpusProjectionEncoder OpusProjectionEncoder;
+
+
+/** Opus projection decoder state.
+  * This contains the complete state of a projection Opus decoder.
+  * It is position independent and can be freely copied.
+  * @see opus_projection_decoder_create
+  * @see opus_projection_decoder_init
+  */
+typedef struct OpusProjectionDecoder OpusProjectionDecoder;
+
+
+/**\name Projection encoder functions */
+/**@{*/
+
+/** Gets the size of an OpusProjectionEncoder structure.
+  * @param channels <tt>int</tt>: The total number of input channels to encode.
+  *                               This must be no more than 255.
+  * @param mapping_family <tt>int</tt>: The mapping family to use for selecting
+  *                                     the appropriate projection.
+  * @returns The size in bytes on success, or a negative error code
+  *          (see @ref opus_errorcodes) on error.
+  */
+OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_projection_ambisonics_encoder_get_size(
+    int channels,
+    int mapping_family
+);
+
+
+/** Allocates and initializes a projection encoder state.
+  * Call opus_projection_encoder_destroy() to release
+  * this object when finished.
+  * @param Fs <tt>opus_int32</tt>: Sampling rate of the input signal (in Hz).
+  *                                This must be one of 8000, 12000, 16000,
+  *                                24000, or 48000.
+  * @param channels <tt>int</tt>: Number of channels in the input signal.
+  *                               This must be at most 255.
+  *                               It may be greater than the number of
+  *                               coded channels (<code>streams +
+  *                               coupled_streams</code>).
+  * @param mapping_family <tt>int</tt>: The mapping family to use for selecting
+  *                                     the appropriate projection.
+  * @param[out] streams <tt>int *</tt>: The total number of streams that will
+  *                                     be encoded from the input.
+  * @param[out] coupled_streams <tt>int *</tt>: Number of coupled (2 channel)
+  *                                 streams that will be encoded from the input.
+  * @param application <tt>int</tt>: The target encoder application.
+  *                                  This must be one of the following:
+  * <dl>
+  * <dt>#OPUS_APPLICATION_VOIP</dt>
+  * <dd>Process signal for improved speech intelligibility.</dd>
+  * <dt>#OPUS_APPLICATION_AUDIO</dt>
+  * <dd>Favor faithfulness to the original input.</dd>
+  * <dt>#OPUS_APPLICATION_RESTRICTED_LOWDELAY</dt>
+  * <dd>Configure the minimum possible coding delay by disabling certain modes
+  * of operation.</dd>
+  * </dl>
+  * @param[out] error <tt>int *</tt>: Returns #OPUS_OK on success, or an error
+  *                                   code (see @ref opus_errorcodes) on
+  *                                   failure.
+  */
+OPUS_EXPORT OPUS_WARN_UNUSED_RESULT OpusProjectionEncoder *opus_projection_ambisonics_encoder_create(
+    opus_int32 Fs,
+    int channels,
+    int mapping_family,
+    int *streams,
+    int *coupled_streams,
+    int application,
+    int *error
+) OPUS_ARG_NONNULL(4) OPUS_ARG_NONNULL(5);
+
+
+/** Initialize a previously allocated projection encoder state.
+  * The memory pointed to by \a st must be at least the size returned by
+  * opus_projection_ambisonics_encoder_get_size().
+  * This is intended for applications which use their own allocator instead of
+  * malloc.
+  * To reset a previously initialized state, use the #OPUS_RESET_STATE CTL.
+  * @see opus_projection_ambisonics_encoder_create
+  * @see opus_projection_ambisonics_encoder_get_size
+  * @param st <tt>OpusProjectionEncoder*</tt>: Projection encoder state to initialize.
+  * @param Fs <tt>opus_int32</tt>: Sampling rate of the input signal (in Hz).
+  *                                This must be one of 8000, 12000, 16000,
+  *                                24000, or 48000.
+  * @param channels <tt>int</tt>: Number of channels in the input signal.
+  *                               This must be at most 255.
+  *                               It may be greater than the number of
+  *                               coded channels (<code>streams +
+  *                               coupled_streams</code>).
+  * @param streams <tt>int</tt>: The total number of streams to encode from the
+  *                              input.
+  *                              This must be no more than the number of channels.
+  * @param coupled_streams <tt>int</tt>: Number of coupled (2 channel) streams
+  *                                      to encode.
+  *                                      This must be no larger than the total
+  *                                      number of streams.
+  *                                      Additionally, The total number of
+  *                                      encoded channels (<code>streams +
+  *                                      coupled_streams</code>) must be no
+  *                                      more than the number of input channels.
+  * @param application <tt>int</tt>: The target encoder application.
+  *                                  This must be one of the following:
+  * <dl>
+  * <dt>#OPUS_APPLICATION_VOIP</dt>
+  * <dd>Process signal for improved speech intelligibility.</dd>
+  * <dt>#OPUS_APPLICATION_AUDIO</dt>
+  * <dd>Favor faithfulness to the original input.</dd>
+  * <dt>#OPUS_APPLICATION_RESTRICTED_LOWDELAY</dt>
+  * <dd>Configure the minimum possible coding delay by disabling certain modes
+  * of operation.</dd>
+  * </dl>
+  * @returns #OPUS_OK on success, or an error code (see @ref opus_errorcodes)
+  *          on failure.
+  */
+OPUS_EXPORT int opus_projection_ambisonics_encoder_init(
+    OpusProjectionEncoder *st,
+    opus_int32 Fs,
+    int channels,
+    int mapping_family,
+    int *streams,
+    int *coupled_streams,
+    int application
+) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(5) OPUS_ARG_NONNULL(6);
+
+
+/** Encodes a projection Opus frame.
+  * @param st <tt>OpusProjectionEncoder*</tt>: Projection encoder state.
+  * @param[in] pcm <tt>const opus_int16*</tt>: The input signal as interleaved
+  *                                            samples.
+  *                                            This must contain
+  *                                            <code>frame_size*channels</code>
+  *                                            samples.
+  * @param frame_size <tt>int</tt>: Number of samples per channel in the input
+  *                                 signal.
+  *                                 This must be an Opus frame size for the
+  *                                 encoder's sampling rate.
+  *                                 For example, at 48 kHz the permitted values
+  *                                 are 120, 240, 480, 960, 1920, and 2880.
+  *                                 Passing in a duration of less than 10 ms
+  *                                 (480 samples at 48 kHz) will prevent the
+  *                                 encoder from using the LPC or hybrid modes.
+  * @param[out] data <tt>unsigned char*</tt>: Output payload.
+  *                                           This must contain storage for at
+  *                                           least \a max_data_bytes.
+  * @param [in] max_data_bytes <tt>opus_int32</tt>: Size of the allocated
+  *                                                 memory for the output
+  *                                                 payload. This may be
+  *                                                 used to impose an upper limit on
+  *                                                 the instant bitrate, but should
+  *                                                 not be used as the only bitrate
+  *                                                 control. Use #OPUS_SET_BITRATE to
+  *                                                 control the bitrate.
+  * @returns The length of the encoded packet (in bytes) on success or a
+  *          negative error code (see @ref opus_errorcodes) on failure.
+  */
+OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_projection_encode(
+    OpusProjectionEncoder *st,
+    const opus_int16 *pcm,
+    int frame_size,
+    unsigned char *data,
+    opus_int32 max_data_bytes
+) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2) OPUS_ARG_NONNULL(4);
+
+
+/** Encodes a projection Opus frame from floating point input.
+  * @param st <tt>OpusProjectionEncoder*</tt>: Projection encoder state.
+  * @param[in] pcm <tt>const float*</tt>: The input signal as interleaved
+  *                                       samples with a normal range of
+  *                                       +/-1.0.
+  *                                       Samples with a range beyond +/-1.0
+  *                                       are supported but will be clipped by
+  *                                       decoders using the integer API and
+  *                                       should only be used if it is known
+  *                                       that the far end supports extended
+  *                                       dynamic range.
+  *                                       This must contain
+  *                                       <code>frame_size*channels</code>
+  *                                       samples.
+  * @param frame_size <tt>int</tt>: Number of samples per channel in the input
+  *                                 signal.
+  *                                 This must be an Opus frame size for the
+  *                                 encoder's sampling rate.
+  *                                 For example, at 48 kHz the permitted values
+  *                                 are 120, 240, 480, 960, 1920, and 2880.
+  *                                 Passing in a duration of less than 10 ms
+  *                                 (480 samples at 48 kHz) will prevent the
+  *                                 encoder from using the LPC or hybrid modes.
+  * @param[out] data <tt>unsigned char*</tt>: Output payload.
+  *                                           This must contain storage for at
+  *                                           least \a max_data_bytes.
+  * @param [in] max_data_bytes <tt>opus_int32</tt>: Size of the allocated
+  *                                                 memory for the output
+  *                                                 payload. This may be
+  *                                                 used to impose an upper limit on
+  *                                                 the instant bitrate, but should
+  *                                                 not be used as the only bitrate
+  *                                                 control. Use #OPUS_SET_BITRATE to
+  *                                                 control the bitrate.
+  * @returns The length of the encoded packet (in bytes) on success or a
+  *          negative error code (see @ref opus_errorcodes) on failure.
+  */
+OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_projection_encode_float(
+    OpusProjectionEncoder *st,
+    const float *pcm,
+    int frame_size,
+    unsigned char *data,
+    opus_int32 max_data_bytes
+) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2) OPUS_ARG_NONNULL(4);
+
+
+/** Frees an <code>OpusProjectionEncoder</code> allocated by
+  * opus_projection_ambisonics_encoder_create().
+  * @param st <tt>OpusProjectionEncoder*</tt>: Projection encoder state to be freed.
+  */
+OPUS_EXPORT void opus_projection_encoder_destroy(OpusProjectionEncoder *st);
+
+
+/** Perform a CTL function on a projection Opus encoder.
+  *
+  * Generally the request and subsequent arguments are generated by a
+  * convenience macro.
+  * @param st <tt>OpusProjectionEncoder*</tt>: Projection encoder state.
+  * @param request This and all remaining parameters should be replaced by one
+  *                of the convenience macros in @ref opus_genericctls,
+  *                @ref opus_encoderctls, @ref opus_multistream_ctls, or
+  *                @ref opus_projection_ctls
+  * @see opus_genericctls
+  * @see opus_encoderctls
+  * @see opus_multistream_ctls
+  * @see opus_projection_ctls
+  */
+OPUS_EXPORT int opus_projection_encoder_ctl(OpusProjectionEncoder *st, int request, ...) OPUS_ARG_NONNULL(1);
+
+
+/**@}*/
+
+/**\name Projection decoder functions */
+/**@{*/
+
+/** Gets the size of an <code>OpusProjectionDecoder</code> structure.
+  * @param channels <tt>int</tt>: The total number of output channels.
+  *                               This must be no more than 255.
+  * @param streams <tt>int</tt>: The total number of streams coded in the
+  *                              input.
+  *                              This must be no more than 255.
+  * @param coupled_streams <tt>int</tt>: Number streams to decode as coupled
+  *                                      (2 channel) streams.
+  *                                      This must be no larger than the total
+  *                                      number of streams.
+  *                                      Additionally, The total number of
+  *                                      coded channels (<code>streams +
+  *                                      coupled_streams</code>) must be no
+  *                                      more than 255.
+  * @returns The size in bytes on success, or a negative error code
+  *          (see @ref opus_errorcodes) on error.
+  */
+OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_projection_decoder_get_size(
+    int channels,
+    int streams,
+    int coupled_streams
+);
+
+
+/** Allocates and initializes a projection decoder state.
+  * Call opus_projection_decoder_destroy() to release
+  * this object when finished.
+  * @param Fs <tt>opus_int32</tt>: Sampling rate to decode at (in Hz).
+  *                                This must be one of 8000, 12000, 16000,
+  *                                24000, or 48000.
+  * @param channels <tt>int</tt>: Number of channels to output.
+  *                               This must be at most 255.
+  *                               It may be different from the number of coded
+  *                               channels (<code>streams +
+  *                               coupled_streams</code>).
+  * @param streams <tt>int</tt>: The total number of streams coded in the
+  *                              input.
+  *                              This must be no more than 255.
+  * @param coupled_streams <tt>int</tt>: Number of streams to decode as coupled
+  *                                      (2 channel) streams.
+  *                                      This must be no larger than the total
+  *                                      number of streams.
+  *                                      Additionally, The total number of
+  *                                      coded channels (<code>streams +
+  *                                      coupled_streams</code>) must be no
+  *                                      more than 255.
+  * @param[in] demixing_matrix <tt>const unsigned char[demixing_matrix_size]</tt>: Demixing matrix
+  *                         that mapping from coded channels to output channels,
+  *                         as described in @ref opus_projection and
+  *                         @ref opus_projection_ctls.
+  * @param demixing_matrix_size <tt>opus_int32</tt>: The size in bytes of the
+  *                                                  demixing matrix, as
+  *                                                  described in @ref
+  *                                                  opus_projection_ctls.
+  * @param[out] error <tt>int *</tt>: Returns #OPUS_OK on success, or an error
+  *                                   code (see @ref opus_errorcodes) on
+  *                                   failure.
+  */
+OPUS_EXPORT OPUS_WARN_UNUSED_RESULT OpusProjectionDecoder *opus_projection_decoder_create(
+    opus_int32 Fs,
+    int channels,
+    int streams,
+    int coupled_streams,
+    unsigned char *demixing_matrix,
+    opus_int32 demixing_matrix_size,
+    int *error
+) OPUS_ARG_NONNULL(5);
+
+
+/** Intialize a previously allocated projection decoder state object.
+  * The memory pointed to by \a st must be at least the size returned by
+  * opus_projection_decoder_get_size().
+  * This is intended for applications which use their own allocator instead of
+  * malloc.
+  * To reset a previously initialized state, use the #OPUS_RESET_STATE CTL.
+  * @see opus_projection_decoder_create
+  * @see opus_projection_deocder_get_size
+  * @param st <tt>OpusProjectionDecoder*</tt>: Projection encoder state to initialize.
+  * @param Fs <tt>opus_int32</tt>: Sampling rate to decode at (in Hz).
+  *                                This must be one of 8000, 12000, 16000,
+  *                                24000, or 48000.
+  * @param channels <tt>int</tt>: Number of channels to output.
+  *                               This must be at most 255.
+  *                               It may be different from the number of coded
+  *                               channels (<code>streams +
+  *                               coupled_streams</code>).
+  * @param streams <tt>int</tt>: The total number of streams coded in the
+  *                              input.
+  *                              This must be no more than 255.
+  * @param coupled_streams <tt>int</tt>: Number of streams to decode as coupled
+  *                                      (2 channel) streams.
+  *                                      This must be no larger than the total
+  *                                      number of streams.
+  *                                      Additionally, The total number of
+  *                                      coded channels (<code>streams +
+  *                                      coupled_streams</code>) must be no
+  *                                      more than 255.
+  * @param[in] demixing_matrix <tt>const unsigned char[demixing_matrix_size]</tt>: Demixing matrix
+  *                         that mapping from coded channels to output channels,
+  *                         as described in @ref opus_projection and
+  *                         @ref opus_projection_ctls.
+  * @param demixing_matrix_size <tt>opus_int32</tt>: The size in bytes of the
+  *                                                  demixing matrix, as
+  *                                                  described in @ref
+  *                                                  opus_projection_ctls.
+  * @returns #OPUS_OK on success, or an error code (see @ref opus_errorcodes)
+  *          on failure.
+  */
+OPUS_EXPORT int opus_projection_decoder_init(
+    OpusProjectionDecoder *st,
+    opus_int32 Fs,
+    int channels,
+    int streams,
+    int coupled_streams,
+    unsigned char *demixing_matrix,
+    opus_int32 demixing_matrix_size
+) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(6);
+
+
+/** Decode a projection Opus packet.
+  * @param st <tt>OpusProjectionDecoder*</tt>: Projection decoder state.
+  * @param[in] data <tt>const unsigned char*</tt>: Input payload.
+  *                                                Use a <code>NULL</code>
+  *                                                pointer to indicate packet
+  *                                                loss.
+  * @param len <tt>opus_int32</tt>: Number of bytes in payload.
+  * @param[out] pcm <tt>opus_int16*</tt>: Output signal, with interleaved
+  *                                       samples.
+  *                                       This must contain room for
+  *                                       <code>frame_size*channels</code>
+  *                                       samples.
+  * @param frame_size <tt>int</tt>: The number of samples per channel of
+  *                                 available space in \a pcm.
+  *                                 If this is less than the maximum packet duration
+  *                                 (120 ms; 5760 for 48kHz), this function will not be capable
+  *                                 of decoding some packets. In the case of PLC (data==NULL)
+  *                                 or FEC (decode_fec=1), then frame_size needs to be exactly
+  *                                 the duration of audio that is missing, otherwise the
+  *                                 decoder will not be in the optimal state to decode the
+  *                                 next incoming packet. For the PLC and FEC cases, frame_size
+  *                                 <b>must</b> be a multiple of 2.5 ms.
+  * @param decode_fec <tt>int</tt>: Flag (0 or 1) to request that any in-band
+  *                                 forward error correction data be decoded.
+  *                                 If no such data is available, the frame is
+  *                                 decoded as if it were lost.
+  * @returns Number of samples decoded on success or a negative error code
+  *          (see @ref opus_errorcodes) on failure.
+  */
+OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_projection_decode(
+    OpusProjectionDecoder *st,
+    const unsigned char *data,
+    opus_int32 len,
+    opus_int16 *pcm,
+    int frame_size,
+    int decode_fec
+) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(4);
+
+
+/** Decode a projection Opus packet with floating point output.
+  * @param st <tt>OpusProjectionDecoder*</tt>: Projection decoder state.
+  * @param[in] data <tt>const unsigned char*</tt>: Input payload.
+  *                                                Use a <code>NULL</code>
+  *                                                pointer to indicate packet
+  *                                                loss.
+  * @param len <tt>opus_int32</tt>: Number of bytes in payload.
+  * @param[out] pcm <tt>opus_int16*</tt>: Output signal, with interleaved
+  *                                       samples.
+  *                                       This must contain room for
+  *                                       <code>frame_size*channels</code>
+  *                                       samples.
+  * @param frame_size <tt>int</tt>: The number of samples per channel of
+  *                                 available space in \a pcm.
+  *                                 If this is less than the maximum packet duration
+  *                                 (120 ms; 5760 for 48kHz), this function will not be capable
+  *                                 of decoding some packets. In the case of PLC (data==NULL)
+  *                                 or FEC (decode_fec=1), then frame_size needs to be exactly
+  *                                 the duration of audio that is missing, otherwise the
+  *                                 decoder will not be in the optimal state to decode the
+  *                                 next incoming packet. For the PLC and FEC cases, frame_size
+  *                                 <b>must</b> be a multiple of 2.5 ms.
+  * @param decode_fec <tt>int</tt>: Flag (0 or 1) to request that any in-band
+  *                                 forward error correction data be decoded.
+  *                                 If no such data is available, the frame is
+  *                                 decoded as if it were lost.
+  * @returns Number of samples decoded on success or a negative error code
+  *          (see @ref opus_errorcodes) on failure.
+  */
+OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_projection_decode_float(
+    OpusProjectionDecoder *st,
+    const unsigned char *data,
+    opus_int32 len,
+    float *pcm,
+    int frame_size,
+    int decode_fec
+) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(4);
+
+
+/** Perform a CTL function on a projection Opus decoder.
+  *
+  * Generally the request and subsequent arguments are generated by a
+  * convenience macro.
+  * @param st <tt>OpusProjectionDecoder*</tt>: Projection decoder state.
+  * @param request This and all remaining parameters should be replaced by one
+  *                of the convenience macros in @ref opus_genericctls,
+  *                @ref opus_decoderctls, @ref opus_multistream_ctls, or
+  *                @ref opus_projection_ctls.
+  * @see opus_genericctls
+  * @see opus_decoderctls
+  * @see opus_multistream_ctls
+  * @see opus_projection_ctls
+  */
+OPUS_EXPORT int opus_projection_decoder_ctl(OpusProjectionDecoder *st, int request, ...) OPUS_ARG_NONNULL(1);
+
+
+/** Frees an <code>OpusProjectionDecoder</code> allocated by
+  * opus_projection_decoder_create().
+  * @param st <tt>OpusProjectionDecoder</tt>: Projection decoder state to be freed.
+  */
+OPUS_EXPORT void opus_projection_decoder_destroy(OpusProjectionDecoder *st);
+
+
+/**@}*/
+
+/**@}*/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* OPUS_PROJECTION_H */
diff --git a/2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/source/opus/opus_types.h b/2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/source/opus/opus_types.h
new file mode 100644 (file)
index 0000000..7cf6755
--- /dev/null
@@ -0,0 +1,166 @@
+/* (C) COPYRIGHT 1994-2002 Xiph.Org Foundation */
+/* Modified by Jean-Marc Valin */
+/*
+   Redistribution and use in source and binary forms, with or without
+   modification, are permitted provided that the following conditions
+   are met:
+
+   - Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+
+   - Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+
+   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+   ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
+   OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+   PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+   LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+/* opus_types.h based on ogg_types.h from libogg */
+
+/**
+   @file opus_types.h
+   @brief Opus reference implementation types
+*/
+#ifndef OPUS_TYPES_H
+#define OPUS_TYPES_H
+
+#define opus_int         int                     /* used for counters etc; at least 16 bits */
+#define opus_int64       long long
+#define opus_int8        signed char
+
+#define opus_uint        unsigned int            /* used for counters etc; at least 16 bits */
+#define opus_uint64      unsigned long long
+#define opus_uint8       unsigned char
+
+/* Use the real stdint.h if it's there (taken from Paul Hsieh's pstdint.h) */
+#if (defined(__STDC__) && __STDC__ && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || (defined(__GNUC__) && (defined(_STDINT_H) || defined(_STDINT_H_)) || defined (HAVE_STDINT_H))
+#include <stdint.h>
+#  undef opus_int64
+#  undef opus_int8
+#  undef opus_uint64
+#  undef opus_uint8
+   typedef int8_t opus_int8;
+   typedef uint8_t opus_uint8;
+   typedef int16_t opus_int16;
+   typedef uint16_t opus_uint16;
+   typedef int32_t opus_int32;
+   typedef uint32_t opus_uint32;
+   typedef int64_t opus_int64;
+   typedef uint64_t opus_uint64;
+#elif defined(_WIN32)
+
+#  if defined(__CYGWIN__)
+#    include <_G_config.h>
+     typedef _G_int32_t opus_int32;
+     typedef _G_uint32_t opus_uint32;
+     typedef _G_int16 opus_int16;
+     typedef _G_uint16 opus_uint16;
+#  elif defined(__MINGW32__)
+     typedef short opus_int16;
+     typedef unsigned short opus_uint16;
+     typedef int opus_int32;
+     typedef unsigned int opus_uint32;
+#  elif defined(__MWERKS__)
+     typedef int opus_int32;
+     typedef unsigned int opus_uint32;
+     typedef short opus_int16;
+     typedef unsigned short opus_uint16;
+#  else
+     /* MSVC/Borland */
+     typedef __int32 opus_int32;
+     typedef unsigned __int32 opus_uint32;
+     typedef __int16 opus_int16;
+     typedef unsigned __int16 opus_uint16;
+#  endif
+
+#elif defined(__MACOS__)
+
+#  include <sys/types.h>
+   typedef SInt16 opus_int16;
+   typedef UInt16 opus_uint16;
+   typedef SInt32 opus_int32;
+   typedef UInt32 opus_uint32;
+
+#elif (defined(__APPLE__) && defined(__MACH__)) /* MacOS X Framework build */
+
+#  include <sys/types.h>
+   typedef int16_t opus_int16;
+   typedef u_int16_t opus_uint16;
+   typedef int32_t opus_int32;
+   typedef u_int32_t opus_uint32;
+
+#elif defined(__BEOS__)
+
+   /* Be */
+#  include <inttypes.h>
+   typedef int16 opus_int16;
+   typedef u_int16 opus_uint16;
+   typedef int32_t opus_int32;
+   typedef u_int32_t opus_uint32;
+
+#elif defined (__EMX__)
+
+   /* OS/2 GCC */
+   typedef short opus_int16;
+   typedef unsigned short opus_uint16;
+   typedef int opus_int32;
+   typedef unsigned int opus_uint32;
+
+#elif defined (DJGPP)
+
+   /* DJGPP */
+   typedef short opus_int16;
+   typedef unsigned short opus_uint16;
+   typedef int opus_int32;
+   typedef unsigned int opus_uint32;
+
+#elif defined(R5900)
+
+   /* PS2 EE */
+   typedef int opus_int32;
+   typedef unsigned opus_uint32;
+   typedef short opus_int16;
+   typedef unsigned short opus_uint16;
+
+#elif defined(__SYMBIAN32__)
+
+   /* Symbian GCC */
+   typedef signed short opus_int16;
+   typedef unsigned short opus_uint16;
+   typedef signed int opus_int32;
+   typedef unsigned int opus_uint32;
+
+#elif defined(CONFIG_TI_C54X) || defined (CONFIG_TI_C55X)
+
+   typedef short opus_int16;
+   typedef unsigned short opus_uint16;
+   typedef long opus_int32;
+   typedef unsigned long opus_uint32;
+
+#elif defined(CONFIG_TI_C6X)
+
+   typedef short opus_int16;
+   typedef unsigned short opus_uint16;
+   typedef int opus_int32;
+   typedef unsigned int opus_uint32;
+
+#else
+
+   /* Give up, take a reasonable guess */
+   typedef short opus_int16;
+   typedef unsigned short opus_uint16;
+   typedef int opus_int32;
+   typedef unsigned int opus_uint32;
+
+#endif
+
+#endif  /* OPUS_TYPES_H */
index 7da3545..fe414f2 100644 (file)
@@ -30,7 +30,9 @@ class AI_dev(Abstract):
     def __init__(self):
         # if(dev_type != "7PIN"):
         #     set_ipv4_datacall()
-        self.is_wdt = 0 #是否开启看门狗
+        # 看门狗:通过配置启停;默认喂狗点在 AI_dev_timer_event(10s 周期)
+        self.is_wdt = 1 if cfg_bool("WDT_ENABLED", False) else 0
+        self._wdt_timeout_s = cfg_int("WDT_TIMEOUT_S", 30)
         #AT+QDAI=1,0,0,1,0,0,1,1PCM音频输出设置为主模式、短同步、16 kHz采样率和256 kHz时钟频率,采样位深为16bit,使用的时间间隙数量为1,并且使用第一个时间间隙。
         bt_pm_en = cfg_bool("BT_POWER_MOTOR_ENABLED", False)
         pin_bt_on = cfg_attr("PIN_BT_ON_GPIO", None)
@@ -65,7 +67,15 @@ class AI_dev(Abstract):
         self.KeyAI_press = 0
         self.last_ai_key_time = 0#让ai按键不要频繁调用
         if self.is_wdt == 1:
-            self.wdt = WDT(30) #开启看门狗
+            try:
+                # timeout 必须大于喂狗周期(默认 10s),避免误复位
+                t = int(self._wdt_timeout_s or 0)
+                if t < 15:
+                    t = 15
+                self.wdt = WDT(t)
+            except Exception:
+                # 初始化失败时禁用,避免后续 feed 触发异常
+                self.is_wdt = 0
         # self.wdt_timer = osTimer()
         # self.wdt_timer.start(5000, 1, self.wdt_timer_cb)
         
index c69ab65..00ea6db 100644 (file)
@@ -1,93 +1,93 @@
-# -*- coding: utf-8 -*-\r
-"""长对话/PTT 打断上下文:绑定 turn_gen,收敛 is_ruppt_tts 等 legacy 标志。"""\r
-try:\r
-    import utime\r
-except Exception:\r
-    utime = None\r
-\r
-\r
-class InterruptContext(object):\r
-    KIND_NONE = ""\r
-    KIND_LONG_SHORT = "long_short"\r
-    KIND_PTT_SHORT = "ptt_short"\r
-    KIND_PTT_LONG = "ptt_long"\r
-\r
-    def __init__(self):\r
-        self.active = 0\r
-        self.kind = self.KIND_NONE\r
-        self.gen = 0\r
-        self.pending_uplink = 0\r
-        self.drop_tts = 0\r
-        self.ruppt_tts = 0\r
-        self.settled_ms = 0\r
-        self.cancel_deadline_ms = 0\r
-\r
-    def clear(self, vc=None):\r
-        self.active = 0\r
-        self.kind = self.KIND_NONE\r
-        self.gen = 0\r
-        self.pending_uplink = 0\r
-        self.drop_tts = 0\r
-        self.ruppt_tts = 0\r
-        self.settled_ms = 0\r
-        self.cancel_deadline_ms = 0\r
-        if vc is not None:\r
-            self._sync_legacy(vc)\r
-\r
-    def begin(self, vc, kind, pending_uplink=0, cancel_wait_ms=800):\r
-        self.gen = int(getattr(vc, "_vc_turn_gen", 0))\r
-        self.active = 1\r
-        self.kind = kind or self.KIND_NONE\r
-        self.pending_uplink = 1 if pending_uplink else 0\r
-        self.drop_tts = 1\r
-        self.ruppt_tts = 1\r
-        self.settled_ms = 0\r
-        self.cancel_deadline_ms = 0\r
-        if utime and cancel_wait_ms:\r
-            try:\r
-                self.cancel_deadline_ms = utime.ticks_add(utime.ticks_ms(), int(cancel_wait_ms))\r
-            except Exception:\r
-                pass\r
-        self._sync_legacy(vc)\r
-        return self.gen\r
-\r
-    def settle(self, vc):\r
-        """打断开麦完成:清 is_ruppt/drop 以允许新 TTS;保留 settled_ms 供迟到 canceled 判 stale。"""\r
-        if utime:\r
-            try:\r
-                self.settled_ms = utime.ticks_ms()\r
-            except Exception:\r
-                self.settled_ms = 0\r
-        self.pending_uplink = 0\r
-        self.active = 0\r
-        self.drop_tts = 0\r
-        self.ruppt_tts = 0\r
-        self._sync_legacy(vc)\r
-\r
-    def end_drop_window(self, vc):\r
-        """新一轮 TTS 开始:结束丢弃窗口。"""\r
-        self.drop_tts = 0\r
-        self.ruppt_tts = 0\r
-        self.settled_ms = 0\r
-        self.pending_uplink = 0\r
-        self.active = 0\r
-        self._sync_legacy(vc)\r
-\r
-    def is_stale_gen(self, vc):\r
-        return int(getattr(vc, "_vc_turn_gen", 0)) != int(self.gen)\r
-\r
-    def _sync_legacy(self, vc):\r
-        """与 vc_session_io / media 中既有 getattr 兼容。"""\r
-        vc._vc_pending_interrupt_uplink = 1 if self.pending_uplink else 0\r
-        vc.is_ruppt_tts = 1 if self.ruppt_tts else 0\r
-        vc._drop_tts_audio = 1 if self.drop_tts else 0\r
-        vc._long_dialogue_interrupt_settled_ms = int(self.settled_ms or 0)\r
-        vc._vc_cancel_deadline_ms = int(self.cancel_deadline_ms or 0)\r
-\r
-    def load_legacy(self, vc):\r
-        self.pending_uplink = 1 if getattr(vc, "_vc_pending_interrupt_uplink", 0) else 0\r
-        self.ruppt_tts = 1 if getattr(vc, "is_ruppt_tts", 0) else 0\r
-        self.drop_tts = 1 if getattr(vc, "_drop_tts_audio", 0) else 0\r
-        self.settled_ms = int(getattr(vc, "_long_dialogue_interrupt_settled_ms", 0) or 0)\r
-        self.cancel_deadline_ms = int(getattr(vc, "_vc_cancel_deadline_ms", 0) or 0)\r
-        self.active = 1 if (self.pending_uplink or self.ruppt_tts or self.drop_tts) else 0\r
+# -*- coding: utf-8 -*-
+"""长对话/PTT 打断上下文:绑定 turn_gen,收敛 is_ruppt_tts 等 legacy 标志。"""
+try:
+    import utime
+except Exception:
+    utime = None
+
+
+class InterruptContext(object):
+    KIND_NONE = ""
+    KIND_LONG_SHORT = "long_short"
+    KIND_PTT_SHORT = "ptt_short"
+    KIND_PTT_LONG = "ptt_long"
+
+    def __init__(self):
+        self.active = 0
+        self.kind = self.KIND_NONE
+        self.gen = 0
+        self.pending_uplink = 0
+        self.drop_tts = 0
+        self.ruppt_tts = 0
+        self.settled_ms = 0
+        self.cancel_deadline_ms = 0
+
+    def clear(self, vc=None):
+        self.active = 0
+        self.kind = self.KIND_NONE
+        self.gen = 0
+        self.pending_uplink = 0
+        self.drop_tts = 0
+        self.ruppt_tts = 0
+        self.settled_ms = 0
+        self.cancel_deadline_ms = 0
+        if vc is not None:
+            self._sync_legacy(vc)
+
+    def begin(self, vc, kind, pending_uplink=0, cancel_wait_ms=800):
+        self.gen = int(getattr(vc, "_vc_turn_gen", 0))
+        self.active = 1
+        self.kind = kind or self.KIND_NONE
+        self.pending_uplink = 1 if pending_uplink else 0
+        self.drop_tts = 1
+        self.ruppt_tts = 1
+        self.settled_ms = 0
+        self.cancel_deadline_ms = 0
+        if utime and cancel_wait_ms:
+            try:
+                self.cancel_deadline_ms = utime.ticks_add(utime.ticks_ms(), int(cancel_wait_ms))
+            except Exception:
+                pass
+        self._sync_legacy(vc)
+        return self.gen
+
+    def settle(self, vc):
+        """打断开麦完成:清 is_ruppt/drop 以允许新 TTS;保留 settled_ms 供迟到 canceled 判 stale。"""
+        if utime:
+            try:
+                self.settled_ms = utime.ticks_ms()
+            except Exception:
+                self.settled_ms = 0
+        self.pending_uplink = 0
+        self.active = 0
+        self.drop_tts = 0
+        self.ruppt_tts = 0
+        self._sync_legacy(vc)
+
+    def end_drop_window(self, vc):
+        """新一轮 TTS 开始:结束丢弃窗口。"""
+        self.drop_tts = 0
+        self.ruppt_tts = 0
+        self.settled_ms = 0
+        self.pending_uplink = 0
+        self.active = 0
+        self._sync_legacy(vc)
+
+    def is_stale_gen(self, vc):
+        return int(getattr(vc, "_vc_turn_gen", 0)) != int(self.gen)
+
+    def _sync_legacy(self, vc):
+        """与 vc_session_io / media 中既有 getattr 兼容。"""
+        vc._vc_pending_interrupt_uplink = 1 if self.pending_uplink else 0
+        vc.is_ruppt_tts = 1 if self.ruppt_tts else 0
+        vc._drop_tts_audio = 1 if self.drop_tts else 0
+        vc._long_dialogue_interrupt_settled_ms = int(self.settled_ms or 0)
+        vc._vc_cancel_deadline_ms = int(self.cancel_deadline_ms or 0)
+
+    def load_legacy(self, vc):
+        self.pending_uplink = 1 if getattr(vc, "_vc_pending_interrupt_uplink", 0) else 0
+        self.ruppt_tts = 1 if getattr(vc, "is_ruppt_tts", 0) else 0
+        self.drop_tts = 1 if getattr(vc, "_drop_tts_audio", 0) else 0
+        self.settled_ms = int(getattr(vc, "_long_dialogue_interrupt_settled_ms", 0) or 0)
+        self.cancel_deadline_ms = int(getattr(vc, "_vc_cancel_deadline_ms", 0) or 0)
+        self.active = 1 if (self.pending_uplink or self.ruppt_tts or self.drop_tts) else 0
index 2959665..fcc0ab0 100644 (file)
@@ -1,59 +1,59 @@
-# -*- coding: utf-8 -*-\r
-"""媒体车道仲裁:llm_pcm / notify_tts / local(对齐设计稿幻灯片 4)。"""\r
-try:\r
-    import EventMesh\r
-except Exception:\r
-    EventMesh = None\r
-\r
-LANE_LLM_PCM = 1\r
-LANE_NOTIFY = 2\r
-LANE_LOCAL = 3\r
-\r
-\r
-class MediaArbiter(object):\r
-    @staticmethod\r
-    def llm_active(vc):\r
-        if hasattr(vc, "_vc_tts_playback_active"):\r
-            return vc._vc_tts_playback_active()\r
-        return False\r
-\r
-    @staticmethod\r
-    def before_local(vc):\r
-        """local 播:仅打断 llm_pcm;不停录、不断 notify WS。"""\r
-        if not MediaArbiter.llm_active(vc):\r
-            return\r
-        try:\r
-            vc._ptt_hard_mute_local_playback()\r
-            vc.VC_Play_End()\r
-        except Exception:\r
-            pass\r
-\r
-    @staticmethod\r
-    def before_notify(vc):\r
-        """notify TTS:关 llm_pcm + local(设计稿;会话接管仍由 play_tts_cb 建链)。"""\r
-        MediaArbiter.before_local(vc)\r
-        if getattr(vc, "_vc_local_play_busy", None) and vc._vc_local_play_busy():\r
-            try:\r
-                vc.aud.stopAll()\r
-            except Exception:\r
-                pass\r
-        if hasattr(vc, "_vc_stop_downlink_for_interrupt"):\r
-            vc._vc_stop_downlink_for_interrupt("notify")\r
-\r
-    @staticmethod\r
-    def before_llm_pcm(vc):\r
-        """llm 下行:停 local 短音;notify 走 defer 队列。"""\r
-        if getattr(vc, "_vc_local_play_busy", None) and vc._vc_local_play_busy():\r
-            try:\r
-                vc.aud.stopAll()\r
-            except Exception:\r
-                pass\r
-\r
-    @staticmethod\r
-    def montage_allowed(vc):\r
-        """llm 播时缓存/跳过 montage(vc_buttons 已有类似逻辑,集中判断)。"""\r
-        if MediaArbiter.llm_active(vc):\r
-            return False\r
-        if EventMesh and EventMesh.publish("get_vc_tts_playback_active") == 1:\r
-            return False\r
-        return True\r
+# -*- coding: utf-8 -*-
+"""媒体车道仲裁:llm_pcm / notify_tts / local(对齐设计稿幻灯片 4)。"""
+try:
+    import EventMesh
+except Exception:
+    EventMesh = None
+
+LANE_LLM_PCM = 1
+LANE_NOTIFY = 2
+LANE_LOCAL = 3
+
+
+class MediaArbiter(object):
+    @staticmethod
+    def llm_active(vc):
+        if hasattr(vc, "_vc_tts_playback_active"):
+            return vc._vc_tts_playback_active()
+        return False
+
+    @staticmethod
+    def before_local(vc):
+        """local 播:仅打断 llm_pcm;不停录、不断 notify WS。"""
+        if not MediaArbiter.llm_active(vc):
+            return
+        try:
+            vc._ptt_hard_mute_local_playback()
+            vc.VC_Play_End()
+        except Exception:
+            pass
+
+    @staticmethod
+    def before_notify(vc):
+        """notify TTS:关 llm_pcm + local(设计稿;会话接管仍由 play_tts_cb 建链)。"""
+        MediaArbiter.before_local(vc)
+        if getattr(vc, "_vc_local_play_busy", None) and vc._vc_local_play_busy():
+            try:
+                vc.aud.stopAll()
+            except Exception:
+                pass
+        if hasattr(vc, "_vc_stop_downlink_for_interrupt"):
+            vc._vc_stop_downlink_for_interrupt("notify")
+
+    @staticmethod
+    def before_llm_pcm(vc):
+        """llm 下行:停 local 短音;notify 走 defer 队列。"""
+        if getattr(vc, "_vc_local_play_busy", None) and vc._vc_local_play_busy():
+            try:
+                vc.aud.stopAll()
+            except Exception:
+                pass
+
+    @staticmethod
+    def montage_allowed(vc):
+        """llm 播时缓存/跳过 montage(vc_buttons 已有类似逻辑,集中判断)。"""
+        if MediaArbiter.llm_active(vc):
+            return False
+        if EventMesh and EventMesh.publish("get_vc_tts_playback_active") == 1:
+            return False
+        return True
index ee63ccf..4dfcef8 100644 (file)
@@ -1,73 +1,73 @@
-# -*- coding: utf-8 -*-\r
-"""单对话 / 长对话按键策略:入口仅转发 KeyRouter(设计稿表驱动)。"""\r
-try:\r
-    import EventMesh\r
-except Exception:\r
-    EventMesh = None\r
-try:\r
-    from vc_key_router import KeyRouter\r
-except Exception:\r
-    KeyRouter = None\r
-\r
-\r
-class VCModeStrategy(object):\r
-    def on_key_press(self, vc):\r
-        return False\r
-\r
-    def on_key_release(self, vc):\r
-        return False\r
-\r
-    def on_key_long_press(self, vc):\r
-        return False\r
-\r
-\r
-class LongDialogueStrategy(VCModeStrategy):\r
-    def on_key_press(self, vc):\r
-        if KeyRouter is not None:\r
-            return KeyRouter.dispatch_press(vc)\r
-        return False\r
-\r
-    def on_key_release(self, vc):\r
-        return False\r
-\r
-    def on_key_long_press(self, vc):\r
-        if vc._vc_ms_keys_blocked("AI_long_press"):\r
-            return True\r
-        if getattr(vc, "trans_flag", 0) == 1:\r
-            vc.Close()\r
-            EventMesh.publish("start_voice_record", 4)\r
-        vc.AI_key_long_press_flag = 1\r
-        if hasattr(vc, "_vc_key_router_press_cb"):\r
-            vc._vc_enqueue_btn(vc._vc_key_router_press_cb, priority=1)\r
-        else:\r
-            vc._vc_enqueue_btn(vc._ai_key_press_long_dialogue_dispatch, priority=1)\r
-        return True\r
-\r
-\r
-class PTTStrategy(VCModeStrategy):\r
-    def on_key_press(self, vc):\r
-        if KeyRouter is not None:\r
-            return KeyRouter.dispatch_press(vc)\r
-        return True\r
-\r
-    def on_key_release(self, vc):\r
-        vc._ai_key_release_handle_ptt()\r
-        return True\r
-\r
-    def on_key_long_press(self, vc):\r
-        if vc._vc_ms_keys_blocked("AI_long_press"):\r
-            return True\r
-        if getattr(vc, "trans_flag", 0) == 1:\r
-            vc.Close()\r
-            EventMesh.publish("start_voice_record", 4)\r
-        vc.AI_key_long_press_flag = 1\r
-        vc._ptt_idle_latch = 0\r
-        vc._ptt_short_press_stop = 0\r
-        vc._vc_enqueue_btn(vc.ptt_begin, priority=1)\r
-        return True\r
-\r
-\r
-def strategy_for_mode(vc_mode):\r
-    if int(vc_mode) == 1:\r
-        return PTTStrategy()\r
-    return LongDialogueStrategy()\r
+# -*- coding: utf-8 -*-
+"""单对话 / 长对话按键策略:入口仅转发 KeyRouter(设计稿表驱动)。"""
+try:
+    import EventMesh
+except Exception:
+    EventMesh = None
+try:
+    from vc_key_router import KeyRouter
+except Exception:
+    KeyRouter = None
+
+
+class VCModeStrategy(object):
+    def on_key_press(self, vc):
+        return False
+
+    def on_key_release(self, vc):
+        return False
+
+    def on_key_long_press(self, vc):
+        return False
+
+
+class LongDialogueStrategy(VCModeStrategy):
+    def on_key_press(self, vc):
+        if KeyRouter is not None:
+            return KeyRouter.dispatch_press(vc)
+        return False
+
+    def on_key_release(self, vc):
+        return False
+
+    def on_key_long_press(self, vc):
+        if vc._vc_ms_keys_blocked("AI_long_press"):
+            return True
+        if getattr(vc, "trans_flag", 0) == 1:
+            vc.Close()
+            EventMesh.publish("start_voice_record", 4)
+        vc.AI_key_long_press_flag = 1
+        if hasattr(vc, "_vc_key_router_press_cb"):
+            vc._vc_enqueue_btn(vc._vc_key_router_press_cb, priority=1)
+        else:
+            vc._vc_enqueue_btn(vc._ai_key_press_long_dialogue_dispatch, priority=1)
+        return True
+
+
+class PTTStrategy(VCModeStrategy):
+    def on_key_press(self, vc):
+        if KeyRouter is not None:
+            return KeyRouter.dispatch_press(vc)
+        return True
+
+    def on_key_release(self, vc):
+        vc._ai_key_release_handle_ptt()
+        return True
+
+    def on_key_long_press(self, vc):
+        if vc._vc_ms_keys_blocked("AI_long_press"):
+            return True
+        if getattr(vc, "trans_flag", 0) == 1:
+            vc.Close()
+            EventMesh.publish("start_voice_record", 4)
+        vc.AI_key_long_press_flag = 1
+        vc._ptt_idle_latch = 0
+        vc._ptt_short_press_stop = 0
+        vc._vc_enqueue_btn(vc.ptt_begin, priority=1)
+        return True
+
+
+def strategy_for_mode(vc_mode):
+    if int(vc_mode) == 1:
+        return PTTStrategy()
+    return LongDialogueStrategy()
index 781d2cc..d197bb7 100644 (file)
-# -*- coding: utf-8 -*-\r
-"""通知通道:server.started 媒体排队、play_tts 与对话会话分流。"""\r
-try:\r
-    from vc_fsm import VCTurnState\r
-except Exception:\r
-    VCTurnState = None\r
-\r
-import EventMesh\r
-from vc_utils import cfg_bool\r
-\r
-# play_tts 通道\r
-CHANNEL_TAKEOVER = "takeover"   # 断连重连 WS synthesis(IoT 查找设备/模式切换/无对话)\r
-CHANNEL_DEFER = "defer"         # 对话进行中排队,空闲后播放(is_close_VC=0 的 IoT 查询等)\r
-\r
-# TTS 业务种类(_pending_tts_kind / play_tts 第三参数)\r
-TTS_KIND_FIND_DEVICE = "find_device"\r
-TTS_KIND_MODE_SWITCH_LONG = "mode_switch_long"\r
-TTS_KIND_MODE_SWITCH_PTT = "mode_switch_ptt"\r
-TTS_KIND_BOOT_PROMPT = "boot_prompt"\r
-TTS_KIND_PROMPT = "prompt"\r
-\r
-# 须立即占用会话、不可 defer\r
-_TAKEOVER_KINDS = (\r
-    TTS_KIND_FIND_DEVICE,\r
-    TTS_KIND_MODE_SWITCH_LONG,\r
-    TTS_KIND_MODE_SWITCH_PTT,\r
-    TTS_KIND_BOOT_PROMPT,\r
-    TTS_KIND_PROMPT,\r
-)\r
-\r
-# server.started plan op\r
-OP_LONG_UPLINK = "long_uplink"\r
-OP_ALARM_VOICE = "alarm_voice"\r
-OP_VOICE_URL = "voice_url"\r
-OP_SYNTHESIS = "synthesis"\r
-OP_SYNTHESIS_HIS_TIMER = "synthesis_his_timer"\r
-OP_SYNTHESIS_WAIT_TIMER = "synthesis_wait_timer"\r
-OP_SYNTHESIS_WAIT_SINGLE = "synthesis_wait_single"\r
-OP_SYNTHESIS_VOICE_TIMER = "synthesis_voice_timer"\r
-OP_SYNTHESIS_MUSIC_TIMER = "synthesis_music_timer"\r
-OP_IDLE_UPLINK = "idle_uplink"\r
-OP_PTT_ROUND = "ptt_round"\r
-OP_UPLOAD_TONE = "upload_tone"\r
-\r
-\r
-def dialog_session_active(vc):\r
-    """对话占用中:通知类 play_tts 应 defer。"""\r
-    if getattr(vc, "Close_flag", 0) == 1:\r
-        return False\r
-    if getattr(vc, "VC_satrt_flag", 0) != 1:\r
-        return False\r
-    if getattr(vc, "AI_client_VC_isconnect", 0) != 1:\r
-        return False\r
-    if getattr(vc, "VC_Play_flag", 0) == 1:\r
-        return True\r
-    if getattr(vc, "VC_record_state_flag", 0) != 0:\r
-        return True\r
-    if getattr(vc, "music_play_flag", 0) == 1:\r
-        return True\r
-    if VCTurnState is not None and getattr(vc, "fsm", None) is not None:\r
-        t = getattr(vc.fsm, "turn", VCTurnState.Idle)\r
-        if t not in (VCTurnState.Idle, VCTurnState.Listening):\r
-            return True\r
-    return False\r
-\r
-\r
-class NotifyScheduler(object):\r
-    @staticmethod\r
-    def classify_play_tts(vc, is_close_vc):\r
-        if is_close_vc:\r
-            return CHANNEL_TAKEOVER\r
-        k = getattr(vc, "_pending_tts_kind", "") or getattr(vc, "_last_tts_kind", "") or ""\r
-        if k in _TAKEOVER_KINDS:\r
-            return CHANNEL_TAKEOVER\r
-        if dialog_session_active(vc):\r
-            return CHANNEL_DEFER\r
-        return CHANNEL_TAKEOVER\r
-\r
-    @staticmethod\r
-    def plan_on_started(vc, skip_long_uplink=0):\r
-        """替代 vc_session_io started 内 if-elif 媒体分支。"""\r
-        plan = []\r
-\r
-        if (\r
-            not skip_long_uplink\r
-            and getattr(vc, "VC_mode", 0) == 0\r
-            and getattr(vc, "Close_flag", 0) == 0\r
-            and not getattr(vc, "_vc_boot_standby", 0)\r
-        ):\r
-            plan.append({"op": OP_LONG_UPLINK})\r
-\r
-        tts = getattr(vc, "AI_TTS_str", "") or ""\r
-        url = getattr(vc, "AI_new_voice_url", "") or ""\r
-        alarm = getattr(vc, "alarm_play_flag", 0) == 1\r
-        music = getattr(vc, "music_play_flag", 0) == 1\r
-\r
-        if url and alarm:\r
-            plan.append({"op": OP_ALARM_VOICE})\r
-        elif not tts and url and not music:\r
-            plan.append({"op": OP_VOICE_URL})\r
-        elif tts and not url:\r
-            plan.append({"op": OP_SYNTHESIS})\r
-        elif tts and url and not music:\r
-            his = EventMesh.publish("get_history_voice_flag") == 1\r
-            if his:\r
-                wait = EventMesh.publish("get_wait_voice_flag") == 0\r
-                if wait:\r
-                    plan.append({"op": OP_SYNTHESIS_HIS_TIMER})\r
-                else:\r
-                    notice = getattr(vc, "pwk_notice_flag", 0) == 0\r
-                    if notice:\r
-                        plan.append({"op": OP_SYNTHESIS_WAIT_TIMER})\r
-                    else:\r
-                        plan.append({"op": OP_SYNTHESIS_WAIT_SINGLE})\r
-            else:\r
-                plan.append({"op": OP_SYNTHESIS_VOICE_TIMER})\r
-        elif tts and url and music:\r
-            plan.append({"op": OP_SYNTHESIS_MUSIC_TIMER})\r
-        else:\r
-            if cfg_bool("UPLOAD_START_TONE_ENABLED", False):\r
-                plan.append({"op": OP_UPLOAD_TONE})\r
-            if getattr(vc, "VC_mode", 0) == 0:\r
-                plan.append({"op": OP_IDLE_UPLINK})\r
-            else:\r
-                plan.append({"op": OP_PTT_ROUND})\r
-\r
-        return plan\r
+# -*- coding: utf-8 -*-
+"""通知通道:server.started 媒体排队、play_tts 与对话会话分流。"""
+try:
+    from vc_fsm import VCTurnState
+except Exception:
+    VCTurnState = None
+
+import EventMesh
+from vc_utils import cfg_bool
+
+# play_tts 通道
+CHANNEL_TAKEOVER = "takeover"   # 断连重连 WS synthesis(IoT 查找设备/模式切换/无对话)
+CHANNEL_DEFER = "defer"         # 对话进行中排队,空闲后播放(is_close_VC=0 的 IoT 查询等)
+
+# TTS 业务种类(_pending_tts_kind / play_tts 第三参数)
+TTS_KIND_FIND_DEVICE = "find_device"
+TTS_KIND_MODE_SWITCH_LONG = "mode_switch_long"
+TTS_KIND_MODE_SWITCH_PTT = "mode_switch_ptt"
+TTS_KIND_BOOT_PROMPT = "boot_prompt"
+TTS_KIND_PROMPT = "prompt"
+
+# 须立即占用会话、不可 defer
+_TAKEOVER_KINDS = (
+    TTS_KIND_FIND_DEVICE,
+    TTS_KIND_MODE_SWITCH_LONG,
+    TTS_KIND_MODE_SWITCH_PTT,
+    TTS_KIND_BOOT_PROMPT,
+    TTS_KIND_PROMPT,
+)
+
+# server.started plan op
+OP_LONG_UPLINK = "long_uplink"
+OP_ALARM_VOICE = "alarm_voice"
+OP_VOICE_URL = "voice_url"
+OP_SYNTHESIS = "synthesis"
+OP_SYNTHESIS_HIS_TIMER = "synthesis_his_timer"
+OP_SYNTHESIS_WAIT_TIMER = "synthesis_wait_timer"
+OP_SYNTHESIS_WAIT_SINGLE = "synthesis_wait_single"
+OP_SYNTHESIS_VOICE_TIMER = "synthesis_voice_timer"
+OP_SYNTHESIS_MUSIC_TIMER = "synthesis_music_timer"
+OP_IDLE_UPLINK = "idle_uplink"
+OP_PTT_ROUND = "ptt_round"
+OP_UPLOAD_TONE = "upload_tone"
+
+
+def dialog_session_active(vc):
+    """对话占用中:通知类 play_tts 应 defer。"""
+    if getattr(vc, "Close_flag", 0) == 1:
+        return False
+    if getattr(vc, "VC_satrt_flag", 0) != 1:
+        return False
+    if getattr(vc, "AI_client_VC_isconnect", 0) != 1:
+        return False
+    if getattr(vc, "VC_Play_flag", 0) == 1:
+        return True
+    if getattr(vc, "VC_record_state_flag", 0) != 0:
+        return True
+    if getattr(vc, "music_play_flag", 0) == 1:
+        return True
+    if VCTurnState is not None and getattr(vc, "fsm", None) is not None:
+        t = getattr(vc.fsm, "turn", VCTurnState.Idle)
+        if t not in (VCTurnState.Idle, VCTurnState.Listening):
+            return True
+    return False
+
+
+class NotifyScheduler(object):
+    @staticmethod
+    def classify_play_tts(vc, is_close_vc):
+        if is_close_vc:
+            return CHANNEL_TAKEOVER
+        k = getattr(vc, "_pending_tts_kind", "") or getattr(vc, "_last_tts_kind", "") or ""
+        if k in _TAKEOVER_KINDS:
+            return CHANNEL_TAKEOVER
+        if dialog_session_active(vc):
+            return CHANNEL_DEFER
+        return CHANNEL_TAKEOVER
+
+    @staticmethod
+    def plan_on_started(vc, skip_long_uplink=0):
+        """替代 vc_session_io started 内 if-elif 媒体分支。"""
+        plan = []
+
+        if (
+            not skip_long_uplink
+            and getattr(vc, "VC_mode", 0) == 0
+            and getattr(vc, "Close_flag", 0) == 0
+            and not getattr(vc, "_vc_boot_standby", 0)
+        ):
+            plan.append({"op": OP_LONG_UPLINK})
+
+        tts = getattr(vc, "AI_TTS_str", "") or ""
+        url = getattr(vc, "AI_new_voice_url", "") or ""
+        alarm = getattr(vc, "alarm_play_flag", 0) == 1
+        music = getattr(vc, "music_play_flag", 0) == 1
+
+        if url and alarm:
+            plan.append({"op": OP_ALARM_VOICE})
+        elif not tts and url and not music:
+            plan.append({"op": OP_VOICE_URL})
+        elif tts and not url:
+            plan.append({"op": OP_SYNTHESIS})
+        elif tts and url and not music:
+            his = EventMesh.publish("get_history_voice_flag") == 1
+            if his:
+                wait = EventMesh.publish("get_wait_voice_flag") == 0
+                if wait:
+                    plan.append({"op": OP_SYNTHESIS_HIS_TIMER})
+                else:
+                    notice = getattr(vc, "pwk_notice_flag", 0) == 0
+                    if notice:
+                        plan.append({"op": OP_SYNTHESIS_WAIT_TIMER})
+                    else:
+                        plan.append({"op": OP_SYNTHESIS_WAIT_SINGLE})
+            else:
+                plan.append({"op": OP_SYNTHESIS_VOICE_TIMER})
+        elif tts and url and music:
+            plan.append({"op": OP_SYNTHESIS_MUSIC_TIMER})
+        else:
+            if cfg_bool("UPLOAD_START_TONE_ENABLED", False):
+                plan.append({"op": OP_UPLOAD_TONE})
+            if getattr(vc, "VC_mode", 0) == 0:
+                plan.append({"op": OP_IDLE_UPLINK})
+            else:
+                plan.append({"op": OP_PTT_ROUND})
+
+        return plan
index e6aa9b6..12e99ea 100644 (file)
-# -*- coding: utf-8 -*-\r
-"""FOTA / DMP 上报。小程序上的版本,是这个ota接口上报的。"""\r
-try:\r
-    from qp_log import qp_print as print\r
-except Exception:\r
-    pass\r
-import EventMesh\r
-import usys\r
-import utime\r
-import osTimer\r
-import net\r
-import sim\r
-import modem\r
-import request\r
-import constants\r
-import version_util\r
-from misc import Power\r
-import _thread\r
-\r
-def _build_ota_task_url(source_version):\r
-    """OTA 检查任务 URL:default_srv.OTA_TASK_URL_FMT,否则 DMP_BASE + /ota/task。"""\r
-    fmt = getattr(constants, "OTA_TASK_URL_FMT", None) or ""\r
-    if not fmt:\r
-        base = getattr(constants, "DMP_BASE", None) or ""\r
-        if base:\r
-            fmt = base + "/ota/task?deviceId={}&sourceVersion={}"\r
-    if not fmt:\r
-        return None\r
-    return fmt.format(modem.getDevImei(), source_version)\r
-\r
-\r
-def _build_ota_result_url(current_version):\r
-    """OTA 结果上报:DMP_BASE + default_srv.OTA_RESULT_PATH_FMT。"""\r
-    path_fmt = getattr(\r
-        constants,\r
-        "OTA_RESULT_PATH_FMT",\r
-        "/ota/result?deviceId={}&currentVersion={}",\r
-    )\r
-    base = getattr(constants, "DMP_BASE", None) or ""\r
-    return base + path_fmt.format(modem.getDevImei(), current_version)\r
-\r
-\r
-class OTA():\r
-    def __init__(self):\r
-        #EventMesh.subscribe("min_sys_ota",self.min_sys_ota)\r
-        self.downloadFileVoURL1= ""\r
-        self.downloadFileVoURL2= ""\r
-        self.downloadFileVoURLBT=""\r
-        self.BT_ota_size =0\r
-        self.ota_task_id  = None\r
-    #蓝牙升级升级,返回0,没有升级;返回,1有升级,正在执行升级;返回2,电压不够\r
-    def bt_ota(self,event=None,msg=None):\r
-        print("bt_ota_ota")\r
-        signal = net.csqQueryPoll()\r
-        if signal == -1 or sim.getStatus()  != 1:#网络不正常\r
-            print("bt_ota 无 SIM卡!!!!!!!!\r\n")\r
-            return 0\r
-        # return 0\r
-        response = None\r
-        ret_str =0\r
-\r
-        self.downloadFileVoURLBT=""\r
-        try:\r
-            #sourceVersion = versions.Build_Time\r
-            # sourceVersion = "7PIN-"+sourceVersion[:10]+"-"+sourceVersion[11:-3]\r
-            # print("sourceVersion:{}".format(sourceVersion))\r
-            # sourceVersion = sourceVersion.replace(" ", "0")\r
-            # print("sourceVersion2:{}".format(sourceVersion))\r
-            sourceVersion = version_util.get_unified_version()\r
-            print("sourceVersion:{}".format(sourceVersion))\r
-            bt_versions = EventMesh.publish("get_bt_versions")\r
-            if bt_versions == None:\r
-                bt_versions=""\r
-            print("bt_versions:{}".format(bt_versions))\r
-            url = _build_ota_task_url(sourceVersion)\r
-            if not url:\r
-                print("bt_ota: OTA_TASK_URL_FMT 未配置")\r
-                return 0\r
-            print(url)\r
-            response = request.get(url,timeout=5)\r
-            if response.status_code == 200:\r
-                data = response.json()\r
-                print("OTA升级请求:{}".format(data))\r
-                \r
-                if data:\r
-                    code = data.get("code")\r
-                    if code == 20007:\r
-                        file_list = (data.get("data") or {}).get("fileList")\r
-                        if file_list and data.get("data", {}).get("targetVersion") != bt_versions:\r
-                            for fileList in file_list:\r
-                                if fileList.get("fileName") == "update.ufw":\r
-                                    self.BT_ota_size = fileList.get("size", 0)\r
-                                    self.downloadFileVoURLBT = fileList.get("url", "")\r
-                    elif code == 20006:\r
-                        ret_str = 0\r
-            else:\r
-                print("bt_ota get error")\r
-            response.close()\r
-        except Exception as e:\r
-            usys.print_exception(e)\r
-            if response != None:\r
-                response.close()\r
-        \r
-        print("downloadFileVoURLBT{}".format(self.downloadFileVoURLBT))\r
-        print("bt_ota end") \r
-        if self.downloadFileVoURLBT !="":\r
-            battery = EventMesh.publish("get_battery")\r
-            if battery>=40:\r
-                self.ota_timer = osTimer()\r
-                #self.ota_timer.start(15000, 0, self.ota_timer_cb)\r
-                if self.ota_task_id ==None:\r
-                    self.ota_task_id = _thread.start_new_thread(self.ota_task,())\r
-                ret_str =  1  \r
-            else:\r
-                ret_str =  2\r
-        return ret_str\r
-    #小系统升级,返回0,没有升级;返回,1有升级,正在执行升级;返回2,电压不够\r
-    def min_sys_ota(self,event=None,msg=None):\r
-        print("min_sys_ota")\r
-        signal = net.csqQueryPoll()\r
-        if signal == -1 or sim.getStatus()  != 1:#网络不正常\r
-            print("min_sys_ota 无 SIM卡!!!!!!!!\r\n")\r
-            return 0\r
-        # return 0\r
-        response = None\r
-        ret_str =0\r
-        self.downloadFileVoURL1= ""\r
-        self.downloadFileVoURL2= ""\r
-        #self.downloadFileVoURLBT=""\r
-        try:\r
-            sourceVersion = version_util.get_unified_version()\r
-            print("sourceVersion:{}".format(sourceVersion))\r
-            url = _build_ota_task_url(sourceVersion)\r
-            if not url:\r
-                print("min_sys_ota: OTA_TASK_URL_FMT 未配置")\r
-                return 0\r
-            print(url)\r
-            response = request.get(url,timeout=5)\r
-            if response.status_code == 200:\r
-                data = response.json()\r
-                print("OTA升级请求:{}".format(data))\r
-                \r
-                if data:\r
-                    code = data.get("code")\r
-                    if code == 20007:\r
-                        file_list = (data.get("data") or {}).get("fileList")\r
-                        if file_list:\r
-                            for fileList in file_list:\r
-                                name = fileList.get("fileName")\r
-                                url = fileList.get("url", "")\r
-                                if name == "dfota_2.bin":\r
-                                    self.downloadFileVoURL2 = url\r
-                                elif name == "dfota_1.bin":\r
-                                    self.downloadFileVoURL1 = url\r
-                                elif name == "update.ufw":\r
-                                    self.BT_ota_size = fileList.get("size", 0)\r
-                                    self.downloadFileVoURLBT = url\r
-                    elif code == 20006:\r
-                        ret_str = 0\r
-            else:\r
-                print("min_sys_ota get error")\r
-            response.close()\r
-        except Exception as e:\r
-            usys.print_exception(e)\r
-            if response != None:\r
-                response.close()\r
-        \r
-        print("min_sys_ota:downloadFileVoURL1:{},\ndownloadFileVoURL2:{},\ndownloadFileVoURLBT{}".format(self.downloadFileVoURL1,self.downloadFileVoURL2,self.downloadFileVoURLBT))\r
-        print("min_sys_ota end") \r
-        if self.downloadFileVoURL2!="" and self.downloadFileVoURL1!="" :\r
-            battery = EventMesh.publish("get_battery")\r
-            if battery>=40:\r
-                self.ota_timer = osTimer()\r
-                #self.ota_timer.start(15000, 0, self.ota_timer_cb)\r
-                if self.ota_task_id ==None:\r
-                    self.ota_task_id = _thread.start_new_thread(self.ota_task,())\r
-                ret_str =  1  \r
-            else:\r
-                ret_str =  2\r
-        return ret_str\r
-    \r
-    # def ota_timer_cb(self, *args, **kwargs):\r
-    #     EventMesh.publish("publish_AI_btnInfo",{"func":self.usb_event})\r
-\r
-    def ota_task(self):\r
-        import fota\r
-        utime.sleep_ms(15000)\r
-        count = 30#最多等待30秒\r
-        while 1:\r
-            count-=1\r
-            VC_satrt_flag = EventMesh.publish("get_VC_satrt_flag")#获取vc是否在运行\r
-            if VC_satrt_flag == None:\r
-                VC_satrt_flag = 0\r
-            voice_record_satrt_flag = EventMesh.publish("get_voice_record_flag")#获取静默或者语音留言是否在运行\r
-            if voice_record_satrt_flag == None:\r
-                voice_record_satrt_flag = 0\r
-            if VC_satrt_flag == 0 or count<=0 or voice_record_satrt_flag == 0:\r
-                break\r
-            utime.sleep_ms(100)\r
-        if self.downloadFileVoURLBT != "" and self.BT_ota_size != 0:\r
-            count = 5 #重试5次\r
-            while 1:\r
-                count -=1\r
-                ret = EventMesh.publish("bt_ota_run",[self.downloadFileVoURLBT,self.BT_ota_size ]) #升级蓝牙\r
-\r
-                if ret == 0 or count <=0:\r
-                    break\r
-                utime.sleep_ms(1000)\r
-            utime.sleep_ms(1000)\r
-            #EventMesh.publish("rest_TB") #复位蓝牙\r
-            utime.sleep_ms(50000)\r
-            if self.downloadFileVoURL1 == "" and self.downloadFileVoURL2 == "": #cat1没有升级的时候,要重启设备\r
-                Power.powerRestart()\r
-        if self.downloadFileVoURL1 != "" and self.downloadFileVoURL2 != "":\r
-            fota_obj = fota() \r
-            fota_obj.httpDownload(url1=self.downloadFileVoURL1,url2=self.downloadFileVoURL2)\r
-    #ota升级结果返回,开机时调用一次即可\r
-    def ota_result(self,event=None,msg=None):\r
-        response = None\r
-        try:\r
-            currentVersion = version_util.get_unified_version()\r
-            print("currentVersion:{}".format(currentVersion))\r
-            url = _build_ota_result_url(currentVersion)\r
-            print(url)\r
-            response = request.post(url,timeout=5)\r
-            if response.status_code == 200:\r
-                data = response.json()\r
-                print("OTA升级结果上报:{}".format(data))\r
-            else:\r
-                print("ota_result  error!!!!")\r
-                for i in response.text:\r
-                    print(i)\r
-            response.close()\r
-        except Exception as e:\r
-            usys.print_exception(e)\r
-            if response != None:\r
-                response.close()\r
-    #ICCID上传\r
-    def pots_ICCID(self,event=None,msg=None):\r
-        response = None\r
-        try:\r
-            iccid = sim.getIccid()\r
-            if iccid != -1 and len(iccid) > 5:\r
-                print("pots_ICCID:{}".format(iccid))\r
-                #Headers = {'Transfer-Encodong':'chunked'}\r
-                token = EventMesh.publish("get_dev_token")\r
-                headers_T = None\r
-                if token:\r
-                    headers_T = {"bz-dt":"{}".format(token)}\r
-                #http://dmp.raisound.com/bz-api/dev/iccid?deviceId=866610001099679&iccid=89860002192307889057\r
-                url =None\r
-                url = (constants.DMP_BASE + "/dev/iccid?deviceId={}&iccid={}").format(modem.getDevImei(),iccid)\r
-                print("{} H:{}".format(url,headers_T))\r
-                response = request.post(url,headers = headers_T,timeout=5)\r
-                if response.status_code == 200:\r
-                    data = response.json()\r
-                    print("pots_ICCID:{}".format(data))\r
-                else:\r
-                    print("pots_ICCID  error!!!!")\r
-                    for i in response.text:\r
-                        print(i)\r
-                response.close()\r
-        except Exception as e:\r
-            usys.print_exception(e)\r
-            if response != None:\r
-                response.close()\r
+# -*- coding: utf-8 -*-
+"""FOTA / DMP 上报。小程序上的版本,是这个ota接口上报的。"""
+try:
+    from qp_log import qp_print as print
+except Exception:
+    pass
+import EventMesh
+import usys
+import utime
+import osTimer
+import net
+import sim
+import modem
+import request
+import constants
+import version_util
+from misc import Power
+import _thread
+
+def _build_ota_task_url(source_version):
+    """OTA 检查任务 URL:default_srv.OTA_TASK_URL_FMT,否则 DMP_BASE + /ota/task。"""
+    fmt = getattr(constants, "OTA_TASK_URL_FMT", None) or ""
+    if not fmt:
+        base = getattr(constants, "DMP_BASE", None) or ""
+        if base:
+            fmt = base + "/ota/task?deviceId={}&sourceVersion={}"
+    if not fmt:
+        return None
+    return fmt.format(modem.getDevImei(), source_version)
+
+
+def _build_ota_result_url(current_version):
+    """OTA 结果上报:DMP_BASE + default_srv.OTA_RESULT_PATH_FMT。"""
+    path_fmt = getattr(
+        constants,
+        "OTA_RESULT_PATH_FMT",
+        "/ota/result?deviceId={}&currentVersion={}",
+    )
+    base = getattr(constants, "DMP_BASE", None) or ""
+    return base + path_fmt.format(modem.getDevImei(), current_version)
+
+
+class OTA():
+    def __init__(self):
+        #EventMesh.subscribe("min_sys_ota",self.min_sys_ota)
+        self.downloadFileVoURL1= ""
+        self.downloadFileVoURL2= ""
+        self.downloadFileVoURLBT=""
+        self.BT_ota_size =0
+        self.ota_task_id  = None
+    #蓝牙升级升级,返回0,没有升级;返回,1有升级,正在执行升级;返回2,电压不够
+    def bt_ota(self,event=None,msg=None):
+        print("bt_ota_ota")
+        signal = net.csqQueryPoll()
+        if signal == -1 or sim.getStatus()  != 1:#网络不正常
+            print("bt_ota 无 SIM卡!!!!!!!!\r\n")
+            return 0
+        # return 0
+        response = None
+        ret_str =0
+
+        self.downloadFileVoURLBT=""
+        try:
+            #sourceVersion = versions.Build_Time
+            # sourceVersion = "7PIN-"+sourceVersion[:10]+"-"+sourceVersion[11:-3]
+            # print("sourceVersion:{}".format(sourceVersion))
+            # sourceVersion = sourceVersion.replace(" ", "0")
+            # print("sourceVersion2:{}".format(sourceVersion))
+            sourceVersion = version_util.get_unified_version()
+            print("sourceVersion:{}".format(sourceVersion))
+            bt_versions = EventMesh.publish("get_bt_versions")
+            if bt_versions == None:
+                bt_versions=""
+            print("bt_versions:{}".format(bt_versions))
+            url = _build_ota_task_url(sourceVersion)
+            if not url:
+                print("bt_ota: OTA_TASK_URL_FMT 未配置")
+                return 0
+            print(url)
+            response = request.get(url,timeout=5)
+            if response.status_code == 200:
+                data = response.json()
+                print("OTA升级请求:{}".format(data))
+                
+                if data:
+                    code = data.get("code")
+                    if code == 20007:
+                        file_list = (data.get("data") or {}).get("fileList")
+                        if file_list and data.get("data", {}).get("targetVersion") != bt_versions:
+                            for fileList in file_list:
+                                if fileList.get("fileName") == "update.ufw":
+                                    self.BT_ota_size = fileList.get("size", 0)
+                                    self.downloadFileVoURLBT = fileList.get("url", "")
+                    elif code == 20006:
+                        ret_str = 0
+            else:
+                print("bt_ota get error")
+            response.close()
+        except Exception as e:
+            usys.print_exception(e)
+            if response != None:
+                response.close()
+        
+        print("downloadFileVoURLBT{}".format(self.downloadFileVoURLBT))
+        print("bt_ota end") 
+        if self.downloadFileVoURLBT !="":
+            battery = EventMesh.publish("get_battery")
+            if battery>=40:
+                self.ota_timer = osTimer()
+                #self.ota_timer.start(15000, 0, self.ota_timer_cb)
+                if self.ota_task_id ==None:
+                    self.ota_task_id = _thread.start_new_thread(self.ota_task,())
+                ret_str =  1  
+            else:
+                ret_str =  2
+        return ret_str
+    #小系统升级,返回0,没有升级;返回,1有升级,正在执行升级;返回2,电压不够
+    def min_sys_ota(self,event=None,msg=None):
+        print("min_sys_ota")
+        signal = net.csqQueryPoll()
+        if signal == -1 or sim.getStatus()  != 1:#网络不正常
+            print("min_sys_ota 无 SIM卡!!!!!!!!\r\n")
+            return 0
+        # return 0
+        response = None
+        ret_str =0
+        self.downloadFileVoURL1= ""
+        self.downloadFileVoURL2= ""
+        #self.downloadFileVoURLBT=""
+        try:
+            sourceVersion = version_util.get_unified_version()
+            print("sourceVersion:{}".format(sourceVersion))
+            url = _build_ota_task_url(sourceVersion)
+            if not url:
+                print("min_sys_ota: OTA_TASK_URL_FMT 未配置")
+                return 0
+            print(url)
+            response = request.get(url,timeout=5)
+            if response.status_code == 200:
+                data = response.json()
+                print("OTA升级请求:{}".format(data))
+                
+                if data:
+                    code = data.get("code")
+                    if code == 20007:
+                        file_list = (data.get("data") or {}).get("fileList")
+                        if file_list:
+                            for fileList in file_list:
+                                name = fileList.get("fileName")
+                                url = fileList.get("url", "")
+                                if name == "dfota_2.bin":
+                                    self.downloadFileVoURL2 = url
+                                elif name == "dfota_1.bin":
+                                    self.downloadFileVoURL1 = url
+                                elif name == "update.ufw":
+                                    self.BT_ota_size = fileList.get("size", 0)
+                                    self.downloadFileVoURLBT = url
+                    elif code == 20006:
+                        ret_str = 0
+            else:
+                print("min_sys_ota get error")
+            response.close()
+        except Exception as e:
+            usys.print_exception(e)
+            if response != None:
+                response.close()
+        
+        print("min_sys_ota:downloadFileVoURL1:{},\ndownloadFileVoURL2:{},\ndownloadFileVoURLBT{}".format(self.downloadFileVoURL1,self.downloadFileVoURL2,self.downloadFileVoURLBT))
+        print("min_sys_ota end") 
+        if self.downloadFileVoURL2!="" and self.downloadFileVoURL1!="" :
+            battery = EventMesh.publish("get_battery")
+            if battery>=40:
+                self.ota_timer = osTimer()
+                #self.ota_timer.start(15000, 0, self.ota_timer_cb)
+                if self.ota_task_id ==None:
+                    self.ota_task_id = _thread.start_new_thread(self.ota_task,())
+                ret_str =  1  
+            else:
+                ret_str =  2
+        return ret_str
+    
+    # def ota_timer_cb(self, *args, **kwargs):
+    #     EventMesh.publish("publish_AI_btnInfo",{"func":self.usb_event})
+
+    def ota_task(self):
+        import fota
+        utime.sleep_ms(15000)
+        count = 30#最多等待30秒
+        while 1:
+            count-=1
+            VC_satrt_flag = EventMesh.publish("get_VC_satrt_flag")#获取vc是否在运行
+            if VC_satrt_flag == None:
+                VC_satrt_flag = 0
+            voice_record_satrt_flag = EventMesh.publish("get_voice_record_flag")#获取静默或者语音留言是否在运行
+            if voice_record_satrt_flag == None:
+                voice_record_satrt_flag = 0
+            if VC_satrt_flag == 0 or count<=0 or voice_record_satrt_flag == 0:
+                break
+            utime.sleep_ms(100)
+        if self.downloadFileVoURLBT != "" and self.BT_ota_size != 0:
+            count = 5 #重试5次
+            while 1:
+                count -=1
+                ret = EventMesh.publish("bt_ota_run",[self.downloadFileVoURLBT,self.BT_ota_size ]) #升级蓝牙
+
+                if ret == 0 or count <=0:
+                    break
+                utime.sleep_ms(1000)
+            utime.sleep_ms(1000)
+            #EventMesh.publish("rest_TB") #复位蓝牙
+            utime.sleep_ms(50000)
+            if self.downloadFileVoURL1 == "" and self.downloadFileVoURL2 == "": #cat1没有升级的时候,要重启设备
+                Power.powerRestart()
+        if self.downloadFileVoURL1 != "" and self.downloadFileVoURL2 != "":
+            fota_obj = fota() 
+            fota_obj.httpDownload(url1=self.downloadFileVoURL1,url2=self.downloadFileVoURL2)
+    #ota升级结果返回,开机时调用一次即可
+    def ota_result(self,event=None,msg=None):
+        response = None
+        try:
+            currentVersion = version_util.get_unified_version()
+            print("currentVersion:{}".format(currentVersion))
+            url = _build_ota_result_url(currentVersion)
+            print(url)
+            response = request.post(url,timeout=5)
+            if response.status_code == 200:
+                data = response.json()
+                print("OTA升级结果上报:{}".format(data))
+            else:
+                print("ota_result  error!!!!")
+                for i in response.text:
+                    print(i)
+            response.close()
+        except Exception as e:
+            usys.print_exception(e)
+            if response != None:
+                response.close()
+    #ICCID上传
+    def pots_ICCID(self,event=None,msg=None):
+        response = None
+        try:
+            iccid = sim.getIccid()
+            if iccid != -1 and len(iccid) > 5:
+                print("pots_ICCID:{}".format(iccid))
+                #Headers = {'Transfer-Encodong':'chunked'}
+                token = EventMesh.publish("get_dev_token")
+                headers_T = None
+                if token:
+                    headers_T = {"bz-dt":"{}".format(token)}
+                #http://dmp.raisound.com/bz-api/dev/iccid?deviceId=866610001099679&iccid=89860002192307889057
+                url =None
+                url = (constants.DMP_BASE + "/dev/iccid?deviceId={}&iccid={}").format(modem.getDevImei(),iccid)
+                print("{} H:{}".format(url,headers_T))
+                response = request.post(url,headers = headers_T,timeout=5)
+                if response.status_code == 200:
+                    data = response.json()
+                    print("pots_ICCID:{}".format(data))
+                else:
+                    print("pots_ICCID  error!!!!")
+                    for i in response.text:
+                        print(i)
+                response.close()
+        except Exception as e:
+            usys.print_exception(e)
+            if response != None:
+                response.close()
index e4fc981..74961cd 100644 (file)
@@ -1,75 +1,75 @@
-# -*- coding: utf-8 -*-\r
-"""LED 呈现:由 UX 四态 + 覆盖态推导 ai_state(唯一 set_led_state 入口)。"""\r
-try:\r
-    from vc_fsm import VCTurnState\r
-except Exception:\r
-    VCTurnState = None\r
-try:\r
-    from vc_ux import derive_ux_state, UX_RECORDING, UX_THINKING, UX_TTS\r
-except Exception:\r
-    derive_ux_state = None\r
-\r
-\r
-def build_present_state(vc):\r
-    """只读聚合,不写 vc。"""\r
-    st = {\r
-        "mode": int(getattr(vc, "VC_mode", 0)),\r
-        "turn": int(getattr(getattr(vc, "fsm", None), "turn", -1)),\r
-        "force_idle": 0,\r
-        "hold_listening": 0,\r
-        "prefer_off": 0,\r
-        "stream_active": 0,\r
-        "ptt_await_server": 0,\r
-        "override_ai": None,\r
-        "override_prefer_off": 0,\r
-    }\r
-    ov = getattr(vc, "_led_override", None)\r
-    if ov and isinstance(ov, (tuple, list)) and len(ov) >= 1:\r
-        st["override_ai"] = ov[0]\r
-        st["override_prefer_off"] = 1 if (len(ov) > 1 and ov[1]) else 0\r
-    if hasattr(vc, "_ptt_should_force_idle_led") and vc._ptt_should_force_idle_led():\r
-        st["force_idle"] = 1\r
-    if hasattr(vc, "_vc_should_hold_listening_led") and vc._vc_should_hold_listening_led():\r
-        st["hold_listening"] = 1\r
-    if hasattr(vc, "_vc_led_should_standby_idle") and vc._vc_led_should_standby_idle():\r
-        st["force_idle"] = 1\r
-        if hasattr(vc, "_vc_led_standby_prefer_off") and vc._vc_led_standby_prefer_off():\r
-            st["prefer_off"] = 1\r
-    if hasattr(vc, "_vc_tts_playback_active") and vc._vc_tts_playback_active():\r
-        st["stream_active"] = 1\r
-    st["ptt_await_server"] = 1 if getattr(vc, "_ptt_await_server", 0) else 0\r
-    return st\r
-\r
-\r
-def present_to_led_msg(vc, present=None):\r
-    """返回传给 set_led_state 的 dict;不发布。"""\r
-    if present is None:\r
-        present = build_present_state(vc)\r
-    if present.get("override_ai"):\r
-        msg = {"ai_state": present["override_ai"]}\r
-        if present.get("override_prefer_off") or present.get("prefer_off"):\r
-            msg["prefer_off"] = 1\r
-        return msg\r
-    if present.get("force_idle"):\r
-        msg = {"ai_state": "idle"}\r
-        if present.get("prefer_off"):\r
-            msg["prefer_off"] = 1\r
-        return msg\r
-    if present.get("hold_listening"):\r
-        return {"ai_state": "listening"}\r
-    if present.get("ptt_await_server") and int(present.get("mode", 0)) == 1:\r
-        return {"ai_state": "thinking"}\r
-    if present.get("stream_active"):\r
-        return {"ai_state": "playing"}\r
-    if derive_ux_state is not None:\r
-        ux = derive_ux_state(vc)\r
-        if ux == UX_RECORDING:\r
-            return {"ai_state": "listening"}\r
-        if ux == UX_TTS:\r
-            return {"ai_state": "playing"}\r
-        if ux == UX_THINKING:\r
-            return {"ai_state": "thinking"}\r
-    msg = {"ai_state": "idle"}\r
-    if present.get("prefer_off"):\r
-        msg["prefer_off"] = 1\r
-    return msg\r
+# -*- coding: utf-8 -*-
+"""LED 呈现:由 UX 四态 + 覆盖态推导 ai_state(唯一 set_led_state 入口)。"""
+try:
+    from vc_fsm import VCTurnState
+except Exception:
+    VCTurnState = None
+try:
+    from vc_ux import derive_ux_state, UX_RECORDING, UX_THINKING, UX_TTS
+except Exception:
+    derive_ux_state = None
+
+
+def build_present_state(vc):
+    """只读聚合,不写 vc。"""
+    st = {
+        "mode": int(getattr(vc, "VC_mode", 0)),
+        "turn": int(getattr(getattr(vc, "fsm", None), "turn", -1)),
+        "force_idle": 0,
+        "hold_listening": 0,
+        "prefer_off": 0,
+        "stream_active": 0,
+        "ptt_await_server": 0,
+        "override_ai": None,
+        "override_prefer_off": 0,
+    }
+    ov = getattr(vc, "_led_override", None)
+    if ov and isinstance(ov, (tuple, list)) and len(ov) >= 1:
+        st["override_ai"] = ov[0]
+        st["override_prefer_off"] = 1 if (len(ov) > 1 and ov[1]) else 0
+    if hasattr(vc, "_ptt_should_force_idle_led") and vc._ptt_should_force_idle_led():
+        st["force_idle"] = 1
+    if hasattr(vc, "_vc_should_hold_listening_led") and vc._vc_should_hold_listening_led():
+        st["hold_listening"] = 1
+    if hasattr(vc, "_vc_led_should_standby_idle") and vc._vc_led_should_standby_idle():
+        st["force_idle"] = 1
+        if hasattr(vc, "_vc_led_standby_prefer_off") and vc._vc_led_standby_prefer_off():
+            st["prefer_off"] = 1
+    if hasattr(vc, "_vc_tts_playback_active") and vc._vc_tts_playback_active():
+        st["stream_active"] = 1
+    st["ptt_await_server"] = 1 if getattr(vc, "_ptt_await_server", 0) else 0
+    return st
+
+
+def present_to_led_msg(vc, present=None):
+    """返回传给 set_led_state 的 dict;不发布。"""
+    if present is None:
+        present = build_present_state(vc)
+    if present.get("override_ai"):
+        msg = {"ai_state": present["override_ai"]}
+        if present.get("override_prefer_off") or present.get("prefer_off"):
+            msg["prefer_off"] = 1
+        return msg
+    if present.get("force_idle"):
+        msg = {"ai_state": "idle"}
+        if present.get("prefer_off"):
+            msg["prefer_off"] = 1
+        return msg
+    if present.get("hold_listening"):
+        return {"ai_state": "listening"}
+    if present.get("ptt_await_server") and int(present.get("mode", 0)) == 1:
+        return {"ai_state": "thinking"}
+    if present.get("stream_active"):
+        return {"ai_state": "playing"}
+    if derive_ux_state is not None:
+        ux = derive_ux_state(vc)
+        if ux == UX_RECORDING:
+            return {"ai_state": "listening"}
+        if ux == UX_TTS:
+            return {"ai_state": "playing"}
+        if ux == UX_THINKING:
+            return {"ai_state": "thinking"}
+    msg = {"ai_state": "idle"}
+    if present.get("prefer_off"):
+        msg["prefer_off"] = 1
+    return msg
index 3d15455..366edad 100644 (file)
@@ -224,6 +224,28 @@ class AI_VC(VCSessionIoMixin, VCSessionMediaMixin, Abstract):
         except Exception:
             pass
 
+    def _vc_local_vad_pending_merge_active(self):
+        """本地 imsl 句末 defer 后、关麦前:LONG_DIALOGUE_ASR_CONTINUE_MS 内可续说。"""
+        if not self._vc_is_long_dialogue_mode():
+            return False
+        try:
+            if not getattr(self, "_vc_local_vad_endpoint", None) or not self._vc_local_vad_endpoint():
+                return False
+            if getattr(self, "_turn_has_llm_created", 0) == 1:
+                return False
+            if getattr(self, "_vc_ld_merge_frozen", 0) == 1:
+                return False
+            if getattr(self, "_vc_pending_asr_completed_stop", 0) != 1:
+                return False
+            anchor = getattr(self, "_vc_asr_completed_ms", 0)
+            if not anchor:
+                return False
+            if utime.ticks_diff(utime.ticks_ms(), anchor) >= self._vc_asr_continue_merge_ms():
+                return False
+            return True
+        except Exception:
+            return False
+
     def _vc_asr_continue_merge_active(self):
         """asr.completed 后短窗内仍有 asr.result → 同轮续说 merge。"""
         if not self._vc_is_long_dialogue_mode():
@@ -250,6 +272,8 @@ class AI_VC(VCSessionIoMixin, VCSessionMediaMixin, Abstract):
             return False
         if getattr(self, "_vc_vad_had_active_after_silence", 0) == 1:
             return True
+        if hasattr(self, "_vc_local_vad_pending_merge_active") and self._vc_local_vad_pending_merge_active():
+            return True
         return self._vc_asr_continue_merge_active()
 
     def _vc_note_asr_result_activity(self):
@@ -277,6 +301,13 @@ class AI_VC(VCSessionIoMixin, VCSessionMediaMixin, Abstract):
                 return
             if getattr(self, "record_data_save_flag", 0) != 0:
                 return
+            # 本地/ASR merge 已恢复上行:迟到的 asr.completed 勿再 silence_gate
+            if (
+                getattr(self, "_server_vad_silence", 0) == 0
+                and getattr(self, "VC_record_state_flag", 0) >= 2
+            ):
+                print("[VC][VAD] asr.completed skip stop (merge uplink open)")
+                return
             if getattr(self, "_vc_vad_had_active_after_silence", 0) == 1:
                 print("[VC][VAD] asr.completed defer stop (vad pause merged)")
                 return
@@ -315,6 +346,8 @@ class AI_VC(VCSessionIoMixin, VCSessionMediaMixin, Abstract):
                 return
             if getattr(self, "_vc_pending_asr_completed_stop", 0) != 1:
                 return
+            if getattr(self, "_server_vad_silence", 0) == 0:
+                return
             if self._vc_asr_continue_merge_active():
                 return
             comp = getattr(self, "_vc_asr_completed_ms", 0)
index 59b1e7a..ecc0de1 100644 (file)
@@ -1,88 +1,88 @@
-# -*- coding: utf-8 -*-\r
-"""vc_session 子模块共享 import(io / media / core 显式引用,禁止 import * 扩散到业务外)。"""\r
-from common import Abstract\r
-try:\r
-    from qp_log import qp_print as print\r
-except Exception:\r
-    pass\r
-import EventMesh\r
-import uwebsocket\r
-import usys\r
-import gc\r
-import urandom\r
-import uhashlib\r
-import ubinascii\r
-import ujson\r
-import osTimer\r
-import _thread\r
-from queue import Queue\r
-import utime\r
-import audio\r
-import uos\r
-from machine import Pin\r
-import modem\r
-import sim\r
-import net\r
-import base64\r
-import request\r
-import ql_fs\r
-from misc import Power\r
-import ntptime\r
-import machine\r
-import dataCall\r
-import constants\r
-import versions\r
-import version_util\r
-try:\r
-    import vc_config\r
-except Exception:\r
-    vc_config = None\r
-try:\r
-    import vc_text_intent\r
-except Exception:\r
-    vc_text_intent = None\r
-try:\r
-    import VAD\r
-except Exception:\r
-    pass\r
-try:\r
-    import usr.ai_alarm as _ai_alarm\r
-except Exception:\r
-    import ai_alarm as _ai_alarm\r
-from vc_common import (\r
-    dev_type,\r
-    VC_HEARTBEAT_LOG,\r
-    VC_PROTO_GUARDS,\r
-    VC_WS_IO_LOG,\r
-    _VC_KEEPALIVE_RX_EVENTS,\r
-    _vc_out_json_event_meta,\r
-    PRESS_AUDIO_MODE,\r
-)\r
-from vc_proto import (\r
-    vc_proto_build_ws_url,\r
-    vc_proto_pack_wire,\r
-    vc_proto_normalize_server,\r
-    vc_proto_audio_played_enabled,\r
-    vc_proto_log_start_from_v25,\r
-    vc_proto_log_started_server,\r
-    vc_proto_log_synthesis,\r
-    vc_proto_log_tx_wire,\r
-    is_v3,\r
-    vc_ws_custom_ping_enabled,\r
-)\r
-from vc_fsm import (\r
-    VCSessionState,\r
-    VCTurnState,\r
-    VC_TtsRxPhase,\r
-    VCMode,\r
-    VCStateMachine,\r
-    VC_record_TYPE_PCM,\r
-    VC_record_TYPE_AMR,\r
-    VC_play_TYPE_PCM,\r
-    VC_play_TYPE_MP3,\r
-    AI_client_VC_num,\r
-    AI_client_asr_num,\r
-)\r
-from vc_ota import OTA\r
-from vc_utils import num_str_to_chinese\r
-\r
+# -*- coding: utf-8 -*-
+"""vc_session 子模块共享 import(io / media / core 显式引用,禁止 import * 扩散到业务外)。"""
+from common import Abstract
+try:
+    from qp_log import qp_print as print
+except Exception:
+    pass
+import EventMesh
+import uwebsocket
+import usys
+import gc
+import urandom
+import uhashlib
+import ubinascii
+import ujson
+import osTimer
+import _thread
+from queue import Queue
+import utime
+import audio
+import uos
+from machine import Pin
+import modem
+import sim
+import net
+import base64
+import request
+import ql_fs
+from misc import Power
+import ntptime
+import machine
+import dataCall
+import constants
+import versions
+import version_util
+try:
+    import vc_config
+except Exception:
+    vc_config = None
+try:
+    import vc_text_intent
+except Exception:
+    vc_text_intent = None
+try:
+    import VAD
+except Exception:
+    pass
+try:
+    import usr.ai_alarm as _ai_alarm
+except Exception:
+    import ai_alarm as _ai_alarm
+from vc_common import (
+    dev_type,
+    VC_HEARTBEAT_LOG,
+    VC_PROTO_GUARDS,
+    VC_WS_IO_LOG,
+    _VC_KEEPALIVE_RX_EVENTS,
+    _vc_out_json_event_meta,
+    PRESS_AUDIO_MODE,
+)
+from vc_proto import (
+    vc_proto_build_ws_url,
+    vc_proto_pack_wire,
+    vc_proto_normalize_server,
+    vc_proto_audio_played_enabled,
+    vc_proto_log_start_from_v25,
+    vc_proto_log_started_server,
+    vc_proto_log_synthesis,
+    vc_proto_log_tx_wire,
+    is_v3,
+    vc_ws_custom_ping_enabled,
+)
+from vc_fsm import (
+    VCSessionState,
+    VCTurnState,
+    VC_TtsRxPhase,
+    VCMode,
+    VCStateMachine,
+    VC_record_TYPE_PCM,
+    VC_record_TYPE_AMR,
+    VC_play_TYPE_PCM,
+    VC_play_TYPE_MP3,
+    AI_client_VC_num,
+    AI_client_asr_num,
+)
+from vc_ota import OTA
+from vc_utils import num_str_to_chinese
+
index 817161e..ac66dd1 100644 (file)
@@ -568,6 +568,20 @@ class VCSessionMediaMixin:
         self._uplink_mark_end("local.vad.end")
         self._vc_local_vad_send_audio_completed(defer_stop=False)
 
+    def _vc_local_vad_resume_uplink_merge(self, reason="local.pause"):
+        """句中短停后续说:开 silence_gate + 新 audio.create,同轮 turn 墙钟不重置。"""
+        if not self._vc_local_vad_endpoint():
+            return False
+        if getattr(self, "VC_record_state_flag", 0) < 2:
+            return False
+        self._server_vad_silence = 0
+        self._vc_defer_vad_uplink_stop = 0
+        self._vc_pending_asr_completed_stop = 0
+        self._turn_has_vad_silence = 0
+        self._vc_local_vad_send_audio_create()
+        print("[VAD][local] continue merge -> resume uplink ({})".format(reason))
+        return True
+
     def _vc_vad_on_record_pcm(self, record_buf, record_len):
         """录音线程喂本地 imsl VAD;endpoint 模式驱动断句,debug_only 仅打日志。"""
         vad_state = self._vc_vad_feed_record_pcm(record_buf, record_len)
@@ -576,12 +590,11 @@ class VCSessionMediaMixin:
             if prev != 1:
                 print("[VAD][local] speech start")
                 self._vc_local_vad_last_state = 1
-                if self._vc_local_vad_endpoint() and self._vc_asr_continue_merge_active():
-                    self._server_vad_silence = 0
-                    self._vc_defer_vad_uplink_stop = 0
-                    self._vc_pending_asr_completed_stop = 0
-                    self._vc_local_vad_send_audio_create()
-                    print("[VAD][local] continue merge -> resume uplink")
+                if self._vc_local_vad_endpoint():
+                    if self._vc_asr_continue_merge_active():
+                        self._vc_local_vad_resume_uplink_merge("asr.completed")
+                    elif hasattr(self, "_vc_local_vad_pending_merge_active") and self._vc_local_vad_pending_merge_active():
+                        self._vc_local_vad_resume_uplink_merge("local.pause")
             self.VAD_count = int(getattr(self, "VAD_count", 0)) + 1
             if self.VAD_count >= 20 and self._vc_tts_pipeline_busy():
                 print("[VAD][local] speech hold {} frames (~400ms) interrupt".format(
index 0d0060f..112d363 100644 (file)
@@ -1,47 +1,47 @@
-# -*- coding: utf-8 -*-\r
-"""设计稿 UX 四态:idle / recording / thinking / tts(与 FSM 八态解耦)。"""\r
-try:\r
-    from vc_fsm import VCTurnState\r
-except Exception:\r
-    VCTurnState = None\r
-\r
-UX_IDLE = 0\r
-UX_RECORDING = 1\r
-UX_THINKING = 2\r
-UX_TTS = 3\r
-\r
-_UX_NAMES = ("idle", "recording", "thinking", "tts")\r
-\r
-\r
-def ux_name(ux):\r
-    i = int(ux)\r
-    if 0 <= i < len(_UX_NAMES):\r
-        return _UX_NAMES[i]\r
-    return "idle"\r
-\r
-\r
-def derive_ux_state(vc):\r
-    """对齐 录音上传与播放-演示文稿:按键表与 LED 均基于此四态。"""\r
-    if hasattr(vc, "_vc_tts_playback_active") and vc._vc_tts_playback_active():\r
-        return UX_TTS\r
-    if getattr(vc, "VC_record_state_flag", 0) != 0:\r
-        return UX_RECORDING\r
-    if int(getattr(vc, "_ptt_await_server", 0)) == 1:\r
-        return UX_THINKING\r
-    if VCTurnState is not None:\r
-        t = getattr(getattr(vc, "fsm", None), "turn", VCTurnState.Idle)\r
-        # PTT 轮间:FSM 仍 Playing 但本地已停播 → 设计 idle\r
-        if int(getattr(vc, "VC_mode", 0)) == 1 and t in (\r
-            VCTurnState.Playing,\r
-            VCTurnState.AwaitPlayedAck,\r
-        ):\r
-            return UX_IDLE\r
-        if t == VCTurnState.Thinking:\r
-            return UX_THINKING\r
-        if t in (\r
-            VCTurnState.TtsReceiving,\r
-            VCTurnState.Playing,\r
-            VCTurnState.AwaitPlayedAck,\r
-        ):\r
-            return UX_TTS\r
-    return UX_IDLE\r
+# -*- coding: utf-8 -*-
+"""设计稿 UX 四态:idle / recording / thinking / tts(与 FSM 八态解耦)。"""
+try:
+    from vc_fsm import VCTurnState
+except Exception:
+    VCTurnState = None
+
+UX_IDLE = 0
+UX_RECORDING = 1
+UX_THINKING = 2
+UX_TTS = 3
+
+_UX_NAMES = ("idle", "recording", "thinking", "tts")
+
+
+def ux_name(ux):
+    i = int(ux)
+    if 0 <= i < len(_UX_NAMES):
+        return _UX_NAMES[i]
+    return "idle"
+
+
+def derive_ux_state(vc):
+    """对齐 录音上传与播放-演示文稿:按键表与 LED 均基于此四态。"""
+    if hasattr(vc, "_vc_tts_playback_active") and vc._vc_tts_playback_active():
+        return UX_TTS
+    if getattr(vc, "VC_record_state_flag", 0) != 0:
+        return UX_RECORDING
+    if int(getattr(vc, "_ptt_await_server", 0)) == 1:
+        return UX_THINKING
+    if VCTurnState is not None:
+        t = getattr(getattr(vc, "fsm", None), "turn", VCTurnState.Idle)
+        # PTT 轮间:FSM 仍 Playing 但本地已停播 → 设计 idle
+        if int(getattr(vc, "VC_mode", 0)) == 1 and t in (
+            VCTurnState.Playing,
+            VCTurnState.AwaitPlayedAck,
+        ):
+            return UX_IDLE
+        if t == VCTurnState.Thinking:
+            return UX_THINKING
+        if t in (
+            VCTurnState.TtsReceiving,
+            VCTurnState.Playing,
+            VCTurnState.AwaitPlayedAck,
+        ):
+            return UX_TTS
+    return UX_IDLE
index 16670f1..cb2852d 100644 (file)
@@ -46,5 +46,6 @@
 //#define CONFIG_JPEG 1\r
 #define CONFIG_CAMERA_SAVEPHOTOS 1\r
 #define CONFIG_VAD 1\r
+#define CONFIG_OPUS 1\r
 //闂傚倸鍊搁崐鎼佸磹閹间礁纾归柟闂寸绾惧綊鏌熼梻瀵割槮缁炬儳缍婇弻鐔兼⒒鐎靛壊妲紒鐐劤缂嶅﹪寮婚悢鍏尖拻閻庨潧澹婂Σ顔剧磼閻愵剙鍔ょ紓宥咃躬瀵鎮㈤崗灏栨嫽闁诲酣娼ф竟濠偽i鍓х<闁绘劦鍓欓崝銈囩磽瀹ュ拑韬€殿喖顭烽幃銏ゅ礂鐏忔牗瀚介梺璇查叄濞佳勭珶婵犲伣锝夘敊閸撗咃紲闂佺粯鍔﹂崜娆撳礉閵堝洨纾界€广儱鎷戦煬顒傗偓娈垮枛椤兘骞冮姀銈呯閻忓繑鐗楃€氫粙姊虹拠鏌ュ弰婵炰匠鍕彾濠电姴浼i敐澶樻晩闁告挆鍜冪床闂備胶绮崝锕傚礈濞嗘挸绀夐柕鍫濇川绾剧晫鈧箍鍎遍幏鎴︾叕椤掑倵鍋撳▓鍨灈妞ゎ厾鍏樺顐﹀箛椤撶偟绐炴繝鐢靛Т鐎氱兘宕ラ崨瀛樷拻濞达絿鎳撻婊呯磼鐠囨彃鈧潡鐛径濞炬闁靛繒濮烽鎺旂磽閸屾瑧鍔嶆い顓炴喘瀹曘垽鏌嗗鍡忔嫼闂傚倸鐗婄粙鎾存櫠閺囥垺鐓欓柛鎰叀閸欏嫭銇勯姀鈩冾棃妞ゃ垺锕㈡慨鈧柨娑樺楠炴劙姊虹拠鑼闁稿绋掗弲鍫曟寠婢规繆娅i埀顒佺⊕鑿уù婊勭矒閺屾洝绠涙繝鍌氣拤缂備讲鍋撻悗锝庡枟閻撴稑霉閿濆洦鍤€濠殿喖绉堕埀顒冾潐濞叉牕鐣烽鍕厺閹肩补鍨鹃悢鐓庣畳鐎广儱妫楅崫鐑樻叏婵犲偆鐓肩€规洘甯掗埢搴ㄥ箳閹存繂鑵愬┑锛勫亼閸娿倝宕㈡總鍛婂亱闊洦绋戠粻鏍ㄣ亜閺囨浜惧銈冨灪濞茬喖寮崘顔肩劦妞ゆ帒鍊婚惌鍡楊熆閼搁潧濮囩紒鐘侯潐缁绘盯鏁愭惔鈥愁潻婵犲痉銈呬汗缂佽鲸甯¢幃鈺呮濞戞瑧浜梻浣告惈閻ジ宕伴弽褜娼栭柤濮愬€愰崑鎾绘濞戞﹩妫屽┑鈥虫▕閸犳氨妲愰幘瀵哥懝闁搞儜鍌滅泿缂傚倷绀侀ˇ顖滅礊婵犲偆鍤曢悹鍥ㄧゴ濡插牓鏌曡箛濠冩珕闁哄懏绻堝娲箰鎼达絿鐣靛┑鐐茬湴閸旀垿骞冮悙顒傞檮闁告稑艌閹风儤绻涢弶鎴濇倯闁荤啙鍥х濞寸厧鐡ㄩ悡娆戠棯閺夊灝鑸瑰ù婊€鍗抽弻娑㈠煛閸愩劋妲愬Δ鐘靛仜椤戝寮崘顔肩劦妞ゆ帒瀚崑鍌炴煥閻斿搫校闁绘挻娲熼弻宥夊煛娴e憡鐏撳┑鐐茬墛閿氶棁澶愭煟濡寧鐝悘蹇ラ檮閹便劍绻濋崘鈹夸虎濠碘槅鍋勯崯顐﹀煡婢跺ň鏋庢俊顖涙た濡捇姊婚崒娆掑厡妞ゎ厼鐗撻、鏍幢濞戞顔夐梺鎼炲劀鐏炲墽绋侀梻浣瑰劤缁绘锝炴径鎰;婵せ鍋撻柡灞界Ч婵$兘濡烽妷銉ь儓濠电姰鍨奸~澶娒洪弽顓炵厴闁硅揪闄勯崐椋庘偓鐟板閸犳牕鈻撻懜鐢电瘈婵炲牆鐏濋弸鐔兼煙閸涘﹤鈻曢柕鍡曠窔瀵粙顢橀悙鑼垛偓鍨攽閻愭潙鐏︽い顓炴喘閺佸秴鈻庨幘绮规嫼濠殿喚鎳撳ú銈夋倶閳哄懏鐓欓悹鍥囧懐鐦堥梺璇″櫙缁绘繃淇婇悜鑺ユ櫆闁告挆鍛潓闂傚倸鍊搁崐鎼佹偋婵犲嫮鐭欓柟鐑橆檪婢舵劕顫呴幒铏濠婂牆绠规繛锝庡墮閻掔儤绻涢崼鐔割棃婵☆偂鐒﹀鍕偓锝庡墰閻﹀牊绻濋悽闈浶㈤柛濠冩倐椤㈡棃顢曢妶鍥╋紲闂佺粯锚绾绢厽鏅舵潏鈺冪<閺夊牄鍔岀粭褏绱掓潏銊ョ瑨閾伙綁鏌涜箛鏇炲付闁搞劑浜堕弻锝嗘償閵堝孩缍堝┑鐐村絻缁绘ê鐣峰┑瀣闁挎棁銆€閸嬫挻鎷呴崜鍙夊缓闂侀€炲苯澧存鐐插暣婵偓闁靛牆鎳庣粣娑欑節閻㈤潧孝闁稿﹦鏁诲畷鎴﹀箻缂佹鍙嗛柣搴岛閺呮繄绮诲鑸碘拺缂備焦锚婵箑霉濠婂嫮鐭掗柛鈹惧亾濡炪倖鍨堕崕鎶藉焵椤掍胶澧辩紒顔碱儏椤撳ジ宕担鍝勫汲闂備礁澹婇崑鍛崲閸曨垰钃熼柛顐犲劜閻撶喖骞栧ǎ顒€鐏柍顖涙礋閹洦寰勫畝鈧壕濂告偣閸パ冪骇妞ゃ儯鍨介弻锛勪沪閸撗勫垱濡炪們鍨哄ú鐔煎极閹版澘骞㈡繛鍡樕戣ⅲ闂備浇顕уù鐑藉箠閹捐绠熼柨娑樺瀹曟煡鏌涢幇闈涙灈濡楀懘姊洪崨濠冨闁搞劋鍗冲畷姗€鍩€椤掑嫭鈷戦梻鍫熶腹濞戙垹宸濇い鏍ㄨ壘缁犲姊婚崒姘偓椋庣矆娓氣偓楠炴顭ㄩ崼婵堬紱濠电偞鍨崹娲磻婢舵劖鐓熼柟鎯у暱閻︺劍绻涢崗鑲╁⒈缂佽鲸鎸婚幏鍛存嚃閳╁啫鐏﹂柛鎺戯躬楠炴﹢顢欓悾灞藉及闂傚鍋勫ú锕€煤濮椻偓瀹曠敻鍩€椤掑倻纾藉ù锝堫嚃濞堬絿绱掔紒妯肩畵妞ゎ偄绻愮叅妞ゅ繐瀚畵宥咁渻閵堝棙瀵欓柛娑卞幖姝囧┑鐘垫暩婵參骞忛崘顔肩<婵犲﹤鎳愰崢顖炴煟鎼淬値娼愭繛鍙壝悾婵嬪箹娴e搫绁﹂梺鍦劋閸わ箓寮埀顒傛崲濠靛绀冮柍鍝勫€昏ぐ銊︾節閻㈤潧校妞ゆ梹鐗犲畷鏉课旈崨顏佸亾閿曞倸鐐婃い鎺嗗亾闁稿被鍔庨幉绋款吋婢跺﹦鍘洪梺鍦亾濡炲潡寮崘顔界叆闁哄啫娉﹂幒妤€绠繛宸簼閳锋垿鏌涘☉姗堝姛闁宠棄顦甸弻銊╁即濡搫濮曢悗鍨緲鐎氭澘鐣烽悢纰辨晬婵炴垶鑹鹃獮鍫ユ⒒娓氣偓濞佳団€﹂鐘典笉闁规璇差槺閳ь剨缍嗛崜娑氬閸忕浜滈柡鍐e亾妞ゆ垶鐟╁畷闈涒枎閹惧鍘撻梺鑺ッˇ钘壩i幖浣圭厓閻犲洦鐓¢妤併亜閹剧偨鍋㈢€规洜鍠栭、姗€鎮╅搹顐g彜闂傚倸鍊搁崐鎼佸磹妞嬪海鐭嗗ù锝夋交閼板潡姊洪鈧粔瀵稿閸ф鐓忛柛顐g箥濡叉悂鏌涢妸銉モ偓鍧楀蓟濞戔懇鈧箓骞嬪┑鍛晼婵$偑鍊愰弲婊堟偂閿熺姴钃熼柨婵嗩槸缁犳稒銇勯弮鍌氬付濠碘剝妞藉铏圭磼濡闉嶅┑鐐跺皺閸犳牕顕f繝姘櫜濠㈣泛锕ラˉ婵嗏攽閻愬弶顥犻柛瀣崌閹潡宕堕浣叉嫼缂備礁顑呴悘婵嬵敆閵忊剝鍙忓┑鐘插€荤粔鐑橆殽閻愯尙澧﹀┑鈩冩倐閺佸倿宕滆濡插洭姊绘担鍛婂暈婵炶绠撳畷銏ゆ嚃閳哄啰鐣堕梺璺ㄥ枔婵敻鍩涢幋锔界厽闁绘柨鎲$欢鍙変繆閹绘帩鐓奸柡宀€鍠栭幖褰掝敃閵忕媭娼曢梻浣告啞鐢鏁幒妤€鐓濋幖娣妼缁犺崵鈧娲栧ù鍌炲船閸洘鈷戠痪顓炴噹娴滃綊鎮跺☉鏍у姎妞ゎ剙锕ㄩˇ鍦偓瑙勬礃閸ㄥ潡鐛Ο濂借櫣绱掑Ο缁樼彨闂傚倷鑳剁划顖炲礉濡ゅ啯鍋橀柕澶嗘櫅缁狀垱绻涘顔荤凹闁绘挾鍠栭弻锝呂熼崫鍕獓缂備讲鍋撶€光偓閸曨剛鍘撻悷婊勭矒瀹曟粌鈹戦崱蹇旂€洪梺鍝勬储閸ㄦ椽宕愰崼鏇熺厱妞ゆ劗濮撮崝婊堟煃闁垮鐏╃紒杈ㄥ笧閳ь剨缍嗘禍婊堟儍閿熺姵鐓涢柍褜鍓氱换婵嗩潩椤撶姴骞嶆俊鐐€栧濠氬储瑜旈崺鈧い鎺嗗亾婵炲皷鈧磭鏆﹂悷娆忓閸嬪懘鏌涢幇銊︽珕婵炲懎娲铏圭矙閹稿孩鎷卞┑顔角滈崝鎴濈暦閹扮増鍊风€瑰壊鍠楃€靛矂姊洪棃娑氬闁硅櫕鍔楃划濠氬箥椤斿墽锛滄繝銏f硾閺堫剟寮抽鍕厱闁崇懓鐏濋悘鈺呮煟閿濆棛绠炵€规洜鍠栭、妤呭磼濮橆剛顔戦梻鍌欒兌閹虫捇宕ョ€n喗鍋╂い蹇撶墕閺勩儵鏌涢弴銊ョ仩闁汇値鍣i悡顐﹀炊閵娧€濮囬梺缁樻尰濞茬喖寮婚敐鍛傜喓鎷犻幓鎺濇浇婵犵數鍋涢悧濠勫垝瀹ュ鈧啴濡烽埡鍌氣偓鐑芥煙缂佹ê绗氭繛鍫濐煼閹鎲撮崟顒傤槰闁汇埄鍨辩敮锟犳晲閻愭祴鏀介柛銉e妿缁夊爼姊洪棃娑辩叚閻庨潧鐭傚畷顖涙償閵婏腹鎷婚梺绋挎湰閻熝囁囬敂鐣岀瘈闁逞屽墴閺屽棗顓奸崨顖ょ吹闂備線娼ч悧鍡浰囬銏犵劦妞ゆ巻鍋撻柛鐔告綑閻g兘宕¢悙鈺傤潔濠碘槅鍨抽妴瀣椤斿皷鏀介柨娑樺娴犳粍銇勯幋婵囧櫣闂囧顪冪€n亪顎楁い銉﹀哺閺屾稖绠涢弴銊ュ妴婵炲瓨绮嶇划鎾诲蓟閿熺姴绀冮柨婵嗘噸婢规洘淇婇悙顏勨偓鏍垂閸洘鍋¢柕澶嗘杹閳ь剨绠撳畷鍫曨敆閳ь剛绮诲☉銏$厽婵°倐鍋撻柣妤€妫濋崺鈧い鎺嗗亾闁诲繑宀搁獮鍫ュΩ閵夊海鍠栧畷顐﹀礋椤掍胶妲繝鐢靛仜閻°劎鍒掔仦鏂よ€块弶鍫氭櫆椤洟鏌熼悜妯诲鞍缂傚秴娲弻鏇熺節韫囨洜鏆犵紒鍓у亾婵炲﹪骞冨Δ鍐╁枂闁告洦鍓涢ˇ銊╂煟閵忊晛鐏¢悽顖ょ節瀹曟椽濮€閳╁啫鍔呴梺闈涱焾閸庢娊顢樺ú顏呪拺闁圭娴风粻鎾寸箾鐏炲倸濡奸柣锝囧厴瀹曞ジ寮撮悢鍙夊闂備胶顭堥張顒勬偡瑜斿畷婵嗩吋婢跺鍘靛銈嗘閸嬫劙宕洪敐鍥e亾鐟欏嫭绀冪紒璇插缁傛帡鏁冮崒娑樹患闁诲繒鍋熼崑鎾活敊閺囩喍绻嗛柣鎰典簻閳ь剚鐗滈弫顕€骞掑Δ鈧壕鍦磼鐎n偒鍎ラ柛銈嗘礋閺岋紕浠︾拠鎻掑闂佹娊鏀辩敮鎺楁箒闂佹寧绻傞幊蹇涘疮閻愮儤鐓欐い鏍ㄦ皑婢с垻绱掓潏銊ョ瑲鐎垫澘瀚埀顒婄秵閸撴瑥顕i妸鈺傚€甸悷娆忓缁€鍐磼鐠囨彃鈧潡銆佸Ο鑽ら檮缂佸鐏濈粣娑橆渻閵堝懐绠伴柟铏姍閸┾偓妞ゆ帊鐒﹂妵婵囨叏婵犲懏顏犵紒杈ㄥ笒椤粓宕卞▎蹇撔ㄧ紓鍌氬€风欢锟犲闯椤曗偓瀹曞綊宕奸弴鐐电暫闂佺偨鍎查弸濂稿几鎼淬劍鐓欓悗鐢殿焾鍟搁梺鎸庣⊕缁诲啰鎹㈠☉娆愮秶闁告挆鍐ㄧ厒婵$偑鍊ら崑鍛存偋閻樻眹鈧線寮崼婵嗚€垮┑鐐叉缁绘劗鎲撮敃鈧埞鎴炲箠闁稿ě鍛筏濞寸姴顑呴悿顔姐亜閺嶎偄浠﹂柛瀣€块弻娑㈠箛閸忓摜鍑归梺鍝ュУ閸旀牜鎹㈠┑鍥╃瘈闁稿本绮岄。铏圭磽娴f彃浜鹃梺鍓插亞閸犳劙宕h箛鏂剧箚妞ゆ牗纰嶉崑銉╂煕濠靛洦銇濋柡宀嬬節瀹曞崬螣閼测晝鍘滈梻浣告惈閻ジ宕伴弽顓炵畺婵犲﹤鍠氬銊╂煕閳╁喛渚涢柛姘噽缁辨捇宕掑顑藉亾閸濄儳鐭撻柣銏犳啞閸嬪淇婇妶鍛殲鐎规洖寮剁换婵嬫濞戝崬鍓卞銈冨劚閻楀﹦鎹㈠☉銏犵婵犻潧妫滈崺鐐烘⒑閸涘﹥宕岀紒鐘崇墪椤繘鎮滃Ο璇差潯闂佽顔栭崳顔嘉i灏栨斀闁绘劘灏欏﹢鎾煕閺冣偓閸ㄥ潡鎮伴钘夌窞闁归偊鍓欑粣娑欑節閻㈤潧孝闁哥噥鍋婂畷婵嬪川鐎涙ǚ鎷洪梻鍌氱墛娓氭鎮¢鐘电<闁绘ê鍟块悘锔剧磼閸屾稑娴柟顔界懇椤㈡宕掑搴℃櫗闂傚倷绀佸﹢閬嶅磻閹炬剚鐒芥繛鍡樻尰閸婅法鎲搁悧鍫濈瑲闁绘挻娲熼幃妤呮晲鎼粹€茬凹閻庤娲栭惌鍌炲蓟閳ュ磭鏆嗛柍褜鍓熷畷浼村冀椤撴壕鍋撴担绯曟瀻闁瑰濞€閳瑰繘鏌f惔顖滅У闁稿妫濆鎶藉Ψ閳哄倵鎷绘繛杈剧到閹芥粓鏁嶅鍥╃<妞ゆ洖鎳庨悘锔筋殽閻愭潙鐏寸€规洘鍎奸ˇ鎾煛閸☆厼顩柟鍙夋倐閹囧醇濠靛懎鍨旈梻浣芥〃缁€渚€鏁冮鍫濊摕闁挎繂顦伴弲鏌ユ煕濞戝崬寮炬繛鍫弮濮婅櫣娑甸崨顓犳闂佺顑嗛幐楣冨箲閵忕姭鏀介悗锝庡亜娴犳椽姊婚崒姘卞闁告巻鍋撻梺闈涱槴閺呮粓鎮″☉妯忓綊鏁愰崼顐g秷闂佺锕ラ崝妤呭焵椤掑喚娼愭繛鍙夛耿瀹曞綊鎮界粙璺ㄥ弨婵犮垼鍩栭崝鏇綖閸涘瓨鐓冮柍杞扮閺嗙偤鏌e┑鍥╁⒌婵﹦绮粭鐔煎焵椤掆偓椤洩顦圭弧鎾绘煃瑜滈崜娆撳煘閹达箑鐏抽柧蹇e亜閺嬬娀姊虹化鏇熸珖闁稿鐩、妯荤附缁嬪灝绐涘銈呯箰閹冲繘寮堕幖浣光拻濞达綀娅g敮娑㈡煥濮樻墎鍋撳▓鍨灕闁糕晜鐗曢銉╁礋椤栨氨顦板銈嗙墬缁嬫捇宕㈡潏銊х瘈闁汇垽娼у瓭闂佺顑呭Λ婵嬪箖閳╁啰闄勯柛娑橈功閸樻悂鎮楅崗澶婁壕闁诲函缍嗛崜娑㈠汲閻樼粯鐓eù鍏肩懅閸掍即鏌曢崱妯虹瑨妞ゎ偅绻堥幃鈩冩償閿濆嫮鏁炬繝寰锋澘鈧牕螞閸愵煈娼栫紓浣股戞刊鎾煕濞戞﹫宸ラ柡鍡楃墦閺岋箓宕橀缁樺枤闂佸搫鐬奸崰鏍€佸▎鎾村亗閹煎瓨锚娴滈箖鏌熼梻瀵哥瓘缂傚秵鐗犻悡顐﹀炊閵娧€濮囬梺璇″灣閸嬨倝寮诲☉銏℃櫆閻犲洦褰冪粻濠氭⒑缂佹ɑ灏伴柟鐟版搐椤繐煤椤忓嫭宓嶅銈嗘寙閸涱厼歇闂備浇顕х€涒晝绮欓崼銉ョ柧闁绘宕靛畵渚€鐓崶銊р槈缁绢厸鍋撻梻浣虹帛閸ㄩ潧螞濞嗘垟鍋撻棃娑氱劯婵﹥妞藉Λ鍐ㄢ槈濮橆剦鏆梻浣告憸閸c儵宕戦崨顔锯攳濠电姴娲ょ粈鍌炴⒒閸屾凹鍤熺紒鐘宠壘椤啴濡堕崱妤€衼缂備焦褰冮悘婵堝弲闂佸湱铏庨崰妤呮偂閺囥垺鐓冮悷娆忓閸斻倕霉濠婂懎浜惧ǎ鍥э躬閹瑩顢旈崟銊ヤ壕闁哄稁鍋呴弳婊冣攽閻樿弓绱栫憸鐗堝笒閻愬﹪鏌曟繛褍鎳庢鍕節濞堝灝鏋熼柕鍥ㄧ洴瀹曟垿骞樼紒妯煎幐闁诲繒鍋涙晶浠嬪煡婢跺浜滄い鎰剁悼缁犵偞銇勯姀鈽嗘畷鐎垫澘瀚换婵嬪磼濮樺吋顥忕紓鍌氬€搁崐鎼佸磹妞嬪海鐭嗗〒姘e亾闁诡垰鏈幏鍛寸嵁婢跺摜鐭掗梻浣告啞缁哄潡宕曢幓鎺旀殾闁告瑥顦辩弧鈧梻鍌氱墛娓氭宕曡箛娑欑厽闁归偊鍓ㄩ煬顒勬煛鐏炵偓绀冪紒缁樼洴瀹曞綊顢欓悡搴綍闂傚倷鑳堕…鍫ヮ敄閸℃稑绠查柛銉墮閽冪喖鏌曟繛褉鍋撻柛瀣崌閺佹劙宕橀妸銉€辩紓鍌欓檷閸斿矂鈥﹀畡鎷旀盯宕ㄩ幖顓熸櫇闂侀潧绻嗛埀顒佸墯濡查亶姊绘担鐑樺殌闁硅绻濋獮鍐磼閻愵亖鍋撴笟鈧顕€宕煎顎板喚鐔嗛悹杞拌閸庢垿鏌涘鈧禍鍫曞蓟閿濆棙鍎熸い鏍ㄧ矌鏍¢梻浣侯焾椤戝懘骞婃惔銊﹀仼鐎瑰嫭澹嗛弳鍡涙煃瑜滈崜鐔煎春閳ь剚銇勯幒宥囪窗闁哥喎绻橀弻娑㈡偐閾忣偆顦梺鍛婂笚鐢帡鍩㈡惔銊ョ闁瑰吀绀佹禍鎯归敐鍛棌婵炵鍔戦弻宥堫檨闁告挾鍠栭悰顕€宕橀妸銏$€婚棅顐㈡搐閿曘儵鎮樻笟鈧娲捶椤撗呭姼閻庡湱纭堕弲鐘充繆閻戣棄鐓涢柛灞绢殕鐎氬ジ姊绘担鍝勫付妞ゎ偅娲熷畷鎰板即閵忕姴鍤戦梺鐟邦嚟婵澹曢崗绗轰簻闁哄啫娲ゆ禍褰掓煟韫囨稐鎲鹃柡宀€鍠栭悰顕€宕归鍙ョ礄婵°倗濮烽崑娑樏洪銏犺摕闁搞儺鍓氶弲婊堟煠閹帒鍔滈柣婵勫姂濮婂宕掑▎鎴犵崲濠电偘鍖犻崵韬插姂閸┾偓妞ゆ巻鍋撻柍瑙勫灴閸ㄩ箖鎼归銏㈢崺闁诲孩顔栭崯顐﹀炊瑜忛崝锕€顪冮妶鍡楃瑨閻庢凹鍙冮崺娑㈠箣閿旂晫鍘甸梺鍏肩ゴ閺呮稒绂掑鍫熺厱闁哄倸鎼禍楣冩⒒閸屾瑧顦﹂柟璇х磿閸掓帡宕奸妷锕€鈧潡鏌ㄩ弴姘愁唹闁告瑩绠栧濠氬磼濮橆兘鍋撻幖浣哥9闁归棿绀佺壕鐟邦渻鐎n亝鎹i柣顓炴閵嗘帒顫濋敐鍛闁诲氦顫夊ú蹇涘磿閹惰棄鐒垫い鎺戯功缁夌敻鏌涢幘瀵告创闁诡垰鐭傚畷濂稿Ψ閿旀儳骞嶇紓鍌氬€烽梽宥夊垂瑜版帒鍑犳繛鎴欏灪閻撶喖鏌曢崼婵愭Ш闁伙絾妞介弻锛勪沪閻e睗锝嗙箾绾板彉閭柟顔ㄥ洤閱囨慨姗嗗厸婢规洟姊洪棃娑辨Ф闁稿骸绉寸叅妞ゅ繐绉甸弲婊堟⒑閸涘﹥澶勯柛娆忛叄瀹曨垶宕惰閺€浠嬫煟閹邦垰鐓愮憸鎶婂懐纾奸棅顐幘閻瑧鈧娲忛崹褰掆€﹂妸鈺侀唶婵犻潧鐗滈崬鍨節閻㈤潧浠滄俊顖氾攻缁傚秴鈹戠€n亞鍘遍梺鍦劋椤ㄥ棝鎮¢弴銏″€堕柣鎰版涧娴滈箖鏌i妸锕€鐏ユい顓″劵椤﹀磭绱掔€n偅灏垫俊鍙夊姍楠炴帡寮崫鍕闂佹寧绻傛鍛婄濠靛鍊堕煫鍥ㄦ礃閺嗏晝绱掓潏銊ユ诞妞ゃ垺鐟ч崰濠冩綇閳轰焦鍊梻鍌欐祰椤曟牠宕板Δ鍛仭闁冲搫鎳庣粻鏍ㄧ節婵犲倸鎮╅柣鏂垮悑閸嬪倿骞栨潏鍓х?闁汇倕瀚埞鎴︽偐閸偅姣勬繝娈垮枤閸忔ê顕i锕€宸濆┑鐘插暙瀵潡姊洪崷顓℃闁哥姵鐗犻幃鍧楊敋閳ь剟寮婚敐鍛傛棃鍩€椤掑嫭鍋嬪┑鐘插€甸弸宥夋煟濡偐甯涢柣鎾跺枛閺屾洝绠涢弴鐐愶綁鏌涢悢鍝勪槐闁?\r
 //#define CONFIG_juphoon 1\r
index fa64f50..df238f1 100644 (file)
@@ -64,4 +64,6 @@ CONFIG_VIOCE_CALL=y
 #CONFIG_SC7A20=y\r
 CONFIG_VAD=y\r
 # CONFIG_QP_LOG is not set\r
+# Opus 编解码(需先运行 tools\build_opus_min.bat 生成 libopus_min.a)\r
+CONFIG_OPUS=y\r
 #CONFIG_juphoon=y\r
diff --git a/2.sdk/project/7PIN_1_5/sdk/system/platform/ASR_1606/boards/EG810MCN_GA_VOLTE/images/firmware_base_release_pack/README.md b/2.sdk/project/7PIN_1_5/sdk/system/platform/ASR_1606/boards/EG810MCN_GA_VOLTE/images/firmware_base_release_pack/README.md
new file mode 100644 (file)
index 0000000..c2605df
--- /dev/null
@@ -0,0 +1,11 @@
+此目录用于“解开管理” `firmware_base_release_pack.zip` 内的配置文件(源文件)。
+
+约定:
+- 源文件:`firmware_base_release_pack/**`(本目录)
+- 打包输入:`firmware_base_release_pack.zip`
+- 修改分区/模板等配置时,只改本目录内对应文件
+- 编译/打包前执行 `tools/sync_base_pack_config.bat`,将本目录内容增量更新到 zip
+- `new_clean.bat` 与 `new.bat`(xcopy 前)都会自动 sync;脚本会删除 zip 内旧路径条目并做 sha256 校验,避免 7z 产生重复 config 条目
+
+注意:
+- zip 在编译过程中会被 `new.bat` 更新写入(加入 images/*.bin),因此 zip 仅作为打包输入/发布载体,不作为配置源文件维护。
diff --git a/2.sdk/project/7PIN_1_5/sdk/system/platform/ASR_1606/boards/EG810MCN_GA_VOLTE/images/firmware_base_release_pack/config/partition/CRANEL_SINGLE_QUEC_FLASH_LAYOUT_8M_GNSS_OPEN_VOLTE.json b/2.sdk/project/7PIN_1_5/sdk/system/platform/ASR_1606/boards/EG810MCN_GA_VOLTE/images/firmware_base_release_pack/config/partition/CRANEL_SINGLE_QUEC_FLASH_LAYOUT_8M_GNSS_OPEN_VOLTE.json
new file mode 100644 (file)
index 0000000..0342a45
--- /dev/null
@@ -0,0 +1,137 @@
+{
+   "name" : "CRANEL_SINGLE_QUEC_FLASH_LAYOUT_8M_GNSS_OPEN_VOLTE",
+   "partitions" : [
+      {
+         "format" : "flash",
+         "name" : "qspi",
+         "partitions" : [
+            {
+               "format" : "ubi",
+               "name" : "bootloader",
+               "size" : "88KiB"
+            },
+            {
+               "format" : "part",
+               "name" : "system",
+               "partitions" : [
+                  {
+                     "format" : "raw",
+                     "name" : "ptable",
+                     "size" : "4KiB"
+                  },
+                  {
+                     "format" : "raw",
+                     "name" : "fwcerts",
+                     "size" : "12KiB"
+                  },
+                  {
+                     "format" : "raw",
+                     "name" : "rd",
+                     "size" : "32KiB"
+                  },
+                  {
+                     "format" : "raw",
+                     "name" : "cp",
+                     "size" : "0"
+                  },
+                  {
+                     "format" : "raw",
+                     "name" : "dsp",
+                     "size" : "0"
+                  },
+                  {
+                     "format" : "raw",
+                     "name" : "rfbin",
+                     "size" : "0"
+                  },
+                  {
+                     "disable" : false,
+                     "format" : "raw",
+                     "name" : "logo",
+                     "size" : "0"
+                  },
+                  {
+                     "format" : "raw",
+                     "name" : "gnss_boot",
+                     "size" : "0"
+                  },
+                  {
+                     "format" : "raw",
+                     "name" : "gnss_firm",
+                     "size" : "0"
+                  }
+               ],
+               "size" : "0"
+            },
+            {
+               "format" : "raw",
+               "name" : "pad",
+               "size" : "12KiB"
+            },
+            {
+               "format" : "raw",
+               "name" : "customer_app",
+               "size" : "1500KiB"
+            },
+            {
+               "format" : "raw",
+               "name" : "customer_fs",
+               "size" : "984KiB"
+            },
+            {
+               "format" : "raw",
+               "name" : "customer_backup_fs",
+               "size" : "16KiB"
+            },
+            {
+               "format" : "raw",
+               "name" : "nvm",
+               "size" : "196KiB"
+            },
+            {
+               "format" : "raw",
+               "name" : "secdat",
+               "size" : "24KiB"
+            },
+            {
+               "format" : "raw",
+               "name" : "erase_rd",
+               "size" : "4KiB"
+            },
+            {
+               "format" : "raw",
+               "name" : "updater",
+               "size" : "96KiB"
+            },
+            {
+               "format" : "raw",
+               "name" : "fota_param",
+               "size" : "12KiB"
+            },
+            {
+               "format" : "raw",
+               "name" : "quec_cfg",
+               "size" : "32KiB"
+            },
+            {
+               "format" : "part",
+               "name" : "factory",
+               "partitions" : [
+                  {
+                     "format" : "raw",
+                     "name" : "factory_a",
+                     "size" : "32KiB"
+                  },
+                  {
+                     "format" : "raw",
+                     "name" : "factory_b",
+                     "size" : "32KiB"
+                  }
+               ],
+               "size" : "0"
+            }
+         ],
+         "vstart" : "0x80000000"
+      }
+   ]
+}
index 80c7a39..5567586 100644 (file)
@@ -1,11 +1,15 @@
-\r
-#ifndef __APP_LINK_START_ADDR_H__\r
-#define __APP_LINK_START_ADDR_H__\r
-\r
-#define APP_LINK_START_ADDR  0x80521000\r
-#define APP_FLASH_MAX_SIZE 0x120000\r
-\r
-#define APP_RAM_START 0x7E3E0000\r
-#define APP_RAM_MAX_SIZE 0x180000\r
-\r
-#endif\r
+
+#ifndef __APP_LINK_START_ADDR_H__
+#define __APP_LINK_START_ADDR_H__
+
+#define APP_LINK_START_ADDR  0x80521000
+/* 对齐 K8:为 Opus(~250KB) 等扩展预留 APP 区;物理分区需与基线一致 */
+#define APP_FLASH_MAX_SIZE 0x180000
+// 1.5M 大小 0x180000
+// 1.2M 大小 0x120000
+// 1.8M 大小 0x1F8000  
+
+#define APP_RAM_START 0x7E3E0000
+#define APP_RAM_MAX_SIZE 0x180000
+
+#endif
diff --git a/2.sdk/project/7PIN_1_5/tools/build_opus_min.bat b/2.sdk/project/7PIN_1_5/tools/build_opus_min.bat
new file mode 100644 (file)
index 0000000..46f5236
--- /dev/null
@@ -0,0 +1,38 @@
+@echo off\r
+setlocal\r
+REM 将 opus-1.4 源码目录放到 tools\opus_src(仅构建 .a 时用,固件不引用该路径)\r
+set "OPUS_SRC=%~dp0opus_src"\r
+set "OUT_A=%~dp0..\sdk\services\microPython\ports\quectel\core\source\libopus_min.a"\r
+set "BUILD_DIR=%OPUS_SRC%\build-arm-eg810"\r
+set "GCC_ROOT=D:\helios\gcc-arm-none-eabi-10.2.1"\r
+set "CC=D:/helios/gcc-arm-none-eabi-10.2.1/bin/arm-none-eabi-gcc.exe"\r
+set "AR=D:/helios/gcc-arm-none-eabi-10.2.1/bin/arm-none-eabi-ar.exe"\r
+set "SIZE=D:/helios/gcc-arm-none-eabi-10.2.1/bin/arm-none-eabi-size.exe"\r
+\r
+if not exist "%CC%" (\r
+    echo [ERR] missing %CC%\r
+    exit /b 1\r
+)\r
+if not exist "%OPUS_SRC%\CMakeLists.txt" (\r
+    echo [ERR] missing %OPUS_SRC%\r
+    exit /b 1\r
+)\r
+\r
+if not exist "%BUILD_DIR%" mkdir "%BUILD_DIR%"\r
+cd /d "%BUILD_DIR%"\r
+\r
+cmake -G "Unix Makefiles" -DCMAKE_SYSTEM_NAME=Generic -DCMAKE_SYSTEM_PROCESSOR=arm -DCMAKE_C_COMPILER="%CC%" -DCMAKE_AR="%AR%" -DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY -DCMAKE_BUILD_TYPE=MinSizeRel -DCMAKE_C_FLAGS="-mthumb -mcpu=cortex-r5 -Os -ffunction-sections -fdata-sections" -DOPUS_FIXED_POINT=ON -DOPUS_ENABLE_FLOAT_API=OFF -DOPUS_CUSTOM_MODES=OFF -DOPUS_BUILD_PROGRAMS=OFF -DOPUS_BUILD_TESTING=OFF -DOPUS_BUILD_SHARED_LIBRARY=OFF -DOPUS_ASSERTIONS=OFF -DOPUS_HARDENING=OFF -DOPUS_FORTIFY_SOURCE=OFF -DOPUS_STACK_PROTECTOR=OFF -DOPUS_DISABLE_INTRINSICS=OFF -DOPUS_INSTALL_PKG_CONFIG_MODULE=OFF -DOPUS_INSTALL_CMAKE_CONFIG_MODULE=OFF "%OPUS_SRC%"\r
+if errorlevel 1 exit /b 1\r
+\r
+cmake --build . --target opus -j\r
+if errorlevel 1 exit /b 1\r
+\r
+if not exist "libopus.a" (\r
+    echo [ERR] libopus.a not built\r
+    exit /b 1\r
+)\r
+\r
+copy /y "libopus.a" "%OUT_A%"\r
+echo [OK] %OUT_A%\r
+"%SIZE%" -t x -B "%OUT_A%"\r
+exit /b 0\r
diff --git a/2.sdk/project/7PIN_1_5/tools/build_opus_min.ps1 b/2.sdk/project/7PIN_1_5/tools/build_opus_min.ps1
new file mode 100644 (file)
index 0000000..f32e323
--- /dev/null
@@ -0,0 +1,54 @@
+# Cross-build opus-1.4 -> libopus_min.a (ARM thumb, fixed-point, MinSizeRel)\r
+$ErrorActionPreference = "Stop"\r
+$OpusSrc = Join-Path $PSScriptRoot "opus_src"\r
+if (-not (Test-Path (Join-Path $OpusSrc "CMakeLists.txt"))) {\r
+    throw "Put opus-1.4 sources under: $OpusSrc"\r
+}\r
+$OpusSrc = (Resolve-Path $OpusSrc).Path\r
+$OutA = Join-Path $PSScriptRoot "..\sdk\services\microPython\ports\quectel\core\source\libopus_min.a"\r
+$BuildDir = Join-Path $OpusSrc "build-arm-eg810"\r
+$GccRoot = "D:\helios\gcc-arm-none-eabi-10.2.1"\r
+$Cc = Join-Path $GccRoot "bin\arm-none-eabi-gcc.exe"\r
+$Ar = Join-Path $GccRoot "bin\arm-none-eabi-ar.exe"\r
+$Size = Join-Path $GccRoot "bin\arm-none-eabi-size.exe"\r
+\r
+if (-not (Test-Path $Cc)) { throw "ARM GCC not found: $Cc" }\r
+if (-not (Test-Path (Join-Path $OpusSrc "CMakeLists.txt"))) { throw "opus source missing: $OpusSrc" }\r
+\r
+New-Item -ItemType Directory -Force -Path $BuildDir | Out-Null\r
+Push-Location $BuildDir\r
+try {\r
+    $cmakeArgs = @(\r
+        "-G", "Unix Makefiles",\r
+        "-DCMAKE_SYSTEM_NAME=Generic",\r
+        "-DCMAKE_SYSTEM_PROCESSOR=arm",\r
+        "-DCMAKE_C_COMPILER=$Cc",\r
+        "-DCMAKE_AR=$Ar",\r
+        "-DCMAKE_BUILD_TYPE=MinSizeRel",\r
+        '-DCMAKE_C_FLAGS=-mthumb -mcpu=cortex-r5 -Os -ffunction-sections -fdata-sections',\r
+        "-DOPUS_FIXED_POINT=ON",\r
+        "-DOPUS_ENABLE_FLOAT_API=OFF",\r
+        "-DOPUS_CUSTOM_MODES=OFF",\r
+        "-DOPUS_BUILD_PROGRAMS=OFF",\r
+        "-DOPUS_BUILD_TESTING=OFF",\r
+        "-DOPUS_BUILD_SHARED_LIBRARY=OFF",\r
+        "-DOPUS_ASSERTIONS=OFF",\r
+        "-DOPUS_HARDENING=OFF",\r
+        "-DOPUS_FORTIFY_SOURCE=OFF",\r
+        "-DOPUS_STACK_PROTECTOR=OFF",\r
+        "-DOPUS_DISABLE_INTRINSICS=OFF",\r
+        "-DOPUS_INSTALL_PKG_CONFIG_MODULE=OFF",\r
+        "-DOPUS_INSTALL_CMAKE_CONFIG_MODULE=OFF",\r
+        $OpusSrc\r
+    )\r
+    & cmake @cmakeArgs\r
+    & cmake --build . --target opus -j\r
+    $lib = Join-Path $BuildDir "libopus.a"\r
+    if (-not (Test-Path $lib)) { throw "libopus.a not found" }\r
+    Copy-Item -Force $lib $OutA\r
+    Write-Host "[OK] $OutA"\r
+    & $Size -t x -B $OutA\r
+}\r
+finally {\r
+    Pop-Location\r
+}\r
diff --git a/2.sdk/project/7PIN_1_5/tools/ensure_helios_opus_mk.ps1 b/2.sdk/project/7PIN_1_5/tools/ensure_helios_opus_mk.ps1
new file mode 100644 (file)
index 0000000..ff174ed
--- /dev/null
@@ -0,0 +1,21 @@
+# xcopy 后确保 Helios microPython.mk 能 -include microPython_opus.mk(仅补一行锚点,可重复执行)\r
+param([string]$HeliosRoot)\r
+$ErrorActionPreference = 'Stop'\r
+if (-not $HeliosRoot) { $HeliosRoot = Join-Path $PSScriptRoot '..\..\Helios_SDK' }\r
+$mk = Join-Path $HeliosRoot 'services\microPython\microPython.mk'\r
+if (-not (Test-Path -LiteralPath $mk)) { Write-Error "missing $mk"; exit 2 }\r
+$enc = New-Object System.Text.UTF8Encoding @($false)\r
+$lines = [System.IO.File]::ReadAllLines($mk, $enc)\r
+if (($lines -join "`n") -match 'services/microPython/microPython_opus\.mk') { Write-Host 'ensure_helios_opus_mk: OK (already)'; exit 0 }\r
+$out = New-Object System.Collections.Generic.List[string]\r
+$done = $false\r
+foreach ($line in $lines) {\r
+    [void]$out.Add($line)\r
+    if (-not $done -and $line -match 'libimslvad\.a\s*$') {\r
+        [void]$out.Add('-include services/microPython/microPython_opus.mk')\r
+        $done = $true\r
+    }\r
+}\r
+if (-not $done) { Write-Error 'anchor libimslvad.a not found'; exit 3 }\r
+[System.IO.File]::WriteAllLines($mk, $out.ToArray(), $enc)\r
+Write-Host 'ensure_helios_opus_mk: inserted -include microPython_opus.mk'\r
diff --git a/2.sdk/project/7PIN_1_5/tools/sync_base_pack_config.bat b/2.sdk/project/7PIN_1_5/tools/sync_base_pack_config.bat
new file mode 100644 (file)
index 0000000..f94a5f0
--- /dev/null
@@ -0,0 +1,18 @@
+@echo off
+setlocal EnableDelayedExpansion
+
+rem 2.sdk 根目录(tools 的上两级)
+cd /d "%~dp0..\..\"
+set "ROOT=%CD%"
+
+set "PROJECT=7PIN_1_5"
+set "BOARD=EG810MCN_GA_VOLTE"
+
+powershell -NoProfile -ExecutionPolicy Bypass -File "%ROOT%\project\%PROJECT%\tools\sync_base_pack_config.ps1" -Root:"%ROOT%" -Project:"%PROJECT%" -Board:"%BOARD%"
+if errorlevel 1 (
+  echo [ERROR] sync_base_pack_config failed
+  exit /b 1
+)
+
+exit /b 0
+
diff --git a/2.sdk/project/7PIN_1_5/tools/sync_base_pack_config.ps1 b/2.sdk/project/7PIN_1_5/tools/sync_base_pack_config.ps1
new file mode 100644 (file)
index 0000000..ff994cc
--- /dev/null
@@ -0,0 +1,107 @@
+param(
+  [string]$Root,
+  [string]$Project = "7PIN_1_5",
+  [string]$Board = "EG810MCN_GA_VOLTE"
+)
+
+$ErrorActionPreference = "Stop"
+
+if ([string]::IsNullOrWhiteSpace($Root)) {
+  $Root = (Resolve-Path (Join-Path $PSScriptRoot "..\..")).Path
+}
+$Root = (Resolve-Path $Root).Path
+
+$zip = Join-Path $Root ("project\" + $Project + "\sdk\system\platform\ASR_1606\boards\" + $Board + "\images\firmware_base_release_pack.zip")
+$src = Join-Path $Root ("project\" + $Project + "\sdk\system\platform\ASR_1606\boards\" + $Board + "\images\firmware_base_release_pack")
+$sevenZip = Join-Path $Root "Helios_SDK\tools\common\win32\7z\7z.exe"
+
+if (-not (Test-Path $src)) { throw ("base pack src dir not found: " + $src) }
+if (-not (Test-Path $zip)) { throw ("base pack zip not found: " + $zip) }
+if (-not (Test-Path $sevenZip)) { throw ("7z.exe not found: " + $sevenZip) }
+
+$includeGlobs = @(
+  "config\partition\*.json",
+  "config\template\*.json",
+  "release_info\*.txt"
+)
+
+function Remove-ZipByLeaf([string]$Archive, [string]$LeafName) {
+  # 旧 7z 在无匹配时会返回非 0,这里不作为失败
+  & $sevenZip d -y $Archive ("*" + $LeafName) | Out-Null
+  $global:LASTEXITCODE = 0
+}
+
+function Verify-ZipEntry([string]$Archive, [string]$ArcPathWin, [string]$ArcPathUnix, [string]$LocalFile) {
+  $leaf = [System.IO.Path]::GetFileName($LocalFile)
+  $tmp = Join-Path ([System.IO.Path]::GetTempPath()) ("base_pack_sync_" + [guid]::NewGuid().ToString("N"))
+  New-Item -ItemType Directory -Force -Path $tmp | Out-Null
+  try {
+    $candidates = @($ArcPathWin, $ArcPathUnix, ("*" + $leaf)) | Select-Object -Unique
+    $ok = $false
+    foreach ($c in $candidates) {
+      & $sevenZip e -y ("-o" + $tmp) $Archive $c | Out-Null
+      if ($LASTEXITCODE -eq 0) {
+        $filesNow = @(Get-ChildItem -LiteralPath $tmp -File -Recurse -ErrorAction SilentlyContinue)
+        if ($filesNow.Count -gt 0) {
+          $ok = $true
+          break
+        }
+      }
+    }
+    if (-not $ok) {
+      throw ("verify extract failed: " + $leaf + " by paths [" + ($candidates -join ", ") + "]")
+    }
+
+    $picked = Join-Path $tmp $leaf
+    if (-not (Test-Path $picked)) {
+      $files = @(Get-ChildItem -LiteralPath $tmp -File -Recurse -ErrorAction SilentlyContinue)
+      if ($files.Count -eq 1) {
+        $picked = $files[0].FullName
+      } else {
+        $names = ($files | ForEach-Object { $_.FullName }) -join "; "
+        throw ("verify extract missing: " + $leaf + " under " + $tmp + " got [" + $names + "]")
+      }
+    }
+
+    $srcHash = (Get-FileHash -Algorithm SHA256 -Path $LocalFile).Hash
+    $zipHash = (Get-FileHash -Algorithm SHA256 -Path $picked).Hash
+    if ($srcHash -ne $zipHash) {
+      throw ("zip entry mismatch: " + $leaf + " (src=" + $srcHash + " zip=" + $zipHash + ")")
+    }
+  } finally {
+    Remove-Item -LiteralPath $tmp -Recurse -Force -ErrorAction SilentlyContinue
+  }
+}
+
+$updated = 0
+Push-Location $src
+try {
+  foreach ($g in $includeGlobs) {
+    $matches = @(Get-ChildItem -Path $g -File -ErrorAction SilentlyContinue)
+    foreach ($m in $matches) {
+      $relWin = $m.FullName.Substring($src.Length).TrimStart("\")
+      $local = Join-Path $src $relWin
+      $leaf = $m.Name
+
+      Remove-ZipByLeaf $zip $leaf
+
+      $addOut = & $sevenZip a -y $zip $relWin 2>&1
+      if ($LASTEXITCODE -ne 0) {
+        throw ("7z add failed: " + $relWin + " :: " + ($addOut -join " | "))
+      }
+
+      $arcPathUnix = $relWin -replace "\\", "/"
+      Verify-ZipEntry $zip $relWin $arcPathUnix $local
+      $updated++
+      Write-Host ("[sync] " + $arcPathUnix)
+    }
+  }
+} finally {
+  Pop-Location
+}
+
+if ($updated -eq 0) {
+  throw ("no config files matched under: " + $src)
+}
+
+Write-Host ("[OK] base pack config synced (" + $updated + " files, sha256 verified) -> " + $zip)