├── .cproject ├── .devcontainer ├── Dockerfile └── devcontainer.json ├── .gitignore ├── .project ├── .settings ├── org.eclipse.cdt.core.prefs ├── org.eclipse.cdt.managedbuilder.core.prefs └── org.eclipse.core.resources.prefs ├── .vscode ├── settings.json └── tasks.json ├── ATCtelink.py ├── BoardPinout ├── Mi_LCD_Segments.jpeg ├── PcbPins.gif ├── PcbSide1.jpg ├── PcbSide2.jpg ├── README.md ├── RS_LYWSD03MMC_1.jpg ├── TabPins.gif ├── XiaomiLYWSD03MMC_B15_1.jpg └── XiaomiLYWSD03MMC_B15_2.jpg ├── InfoMijiaBLE ├── Mijia BLE Broadcasting Protocol-Mi Beacon v4.md ├── Mijia BLE MiBeacon protocol v5.md ├── Mijia BLE Object Definition.md ├── Mijia BLE connection protocol-Mi Service v4.md └── README.md ├── LICENSE ├── MakeAll.cmd ├── README.md ├── SDK ├── .gitignore ├── LICENSE ├── components │ ├── application │ │ ├── app │ │ │ ├── usbaud.c │ │ │ ├── usbaud.h │ │ │ ├── usbaud_i.h │ │ │ ├── usbcdc.c │ │ │ ├── usbcdc.h │ │ │ ├── usbcdc_i.h │ │ │ ├── usbkb.c │ │ │ ├── usbkb.h │ │ │ ├── usbkb_i.h │ │ │ ├── usbmouse.c │ │ │ ├── usbmouse.h │ │ │ └── usbmouse_i.h │ │ ├── keyboard │ │ │ ├── keyboard.c │ │ │ └── keyboard.h │ │ ├── print │ │ │ ├── putchar.c │ │ │ ├── putchar.h │ │ │ ├── u_printf.c │ │ │ └── u_printf.h │ │ ├── rf_frame.h │ │ └── usbstd │ │ │ ├── AudioClassCommon.h │ │ │ ├── CDCClassCommon.h │ │ │ ├── CDCClassDevice.h │ │ │ ├── HIDClassCommon.h │ │ │ ├── HIDClassDevice.h │ │ │ ├── HIDReportData.h │ │ │ ├── MassStorageClassCommon.h │ │ │ ├── PrinterClassCommon.h │ │ │ ├── StdDescriptors.h │ │ │ ├── StdRequestType.h │ │ │ ├── USBController.h │ │ │ ├── usb.c │ │ │ ├── usb.h │ │ │ ├── usbdesc.c │ │ │ ├── usbdesc.h │ │ │ ├── usbhw.c │ │ │ ├── usbhw.h │ │ │ ├── usbhw_i.h │ │ │ └── usbkeycode.h │ ├── boot │ │ ├── 8251 │ │ │ ├── cstartup_8251.S │ │ │ ├── cstartup_8251_RET_16K.S │ │ │ └── cstartup_8251_RET_32K.S │ │ ├── 8253 │ │ │ ├── cstartup_8253.S │ │ │ ├── cstartup_8253_RET_16K.S │ │ │ └── cstartup_8253_RET_32K.S │ │ ├── 8258 │ │ │ ├── cstartup_8258.S │ │ │ ├── cstartup_8258_RET_16K.S │ │ │ └── cstartup_8258_RET_32K.S │ │ ├── boot_16k_retn_8251_8253_8258.link │ │ ├── boot_32k_retn_8251.link │ │ ├── boot_32k_retn_8253_8258.link │ │ └── div_mod.S │ ├── common │ │ ├── assert.h │ │ ├── bit.h │ │ ├── breakpoint.c │ │ ├── breakpoint.h │ │ ├── config │ │ │ └── user_config.h │ │ ├── log.c │ │ ├── log.h │ │ ├── log_id.h │ │ ├── macro_trick.h │ │ ├── selection_sort.c │ │ ├── selection_sort.h │ │ ├── static_assert.h │ │ ├── string.c │ │ ├── string.h │ │ ├── types.h │ │ ├── utility.c │ │ └── utility.h │ ├── config.h │ ├── drivers.h │ ├── drivers │ │ └── 8258 │ │ │ ├── adc.c │ │ │ ├── adc.h │ │ │ ├── aes.c │ │ │ ├── aes.h │ │ │ ├── analog.c │ │ │ ├── analog.h │ │ │ ├── audio.c │ │ │ ├── audio.h │ │ │ ├── bsp.c │ │ │ ├── bsp.h │ │ │ ├── clock.c │ │ │ ├── clock.h │ │ │ ├── compiler.h │ │ │ ├── dfifo.h │ │ │ ├── dma.h │ │ │ ├── driver_8258.h │ │ │ ├── emi.c │ │ │ ├── emi.h │ │ │ ├── flash.c │ │ │ ├── flash.h │ │ │ ├── gpio.h │ │ │ ├── gpio_8258.c │ │ │ ├── gpio_8258.h │ │ │ ├── gpio_default_8258.h │ │ │ ├── i2c.c │ │ │ ├── i2c.h │ │ │ ├── irq.h │ │ │ ├── lpc.c │ │ │ ├── lpc.h │ │ │ ├── pga.h │ │ │ ├── pm.h │ │ │ ├── pwm.h │ │ │ ├── qdec.c │ │ │ ├── qdec.h │ │ │ ├── random.h │ │ │ ├── register.h │ │ │ ├── register_8258.h │ │ │ ├── rf_drv.h │ │ │ ├── rf_pa.c │ │ │ ├── rf_pa.h │ │ │ ├── s7816.c │ │ │ ├── s7816.h │ │ │ ├── spi.c │ │ │ ├── spi.h │ │ │ ├── spi_i.h │ │ │ ├── timer.c │ │ │ ├── timer.h │ │ │ ├── uart.c │ │ │ ├── uart.h │ │ │ ├── watchdog.c │ │ │ └── watchdog.h │ ├── freertos │ │ ├── config │ │ │ └── FreeRTOSConfig.h │ │ ├── croutine.c │ │ ├── event_groups.c │ │ ├── include │ │ │ ├── FreeRTOS.h │ │ │ ├── StackMacros.h │ │ │ ├── croutine.h │ │ │ ├── deprecated_definitions.h │ │ │ ├── event_groups.h │ │ │ ├── freertos_api.h │ │ │ ├── list.h │ │ │ ├── message_buffer.h │ │ │ ├── mpu_prototypes.h │ │ │ ├── mpu_wrappers.h │ │ │ ├── portable.h │ │ │ ├── projdefs.h │ │ │ ├── queue.h │ │ │ ├── semphr.h │ │ │ ├── stack_macros.h │ │ │ ├── stream_buffer.h │ │ │ ├── task.h │ │ │ └── timers.h │ │ ├── list.c │ │ ├── portable │ │ │ ├── Common │ │ │ │ └── mpu_wrappers.c │ │ │ ├── MemMang │ │ │ │ ├── heap_1.c │ │ │ │ ├── heap_2.c │ │ │ │ ├── heap_3.c │ │ │ │ ├── heap_4.c │ │ │ │ └── heap_5.c │ │ │ └── gcc │ │ │ │ ├── port.c │ │ │ │ └── portmacro.h │ │ ├── queue.c │ │ ├── stream_buffer.c │ │ ├── tasks.c │ │ └── timers.c │ ├── proj_lib │ │ ├── firmware_encrypt.h │ │ ├── libfirmware_encrypt.a │ │ ├── liblt_8258.a │ │ └── liblt_8258_rtos.a │ ├── stack │ │ └── ble │ │ │ ├── attr │ │ │ ├── att.h │ │ │ ├── gatt.h │ │ │ └── gatt_uuid.h │ │ │ ├── ble.h │ │ │ ├── ble_common.h │ │ │ ├── ble_controller.h │ │ │ ├── blt_config.h │ │ │ ├── bqb │ │ │ └── bqb_ll.h │ │ │ ├── crypt │ │ │ ├── aes │ │ │ │ └── aes_att.h │ │ │ ├── aes_ccm.h │ │ │ └── le_crypto.h │ │ │ ├── gap │ │ │ ├── gap.h │ │ │ └── gap_event.h │ │ │ ├── hci │ │ │ ├── hci.h │ │ │ ├── hci_cmd.h │ │ │ ├── hci_const.h │ │ │ ├── hci_event.h │ │ │ └── usb_desc.h │ │ │ ├── l2cap │ │ │ └── l2cap.h │ │ │ ├── ll │ │ │ ├── ll.h │ │ │ ├── ll_adv.h │ │ │ ├── ll_conn │ │ │ │ ├── ll_conn.h │ │ │ │ ├── ll_conn_csa.h │ │ │ │ ├── ll_conn_phy.h │ │ │ │ ├── ll_master.h │ │ │ │ └── ll_slave.h │ │ │ ├── ll_encrypt.h │ │ │ ├── ll_ext.h │ │ │ ├── ll_ext_adv.h │ │ │ ├── ll_ext_scan.h │ │ │ ├── ll_init.h │ │ │ ├── ll_pm.h │ │ │ ├── ll_scan.h │ │ │ └── ll_whitelist.h │ │ │ ├── llms │ │ │ ├── llms.h │ │ │ ├── llms_adv.h │ │ │ ├── llms_init.h │ │ │ ├── llms_master.h │ │ │ ├── llms_scan.h │ │ │ ├── llms_slave.h │ │ │ ├── llms_slot.h │ │ │ └── trace.h │ │ │ ├── phy │ │ │ ├── phy.h │ │ │ └── phy_test.h │ │ │ ├── service │ │ │ ├── ble_ll_ota.h │ │ │ ├── device_information.h │ │ │ └── hids.h │ │ │ ├── smp │ │ │ ├── smp.h │ │ │ ├── smp_central.h │ │ │ ├── smp_const.h │ │ │ ├── smp_peripheral.h │ │ │ └── smp_storage.h │ │ │ └── trace.h │ ├── tinyFlash │ │ ├── README.md │ │ ├── tinyFlash.c │ │ └── tinyFlash.h │ ├── tl_common.h │ └── vendor │ │ └── common │ │ ├── blt_common.c │ │ ├── blt_common.h │ │ ├── blt_fw_sign.c │ │ ├── blt_fw_sign.h │ │ ├── blt_led.c │ │ ├── blt_led.h │ │ ├── blt_soft_timer.c │ │ ├── blt_soft_timer.h │ │ ├── default_config.h │ │ ├── tl_audio.c │ │ ├── tl_audio.h │ │ └── user_config.h └── make │ ├── application.mk │ ├── boot.mk │ ├── common.mk │ ├── drivers_8258.mk │ ├── freertos.mk │ ├── tinyFlash.mk │ └── vendor_common.mk ├── TB03F.cmd ├── TelinkIDEmk.cmd ├── TlsrPgm.py ├── bin ├── ATC_v51.bin ├── ATC_v52.bin ├── BTE_v51.bin ├── BTE_v52.bin ├── BTH_v51.bin ├── BTH_v52.bin ├── CGDK2_v51.bin ├── CGDK2_v52.bin ├── CGG1M_v51.bin ├── CGG1M_v52.bin ├── CGG1_v51.bin ├── CGG1_v52.bin ├── LKTMZL02_v51.bin ├── LKTMZL02_v52.bin ├── MHO_C122_v51.bin ├── MHO_C122_v52.bin ├── MHO_C401N_v51.bin ├── MHO_C401N_v52.bin ├── MHO_C401_v51.bin ├── MHO_C401_v52.bin ├── MJ6_v51.bin ├── MJ6_v52.bin ├── Original │ ├── 1286-0202-10033607-TH03_Tuya_OTA.zigbee │ ├── Original_OTA_CGDK2_v1.1.1_0210.bin │ ├── Original_OTA_CGDK2_v1.1.1_0217.bin │ ├── Original_OTA_CGDK2_v1.1.1_0223.bin │ ├── Original_OTA_CGG1M_v2.2.1.bin │ ├── Original_OTA_CGG1_v1.0.1_0093.bin │ ├── Original_OTA_MHO_C122_tuya.bin │ ├── Original_OTA_SJWS01LM_1.1.1_0018.bin │ ├── Original_OTA_Xiaomi_LYWSD03MMC_v1.0.0_0109.bin │ ├── Original_OTA_Xiaomi_LYWSD03MMC_v1.0.0_0130.bin │ ├── Original_OTA_Xiaomi_LYWSD03MMC_v2.1.1_0159c.bin │ ├── Original_OTA_Xiaomi_MHO_C401_v1.0.0_0010.bin │ ├── Original_OTA_Xiaomi_MHO_C401_v1.0.0_0016.bin │ ├── Original_OTA_Xiaomi_MJWSD05MMC_en_2.0.0_0005.bin │ ├── Original_OTA_Xiaomi_MJWSD05MMC_v2.0.0_0026.bin │ ├── Original_OTA_Xiaomi_MJWSD06MMC_v2.1.1_0009.bin │ └── README.md ├── PLM1_v52.bin ├── README.md ├── TB03F_v51.bin ├── TB03F_v52.bin ├── TB_BME280_v52.bin ├── TB_ENS160_v52.bin ├── TB_INA226_v52.bin ├── TB_INA3221_v52.bin ├── TB_PLM_v52.bin ├── TB_SCD41_v52.bin ├── TH03Z_v51.bin ├── TH03Z_v52.bin ├── TH03_v51.bin ├── TH03_v52.bin ├── TNK01_v51.bin ├── TNK01_v52.bin ├── TS0201S1_v51.bin ├── TS0201S1_v52.bin ├── TS0201S2_v51.bin ├── TS0201S2_v52.bin ├── TS0201_v51.bin ├── TS0201_v52.bin ├── ZG227Z_v51.bin ├── ZG227Z_v52.bin ├── ZTH01S1_v51.bin ├── ZTH01S1_v52.bin ├── ZTH01S2_v51.bin ├── ZTH01S2_v52.bin ├── ZTH01_v51.bin ├── ZTH01_v52.bin ├── ZTH02_v51.bin ├── ZTH02_v52.bin ├── ZTH05_v51.bin ├── ZTH05_v52.bin ├── ZYZTH02P_v51.bin ├── ZYZTH02P_v52.bin ├── ZYZTH02S1_v51.bin ├── ZYZTH02S1_v52.bin ├── ZYZTH02S2_v51.bin ├── ZYZTH02S2_v52.bin ├── ZYZTH02_v51.bin └── ZYZTH02_v52.bin ├── firmware.json ├── img ├── GraphAtc_html.gif ├── KeysProgStage1.gif ├── KeysProgStage2.gif ├── OnOff.gif ├── PowerAdvInt.gif ├── PowerLife.gif ├── README.md ├── ShowData.gif ├── USBCOMFlashTxHtml.gif ├── atime.png ├── nRFConnect_set_default.png ├── power_x.gif ├── trg_grf.gif ├── trg_menu.gif └── webpgm.png ├── makefile ├── python-interface ├── README.md ├── atc_mi_interface │ ├── __init__.py │ ├── __main__.py │ ├── __version__.py │ ├── atc_mi_adv_format.py │ ├── atc_mi_advertising.py │ ├── atc_mi_config.py │ ├── atc_mi_construct.py │ ├── atc_mi_construct_adapters.py │ ├── atc_mi_format_test.py │ └── construct_module.py ├── gui-requirements.txt ├── images │ ├── atc_mi_config.gif │ └── ble_browser.gif ├── requirements.txt └── setup.py ├── signfiles └── sign_2.1.1_0159c.bin ├── src ├── TlsrMemInfo.py ├── TlsrRetMemAddr.py ├── app.c ├── app.h ├── app_att.c ├── app_config.h ├── battery.c ├── battery.h ├── ble.c ├── ble.h ├── blt_common.c ├── bme280.c ├── bme280.h ├── boot.link ├── boot.mk ├── bthome_beacon.c ├── bthome_beacon.h ├── ccm.c ├── ccm.h ├── cmd_parser.c ├── cmd_parser.h ├── cstartup_825x.S ├── custom_beacon.c ├── custom_beacon.h ├── div_mod.mk ├── drivers_8258.mk ├── ens160.c ├── ens160.h ├── epd.h ├── epd_cgg1.c ├── epd_cgg1n.c ├── epd_mho_c401.c ├── epd_mho_c401n.c ├── ext_ota.c ├── ext_ota.h ├── flash_eep.c ├── flash_eep.h ├── hx71x.c ├── hx71x.h ├── i2c.c ├── i2c.h ├── ina226.c ├── ina3221.c ├── lcd.c ├── lcd.h ├── lcd_cgdk2.c ├── lcd_lktmzl02.c ├── lcd_lywsd03mmc.c ├── lcd_mho_c122.c ├── lcd_mjwsd05mmc.c ├── lcd_mjwsd05mmc_en.c ├── lcd_mjwsd06mmc.c ├── lcd_th03.c ├── lcd_zth03.c ├── lcd_zth05z.c ├── lcd_zy_zth02pro.c ├── logger.c ├── logger.h ├── main.c ├── mi_beacon.c ├── mi_beacon.h ├── my18b20.c ├── my18b20.h ├── project.mk ├── rds_count.c ├── rds_count.h ├── rh.c ├── rh.h ├── rtc.h ├── rtc_pcf85163.c ├── scanning.c ├── scanning.h ├── scd41.c ├── sdm_out.c ├── sdm_out.h ├── sensor.h ├── sensors.c ├── trigger.c ├── trigger.h ├── uprintf.mk ├── utils.c ├── zb_version.h └── zigbee_ota.py ├── test_adv_cust.py ├── test_adv_key.py ├── utils ├── check_fw ├── tl_check_fw.py ├── tl_check_fw2.exe ├── zb_bin_ota.py └── zigbee_ota.py └── zigbee_ota ├── 1002-0203-60993001-ZYZTH02BLE_v51.zigbee ├── 1002-0203-60993001-ZYZTH02BLE_v52.zigbee ├── 1002-0203-60993001-ZYZTH02PBLE_v51.zigbee ├── 1002-0203-60993001-ZYZTH02PBLE_v52.zigbee ├── 1141-0201-99993001-MHO_C401_v51.zigbee ├── 1141-0201-99993001-MHO_C401_v52.zigbee ├── 1141-0202-99993001-CGG1_v51.zigbee ├── 1141-0202-99993001-CGG1_v52.zigbee ├── 1141-0203-99993001-ATC_v51.zigbee ├── 1141-0203-99993001-ATC_v52.zigbee ├── 1141-0206-99993001-CGDK2_v51.zigbee ├── 1141-0206-99993001-CGDK2_v52.zigbee ├── 1141-0207-99993001-CGG1M_v51.zigbee ├── 1141-0207-99993001-CGG1M_v52.zigbee ├── 1141-0208-99993001-MHO_C401N_v51.zigbee ├── 1141-0208-99993001-MHO_C401N_v52.zigbee ├── 1141-0209-99993001-BTH_v51.zigbee ├── 1141-0209-99993001-BTH_v52.zigbee ├── 1141-020a-99993001-ATC_v51.zigbee ├── 1141-020a-99993001-ATC_v52.zigbee ├── 1141-020b-99993001-MHO_C122_v51.zigbee ├── 1141-020b-99993001-MHO_C122_v52.zigbee ├── 1141-020c-99993001-BTE_v51.zigbee ├── 1141-020c-99993001-BTE_v52.zigbee ├── 1141-020d-99993001-MJ6_v51.zigbee ├── 1141-020d-99993001-MJ6_v52.zigbee ├── 1141-0210-99993001-TB03F_v51.zigbee ├── 1141-0210-99993001-TB03F_v52.zigbee ├── 1141-0210-99993001-TB_BME280_v52.zigbee ├── 1141-0210-99993001-TB_ENS160_v52.zigbee ├── 1141-0210-99993001-TB_INA226_v52.zigbee ├── 1141-0210-99993001-TB_INA3221_v52.zigbee ├── 1141-0210-99993001-TB_SCD41_v52.zigbee ├── 1141-0211-99993001-TS0201S1_v51.zigbee ├── 1141-0211-99993001-TS0201S1_v52.zigbee ├── 1141-0211-99993001-TS0201S2_v51.zigbee ├── 1141-0211-99993001-TS0201S2_v52.zigbee ├── 1141-0211-99993001-TS0201_v51.zigbee ├── 1141-0211-99993001-TS0201_v52.zigbee ├── 1141-0212-99993001-TNK01_v51.zigbee ├── 1141-0212-99993001-TNK01_v52.zigbee ├── 1141-0216-99993001-TH03Z_v51.zigbee ├── 1141-0216-99993001-TH03Z_v52.zigbee ├── 1141-021b-99993001-ZTH01S1_v51.zigbee ├── 1141-021b-99993001-ZTH01S1_v52.zigbee ├── 1141-021b-99993001-ZTH01S2_v51.zigbee ├── 1141-021b-99993001-ZTH01S2_v52.zigbee ├── 1141-021b-99993001-ZTH01_v51.zigbee ├── 1141-021b-99993001-ZTH01_v52.zigbee ├── 1141-021c-99993001-ZTH02_v51.zigbee ├── 1141-021c-99993001-ZTH02_v52.zigbee ├── 1141-021d-99993001-PLM1_v52.zigbee ├── 1141-021d-99993001-TB_PLM_v52.zigbee ├── 1141-021e-99993001-TH03_v51.zigbee ├── 1141-021e-99993001-TH03_v52.zigbee ├── 1141-021f-99993001-LKTMZL02_v51.zigbee ├── 1141-021f-99993001-LKTMZL02_v52.zigbee ├── 1141-0221-99993001-ZTH05_v51.zigbee ├── 1141-0221-99993001-ZTH05_v52.zigbee ├── 1141-0225-99993001-ZYZTH02S1_v51.zigbee ├── 1141-0225-99993001-ZYZTH02S1_v52.zigbee ├── 1141-0225-99993001-ZYZTH02S2_v51.zigbee ├── 1141-0225-99993001-ZYZTH02S2_v52.zigbee ├── 1141-0225-99993001-ZYZTH02_v51.zigbee ├── 1141-0225-99993001-ZYZTH02_v52.zigbee ├── 1141-0226-99993001-ZYZTH02P_v51.zigbee ├── 1141-0226-99993001-ZYZTH02P_v52.zigbee ├── 1141-0227-99993001-ZG227Z_v51.zigbee ├── 1141-0227-99993001-ZG227Z_v52.zigbee ├── 1141-d3a3-01983001-LKTMZL02BLE_v51.zigbee ├── 1141-d3a3-01983001-LKTMZL02BLE_v52.zigbee ├── 1141-d3a3-01983001-TS0201BLE_v51.zigbee ├── 1141-d3a3-01983001-TS0201BLE_v52.zigbee ├── 1286-0202-10993607-TH03BLE_v51.zigbee ├── 1286-0202-10993607-TH03BLE_v52.zigbee ├── 1286-0203-10983001-ZG227ZBLE_v51.zigbee ├── 1286-0203-10983001-ZG227ZBLE_v52.zigbee ├── README.md ├── db15-0203-99993001-ATC_v51.zigbee ├── db15-0203-99993001-ATC_v52.zigbee ├── devbis2ble.json ├── index_v51.json ├── index_v52.json ├── lktml02_tuya2ble.json ├── th03_tuya2ble.json ├── ts0201_tuya2ble.json ├── zg227z_tuya2ble.json ├── zigpy_ota ├── add.cmd ├── cacerts.pem ├── cacerts │ └── otau.meethue.com.pem ├── lib │ └── ota.js ├── scripts │ ├── add.js │ └── updateall.js └── update.cmd ├── zyzth02_tuya2ble.json └── zyzth02p_tuya2ble.json /.devcontainer/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:22.04 2 | ARG DEBIAN_FRONTEND=noninteractive 3 | ENV TZ=Europe/Amsterdam 4 | 5 | # Update package manager and install other package dependencies. 6 | # Remove the apt cache when done since it's useless for Docker and only increases image size 7 | RUN apt-get -y update && \ 8 | apt-get install -y \ 9 | curl \ 10 | xz-utils \ 11 | git \ 12 | dpkg-dev \ 13 | wget \ 14 | libssl-dev \ 15 | libncurses5 libncursesw5 \ 16 | build-essential \ 17 | python3 \ 18 | python-pip \ 19 | && rm -rf /var/lib/apt/lists* -------------------------------------------------------------------------------- /.devcontainer/devcontainer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ATC_MiThermometer", 3 | "build": { 4 | "dockerfile": "Dockerfile" 5 | }, 6 | "runArgs": [ 7 | "--name", 8 | "ATC_MiThermometer", 9 | "--rm" 10 | ], 11 | "postStartCommand": "/usr/bin/git config --global --add safe.directory \"*\";", 12 | "customizations": { 13 | "vscode": { 14 | "extensions": [ 15 | "ms-vscode.cpptools", 16 | "ms-vscode.cpptools-extension-pack", 17 | "spencerwmiles.vscode-task-buttons" 18 | ], 19 | "settings": { 20 | "terminal.integrated.defaultProfile.linux": "bash" 21 | } 22 | } 23 | }, 24 | "workspaceMount": "source=${localWorkspaceFolder},target=/workdir,type=bind,consistency=delegated", 25 | "workspaceFolder": "/workdir" 26 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | __pycache__/ 2 | *.py[cod] 3 | .idea/ 4 | # generated output 5 | out/* 6 | python-interface/atc_mi_interface.egg-info/* 7 | python-interface/build/* 8 | python-interface/dist/* 9 | -------------------------------------------------------------------------------- /.settings/org.eclipse.cdt.core.prefs: -------------------------------------------------------------------------------- 1 | #Thu Feb 03 14:32:37 MSK 2022 2 | eclipse.preferences.version=1 3 | environment/project/com.telink.tc32eclipse.configuration.app.debug.1166174376/append=true 4 | environment/project/com.telink.tc32eclipse.configuration.app.debug.1166174376/appendContributed=true 5 | environment/project/com.telink.tc32eclipse.configuration.app.release.2062992677/CWD/delimiter=; 6 | environment/project/com.telink.tc32eclipse.configuration.app.release.2062992677/CWD/operation=replace 7 | environment/project/com.telink.tc32eclipse.configuration.app.release.2062992677/CWD/value=E\:\\Telink\\TB-04\\wk\\Termometr\\${ProjName} 8 | environment/project/com.telink.tc32eclipse.configuration.app.release.2062992677/PWD/delimiter=; 9 | environment/project/com.telink.tc32eclipse.configuration.app.release.2062992677/PWD/operation=replace 10 | environment/project/com.telink.tc32eclipse.configuration.app.release.2062992677/PWD/value=E\:\\Telink\\TB-04\\wk\\Termometr\\${ProjName} 11 | environment/project/com.telink.tc32eclipse.configuration.app.release.2062992677/SDK/delimiter=; 12 | environment/project/com.telink.tc32eclipse.configuration.app.release.2062992677/SDK/operation=append 13 | environment/project/com.telink.tc32eclipse.configuration.app.release.2062992677/SDK/value=Telink_825X_SDK 14 | environment/project/com.telink.tc32eclipse.configuration.app.release.2062992677/append=true 15 | environment/project/com.telink.tc32eclipse.configuration.app.release.2062992677/appendContributed=true 16 | -------------------------------------------------------------------------------- /.settings/org.eclipse.cdt.managedbuilder.core.prefs: -------------------------------------------------------------------------------- 1 | #Sun Nov 15 06:36:49 MSK 2020 2 | eclipse.preferences.version=1 3 | environment/buildEnvironmentInclude/com.telink.tc32eclipse.configuration.app.debug.1166174376/CPATH/delimiter=; 4 | environment/buildEnvironmentInclude/com.telink.tc32eclipse.configuration.app.debug.1166174376/CPATH/operation=remove 5 | environment/buildEnvironmentInclude/com.telink.tc32eclipse.configuration.app.debug.1166174376/C_INCLUDE_PATH/delimiter=; 6 | environment/buildEnvironmentInclude/com.telink.tc32eclipse.configuration.app.debug.1166174376/C_INCLUDE_PATH/operation=remove 7 | environment/buildEnvironmentInclude/com.telink.tc32eclipse.configuration.app.debug.1166174376/append=true 8 | environment/buildEnvironmentInclude/com.telink.tc32eclipse.configuration.app.debug.1166174376/appendContributed=true 9 | environment/buildEnvironmentLibrary/com.telink.tc32eclipse.configuration.app.debug.1166174376/LIBRARY_PATH/delimiter=; 10 | environment/buildEnvironmentLibrary/com.telink.tc32eclipse.configuration.app.debug.1166174376/LIBRARY_PATH/operation=remove 11 | environment/buildEnvironmentLibrary/com.telink.tc32eclipse.configuration.app.debug.1166174376/append=true 12 | environment/buildEnvironmentLibrary/com.telink.tc32eclipse.configuration.app.debug.1166174376/appendContributed=true 13 | -------------------------------------------------------------------------------- /.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | #Thu Nov 12 19:14:14 MSK 2020 2 | eclipse.preferences.version=1 3 | encoding/=UTF-8 4 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "VsCodeTaskButtons.tasks": [ 3 | { 4 | "label": "$(notebook-move-down) Build", 5 | "task": "Build", 6 | "tooltip": "🛠️ Start a \"Build\" action" 7 | }, 8 | { 9 | "label": "$(search-refresh) Re-Build", 10 | "task": "Re-Build", 11 | "tooltip": "🧹🛠️ Start a \"Clean & Debug-Build\" action" 12 | }, 13 | { 14 | "label": "$(notebook-delete-cell) Clean build", 15 | "task": "Clean", 16 | "tooltip": "🧹 Start a \"clean\" action" 17 | } 18 | ], 19 | } -------------------------------------------------------------------------------- /.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "tasks": [ 4 | { 5 | "label": "Re-Build", 6 | "group": "build", 7 | "type": "shell", 8 | "dependsOrder": "sequence", 9 | "dependsOn": [ 10 | "Clean", 11 | "Build" 12 | ] 13 | }, 14 | { 15 | "label": "Build", 16 | "type": "shell", 17 | "group": "build", 18 | "presentation": { 19 | "echo": true, 20 | "reveal": "always", 21 | "focus": true, 22 | "close": false, 23 | "panel": "dedicated", 24 | "clear": true, 25 | "revealProblems": "onProblem", 26 | }, 27 | "command": "make", 28 | "problemMatcher": { 29 | //Note: If you get a "the description can't be converted into a problem matcher" error here 30 | // The "C/C++" extension has not been installed (yet) 31 | "source": "GCC-Build", 32 | "base": "$gcc", 33 | "fileLocation": [ 34 | "autodetect", 35 | "${workspaceFolder}/build" 36 | ] 37 | } 38 | }, 39 | { 40 | "label": "Clean", 41 | "type": "shell", 42 | "group": "build", 43 | "presentation": { 44 | "echo": true, 45 | "reveal": "always", 46 | "focus": true, 47 | "close": false, 48 | "panel": "dedicated", 49 | "clear": true, 50 | "revealProblems": "never", 51 | }, 52 | "linux": { 53 | "command": "make clean", 54 | }, 55 | "problemMatcher": [] 56 | } 57 | ] 58 | } -------------------------------------------------------------------------------- /BoardPinout/Mi_LCD_Segments.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/BoardPinout/Mi_LCD_Segments.jpeg -------------------------------------------------------------------------------- /BoardPinout/PcbPins.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/BoardPinout/PcbPins.gif -------------------------------------------------------------------------------- /BoardPinout/PcbSide1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/BoardPinout/PcbSide1.jpg -------------------------------------------------------------------------------- /BoardPinout/PcbSide2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/BoardPinout/PcbSide2.jpg -------------------------------------------------------------------------------- /BoardPinout/README.md: -------------------------------------------------------------------------------- 1 | # ATC_MiThermometer - Board 2 | 3 | ## Chips: 4 | 5 | > * [TLSR8251F512ET24](http://wiki.telink-semi.cn/doc/ds/DS_TLSR8251-E_Datasheet%20for%20Telink%20BLE+IEEE802.15.4%20Multi-Standard%20Wireless%20SoC%20TLSR8251.pdf) 6 | > * SHTV3 - analog [SHTC3](https://www.sensirion.com/en/environmental-sensors/humidity-sensors/digital-humidity-sensor-shtc3-our-new-standard-for-consumer-electronics/) 7 | > * IST3055NA0 (datasheet not found) 8 | 9 | ![SCH](https://github.com/pvvx/ATC_MiThermometer/blob/master/BoardPinout/TabPins.gif) 10 | 11 | ![SCH](https://github.com/pvvx/ATC_MiThermometer/blob/master/BoardPinout/PcbSide1.jpg) 12 | 13 | ![SCH](https://github.com/pvvx/ATC_MiThermometer/blob/master/BoardPinout/PcbSide2.jpg) 14 | 15 | ![SCH](https://github.com/pvvx/ATC_MiThermometer/blob/master/BoardPinout/Mi_LCD_Segments.jpeg) 16 | 17 | 18 | ## Xiaomi LYWSD03MMC B1.5 19 | 20 | ![SCH](https://github.com/pvvx/ATC_MiThermometer/blob/master/BoardPinout/XiaomiLYWSD03MMC_B15_1.jpg) 21 | 22 | ![SCH](https://github.com/pvvx/ATC_MiThermometer/blob/master/BoardPinout/XiaomiLYWSD03MMC_B15_2.jpg) 23 | -------------------------------------------------------------------------------- /BoardPinout/RS_LYWSD03MMC_1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/BoardPinout/RS_LYWSD03MMC_1.jpg -------------------------------------------------------------------------------- /BoardPinout/TabPins.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/BoardPinout/TabPins.gif -------------------------------------------------------------------------------- /BoardPinout/XiaomiLYWSD03MMC_B15_1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/BoardPinout/XiaomiLYWSD03MMC_B15_1.jpg -------------------------------------------------------------------------------- /BoardPinout/XiaomiLYWSD03MMC_B15_2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/BoardPinout/XiaomiLYWSD03MMC_B15_2.jpg -------------------------------------------------------------------------------- /InfoMijiaBLE/README.md: -------------------------------------------------------------------------------- 1 | # Mijia BLE Info 2 | 3 | [Mijia BLE MiBeacon protocol v5](https://github.com/pvvx/ATC_MiThermometer/blob/master/InfoMijiaBLE/Mijia%20BLE%20MiBeacon%20protocol%20v5.md) 4 | 5 | [Mijia BLE Object Definition](https://github.com/pvvx/ATC_MiThermometer/blob/master/InfoMijiaBLE/Mijia%20BLE%20Object%20Definition.md) 6 | 7 | [Mijia BLE Broadcasting Protocol-Mi Beacon v4](https://github.com/pvvx/ATC_MiThermometer/blob/master/InfoMijiaBLE/Mijia%20BLE%20Broadcasting%20Protocol-Mi%20Beacon%20v4.md) 8 | 9 | [Mijia BLE connection protocol-Mi Service v4](https://github.com/pvvx/ATC_MiThermometer/blob/master/InfoMijiaBLE/Mijia%20BLE%20connection%20protocol-Mi%20Service%20v4.md) 10 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Permission is hereby granted, free of charge, to any person obtaining 2 | a copy of this software and associated documentation files (the "Software"), 3 | to deal in the Software without restriction, including without limitation the 4 | rights to use, copy, modify, merge, publish, distribute, sublicense, 5 | and/or sell copies of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 8 | INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 9 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 10 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 11 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 12 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 13 | -------------------------------------------------------------------------------- /SDK/.gitignore: -------------------------------------------------------------------------------- 1 | .tools 2 | /tools/ 3 | -------------------------------------------------------------------------------- /SDK/LICENSE: -------------------------------------------------------------------------------- 1 | https://github.com/Ai-Thinker-Open/Telink_825X_SDK -------------------------------------------------------------------------------- /SDK/components/application/app/usbaud_i.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/SDK/components/application/app/usbaud_i.h -------------------------------------------------------------------------------- /SDK/components/application/app/usbcdc.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file usbcdc.h 3 | * 4 | * @brief for TLSR chips 5 | * 6 | * @author public@telink-semi.com; 7 | * @date Sep. 30, 2010 8 | * 9 | * @par Copyright (c) Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential and proprietary property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee in separate contract or the terms described here-in. 16 | * This heading MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | #pragma once 23 | 24 | #include 25 | #include 26 | #include "../common/types.h" 27 | #include "../common/static_assert.h" 28 | #include "../common/bit.h" 29 | 30 | /* Enable C linkage for C++ Compilers: */ 31 | #if defined(__cplusplus) 32 | extern "C" { 33 | #endif 34 | 35 | 36 | typedef void ( *cdc_handlerFn_t)( u8* pData); 37 | 38 | typedef struct { 39 | u8 len; 40 | u8 data[1]; 41 | } usbcdc_txBuf_t; 42 | 43 | 44 | typedef enum usbcdc_sts_e { 45 | // success = 0 46 | USB_BUSY = 1, 47 | USB_MULTIBLOCK, 48 | } usbcdc_sts_t; 49 | 50 | 51 | void CDC_Device_ProcessControlRequest(u8 bRequest, u16 wValue, u16 wIndex, u16 wLength); 52 | 53 | usbcdc_sts_t usbcdc_sendData(u8* buf, u8 len); 54 | u8 usbcdc_sendBulkData(void); 55 | 56 | u8 usbcdc_isAvailable(void); 57 | u8* usbcdc_getData(void); 58 | void usbcdc_init(void); 59 | void usbcdc_setCB(cdc_handlerFn_t rxFunc, cdc_handlerFn_t txCb); 60 | void usbcdc_setRxBuf(u8 *buf); 61 | 62 | 63 | 64 | 65 | /* Disable C linkage for C++ Compilers: */ 66 | #if defined(__cplusplus) 67 | } 68 | #endif 69 | -------------------------------------------------------------------------------- /SDK/components/application/app/usbcdc_i.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file usbcdc_i.h 3 | * 4 | * @brief for TLSR chips 5 | * 6 | * @author public@telink-semi.com; 7 | * @date Sep. 30, 2010 8 | * 9 | * @par Copyright (c) Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential and proprietary property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee in separate contract or the terms described here-in. 16 | * This heading MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | 23 | #pragma once 24 | 25 | #include "usbcdc.h" 26 | 27 | #include "../usbstd/usb.h" 28 | #include "../usbstd/usbhw.h" 29 | #include "../usbstd/usbhw_i.h" 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /SDK/components/application/app/usbkb.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/SDK/components/application/app/usbkb.c -------------------------------------------------------------------------------- /SDK/components/application/app/usbkb.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file usbkb.h 3 | * 4 | * @brief for TLSR chips 5 | * 6 | * @author public@telink-semi.com; 7 | * @date Sep. 30, 2010 8 | * 9 | * @par Copyright (c) Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential and proprietary property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee in separate contract or the terms described here-in. 16 | * This heading MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | #pragma once 23 | #include 24 | #include 25 | #include "tl_common.h" 26 | #include "drivers.h" 27 | //#include "../common/types.h" 28 | //#include "../common/static_assert.h" 29 | //#include "../mcu/clock_i.h" 30 | 31 | /* Enable C linkage for C++ Compilers: */ 32 | #if defined(__cplusplus) 33 | extern "C" { 34 | #endif 35 | 36 | 37 | #define DAT_TYPE_KB 1 38 | #define DAT_TYPE_MOUSE 2 39 | 40 | #define USB_FIFO_NUM 4 41 | #define USB_FIFO_SIZE 8 42 | 43 | extern u8 usb_fifo[USB_FIFO_NUM][USB_FIFO_SIZE]; 44 | extern u8 usb_ff_rptr; 45 | extern u8 usb_ff_wptr; 46 | 47 | 48 | 49 | #define KEYBOARD_REPORT_KEY_MAX 6 50 | typedef struct { 51 | u8 Modifier; /**< Keyboard modifier byte, indicating pressed modifier keys (a combination of 52 | * \c HID_KEYBOARD_MODIFER_* masks). 53 | */ 54 | u8 Reserved; /**< Reserved for OEM use, always set to 0. */ 55 | u8 KeyCode[KEYBOARD_REPORT_KEY_MAX]; /**< Key codes of the currently pressed keys. */ 56 | } usbkb_hid_report_t; 57 | 58 | int usbkb_hid_report_normal(u8 ctrl_key, u8 *keycode); 59 | 60 | int usb_hid_report_fifo_proc(void); 61 | 62 | /* Disable C linkage for C++ Compilers: */ 63 | #if defined(__cplusplus) 64 | } 65 | #endif 66 | 67 | -------------------------------------------------------------------------------- /SDK/components/application/app/usbkb_i.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file usbkb_i.h 3 | * 4 | * @brief for TLSR chips 5 | * 6 | * @author public@telink-semi.com; 7 | * @date Sep. 30, 2010 8 | * 9 | * @par Copyright (c) Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential and proprietary property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee in separate contract or the terms described here-in. 16 | * This heading MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | 23 | #pragma once 24 | 25 | #include "usbkb.h" 26 | #include "../usbstd/usbhw.h" 27 | #include "../usbstd/usbhw_i.h" 28 | #include "../../common/config/user_config.h" 29 | 30 | /** HID class report descriptor. This is a special descriptor constructed with values from the 31 | * USBIF HID class specification to describe the reports and capabilities of the HID device. This 32 | * descriptor is parsed by the host and its contents used to determine what data (and in what encoding) 33 | * the device will send, and what it may be sent back from the host. Refer to the HID specification for 34 | * more details on HID report descriptors. 35 | */ 36 | static const USB_Descriptor_HIDReport_Datatype_t keyboard_report_desc[] = { 37 | HID_DESCRIPTOR_KEYBOARD(KEYBOARD_REPORT_KEY_MAX), 38 | }; 39 | 40 | static inline u8* usbkb_get_report_desc(void) { 41 | return (u8*) (keyboard_report_desc); 42 | } 43 | 44 | static inline u16 usbkb_get_report_desc_size(void) { 45 | return sizeof(keyboard_report_desc); 46 | } 47 | 48 | 49 | -------------------------------------------------------------------------------- /SDK/components/application/app/usbmouse.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/SDK/components/application/app/usbmouse.c -------------------------------------------------------------------------------- /SDK/components/application/app/usbmouse.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file usbmouse.h 3 | * 4 | * @brief for TLSR chips 5 | * 6 | * @author public@telink-semi.com; 7 | * @date Sep. 30, 2010 8 | * 9 | * @par Copyright (c) Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential and proprietary property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee in separate contract or the terms described here-in. 16 | * This heading MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | #pragma once 23 | 24 | 25 | #include 26 | #include 27 | #include "tl_common.h" 28 | //#include "../common/types.h" 29 | //#include "../common/static_assert.h" 30 | //#include "../common/bit.h" 31 | 32 | /* Enable C linkage for C++ Compilers: */ 33 | #if defined(__cplusplus) 34 | extern "C" { 35 | #endif 36 | 37 | 38 | #define MOUSE_REPORT_DATA_LEN (sizeof(mouse_data_t)) 39 | #define MEDIA_REPORT_DATA_LEN 4 40 | int usbmouse_hid_report(u8 report_id, u8 *data, int cnt); 41 | 42 | 43 | /* Disable C linkage for C++ Compilers: */ 44 | #if defined(__cplusplus) 45 | } 46 | #endif 47 | -------------------------------------------------------------------------------- /SDK/components/application/app/usbmouse_i.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/SDK/components/application/app/usbmouse_i.h -------------------------------------------------------------------------------- /SDK/components/application/keyboard/keyboard.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/SDK/components/application/keyboard/keyboard.c -------------------------------------------------------------------------------- /SDK/components/application/print/putchar.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file putchar.h 3 | * 4 | * @brief for TLSR chips 5 | * 6 | * @author public@telink-semi.com; 7 | * @date Sep. 30, 2010 8 | * 9 | * @par Copyright (c) Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential and proprietary property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee in separate contract or the terms described here-in. 16 | * This heading MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | 23 | #pragma once 24 | 25 | #ifndef WIN32 26 | 27 | int putchar(int c); 28 | 29 | #endif 30 | 31 | 32 | -------------------------------------------------------------------------------- /SDK/components/application/print/u_printf.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file u_printf.h 3 | * 4 | * @brief for TLSR chips 5 | * 6 | * @author public@telink-semi.com; 7 | * @date Sep. 30, 2010 8 | * 9 | * @par Copyright (c) Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential and proprietary property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee in separate contract or the terms described here-in. 16 | * This heading MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | #pragma once 23 | 24 | int u_printf(const char *fmt, ...); 25 | int u_sprintf(char* s, const char *fmt, ...); 26 | void u_array_printf(unsigned char*data, unsigned int len); 27 | 28 | #define printf u_printf 29 | #define sprintf u_sprintf 30 | #define array_printf u_array_printf 31 | 32 | 33 | -------------------------------------------------------------------------------- /SDK/components/application/usbstd/CDCClassDevice.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file CDCClassDevice.h 3 | * 4 | * @brief for TLSR chips 5 | * 6 | * @author public@telink-semi.com; 7 | * @date Sep. 30, 2010 8 | * 9 | * @par Copyright (c) Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential and proprietary property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee in separate contract or the terms described here-in. 16 | * This heading MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | #pragma once 23 | 24 | /* Includes: */ 25 | #include 26 | #include "../common/types.h" 27 | 28 | /* Enable C linkage for C++ Compilers: */ 29 | #if defined(__cplusplus) 30 | extern "C" { 31 | #endif 32 | 33 | typedef struct 34 | { 35 | struct 36 | { 37 | u8 ControlInterfaceNumber; 38 | u8 DataINEndpointNumber; 39 | u16 DataINEndpointSize; 40 | bool DataINEndpointDoubleBank; 41 | u8 DataOUTEndpointNumber; 42 | u16 DataOUTEndpointSize; 43 | bool DataOUTEndpointDoubleBank; 44 | u8 NotificationEndpointNumber; 45 | u16 NotificationEndpointSize; 46 | bool NotificationEndpointDoubleBank; 47 | } Config; 48 | 49 | struct 50 | { 51 | struct 52 | { 53 | u16 HostToDevice; 54 | u16 DeviceToHost; 55 | } ControlLineStates; 56 | 57 | CDC_LineEncoding_t LineEncoding; 58 | } State; 59 | } USB_ClassInfo_CDC_Device_t; 60 | 61 | 62 | /* Disable C linkage for C++ Compilers: */ 63 | #if defined(__cplusplus) 64 | } 65 | #endif 66 | -------------------------------------------------------------------------------- /SDK/components/application/usbstd/HIDClassDevice.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file HIDClassDevice.h 3 | * 4 | * @brief for TLSR chips 5 | * 6 | * @author public@telink-semi.com; 7 | * @date Sep. 30, 2010 8 | * 9 | * @par Copyright (c) Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential and proprietary property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee in separate contract or the terms described here-in. 16 | * This heading MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | 23 | #pragma once 24 | 25 | /* Includes: */ 26 | #include "../common/types.h" 27 | 28 | /* Enable C linkage for C++ Compilers: */ 29 | #if defined(__cplusplus) 30 | extern "C" { 31 | #endif 32 | 33 | typedef struct 34 | { 35 | u8 InterfaceNumber; 36 | u8 ReportINEndpointNumber; 37 | u16 ReportINEndpointSize; 38 | bool ReportINEndpointDoubleBank; 39 | void* PrevReportINBuffer; 40 | u8 PrevReportINBufferSize; 41 | } usbhid_config_t; 42 | 43 | typedef struct 44 | { 45 | bool UsingReportProtocol; 46 | u16 PrevFrameNum; 47 | u16 IdleCount; 48 | u16 IdleMSRemaining; 49 | } usbhid_state_t; 50 | 51 | 52 | 53 | /* Disable C linkage for C++ Compilers: */ 54 | #if defined(__cplusplus) 55 | } 56 | #endif 57 | 58 | 59 | -------------------------------------------------------------------------------- /SDK/components/application/usbstd/PrinterClassCommon.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file PrinterClassCommon.h 3 | * 4 | * @brief for TLSR chips 5 | * 6 | * @author public@telink-semi.com; 7 | * @date Sep. 30, 2010 8 | * 9 | * @par Copyright (c) Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential and proprietary property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee in separate contract or the terms described here-in. 16 | * This heading MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | #pragma once 23 | /* Includes: */ 24 | #include "tl_common.h" 25 | 26 | /* Enable C linkage for C++ Compilers: */ 27 | #if defined(__cplusplus) 28 | extern "C" { 29 | #endif 30 | 31 | 32 | #define PRNT_PORTSTATUS_NOTERROR BIT(3) 33 | #define PRNT_PORTSTATUS_SELECT BIT(4) 34 | #define PRNT_PORTSTATUS_PAPEREMPTY BIT(5) 35 | 36 | enum PRNT_Descriptor_ClassSubclassProtocol_t 37 | { 38 | PRNT_CSCP_PrinterClass = 0x07, 39 | PRNT_CSCP_PrinterSubclass = 0x01, 40 | PRNT_CSCP_BidirectionalProtocol = 0x02, 41 | }; 42 | 43 | enum PRNT_ClassRequests_t 44 | { 45 | PRNT_REQ_GetDeviceID, 46 | PRNT_REQ_GetPortStatus, 47 | PRNT_REQ_SoftReset, 48 | }; 49 | 50 | /* Disable C linkage for C++ Compilers: */ 51 | #if defined(__cplusplus) 52 | } 53 | #endif 54 | 55 | -------------------------------------------------------------------------------- /SDK/components/application/usbstd/USBController.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file USBController.h 3 | * 4 | * @brief for TLSR chips 5 | * 6 | * @author public@telink-semi.com; 7 | * @date Sep. 30, 2010 8 | * 9 | * @par Copyright (c) Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential and proprietary property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee in separate contract or the terms described here-in. 16 | * This heading MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | 23 | #pragma once 24 | 25 | /* Enable C linkage for C++ Compilers: */ 26 | #if defined(__cplusplus) 27 | extern "C" { 28 | #endif 29 | 30 | 31 | /**If Isochronous endpoint, 32 | Bits 3..2 = Synchronisation Type (Iso Mode) 33 | 00 = No Synchonisation 34 | 01 = Asynchronous 35 | 10 = Adaptive 36 | 11 = Synchronous 37 | Bits 5..4 = Usage Type (Iso Mode) 38 | 00 = Data Endpoint 39 | 01 = Feedback Endpoint 40 | 10 = Explicit Feedback Data Endpoint 41 | 11 = Reserved 42 | */ 43 | #define EP_SYNC_TYPE_NO_SYNC 0 44 | #define EP_SYNC_TYPE_ASYN 1 45 | #define EP_SYNC_TYPE_ADAPTIVE 2 46 | #define EP_SYNC_TYPE_SYNC 3 47 | 48 | #define EP_USAGE_TYPE_DATA 0 49 | #define EP_USAGE_TYPE_FEEDBACK 1 50 | #define EP_USAGE_TYPE_FEEDBACK_DATA 2 51 | #define EP_USAGE_TYPE_RSV 3 52 | 53 | 54 | #define ENDPOINT_DIR_MASK BIT(7) 55 | #define ENDPOINT_DIR_OUT 0 56 | #define ENDPOINT_DIR_IN BIT(7) 57 | #define EP_TYPE_MASK 3 58 | #define EP_TYPE_CONTROL 0 59 | #define EP_TYPE_ISOCHRONOUS 1 60 | #define EP_TYPE_BULK 2 61 | #define EP_TYPE_INTERRUPT 3 62 | 63 | /* Disable C linkage for C++ Compilers: */ 64 | #if defined(__cplusplus) 65 | } 66 | #endif 67 | 68 | -------------------------------------------------------------------------------- /SDK/components/application/usbstd/usb.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file usb.h 3 | * 4 | * @brief for TLSR chips 5 | * 6 | * @author public@telink-semi.com; 7 | * @date Sep. 30, 2010 8 | * 9 | * @par Copyright (c) Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential and proprietary property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee in separate contract or the terms described here-in. 16 | * This heading MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | 23 | #pragma once 24 | #include "tl_common.h" 25 | #include "usbdesc.h" 26 | 27 | /* Enable C linkage for C++ Compilers: */ 28 | #if defined(__cplusplus) 29 | extern "C" { 30 | #endif 31 | 32 | enum { 33 | // 3000 ms 34 | USB_TIME_BEFORE_ALLOW_SUSPEND = (3000*1000), 35 | }; 36 | 37 | enum { 38 | USB_IRQ_SETUP_REQ = 0, 39 | USB_IRQ_DATA_REQ, 40 | }; 41 | 42 | 43 | // telink usb report ctrl command. used mixed with USB_AUD_PLAY_PAUSE... 44 | enum{ 45 | USB_REPORT_NO_EVENT = 0xf0, 46 | USB_REPORT_RELEASE = 0xff, 47 | }; 48 | 49 | #if (USB_MIC_ENABLE) 50 | extern u8 usb_alt_intf[USB_INTF_MAX]; 51 | static inline int usb_mic_is_enable(){ 52 | return usb_alt_intf[USB_INTF_MIC]; 53 | } 54 | #endif 55 | 56 | extern u8 usb_just_wakeup_from_suspend; 57 | extern u8 usb_has_suspend_irq; 58 | extern u8 edp_toggle[8]; 59 | 60 | void usb_init(); 61 | 62 | #ifndef USB_SOFTWARE_CRC_CHECK 63 | #define USB_SOFTWARE_CRC_CHECK 0 64 | #endif 65 | 66 | #define MS_VENDORCODE 'T' //This must match the char after the "MSFT100" 67 | #define STRING_MSFT L"MSFT100T" 68 | 69 | #define MS_OS_DESCRIPTOR_ENABLE 0 70 | 71 | /* Disable C linkage for C++ Compilers: */ 72 | #if defined(__cplusplus) 73 | } 74 | #endif 75 | 76 | -------------------------------------------------------------------------------- /SDK/components/application/usbstd/usbdesc.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/SDK/components/application/usbstd/usbdesc.h -------------------------------------------------------------------------------- /SDK/components/application/usbstd/usbhw.c: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file usbhw.c 3 | * 4 | * @brief for TLSR chips 5 | * 6 | * @author public@telink-semi.com; 7 | * @date Sep. 30, 2010 8 | * 9 | * @par Copyright (c) Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential and proprietary property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee in separate contract or the terms described here-in. 16 | * This heading MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | #include "tl_common.h" 23 | #include "drivers.h" 24 | 25 | 26 | #include "usbhw.h" 27 | #include "usbhw_i.h" 28 | 29 | // Endpont8 is the alias of endpoint0 30 | void usbhw_disable_manual_interrupt(int m) { 31 | SET_FLD(reg_ctrl_ep_irq_mode, m); 32 | } 33 | 34 | void usbhw_enable_manual_interrupt(int m) { 35 | CLR_FLD(reg_ctrl_ep_irq_mode, m); 36 | } 37 | 38 | void usbhw_write_ep(u32 ep, u8 * data, int len) { 39 | assert(ep < 8); 40 | reg_usb_ep_ptr(ep) = 0; 41 | 42 | foreach(i,len){ 43 | reg_usb_ep_dat(ep) = data[i]; 44 | } 45 | reg_usb_ep_ctrl(ep) = FLD_EP_DAT_ACK; // ACK 46 | } 47 | 48 | // handy help function 49 | void usbhw_write_ctrl_ep_u16(u16 v){ 50 | usbhw_write_ctrl_ep_data(v & 0xff); 51 | usbhw_write_ctrl_ep_data(v >> 8); 52 | } 53 | 54 | u16 usbhw_read_ctrl_ep_u16(void){ 55 | u16 v = usbhw_read_ctrl_ep_data(); 56 | return (usbhw_read_ctrl_ep_data() << 8) | v; 57 | } 58 | 59 | -------------------------------------------------------------------------------- /SDK/components/common/bit.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/SDK/components/common/bit.h -------------------------------------------------------------------------------- /SDK/components/common/breakpoint.c: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file breakpoint.c 3 | * 4 | * @brief for TLSR chips 5 | * 6 | * @author public@telink-semi.com; 7 | * @date Sep. 30, 2010 8 | * 9 | * @par Copyright (c) Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential and proprietary property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee in separate contract or the terms described here-in. 16 | * This heading MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | 23 | #include "breakpoint.h" 24 | 25 | volatile int bp_enable = 1; 26 | volatile int bp_continue; 27 | volatile int bp_counter; 28 | volatile int bp_pos; 29 | 30 | -------------------------------------------------------------------------------- /SDK/components/common/config/user_config.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file user_config.h 3 | * 4 | * @brief for TLSR chips 5 | * 6 | * @author public@telink-semi.com; 7 | * @date Sep. 30, 2010 8 | * 9 | * @par Copyright (c) Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential and proprietary property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee in separate contract or the terms described here-in. 16 | * This heading MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | 23 | #pragma once 24 | 25 | #include "../../vendor/common/user_config.h" 26 | 27 | -------------------------------------------------------------------------------- /SDK/components/common/log.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file log.h 3 | * 4 | * @brief for TLSR chips 5 | * 6 | * @author public@telink-semi.com; 7 | * @date Sep. 30, 2010 8 | * 9 | * @par Copyright (c) Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential and proprietary property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee in separate contract or the terms described here-in. 16 | * This heading MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | 23 | #pragma once 24 | 25 | #include "log_id.h" 26 | #include "application/print/u_printf.h" 27 | 28 | 29 | #ifndef LOG_IN_RAM 30 | #define LOG_IN_RAM 0 31 | #endif 32 | 33 | #define LOG_MASK_BEGIN 0x40 34 | #define LOG_MASK_END 0x00 35 | #define LOG_MASK_TGL 0xC0 36 | #define LOG_MASK_DAT 0x80 37 | 38 | static inline void swire2usb_init (void) { 39 | U8_SET(0x800128, 0x00); 40 | U8_SET(0x80012d, 0); 41 | U8_SET(0x80013b, 32); 42 | } 43 | 44 | static inline void usb_log_init (void) { 45 | U8_SET(0x80013c, 0x40); 46 | U8_SET(0x80013d, 0x09); 47 | } 48 | 49 | #if (__LOG_RT_ENABLE__) 50 | void log_write_data(int id, int type, u32 dat); 51 | void log_task_begin(int id); 52 | void log_task_end(int id); 53 | void log_event(int id); 54 | void log_data(int id, u32 dat); 55 | 56 | #define LOG_TICK(id,e) do{log_task_begin(id); e; log_task_end(id);}while(0) 57 | 58 | #define LOG(x, s,...) printf("(%s:%d)" x "\r\n" , __FUNCTION__, __LINE__, ## s) 59 | 60 | #else 61 | #define log_write_data(id, type, dat) 62 | #define log_task_begin(id) 63 | #define log_task_end(id) 64 | #define log_event(id) 65 | #define log_data(id, dat) 66 | #define LOG_TICK(id,e) do{e;}while (0) 67 | 68 | #define LOG(x, s,...) 69 | 70 | #endif 71 | 72 | -------------------------------------------------------------------------------- /SDK/components/common/selection_sort.c: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file selection_sort.c 3 | * 4 | * @brief for TLSR chips 5 | * 6 | * @author public@telink-semi.com; 7 | * @date Sep. 30, 2010 8 | * 9 | * @par Copyright (c) Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential and proprietary property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee in separate contract or the terms described here-in. 16 | * This heading MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | 23 | void selection_sort_char(unsigned char * arr, int size){ 24 | //sorting 25 | int i, j; 26 | for(i = 0; i < size; ++i) 27 | { 28 | for( j = i + 1; j < size; ++j) 29 | { 30 | if (arr[j] < arr[i]) 31 | { 32 | unsigned char t = arr[i]; 33 | arr[i] = arr[j]; 34 | arr[j] = t; 35 | } 36 | } 37 | } 38 | } 39 | 40 | void selection_sort_int(unsigned int * arr, int size){ 41 | //sorting 42 | int i, j; 43 | for(i = 0; i < size; ++i) 44 | { 45 | for( j = i + 1; j < size; ++j) 46 | { 47 | if (arr[j] < arr[i]) 48 | { 49 | unsigned int t = arr[i]; 50 | arr[i] = arr[j]; 51 | arr[j] = t; 52 | } 53 | } 54 | } 55 | } 56 | 57 | 58 | -------------------------------------------------------------------------------- /SDK/components/common/selection_sort.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file selection_sort.h 3 | * 4 | * @brief for TLSR chips 5 | * 6 | * @author public@telink-semi.com; 7 | * @date Sep. 30, 2010 8 | * 9 | * @par Copyright (c) Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential and proprietary property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee in separate contract or the terms described here-in. 16 | * This heading MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | 23 | #pragma once 24 | 25 | void selection_sort_char(unsigned char * arr, int size); 26 | void selection_sort_int(unsigned int * arr, int size); 27 | 28 | -------------------------------------------------------------------------------- /SDK/components/common/static_assert.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file static_assert.h 3 | * 4 | * @brief for TLSR chips 5 | * 6 | * @author public@telink-semi.com; 7 | * @date Sep. 30, 2010 8 | * 9 | * @par Copyright (c) Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential and proprietary property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee in separate contract or the terms described here-in. 16 | * This heading MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | 23 | #pragma once 24 | 25 | // static assertion. evaluate at compile time. It is very useful like, STATIC_ASSERT(sizeof(a) == 5); 26 | 27 | // #define STATIC_ASSERT(expr) { char static_assertion[(expr) ? 1 : -1]; ((void) static_assertion); } // (void) array; to remove compiler unused variable warning 28 | 29 | // more complicated version canbe used anywhere in the source 30 | #define STATIC_ASSERT_M(COND,MSG) typedef char static_assertion_##MSG[(!!(COND))*2-1] 31 | // token pasting madness: 32 | #define STATIC_ASSERT3(X,L) STATIC_ASSERT_M(X,static_assertion_at_line_##L) 33 | #define STATIC_ASSERT2(X,L) STATIC_ASSERT3(X,L) 34 | 35 | #define STATIC_ASSERT(X) STATIC_ASSERT2(X,__LINE__) 36 | 37 | #define STATIC_ASSERT_POW2(expr) STATIC_ASSERT(!((expr) & ((expr)-1))) // assert expr is 2**N 38 | #define STATIC_ASSERT_EVEN(expr) STATIC_ASSERT(!((expr) & 1)) 39 | #define STATIC_ASSERT_ODD(expr) STATIC_ASSERT(((expr) & 1)) 40 | #define STATIC_ASSERT_INT_DIV(a, b) STATIC_ASSERT((a) / (b) * (b) == (a)) 41 | 42 | -------------------------------------------------------------------------------- /SDK/components/config.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file config.h 3 | * 4 | * @brief This is the header file for TLSR8258 5 | * 6 | * @author author@telink-semi.com; 7 | * @date May 8, 2018 8 | * 9 | * @par Copyright (c) 2018, Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee or the terms described here-in. This heading 16 | * MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | 23 | #pragma once 24 | 25 | 26 | #define CHIP_TYPE_8255 1 27 | #define CHIP_TYPE_8258 2 28 | 29 | 30 | 31 | #ifndef CHIP_TYPE 32 | #define CHIP_TYPE 1000 33 | #endif 34 | 35 | 36 | 37 | 38 | 39 | 40 | #define MCU_CORE_8255 1 41 | #define MCU_CORE_8258 2 42 | 43 | 44 | #if(CHIP_TYPE == CHIP_TYPE_8255) 45 | #define MCU_CORE_TYPE MCU_CORE_8255 46 | #elif(CHIP_TYPE == CHIP_TYPE_8258) 47 | #define MCU_CORE_TYPE MCU_CORE_8258 48 | #else 49 | #define MCU_CORE_TYPE 1000 50 | #endif 51 | 52 | 53 | -------------------------------------------------------------------------------- /SDK/components/drivers.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file drivers.h 3 | * 4 | * @brief This is the header file for TLSR8258 5 | * 6 | * @author author@telink-semi.com; 7 | * @date May 8, 2018 8 | * 9 | * @par Copyright (c) 2018, Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee or the terms described here-in. This heading 16 | * MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | 23 | #pragma once 24 | 25 | #include "config.h" 26 | 27 | #if(__TL_LIB_8255__ || (MCU_CORE_TYPE == MCU_CORE_8255)) 28 | #include "drivers/8255/driver_8255.h" 29 | #elif(__TL_LIB_8258__ || (MCU_CORE_TYPE == MCU_CORE_8258)) 30 | #include "drivers/8258/driver_8258.h" 31 | #else 32 | #include "drivers/8258/driver_8258.h" 33 | #endif 34 | -------------------------------------------------------------------------------- /SDK/components/drivers/8258/adc.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/SDK/components/drivers/8258/adc.h -------------------------------------------------------------------------------- /SDK/components/drivers/8258/analog.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file analog.h 3 | * 4 | * @brief This is the header file for TLSR8258 5 | * 6 | * @author Driver Group 7 | * @date May 8, 2018 8 | * 9 | * @par Copyright (c) 2018, Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee or the terms described here-in. This heading 16 | * MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * @par History: 21 | * 1.initial release(DEC. 26 2018) 22 | * 23 | * @version A001 24 | * 25 | *******************************************************************************************************/ 26 | 27 | #pragma once 28 | 29 | #include "compiler.h" 30 | 31 | 32 | /** 33 | * @brief This function serves to analog register read. 34 | * @param[in] addr - address need to be read. 35 | * @return the result of read. 36 | */ 37 | unsigned char analog_read(unsigned char addr); 38 | 39 | /** 40 | * @brief This function serves to analog register write. 41 | * @param[in] addr - address need to be write. 42 | * @param[in] v - the value need to be write. 43 | * @return none. 44 | */ 45 | void analog_write(unsigned char addr, unsigned char v); 46 | 47 | /** 48 | * @brief This function serves to analog register read. 49 | * @param[in] addr - address need to be read. 50 | * @param[in] *buff - the value need to be read. 51 | * @param[in] len - the length of read value. 52 | * @return none. 53 | */ 54 | void analog_read_buff(unsigned char addr, unsigned char *buff, int len); 55 | 56 | /** 57 | * @brief This function serves to analog register write. 58 | * @param[in] addr - address need to be write. 59 | * @param[in] *buff - the value need to be write. 60 | * @param[in] len - the length of write value. 61 | * @return none. 62 | */ 63 | void analog_write_buff(unsigned char addr, unsigned char *buff, int len); 64 | 65 | 66 | #define WriteAnalogReg analog_write 67 | #define ReadAnalogReg analog_read 68 | 69 | -------------------------------------------------------------------------------- /SDK/components/drivers/8258/clock.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/SDK/components/drivers/8258/clock.c -------------------------------------------------------------------------------- /SDK/components/drivers/8258/compiler.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file compiler.h 3 | * 4 | * @brief This is the header file for TLSR8258 5 | * 6 | * @author Driver Group 7 | * @date May 8, 2018 8 | * 9 | * @par Copyright (c) 2018, Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee or the terms described here-in. This heading 16 | * MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * @par History: 21 | * 1.initial release(DEC. 26 2018) 22 | * 23 | * @version A001 24 | * 25 | *******************************************************************************************************/ 26 | 27 | #pragma once 28 | 29 | 30 | #define _attribute_packed_ __attribute__((packed)) 31 | #define _attribute_aligned_(s) __attribute__((aligned(s))) 32 | #define _attribute_session_(s) __attribute__((section(s))) 33 | #define _attribute_ram_code_ _attribute_session_(".ram_code") 34 | #define _attribute_my_ram_code_ _attribute_session_(".my_ram_code") 35 | #define _attribute_custom_code_ _attribute_session_(".custom") volatile 36 | #define _attribute_no_inline_ __attribute__((noinline)) 37 | #define _inline_ inline 38 | 39 | #ifndef BLC_PM_DEEP_RETENTION_MODE_EN 40 | #define BLC_PM_DEEP_RETENTION_MODE_EN 1 41 | #endif 42 | 43 | #if (BLC_PM_DEEP_RETENTION_MODE_EN) 44 | #define _attribute_data_retention_ _attribute_session_(".retention_data") 45 | #else 46 | #define _attribute_data_retention_ 47 | #endif 48 | 49 | 50 | -------------------------------------------------------------------------------- /SDK/components/drivers/8258/driver_8258.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file driver_8258.h 3 | * 4 | * @brief This is the header file for TLSR8258 5 | * 6 | * @author Driver Group 7 | * @date May 8, 2018 8 | * 9 | * @par Copyright (c) 2018, Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee or the terms described here-in. This heading 16 | * MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | #pragma once 23 | 24 | 25 | 26 | #include "drivers/8258/bsp.h" 27 | #include "drivers/8258/aes.h" 28 | #include "drivers/8258/analog.h" 29 | #include "drivers/8258/compiler.h" 30 | #include "drivers/8258/register.h" 31 | #include "drivers/8258/gpio.h" 32 | #include "drivers/8258/pwm.h" 33 | #include "drivers/8258/irq.h" 34 | #include "drivers/8258/clock.h" 35 | #include "drivers/8258/random.h" 36 | #include "drivers/8258/flash.h" 37 | #include "drivers/8258/rf_drv.h" 38 | #include "drivers/8258/pm.h" 39 | #include "drivers/8258/audio.h" 40 | #include "drivers/8258/adc.h" 41 | #include "drivers/8258/i2c.h" 42 | #include "drivers/8258/spi.h" 43 | #include "drivers/8258/uart.h" 44 | #include "drivers/8258/register.h" 45 | #include "drivers/8258/watchdog.h" 46 | #include "drivers/8258/register.h" 47 | #include "drivers/8258/dfifo.h" 48 | #include "drivers/8258/dma.h" 49 | #include "drivers/8258/emi.h" 50 | #include "drivers/8258/timer.h" 51 | 52 | #include "drivers/8258/s7816.h" 53 | #include "drivers/8258/qdec.h" 54 | #include "drivers/8258/lpc.h" 55 | 56 | #include "drivers/8258/rf_pa.h" 57 | -------------------------------------------------------------------------------- /SDK/components/drivers/8258/gpio.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file gpio.h 3 | * 4 | * @brief This is the header file for TLSR8258 5 | * 6 | * @author Driver Group 7 | * @date May 8, 2018 8 | * 9 | * @par Copyright (c) 2018, Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee or the terms described here-in. This heading 16 | * MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | 23 | #pragma once 24 | 25 | 26 | 27 | #include "gpio_default_8258.h" 28 | #include "gpio_8258.h" 29 | 30 | 31 | -------------------------------------------------------------------------------- /SDK/components/drivers/8258/random.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file random.h 3 | * 4 | * @brief This is the header file for TLSR8258 5 | * 6 | * @author Driver Group 7 | * @date May 8, 2018 8 | * 9 | * @par Copyright (c) 2018, Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee or the terms described here-in. This heading 16 | * MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | 23 | #pragma once 24 | 25 | 26 | /** 27 | * @brief This function performs to initials random generator post. 28 | * @param[in] none. 29 | * @return none. 30 | */ 31 | void random_generator_init(void); 32 | 33 | /** 34 | * @brief This function performs to get one random number 35 | * @param[in] none. 36 | * @return the value of one random number. 37 | */ 38 | unsigned int rand(void); 39 | 40 | /** 41 | * @brief This function performs to get a serial of random number. 42 | * @param[in] len- the length of random number 43 | * @param[in] data - the first address of buffer store random number in 44 | * @return the result of a serial of random number. 45 | */ 46 | void generateRandomNum(int len, unsigned char *data); 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /SDK/components/drivers/8258/register.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file register.h 3 | * 4 | * @brief This is the header file for TLSR8258 5 | * 6 | * @author Driver Group 7 | * @date May 8, 2018 8 | * 9 | * @par Copyright (c) 2018, Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee or the terms described here-in. This heading 16 | * MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | #pragma once 23 | 24 | 25 | 26 | #include "register_8258.h" 27 | 28 | 29 | -------------------------------------------------------------------------------- /SDK/components/drivers/8258/rf_drv.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/SDK/components/drivers/8258/rf_drv.h -------------------------------------------------------------------------------- /SDK/components/drivers/8258/rf_pa.c: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file rf_pa.c 3 | * 4 | * @brief This is the header file for TLSR8258 5 | * 6 | * @author public@telink-semi.com; 7 | * @date May 8, 2018 8 | * 9 | * @par Copyright (c) 2018, Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee or the terms described here-in. This heading 16 | * MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | 23 | #include "rf_pa.h" 24 | #include "gpio.h" 25 | #include "compiler.h" 26 | 27 | _attribute_data_retention_ rf_pa_callback_t blc_rf_pa_cb = 0; 28 | 29 | void app_rf_pa_handler(int type) 30 | { 31 | #if(PA_ENABLE) 32 | if(type == PA_TYPE_TX_ON){ 33 | gpio_set_output_en(PA_RXEN_PIN, 0); 34 | gpio_write(PA_RXEN_PIN, 0); 35 | gpio_set_output_en(PA_TXEN_PIN, 1); 36 | gpio_write(PA_TXEN_PIN, 1); 37 | } 38 | else if(type == PA_TYPE_RX_ON){ 39 | gpio_set_output_en(PA_TXEN_PIN, 0); 40 | gpio_write(PA_TXEN_PIN, 0); 41 | gpio_set_output_en(PA_RXEN_PIN, 1); 42 | gpio_write(PA_RXEN_PIN, 1); 43 | } 44 | else{ 45 | gpio_set_output_en(PA_RXEN_PIN, 0); 46 | gpio_write(PA_RXEN_PIN, 0); 47 | gpio_set_output_en(PA_TXEN_PIN, 0); 48 | gpio_write(PA_TXEN_PIN, 0); 49 | } 50 | #endif 51 | } 52 | 53 | 54 | void rf_pa_init(void) 55 | { 56 | #if(PA_ENABLE) 57 | //rf_set_power_level_index (RF_POWER_0dBm); 58 | gpio_set_func(PA_TXEN_PIN, AS_GPIO); 59 | gpio_set_output_en(PA_TXEN_PIN, 0); 60 | gpio_write(PA_TXEN_PIN, 0); 61 | 62 | gpio_set_func(PA_RXEN_PIN, AS_GPIO); 63 | gpio_set_output_en(PA_RXEN_PIN, 0); 64 | gpio_write(PA_RXEN_PIN, 0); 65 | 66 | blc_rf_pa_cb = app_rf_pa_handler; 67 | #endif 68 | } 69 | 70 | -------------------------------------------------------------------------------- /SDK/components/drivers/8258/rf_pa.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file rf_pa.h 3 | * 4 | * @brief This is the header file for TLSR8258 5 | * 6 | * @author public@telink-semi.com; 7 | * @date May 8, 2018 8 | * 9 | * @par Copyright (c) 2018, Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee or the terms described here-in. This heading 16 | * MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | 23 | #ifndef BLT_PA_H_ 24 | #define BLT_PA_H_ 25 | 26 | #include "gpio.h" 27 | 28 | 29 | #ifndef PA_ENABLE 30 | #define PA_ENABLE 0 31 | #endif 32 | 33 | 34 | 35 | #ifndef PA_TXEN_PIN 36 | #define PA_TXEN_PIN GPIO_PB2 37 | #endif 38 | 39 | #ifndef PA_RXEN_PIN 40 | #define PA_RXEN_PIN GPIO_PB3 41 | #endif 42 | 43 | 44 | 45 | #define PA_TYPE_OFF 0 46 | #define PA_TYPE_TX_ON 1 47 | #define PA_TYPE_RX_ON 2 48 | 49 | 50 | typedef void (*rf_pa_callback_t)(int type); 51 | extern rf_pa_callback_t blc_rf_pa_cb; 52 | 53 | 54 | 55 | void rf_pa_init(void); 56 | 57 | 58 | #endif /* BLT_PA_H_ */ 59 | -------------------------------------------------------------------------------- /SDK/components/drivers/8258/watchdog.c: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file watchdog.c 3 | * 4 | * @brief This is the source file for TLSR8258 5 | * 6 | * @author Driver Group 7 | * @date May 8, 2018 8 | * 9 | * @par Copyright (c) 2018, Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee or the terms described here-in. This heading 16 | * MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * @par History: 21 | * 1.initial release(DEC. 26 2018) 22 | * 23 | * @version A001 24 | * 25 | *******************************************************************************************************/ 26 | 27 | #include "register.h" 28 | 29 | /** 30 | * @brief This function set the seconds period.It is likely with WD_SetInterval. 31 | * Just this function calculate the value to set the register automatically . 32 | * @param[in] period_s - The seconds to set. unit is second 33 | * @return none 34 | */ 35 | void wd_set_interval_ms(unsigned int period_ms,unsigned long int tick_per_ms) 36 | { 37 | static unsigned short tmp_period_ms = 0; 38 | tmp_period_ms = (period_ms*tick_per_ms>>18); 39 | reg_tmr2_tick = 0x00000000; //reset tick register 40 | reg_tmr_ctrl &= (~FLD_TMR_WD_CAPT); 41 | reg_tmr_ctrl |= (tmp_period_ms<<9); //set the capture register 42 | } 43 | 44 | -------------------------------------------------------------------------------- /SDK/components/drivers/8258/watchdog.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file watchdog.h 3 | * 4 | * @brief This is the header file for TLSR8258 5 | * 6 | * @author Driver Group 7 | * @date May 8, 2018 8 | * 9 | * @par Copyright (c) 2018, Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee or the terms described here-in. This heading 16 | * MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * @par History: 21 | * 1.initial release(DEC. 26 2018) 22 | * 23 | * @version A001 24 | * 25 | *******************************************************************************************************/ 26 | 27 | #pragma once 28 | 29 | 30 | #include "register.h" 31 | 32 | /** 33 | * @brief This function set the seconds period.It is likely with WD_SetInterval. 34 | * Just this function calculate the value to set the register automatically . 35 | * @param[in] period_s - The seconds to set. unit is second 36 | * @return none 37 | */ 38 | extern void wd_set_interval_ms(unsigned int period_ms,unsigned long int tick_per_ms); 39 | 40 | /** 41 | * @brief start watchdog. ie enable watchdog 42 | * @param[in] none 43 | * @return none 44 | */ 45 | static inline void wd_start(void){ 46 | BM_SET(reg_tmr_ctrl, FLD_TMR2_EN); 47 | BM_SET(reg_tmr_ctrl, FLD_TMR_WD_EN); 48 | } 49 | /** 50 | * @brief stop watchdog. ie disable watchdog 51 | * @param[in] none 52 | * @return none 53 | */ 54 | static inline void wd_stop(void){ 55 | BM_CLR(reg_tmr_ctrl, FLD_TMR_WD_EN); 56 | } 57 | 58 | /** 59 | * @brief clear watchdog. 60 | * @param[in] none 61 | * @return none 62 | */ 63 | static inline void wd_clear(void) 64 | { 65 | reg_tmr_sta = FLD_TMR_STA_WD; 66 | } 67 | 68 | -------------------------------------------------------------------------------- /SDK/components/freertos/config/FreeRTOSConfig.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/SDK/components/freertos/config/FreeRTOSConfig.h -------------------------------------------------------------------------------- /SDK/components/freertos/include/freertos_api.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file drivers.h 3 | * 4 | * @brief This is the header file for TLSR8258 5 | * 6 | * @author author@telink-semi.com; 7 | * @date May 8, 2018 8 | * 9 | * @par Copyright (c) 2018, Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee or the terms described here-in. This heading 16 | * MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | 23 | #pragma once 24 | 25 | #include "freertos/include/FreeRTOS.h" 26 | #include "freertos/include/task.h" 27 | #include "freertos/include/queue.h" 28 | #include "freertos/include/timers.h" 29 | #include "freertos/include/list.h" 30 | #include "freertos/include/message_buffer.h" 31 | 32 | 33 | -------------------------------------------------------------------------------- /SDK/components/freertos/portable/gcc/port.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/SDK/components/freertos/portable/gcc/port.c -------------------------------------------------------------------------------- /SDK/components/proj_lib/firmware_encrypt.h: -------------------------------------------------------------------------------- 1 | /* 2 | * encrypt.h 3 | * 4 | * Created on: 2019-3-27 5 | * Author: Administrator 6 | */ 7 | 8 | #ifndef ENCRYPT_H_ 9 | #define ENCRYPT_H_ 10 | 11 | void firmware_encrypt_based_on_uid(unsigned char* uid,unsigned char* ciphertext); 12 | 13 | #endif /* ENCRYPT_H_ */ 14 | -------------------------------------------------------------------------------- /SDK/components/proj_lib/libfirmware_encrypt.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/SDK/components/proj_lib/libfirmware_encrypt.a -------------------------------------------------------------------------------- /SDK/components/proj_lib/liblt_8258.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/SDK/components/proj_lib/liblt_8258.a -------------------------------------------------------------------------------- /SDK/components/proj_lib/liblt_8258_rtos.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/SDK/components/proj_lib/liblt_8258_rtos.a -------------------------------------------------------------------------------- /SDK/components/stack/ble/ble_controller.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file ble_controller.h 3 | * 4 | * @brief for TLSR chips 5 | * 6 | * @author BLE Group 7 | * @date Sep. 18, 2018 8 | * 9 | * @par Copyright (c) Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential and proprietary property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee in separate contract or the terms described here-in. 16 | * This heading MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | 23 | #ifndef BLE_CONTROLLER_H_ 24 | #define BLE_CONTROLLER_H_ 25 | 26 | 27 | #include "blt_config.h" 28 | #include "ble_common.h" 29 | 30 | 31 | #include "phy/phy.h" 32 | #include "phy/phy_test.h" 33 | 34 | 35 | 36 | #include "hci/hci.h" 37 | #include "hci/hci_const.h" 38 | #include "hci/hci_event.h" 39 | #include "hci/usb_desc.h" 40 | 41 | 42 | #include "ll/ll.h" 43 | #include "ll/ll_adv.h" 44 | #include "ll/ll_encrypt.h" 45 | #include "ll/ll_init.h" 46 | #include "ll/ll_pm.h" 47 | #include "ll/ll_scan.h" 48 | #include "ll/ll_whitelist.h" 49 | #include "ll/ll_conn/ll_conn.h" 50 | #include "ll/ll_conn/ll_slave.h" 51 | #include "ll/ll_conn/ll_master.h" 52 | #include "ll/ll_conn/ll_conn_phy.h" 53 | #include "ll/ll_conn/ll_conn_csa.h" 54 | 55 | #include "ll/ll_ext.h" 56 | #include "ll/ll_ext_adv.h" 57 | #include "ll/ll_ext_scan.h" 58 | 59 | 60 | 61 | #include "llms/llms.h" 62 | #include "llms/llms_slot.h" 63 | #include "llms/llms_adv.h" 64 | #include "llms/llms_scan.h" 65 | #include "llms/llms_init.h" 66 | #include "llms/llms_slave.h" 67 | #include "llms/llms_master.h" 68 | 69 | 70 | 71 | #include "bqb/bqb_ll.h" 72 | 73 | #endif /* BLE_H_ */ 74 | -------------------------------------------------------------------------------- /SDK/components/stack/ble/ll/ll_conn/ll_conn_csa.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file ll_conn_csa.h 3 | * 4 | * @brief for TLSR chips 5 | * 6 | * @author BLE Group 7 | * @date July. 4, 2019 8 | * 9 | * @par Copyright (c) Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential and proprietary property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee in separate contract or the terms described here-in. 16 | * This heading MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | 23 | #ifndef LL_CONN_CSA_H_ 24 | #define LL_CONN_CSA_H_ 25 | 26 | 27 | 28 | /******************************* Macro & Enumeration variables for Stack, user can not use!!!! ********************************/ 29 | 30 | //See the Core_v5.0(Vol 6/Part B/4.5.8, "Data Channel Index Selection") for more information. 31 | typedef enum { 32 | CHANNAL_SELECTION_ALGORITHM_1 = 0x00, 33 | CHANNAL_SELECTION_ALGORITHM_2 = 0x01, 34 | } channel_algorithm_t; 35 | 36 | 37 | 38 | typedef u8 (*ll_chn_index_calc_callback_t)(u8*, u16, u16); 39 | extern ll_chn_index_calc_callback_t ll_chn_index_calc_cb; 40 | 41 | 42 | 43 | 44 | 45 | 46 | /******************************** Macro & Enumeration variables for User *****************************************************/ 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | /******************************** User Interface ****************************************************************************/ 61 | void blc_ll_initChannelSelectionAlgorithm_2_feature(void); 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | /******************************* Stack Interface, user can not use!!! *******************************************************/ 78 | u8 blc_calc_remapping_table(u8 chm[5]); 79 | 80 | u8 blc_ll_channel_index_calc_csa2(u8 chm[5], u16 event_cntr, u16 channel_id); 81 | 82 | 83 | 84 | 85 | #endif /* LL_CONN_CSA_H_ */ 86 | -------------------------------------------------------------------------------- /SDK/components/stack/ble/ll/ll_conn/ll_conn_phy.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file ll_conn_phy.h 3 | * 4 | * @brief for TLSR chips 5 | * 6 | * @author BLE Group 7 | * @date July. 4, 2019 8 | * 9 | * @par Copyright (c) Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential and proprietary property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee in separate contract or the terms described here-in. 16 | * This heading MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | 23 | #ifndef LL_CONN_PHY_H_ 24 | #define LL_CONN_PHY_H_ 25 | 26 | 27 | #include "stack/ble/phy/phy.h" 28 | 29 | 30 | 31 | /******************************* Macro & Enumeration variables for Stack, user can not use!!!! ********************************/ 32 | #if (LL_FEATURE_ENABLE_LE_2M_PHY | LL_FEATURE_ENABLE_LE_CODED_PHY) 33 | 34 | ll_conn_phy_t* blt_ll_get_conn_phy_ptr(u16 connHandle); 35 | extern _attribute_aligned_(4) ll_conn_phy_t blt_conn_phy; 36 | 37 | 38 | typedef int (*ll_conn_phy_update_callback_t)(void); 39 | typedef int (*ll_conn_phy_switch_callback_t)(void); 40 | 41 | extern ll_conn_phy_update_callback_t ll_conn_phy_update_cb; 42 | extern ll_conn_phy_switch_callback_t ll_conn_phy_swicth_cb; 43 | 44 | #endif 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | /******************************** Macro & Enumeration variables for User *****************************************************/ 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | /******************************** User Interface ****************************************************************************/ 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | /******************************* Stack Interface, user can not use!!! *******************************************************/ 87 | //2M/Coded PHY 88 | void blt_ll_sendPhyReq(void); 89 | int blt_ll_updateConnPhy(void); 90 | int blt_ll_switchConnPhy(void); 91 | 92 | 93 | 94 | 95 | #endif /* LL_CONN_CSA_H_ */ 96 | -------------------------------------------------------------------------------- /SDK/components/stack/ble/ll/ll_encrypt.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file ll_encrypt.h 3 | * 4 | * @brief for TLSR chips 5 | * 6 | * @author public@telink-semi.com; 7 | * @date Sep. 18, 2015 8 | * 9 | * @par Copyright (c) Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential and proprietary property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee in separate contract or the terms described here-in. 16 | * This heading MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | /* 23 | * ble_ll_encrypt.h 24 | * 25 | * Created on: 2016-9-22 26 | * Author: Telink 27 | */ 28 | 29 | #ifndef BLE_LL_ENCRYPT_H_ 30 | #define BLE_LL_ENCRYPT_H_ 31 | 32 | 33 | 34 | 35 | 36 | typedef struct { 37 | u32 pkt; 38 | u8 dir; 39 | u8 iv[8]; 40 | } ble_cyrpt_nonce_t; 41 | 42 | 43 | typedef struct { 44 | u32 enc_pno; 45 | u32 dec_pno; 46 | u8 sk[16]; //session key 47 | ble_cyrpt_nonce_t nonce; 48 | u8 st; 49 | u8 enable; //1: slave enable; 2: master enable 50 | u8 mic_fail; 51 | } ble_crypt_para_t; 52 | 53 | #endif /* BLE_LL_ENCRYPT_H_ */ 54 | -------------------------------------------------------------------------------- /SDK/components/stack/ble/ll/ll_ext_scan.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file ll_ext_scan.h 3 | * 4 | * @brief for TLSR chips 5 | * 6 | * @author public@telink-semi.com; 7 | * @date Feb. 1, 2018 8 | * 9 | * @par Copyright (c) Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential and proprietary property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee in separate contract or the terms described here-in. 16 | * This heading MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | 23 | #ifndef LL_SCAN_EXT_H_ 24 | #define LL_SCAN_EXT_H_ 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include "stack/ble/ll/ll_conn/ll_slave.h" 38 | #include "stack/ble/ll/ll_conn/ll_master.h" 39 | 40 | 41 | #include "tl_common.h" 42 | #include "drivers.h" 43 | 44 | 45 | /******************************************** User Interface ********************************************************************/ 46 | ble_sts_t blc_ll_setExtScanParam_1_phy (own_addr_type_t ownAddrType, scan_fp_type_t scanFilterPolicy, u8 scan_phys, 47 | scan_type_t scanType, u16 scan_interval, u16 scan_window); 48 | 49 | ble_sts_t blc_hci_le_setExtScanEnable (scan_en_t extScan_en, dupFilter_en_t filter_duplicate, u16 duration, u16 period); 50 | 51 | 52 | 53 | /****************************************** Stack Interface, user can not use!!! *************************************************/ 54 | 55 | ble_sts_t blc_hci_le_setExtScanParam (own_addr_type_t ownAddrType, scan_fp_type_t scanFilterPolicy, u8 scan_phys, u8 *pData); 56 | 57 | 58 | #endif /* LL_SCAN_EXT_H_ */ 59 | -------------------------------------------------------------------------------- /SDK/components/stack/ble/llms/llms_adv.h: -------------------------------------------------------------------------------- 1 | /* 2 | * llms_adv.h 3 | * 4 | * Created on: 2019-5-25 5 | * Author: Administrator 6 | */ 7 | 8 | #ifndef LLMS_ADV_H_ 9 | #define LLMS_ADV_H_ 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | /************************************ User Interface ******************************************************/ 24 | void blc_llms_initAdvertising_module(void); 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | /*********************************** Stack Interface, user can not use!!! **********************************/ 33 | int blt_llms_send_adv(void); 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | #endif /* LLMS_ADV_H_ */ 44 | -------------------------------------------------------------------------------- /SDK/components/stack/ble/llms/llms_init.h: -------------------------------------------------------------------------------- 1 | /* 2 | * llms_init.h 3 | * 4 | * Created on: 2019-5-25 5 | * Author: Administrator 6 | */ 7 | 8 | #ifndef LLMS_INIT_H_ 9 | #define LLMS_INIT_H_ 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | extern int blms_create_connection; 19 | extern u32 blms_timeout_connectDevice; 20 | extern u32 blms_tick_connectDevice; 21 | 22 | 23 | 24 | /************************************ User Interface ******************************************************/ 25 | 26 | 27 | 28 | 29 | /*********************************** Stack Interface, user can not use!!! **********************************/ 30 | int blt_llms_procInitPkt(u8 *raw_pkt); 31 | 32 | 33 | 34 | 35 | #endif /* LLMS_INIT_H_ */ 36 | -------------------------------------------------------------------------------- /SDK/components/stack/ble/llms/llms_master.h: -------------------------------------------------------------------------------- 1 | /* 2 | * llms_master.h 3 | * 4 | * Created on: 2019-5-24 5 | * Author: Administrator 6 | */ 7 | 8 | #ifndef LLMS_MASTER_H_ 9 | #define LLMS_MASTER_H_ 10 | 11 | 12 | 13 | /*************************************************************************** 14 | * 17 19 23 29 31 37 39 41 15 | * 21.25 23.75 28.75 36.25 38.75 46.25 48.75 51.25 16 | * X X 17 | * V V V 18 | * 19 | * 23 29 31 37 41 20 | **************************************************************************/ 21 | #define MASTER_CONN_INTER_23 23 22 | #define MASTER_CONN_INTER_29 29 23 | #define MASTER_CONN_INTER_31 31 24 | #define MASTER_CONN_INTER_37 37 25 | #define MASTER_CONN_INTER_41 41 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | typedef struct { 34 | u8 conn_policy; 35 | u8 conn_advType; 36 | u8 conn_num; 37 | u8 cur_connInterval; 38 | 39 | 40 | u8 conn_mac[6]; 41 | 42 | } st_llm_conn_t; 43 | 44 | extern st_llm_conn_t bltcm; 45 | 46 | 47 | /************************************ User Interface ******************************************************/ 48 | 49 | 50 | 51 | 52 | /*********************************** Stack Interface, user can not use!!! **********************************/ 53 | int blms_m_connect (rf_packet_connect_t * pInit); 54 | int blms_btx_start (void); 55 | int blms_btx_post (void); 56 | 57 | 58 | 59 | #endif /* LLMS_MASTER_H_ */ 60 | -------------------------------------------------------------------------------- /SDK/components/stack/ble/llms/llms_scan.h: -------------------------------------------------------------------------------- 1 | /* 2 | * llms_scan.h 3 | * 4 | * Created on: 2019-5-25 5 | * Author: Administrator 6 | */ 7 | 8 | #ifndef LLMS_SCAN_H_ 9 | #define LLMS_SCAN_H_ 10 | 11 | 12 | 13 | /************************************ User Interface ******************************************************/ 14 | void blc_llms_initScanning_module(void); 15 | 16 | 17 | 18 | /*********************************** Stack Interface, user can not use!!! **********************************/ 19 | 20 | void blt_llms_switchScanChannel (int set_chn); 21 | int blt_llms_procScanPkt(u8 *raw_pkt, u8 *new_pkt, u32 tick_now); 22 | int blt_llms_procScanData(u8 *raw_pkt); 23 | 24 | #endif /* LLMS_SCAN_H_ */ 25 | -------------------------------------------------------------------------------- /SDK/components/stack/ble/llms/llms_slave.h: -------------------------------------------------------------------------------- 1 | /* 2 | * llms_slave.h 3 | * 4 | * Created on: 2019-5-24 5 | * Author: Administrator 6 | */ 7 | 8 | #ifndef LLMS_SLAVE_H_ 9 | #define LLMS_SLAVE_H_ 10 | 11 | 12 | 13 | #define SLAVE_SYNC_CONN_CREATE BIT(0) 14 | #define SLAVE_SYNC_CONN_UPDATE BIT(1) 15 | #define SLAVE_SYNC_HIGH_DUTY BIT(7) 16 | 17 | 18 | #define SLAVE_SYNC_HIGHDUTY_SUPPORT_EN 0 19 | 20 | 21 | #define BRX_EARLY_SET_SYNC 300 22 | #define BRX_EARLY_SET_COMMON 200 23 | 24 | 25 | 26 | typedef struct { 27 | u8 slaveSync; // conn create or conn_param_update 28 | u8 conn_rcvd_ack_pkt; 29 | u8 rsvd1; 30 | u8 rsvd2; 31 | 32 | 33 | u32 connExpectTime; 34 | u32 conn_start_time; 35 | u32 conn_duration; 36 | 37 | u32 tick_1st_rx; 38 | 39 | } st_llms_s_conn_t; 40 | 41 | extern st_llms_s_conn_t bltcs; 42 | 43 | 44 | 45 | /************************************ User Interface ******************************************************/ 46 | 47 | 48 | 49 | 50 | /*********************************** Stack Interface, user can not use!!! **********************************/ 51 | int blms_s_connect (rf_packet_connect_t * pInit); 52 | int blms_brx_start(void); 53 | int blms_brx_post(void); 54 | 55 | 56 | 57 | 58 | #endif /* LLMS_SLAVE_H_ */ 59 | -------------------------------------------------------------------------------- /SDK/components/stack/ble/llms/trace.h: -------------------------------------------------------------------------------- 1 | #ifndef TRACE_H_ 2 | #define TRACE_H_ 3 | 4 | #define TR_T_irq 1 5 | #define TR_T_irq_rx 2 6 | #define TR_T_irq_tx 3 7 | #define TR_T_irq_sysTimer 4 8 | #define TR_T_irq_adv 5 9 | 10 | 11 | #define TR_T_irq_cmddone 6 12 | #define TR_T_irq_rxTmt 7 13 | #define TR_T_irq_rxFirstTmt 8 14 | #define TR_T_irq_fsmTmt 9 15 | 16 | 17 | 18 | #define TR_T_ll_brx_start 10 19 | #define TR_T_ll_brx_post 11 20 | 21 | #define TR_T_ll_btx_start 12 22 | #define TR_T_ll_btx_post 13 23 | #define TR_T_ll_1stRx 14 24 | 25 | #define TR_T_ll_terminate 15 26 | 27 | #define TR_T_rx_crc 18 28 | #define TR_T_rx_conn 20 29 | 30 | 31 | #define TR_T_slot_update 20 32 | #define TR_T_slot_runout 22 33 | #define TR_T_slot_rebuild 23 34 | #define TR_T_slot_locate 24 35 | #define TR_T_slot_task 25 36 | 37 | #define TR_T_slot_jump 26 38 | 39 | #define TR_T_slave_sync 30 40 | #define TR_T_slave_sync_done 31 41 | 42 | 43 | #define TR_24_ll_chn 0 44 | #define TR_24_ll_duration 1 45 | 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /SDK/components/tinyFlash/README.md: -------------------------------------------------------------------------------- 1 | # tinyFlash 2 | 3 | 一种轻量级的flash数据存储方案 4 | 5 | ## 设计原理 6 | 7 | 本方案采用两个扇区轮流使用的方法存储数据,每个扇区4096字节,扇区状态如下表: 8 | 9 | |扇区编号|使用状态|数据分布| 10 | |--------|----|---| 11 | |扇区一 |使用中|0xAA ·······················································| 12 | |扇区二 |未使用|0xFF ·······················································| 13 | 14 | 使用中的扇区数据分布如下表: 15 | 16 | |扇区头部|K1|V1|K2|V2|.....|Kn|Vn| 17 | |--------|----|---|----|----|----|-----|-----| 18 | |32字节 |3字节|n字节|3字节|n字节|.....|3字节|n字节| 19 | 20 | 每个K-V数据存储形式如下表: 21 | 22 | |第一字节|第二字节|第三字节|n个字节| 23 | |--------|----|---|----| 24 | |Key |~Key|Len|Len个字节数据内容| 25 | 26 | 第一个字节存放的是数据的Key,取值范围是 0x01 - 0xFE 27 | 28 | 第二个字节的数据为Key取反,如果第二个字节的数据为0x00,表示该处存储的数据已被废弃 29 | 30 | 第三个自己表示数据长度,取值范围是0x01 - 0xFF 31 | 32 | 之后的字节是数据的内容,最长不得超过0xFF 33 | 34 | ## API介绍 35 | 36 | ------------------------------------------------------------------------------- 37 | bool tinyFlash_Init(unsigned long start_addr, unsigned long len); 38 | 39 | 函数功能:初始化tinyFlash 40 | 41 | 参数 start_addr:tinyFlash区域在Flash芯片上的起始地址 42 | 43 | 参数 len: tinyFlash区域总长度,单位字节 44 | 45 | ------------------------------------------------------------------------------- 46 | int tinyFlash_Read(unsigned char KEY, unsigned char * buf, unsigned char * len); 47 | 48 | 函数功能:从tinyFlash中读取Key中存储的数据内容,数据长度,或者删除数据 49 | 50 | 参数 KEY:要读取的Key 51 | 52 | 参数 buf:Key中存储的数据内容的传出指针,如果该指针为NULL,则只传输数据长度 53 | 54 | 参数 len: 传入的是最大能接受的数据长度,传输的是读取到的实际数据长度,如果为NULL则为删除该KEY 55 | 56 | ------------------------------------------------------------------------------ 57 | int tinyFlash_Write(unsigned char KEY, unsigned char * buf, unsigned char len); 58 | 59 | 函数功能: 向tinyFlash中存储一个数据 60 | 61 | 参数 KEY: 要存储的数据的Key值 62 | 63 | 参数 buf: 要存储的数据内容 64 | 65 | 参数 len: 要存储的数据长度 66 | 67 | ------------------------------------------------------------------------------ 68 | void tinyFlash_Format(void); 69 | 70 | 函数功能:格式化tinyFlash数据区域,擦除全部tinyFlash扇区 71 | 72 | -------------------------------------------------------------------------------- 73 | 74 | ## 接下来的工作 75 | - 多扇区支持 76 | - 数据加密 77 | - 优化查找及存储速度 78 | - 意外掉电防护 -------------------------------------------------------------------------------- /SDK/components/tinyFlash/tinyFlash.h: -------------------------------------------------------------------------------- 1 | #ifndef __tiny_Flash__ 2 | #define __tiny_Flash__ 3 | 4 | bool tinyFlash_Init(unsigned long start_addr, unsigned long len); 5 | 6 | int tinyFlash_Read(unsigned char KEY, unsigned char * buf, unsigned char * len); 7 | 8 | int tinyFlash_Write(unsigned char KEY, unsigned char * buf, unsigned char len); 9 | 10 | void tinyFlash_Swap(void); 11 | 12 | void tinyFlash_Format(void); 13 | 14 | void tinyFlash_Debug(unsigned long addr); 15 | #endif -------------------------------------------------------------------------------- /SDK/components/tl_common.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file tl_common.h 3 | * 4 | * @brief This is the header file for TLSR8258 5 | * 6 | * @author author@telink-semi.com; 7 | * @date May 8, 2018 8 | * 9 | * @par Copyright (c) 2018, Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee or the terms described here-in. This heading 16 | * MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | 23 | #pragma once 24 | 25 | 26 | #include "common/types.h" 27 | #include "common/bit.h" 28 | #include "common/utility.h" 29 | #include "common/static_assert.h" 30 | #include "common/assert.h" 31 | 32 | 33 | #include "vendor/common/user_config.h" 34 | #include "config.h" 35 | 36 | #include "common/breakpoint.h" 37 | #include "common/log.h" 38 | 39 | #include "common/string.h" -------------------------------------------------------------------------------- /SDK/components/vendor/common/blt_common.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file blt_common.h 3 | * 4 | * @brief for TLSR chips 5 | * 6 | * @author public@telink-semi.com; 7 | * @date Sep. 18, 2018 8 | * 9 | * @par Copyright (c) Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential and proprietary property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee in separate contract or the terms described here-in. 16 | * This heading MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | 23 | #ifndef BLT_COMMON_H_ 24 | #define BLT_COMMON_H_ 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | void blc_initMacAddress(int flash_addr, u8 *mac_public, u8 *mac_random_static); 33 | 34 | 35 | 36 | 37 | #endif /* BLT_COMMON_H_ */ 38 | -------------------------------------------------------------------------------- /SDK/components/vendor/common/blt_fw_sign.c: -------------------------------------------------------------------------------- 1 | /* 2 | * blt_fw_signature.c 3 | * 4 | * Created on: 2019-5-5 5 | * Author: Administrator 6 | */ 7 | 8 | 9 | #include "tl_common.h" 10 | #include "drivers.h" 11 | #include "blt_fw_sign.h" 12 | #include "stack/ble/blt_config.h" 13 | #include "proj_lib/firmware_encrypt.h" 14 | 15 | void blt_firmware_signature_check(void) 16 | { 17 | unsigned int flash_mid; 18 | unsigned char flash_uid[16]; 19 | unsigned char signature_enc_key[16]; 20 | int flag = flash_read_mid_uid_with_check(&flash_mid, flash_uid); 21 | 22 | if(flag==0){ //reading flash UID error 23 | while(1); 24 | } 25 | 26 | firmware_encrypt_based_on_uid (flash_uid, signature_enc_key); 27 | 28 | if(memcmp(signature_enc_key, (u8*)CUST_FIRMWARE_SIGNKEY_ADDR, 16)){ //signature not match 29 | while(1); //user can change the code here to stop firmware running 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /SDK/components/vendor/common/blt_fw_sign.h: -------------------------------------------------------------------------------- 1 | /* 2 | * blt_fw_signature.h 3 | * 4 | * Created on: 2019-5-5 5 | * Author: Administrator 6 | */ 7 | 8 | #ifndef BLT_FW_SIGN_H_ 9 | #define BLT_FW_SIGN_H_ 10 | 11 | 12 | void blt_firmware_signature_check(void); 13 | 14 | 15 | 16 | #endif /* BLT_FW_SIGNATURE_H_ */ 17 | -------------------------------------------------------------------------------- /SDK/components/vendor/common/blt_led.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file blt_led.h 3 | * 4 | * @brief for TLSR chips 5 | * 6 | * @author public@telink-semi.com; 7 | * @date Sep. 18, 2015 8 | * 9 | * @par Copyright (c) Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential and proprietary property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee in separate contract or the terms described here-in. 16 | * This heading MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | /* 23 | * blt_led.h 24 | * 25 | * Created on: 2016-1-29 26 | * Author: Administrator 27 | */ 28 | 29 | #ifndef BLT_LED_H_ 30 | #define BLT_LED_H_ 31 | 32 | #include "tl_common.h" 33 | 34 | 35 | 36 | #ifndef BLT_APP_LED_ENABLE 37 | #define BLT_APP_LED_ENABLE 0 38 | #endif 39 | 40 | 41 | //led management 42 | typedef struct{ 43 | unsigned short onTime_ms; 44 | unsigned short offTime_ms; 45 | 46 | unsigned char repeatCount; //0xff special for long on(offTime_ms=0)/long off(onTime_ms=0) 47 | unsigned char priority; //0x00 < 0x01 < 0x02 < 0x04 < 0x08 < 0x10 < 0x20 < 0x40 < 0x80 48 | } led_cfg_t; 49 | 50 | typedef struct { 51 | unsigned char isOn; 52 | unsigned char polar; 53 | unsigned char repeatCount; 54 | unsigned char priority; 55 | 56 | 57 | unsigned short onTime_ms; 58 | unsigned short offTime_ms; 59 | 60 | unsigned int gpio_led; 61 | unsigned int startTick; 62 | }device_led_t; 63 | 64 | extern device_led_t device_led; 65 | 66 | #define DEVICE_LED_BUSY (device_led.repeatCount) 67 | 68 | extern void led_proc(void); 69 | extern void device_led_init(u32 gpio,u8 polarity); 70 | int device_led_setup(led_cfg_t led_cfg); 71 | 72 | static inline void device_led_process(void) 73 | { 74 | #if (BLT_APP_LED_ENABLE) 75 | if(DEVICE_LED_BUSY){ 76 | led_proc(); 77 | } 78 | #endif 79 | } 80 | 81 | 82 | 83 | 84 | #endif /* BLT_LED_H_ */ 85 | -------------------------------------------------------------------------------- /SDK/components/vendor/common/blt_soft_timer.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/SDK/components/vendor/common/blt_soft_timer.c -------------------------------------------------------------------------------- /SDK/components/vendor/common/user_config.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file user_config.h 3 | * 4 | * @brief for TLSR chips 5 | * 6 | * @author public@telink-semi.com; 7 | * @date Sep. 18, 2015 8 | * 9 | * @par Copyright (c) Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential and proprietary property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee in separate contract or the terms described here-in. 16 | * This heading MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | 23 | #pragma once 24 | 25 | #include "app_config.h" 26 | 27 | 28 | -------------------------------------------------------------------------------- /SDK/make/application.mk: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Automatically-generated file. Do not edit! 3 | ################################################################################ 4 | 5 | # Add inputs and outputs from these tool invocations to the build variables 6 | 7 | OUT_DIR += /application/app /application/keyboard /application/print /application/usbstd /application/TLV_Flash 8 | 9 | OBJS += \ 10 | $(OUT_PATH)/application/app/usbaud.o \ 11 | $(OUT_PATH)/application/app/usbcdc.o \ 12 | $(OUT_PATH)/application/app/usbkb.o \ 13 | $(OUT_PATH)/application/app/usbmouse.o \ 14 | $(OUT_PATH)/application/keyboard/keyboard.o \ 15 | $(OUT_PATH)/application/print/putchar.o \ 16 | $(OUT_PATH)/application/print/u_printf.o \ 17 | $(OUT_PATH)/application/usbstd/usb.o \ 18 | $(OUT_PATH)/application/usbstd/usbdesc.o \ 19 | $(OUT_PATH)/application/usbstd/usbhw.o 20 | 21 | # Each subdirectory must supply rules for building sources it contributes 22 | $(OUT_PATH)/application/%.o: $(TEL_PATH)/components/application/%.c 23 | @echo 'Building file: $<' 24 | @$(TC32_PATH)tc32-elf-gcc $(GCC_FLAGS) $(INCLUDE_PATHS) -c -o"$@" "$<" 25 | -------------------------------------------------------------------------------- /SDK/make/boot.mk: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Automatically-generated file. Do not edit! 3 | ################################################################################ 4 | 5 | # Add inputs and outputs from these tool invocations to the build variables 6 | OUT_DIR += /boot/8251 /boot/8253 /boot/8258 7 | 8 | # OBJS += \ 9 | # $(OUT_PATH)/boot/8251/cstartup_8251.o \ 10 | # $(OUT_PATH)/boot/8251/cstartup_8251_RET_16K.o \ 11 | # $(OUT_PATH)/boot/8251/cstartup_8251_RET_32K.o 12 | 13 | 14 | # OBJS += \ 15 | # $(OUT_PATH)/boot/8253/cstartup_8253.o \ 16 | # $(OUT_PATH)/boot/8253/cstartup_8253_RET_16K.o \ 17 | # $(OUT_PATH)/boot/8253/cstartup_8253_RET_32K.o 18 | 19 | ifeq ($(RETENTION_RAM_SIZE), 32KB) 20 | BOOT_FLAG := -DMCU_STARTUP_8258_RET_32K 21 | else 22 | BOOT_FLAG := -DMCU_STARTUP_8258_RET_16K 23 | endif 24 | 25 | ifeq ($(USE_FREE_RTOS), 1) 26 | BOOT_FLAG += -DUSE_FREE_RTOS 27 | endif 28 | 29 | OBJS += \ 30 | $(OUT_PATH)/boot/8258/cstartup_8258.o \ 31 | $(OUT_PATH)/boot/8258/cstartup_8258_RET_16K.o \ 32 | $(OUT_PATH)/boot/8258/cstartup_8258_RET_32K.o 33 | 34 | OBJS += $(OUT_PATH)/boot/div_mod.o 35 | 36 | # Each subdirectory must supply rules for building sources it contributes 37 | $(OUT_PATH)/boot/%.o: $(TEL_PATH)/components/boot/%.S 38 | @echo 'Building file: $<' 39 | $(TC32_PATH)tc32-elf-gcc $(BOOT_FLAG) $(GCC_FLAGS) -c -o"$@" "$<" 40 | 41 | -------------------------------------------------------------------------------- /SDK/make/common.mk: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Automatically-generated file. Do not edit! 3 | ################################################################################ 4 | 5 | # Add inputs and outputs from these tool invocations to the build variables 6 | OUT_DIR += /common 7 | 8 | 9 | OBJS += \ 10 | $(OUT_PATH)/common/breakpoint.o \ 11 | $(OUT_PATH)/common/log.o \ 12 | $(OUT_PATH)/common/selection_sort.o \ 13 | $(OUT_PATH)/common/string.o \ 14 | $(OUT_PATH)/common/utility.o 15 | 16 | 17 | # Each subdirectory must supply rules for building sources it contributes 18 | $(OUT_PATH)/common/%.o: $(TEL_PATH)/components/common/%.c 19 | @echo 'Building file: $<' 20 | @$(TC32_PATH)tc32-elf-gcc $(GCC_FLAGS) $(INCLUDE_PATHS) -c -o"$@" "$<" -------------------------------------------------------------------------------- /SDK/make/drivers_8258.mk: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Automatically-generated file. Do not edit! 3 | ################################################################################ 4 | 5 | # Add inputs and outputs from these tool invocations to the build variables 6 | 7 | OUT_DIR += /drivers/8258 8 | 9 | OBJS += \ 10 | $(OUT_PATH)/drivers/8258/adc.o \ 11 | $(OUT_PATH)/drivers/8258/aes.o \ 12 | $(OUT_PATH)/drivers/8258/analog.o \ 13 | $(OUT_PATH)/drivers/8258/audio.o \ 14 | $(OUT_PATH)/drivers/8258/bsp.o \ 15 | $(OUT_PATH)/drivers/8258/clock.o \ 16 | $(OUT_PATH)/drivers/8258/emi.o \ 17 | $(OUT_PATH)/drivers/8258/flash.o \ 18 | $(OUT_PATH)/drivers/8258/gpio_8258.o \ 19 | $(OUT_PATH)/drivers/8258/i2c.o \ 20 | $(OUT_PATH)/drivers/8258/lpc.o \ 21 | $(OUT_PATH)/drivers/8258/qdec.o \ 22 | $(OUT_PATH)/drivers/8258/rf_pa.o \ 23 | $(OUT_PATH)/drivers/8258/s7816.o \ 24 | $(OUT_PATH)/drivers/8258/spi.o \ 25 | $(OUT_PATH)/drivers/8258/timer.o \ 26 | $(OUT_PATH)/drivers/8258/uart.o \ 27 | $(OUT_PATH)/drivers/8258/watchdog.o 28 | 29 | # Each subdirectory must supply rules for building sources it contributes 30 | $(OUT_PATH)/drivers/8258/%.o: $(TEL_PATH)/components/drivers/8258/%.c 31 | @echo 'Building file: $<' 32 | @$(TC32_PATH)tc32-elf-gcc $(GCC_FLAGS) $(INCLUDE_PATHS) -c -o"$@" "$<" 33 | -------------------------------------------------------------------------------- /SDK/make/freertos.mk: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Automatically-generated file. Do not edit! 3 | ################################################################################ 4 | 5 | # Add inputs and outputs from these tool invocations to the build variables 6 | OUT_DIR += /freertos /freertos/portable/MemMang /freertos/portable/gcc /freertos/portable/Common 7 | 8 | 9 | OBJS += \ 10 | $(OUT_PATH)/freertos/croutine.o \ 11 | $(OUT_PATH)/freertos/event_groups.o \ 12 | $(OUT_PATH)/freertos/list.o \ 13 | $(OUT_PATH)/freertos/queue.o \ 14 | $(OUT_PATH)/freertos/stream_buffer.o \ 15 | $(OUT_PATH)/freertos/tasks.o \ 16 | $(OUT_PATH)/freertos/timers.o \ 17 | $(OUT_PATH)/freertos/portable/MemMang/heap_1.o \ 18 | $(OUT_PATH)/freertos/portable/gcc/port.o \ 19 | $(OUT_PATH)/freertos/portable/Common/mpu_wrappers.o 20 | 21 | # Each subdirectory must supply rules for building sources it contributes 22 | $(OUT_PATH)/freertos/%.o: $(TEL_PATH)/components/freertos/%.c 23 | @echo 'Building file: $<' 24 | @$(TC32_PATH)tc32-elf-gcc $(GCC_FLAGS) $(INCLUDE_PATHS) -c -o"$@" "$<" -------------------------------------------------------------------------------- /SDK/make/tinyFlash.mk: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Automatically-generated file. Do not edit! 3 | ################################################################################ 4 | 5 | # Add inputs and outputs from these tool invocations to the build variables 6 | OUT_DIR += /tinyFlash 7 | 8 | 9 | OBJS += $(OUT_PATH)/tinyFlash/tinyFlash.o 10 | 11 | 12 | # Each subdirectory must supply rules for building sources it contributes 13 | $(OUT_PATH)/tinyFlash/%.o: $(TEL_PATH)/components/tinyFlash/%.c 14 | @echo 'Building file: $<' 15 | @$(TC32_PATH)tc32-elf-gcc $(GCC_FLAGS) $(INCLUDE_PATHS) -c -o"$@" "$<" -------------------------------------------------------------------------------- /SDK/make/vendor_common.mk: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Automatically-generated file. Do not edit! 3 | ################################################################################ 4 | 5 | # Add inputs and outputs from these tool invocations to the build variables 6 | 7 | OUT_DIR += /vendor/common 8 | 9 | OBJS += \ 10 | $(OUT_PATH)/vendor/common/blt_common.o \ 11 | $(OUT_PATH)/vendor/common/blt_fw_sign.o \ 12 | $(OUT_PATH)/vendor/common/blt_led.o \ 13 | $(OUT_PATH)/vendor/common/blt_soft_timer.o \ 14 | $(OUT_PATH)/vendor/common/tl_audio.o 15 | 16 | # Each subdirectory must supply rules for building sources it contributes 17 | $(OUT_PATH)/vendor/common/%.o: $(TEL_PATH)/components/vendor/common/%.c $(common_dir) 18 | @echo 'Building file: $<' 19 | @$(TC32_PATH)tc32-elf-gcc $(GCC_FLAGS) $(INCLUDE_PATHS) -c -o"$@" "$<" 20 | 21 | -------------------------------------------------------------------------------- /TB03F.cmd: -------------------------------------------------------------------------------- 1 | @Path=E:\Telink\SDK;E:\Telink\SDK\jre\bin;E:\Telink\SDK\opt\tc32\tools;E:\Telink\SDK\opt\tc32\bin;E:\Telink\SDK\usr\bin;E:\Telink\SDK\bin;%PATH% 2 | @set SWVER=_v52 3 | @set FW_NAME=TB_INA226%SWVER% 4 | @del /Q "%FW_NAME%.bin" 5 | make -s -j PROJECT_NAME=%FW_NAME% POJECT_DEF="-DDEVICE_TYPE=DEVICE_TB03F -DUSE_SENSOR_INA226=1" 6 | @if not exist "%FW_NAME%.bin" goto :error 7 | @set FW_NAME=TB_ENS160%SWVER% 8 | @del /Q "%FW_NAME%.bin" 9 | make -s -j PROJECT_NAME=%FW_NAME% POJECT_DEF="-DDEVICE_TYPE=DEVICE_TB03F -DUSE_SENSOR_ENS160=1" 10 | @if not exist "%FW_NAME%.bin" goto :error 11 | @set FW_NAME=TB_SCD41%SWVER% 12 | @del /Q "%FW_NAME%.bin" 13 | make -s -j PROJECT_NAME=%FW_NAME% POJECT_DEF="-DDEVICE_TYPE=DEVICE_TB03F -DUSE_SENSOR_SCD41=1" 14 | @if not exist "%FW_NAME%.bin" goto :error 15 | @set FW_NAME=TB_BME280%SWVER% 16 | @del /Q "%FW_NAME%.bin" 17 | make -s -j PROJECT_NAME=%FW_NAME% POJECT_DEF="-DDEVICE_TYPE=DEVICE_TB03F -DUSE_SENSOR_BME280=1" 18 | @if not exist %FW_NAME%.bin goto :error 19 | @set FW_NAME=TB_INA3221%SWVER% 20 | @del /Q "%FW_NAME%.bin" 21 | make -s -j PROJECT_NAME=%FW_NAME% POJECT_DEF="-DDEVICE_TYPE=DEVICE_TB03F -DUSE_SENSOR_INA3221=1" 22 | @if not exist "%FW_NAME%.bin" goto :error 23 | @set FW_NAME=TB_PLM%SWVER% 24 | @del /Q "%FW_NAME%.bin" 25 | make -s -j PROJECT_NAME=%FW_NAME% POJECT_DEF="-DDEVICE_TYPE=DEVICE_PLM1 -DTEST_PLM1=1" 26 | @if not exist "%FW_NAME%.bin" goto :error 27 | @exit 28 | :error 29 | echo "Error!" 30 | 31 | -------------------------------------------------------------------------------- /TelinkIDEmk.cmd: -------------------------------------------------------------------------------- 1 | @set TLSDK=E:\Telink\SDK 2 | @PATH=%TLSDK%\jre\bin;%TLSDK%\bin;%TLSDK%\opt\tc32\bin;%TLSDK%\usr\bin;%TLSDK%\opt\tc32\tools;%PATH% 3 | make -s -j PROJECT_NAME=ATC_v51 POJECT_DEF="-DDEVICE_TYPE=DEVICE_LYWSD03MMC" 4 | -------------------------------------------------------------------------------- /bin/ATC_v51.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/bin/ATC_v51.bin -------------------------------------------------------------------------------- /bin/ATC_v52.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/bin/ATC_v52.bin -------------------------------------------------------------------------------- /bin/BTE_v51.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/bin/BTE_v51.bin -------------------------------------------------------------------------------- /bin/BTE_v52.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/bin/BTE_v52.bin -------------------------------------------------------------------------------- /bin/BTH_v51.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/bin/BTH_v51.bin -------------------------------------------------------------------------------- /bin/BTH_v52.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/bin/BTH_v52.bin -------------------------------------------------------------------------------- /bin/CGDK2_v51.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/bin/CGDK2_v51.bin -------------------------------------------------------------------------------- /bin/CGDK2_v52.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/bin/CGDK2_v52.bin -------------------------------------------------------------------------------- /bin/CGG1M_v51.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/bin/CGG1M_v51.bin -------------------------------------------------------------------------------- /bin/CGG1M_v52.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/bin/CGG1M_v52.bin -------------------------------------------------------------------------------- /bin/CGG1_v51.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/bin/CGG1_v51.bin -------------------------------------------------------------------------------- /bin/CGG1_v52.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/bin/CGG1_v52.bin -------------------------------------------------------------------------------- /bin/LKTMZL02_v51.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/bin/LKTMZL02_v51.bin -------------------------------------------------------------------------------- /bin/LKTMZL02_v52.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/bin/LKTMZL02_v52.bin -------------------------------------------------------------------------------- /bin/MHO_C122_v51.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/bin/MHO_C122_v51.bin -------------------------------------------------------------------------------- /bin/MHO_C122_v52.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/bin/MHO_C122_v52.bin -------------------------------------------------------------------------------- /bin/MHO_C401N_v51.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/bin/MHO_C401N_v51.bin -------------------------------------------------------------------------------- /bin/MHO_C401N_v52.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/bin/MHO_C401N_v52.bin -------------------------------------------------------------------------------- /bin/MHO_C401_v51.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/bin/MHO_C401_v51.bin -------------------------------------------------------------------------------- /bin/MHO_C401_v52.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/bin/MHO_C401_v52.bin -------------------------------------------------------------------------------- /bin/MJ6_v51.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/bin/MJ6_v51.bin -------------------------------------------------------------------------------- /bin/MJ6_v52.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/bin/MJ6_v52.bin -------------------------------------------------------------------------------- /bin/Original/1286-0202-10033607-TH03_Tuya_OTA.zigbee: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/bin/Original/1286-0202-10033607-TH03_Tuya_OTA.zigbee -------------------------------------------------------------------------------- /bin/Original/Original_OTA_CGDK2_v1.1.1_0210.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/bin/Original/Original_OTA_CGDK2_v1.1.1_0210.bin -------------------------------------------------------------------------------- /bin/Original/Original_OTA_CGDK2_v1.1.1_0217.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/bin/Original/Original_OTA_CGDK2_v1.1.1_0217.bin -------------------------------------------------------------------------------- /bin/Original/Original_OTA_CGDK2_v1.1.1_0223.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/bin/Original/Original_OTA_CGDK2_v1.1.1_0223.bin -------------------------------------------------------------------------------- /bin/Original/Original_OTA_CGG1M_v2.2.1.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/bin/Original/Original_OTA_CGG1M_v2.2.1.bin -------------------------------------------------------------------------------- /bin/Original/Original_OTA_CGG1_v1.0.1_0093.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/bin/Original/Original_OTA_CGG1_v1.0.1_0093.bin -------------------------------------------------------------------------------- /bin/Original/Original_OTA_MHO_C122_tuya.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/bin/Original/Original_OTA_MHO_C122_tuya.bin -------------------------------------------------------------------------------- /bin/Original/Original_OTA_SJWS01LM_1.1.1_0018.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/bin/Original/Original_OTA_SJWS01LM_1.1.1_0018.bin -------------------------------------------------------------------------------- /bin/Original/Original_OTA_Xiaomi_LYWSD03MMC_v1.0.0_0109.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/bin/Original/Original_OTA_Xiaomi_LYWSD03MMC_v1.0.0_0109.bin -------------------------------------------------------------------------------- /bin/Original/Original_OTA_Xiaomi_LYWSD03MMC_v1.0.0_0130.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/bin/Original/Original_OTA_Xiaomi_LYWSD03MMC_v1.0.0_0130.bin -------------------------------------------------------------------------------- /bin/Original/Original_OTA_Xiaomi_LYWSD03MMC_v2.1.1_0159c.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/bin/Original/Original_OTA_Xiaomi_LYWSD03MMC_v2.1.1_0159c.bin -------------------------------------------------------------------------------- /bin/Original/Original_OTA_Xiaomi_MHO_C401_v1.0.0_0010.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/bin/Original/Original_OTA_Xiaomi_MHO_C401_v1.0.0_0010.bin -------------------------------------------------------------------------------- /bin/Original/Original_OTA_Xiaomi_MHO_C401_v1.0.0_0016.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/bin/Original/Original_OTA_Xiaomi_MHO_C401_v1.0.0_0016.bin -------------------------------------------------------------------------------- /bin/Original/Original_OTA_Xiaomi_MJWSD05MMC_en_2.0.0_0005.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/bin/Original/Original_OTA_Xiaomi_MJWSD05MMC_en_2.0.0_0005.bin -------------------------------------------------------------------------------- /bin/Original/Original_OTA_Xiaomi_MJWSD05MMC_v2.0.0_0026.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/bin/Original/Original_OTA_Xiaomi_MJWSD05MMC_v2.0.0_0026.bin -------------------------------------------------------------------------------- /bin/Original/Original_OTA_Xiaomi_MJWSD06MMC_v2.1.1_0009.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/bin/Original/Original_OTA_Xiaomi_MJWSD06MMC_v2.1.1_0009.bin -------------------------------------------------------------------------------- /bin/Original/README.md: -------------------------------------------------------------------------------- 1 | 2 | * Xiaomi LYWSD03MMC Original Firmware v1.0.0_0109 (HW: B1.4 only) 3 | * Xiaomi LYWSD03MMC Original Firmware v1.0.0_0130 (HW: B1.4..B2.0) 4 | * Xiaomi MJWSD05MMC(ch) Original Firmware v2.0.0_0026 (HW: V2.3) 5 | * Xiaomi MJWSD05MMC(en) Original Firmware v2.0.0_0005 (HW: V2.3) 6 | * Xiaomi MJWSD06MMC Original Firmware v2.1.1_0009 (HW: U1.3) 7 | * MiaoMiaoCe Technology (Beijing) Co., Ltd. MHO-C122 Original Firmware (Tuya) 8 | * Xiaomi MHO-C401 Original Firmware v1.0.0_0010 9 | * Xiaomi and Azarton MHO_C401 Original Firmware v1.0.0_0016 10 | * Xiaomi SJWS01LM Original Firmware v1.1.1_0018 11 | * Qingping CGG1-M 2020-2021 Original Firmware v1.0.1_0093 12 | * Qingping CGG1-M 2022 Original Firmware v2.2.1 13 | * Qingping CGPR1 Original Firmware v1.1.1_0228 14 | * Qingping CGDK2 Original Firmware v1.1.1_0210 15 | * Qingping CGDK2 Original Firmware v1.1.1_0217 16 | * Qingping CGDK2 Original Firmware v1.1.1_0223 17 | 18 | -------------------------------------------------------------------------------- /bin/PLM1_v52.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/bin/PLM1_v52.bin -------------------------------------------------------------------------------- /bin/TB03F_v51.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/bin/TB03F_v51.bin -------------------------------------------------------------------------------- /bin/TB03F_v52.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/bin/TB03F_v52.bin -------------------------------------------------------------------------------- /bin/TB_BME280_v52.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/bin/TB_BME280_v52.bin -------------------------------------------------------------------------------- /bin/TB_ENS160_v52.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/bin/TB_ENS160_v52.bin -------------------------------------------------------------------------------- /bin/TB_INA226_v52.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/bin/TB_INA226_v52.bin -------------------------------------------------------------------------------- /bin/TB_INA3221_v52.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/bin/TB_INA3221_v52.bin -------------------------------------------------------------------------------- /bin/TB_PLM_v52.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/bin/TB_PLM_v52.bin -------------------------------------------------------------------------------- /bin/TB_SCD41_v52.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/bin/TB_SCD41_v52.bin -------------------------------------------------------------------------------- /bin/TH03Z_v51.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/bin/TH03Z_v51.bin -------------------------------------------------------------------------------- /bin/TH03Z_v52.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/bin/TH03Z_v52.bin -------------------------------------------------------------------------------- /bin/TH03_v51.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/bin/TH03_v51.bin -------------------------------------------------------------------------------- /bin/TH03_v52.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/bin/TH03_v52.bin -------------------------------------------------------------------------------- /bin/TNK01_v51.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/bin/TNK01_v51.bin -------------------------------------------------------------------------------- /bin/TNK01_v52.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/bin/TNK01_v52.bin -------------------------------------------------------------------------------- /bin/TS0201S1_v51.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/bin/TS0201S1_v51.bin -------------------------------------------------------------------------------- /bin/TS0201S1_v52.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/bin/TS0201S1_v52.bin -------------------------------------------------------------------------------- /bin/TS0201S2_v51.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/bin/TS0201S2_v51.bin -------------------------------------------------------------------------------- /bin/TS0201S2_v52.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/bin/TS0201S2_v52.bin -------------------------------------------------------------------------------- /bin/TS0201_v51.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/bin/TS0201_v51.bin -------------------------------------------------------------------------------- /bin/TS0201_v52.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/bin/TS0201_v52.bin -------------------------------------------------------------------------------- /bin/ZG227Z_v51.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/bin/ZG227Z_v51.bin -------------------------------------------------------------------------------- /bin/ZG227Z_v52.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/bin/ZG227Z_v52.bin -------------------------------------------------------------------------------- /bin/ZTH01S1_v51.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/bin/ZTH01S1_v51.bin -------------------------------------------------------------------------------- /bin/ZTH01S1_v52.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/bin/ZTH01S1_v52.bin -------------------------------------------------------------------------------- /bin/ZTH01S2_v51.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/bin/ZTH01S2_v51.bin -------------------------------------------------------------------------------- /bin/ZTH01S2_v52.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/bin/ZTH01S2_v52.bin -------------------------------------------------------------------------------- /bin/ZTH01_v51.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/bin/ZTH01_v51.bin -------------------------------------------------------------------------------- /bin/ZTH01_v52.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/bin/ZTH01_v52.bin -------------------------------------------------------------------------------- /bin/ZTH02_v51.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/bin/ZTH02_v51.bin -------------------------------------------------------------------------------- /bin/ZTH02_v52.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/bin/ZTH02_v52.bin -------------------------------------------------------------------------------- /bin/ZTH05_v51.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/bin/ZTH05_v51.bin -------------------------------------------------------------------------------- /bin/ZTH05_v52.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/bin/ZTH05_v52.bin -------------------------------------------------------------------------------- /bin/ZYZTH02P_v51.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/bin/ZYZTH02P_v51.bin -------------------------------------------------------------------------------- /bin/ZYZTH02P_v52.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/bin/ZYZTH02P_v52.bin -------------------------------------------------------------------------------- /bin/ZYZTH02S1_v51.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/bin/ZYZTH02S1_v51.bin -------------------------------------------------------------------------------- /bin/ZYZTH02S1_v52.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/bin/ZYZTH02S1_v52.bin -------------------------------------------------------------------------------- /bin/ZYZTH02S2_v51.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/bin/ZYZTH02S2_v51.bin -------------------------------------------------------------------------------- /bin/ZYZTH02S2_v52.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/bin/ZYZTH02S2_v52.bin -------------------------------------------------------------------------------- /bin/ZYZTH02_v51.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/bin/ZYZTH02_v51.bin -------------------------------------------------------------------------------- /bin/ZYZTH02_v52.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/bin/ZYZTH02_v52.bin -------------------------------------------------------------------------------- /img/GraphAtc_html.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/img/GraphAtc_html.gif -------------------------------------------------------------------------------- /img/KeysProgStage1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/img/KeysProgStage1.gif -------------------------------------------------------------------------------- /img/KeysProgStage2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/img/KeysProgStage2.gif -------------------------------------------------------------------------------- /img/OnOff.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/img/OnOff.gif -------------------------------------------------------------------------------- /img/PowerAdvInt.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/img/PowerAdvInt.gif -------------------------------------------------------------------------------- /img/PowerLife.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/img/PowerLife.gif -------------------------------------------------------------------------------- /img/README.md: -------------------------------------------------------------------------------- 1 | # ATC_MiThermometer Mi-Home keys 2 | 3 | 4 | ### Reading and recovering Mi-Home keys 5 | 6 | >* Stage 1: 7 | 8 | ![SCH](https://github.com/pvvx/ATC_MiThermometer/blob/master/img/KeysProgStage1.gif) 9 | 10 | 11 | >* Stage 2: 12 | 13 | ![SCH](https://github.com/pvvx/ATC_MiThermometer/blob/master/img/KeysProgStage2.gif) 14 | -------------------------------------------------------------------------------- /img/ShowData.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/img/ShowData.gif -------------------------------------------------------------------------------- /img/USBCOMFlashTxHtml.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/img/USBCOMFlashTxHtml.gif -------------------------------------------------------------------------------- /img/atime.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/img/atime.png -------------------------------------------------------------------------------- /img/nRFConnect_set_default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/img/nRFConnect_set_default.png -------------------------------------------------------------------------------- /img/power_x.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/img/power_x.gif -------------------------------------------------------------------------------- /img/trg_grf.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/img/trg_grf.gif -------------------------------------------------------------------------------- /img/trg_menu.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/img/trg_menu.gif -------------------------------------------------------------------------------- /img/webpgm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/img/webpgm.png -------------------------------------------------------------------------------- /python-interface/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/python-interface/README.md -------------------------------------------------------------------------------- /python-interface/atc_mi_interface/__init__.py: -------------------------------------------------------------------------------- 1 | ############################################################################# 2 | # atc_mi_interface module 3 | ############################################################################# 4 | 5 | from .atc_mi_construct import * 6 | from .atc_mi_adv_format import atc_mi_advertising_format 7 | -------------------------------------------------------------------------------- /python-interface/atc_mi_interface/__main__.py: -------------------------------------------------------------------------------- 1 | ############################################################################# 2 | # __main__.py: atc_mi_interface module 3 | ############################################################################# 4 | 5 | import argparse 6 | import sys 7 | from . import atc_mi_advertising 8 | from . import atc_mi_config 9 | from . import atc_mi_format_test 10 | from .__version__ import __version__ 11 | 12 | def main(): 13 | parser = argparse.ArgumentParser( 14 | prog='atc_mi_interface', 15 | description='Subsequent options must follow, related to the selected ' 16 | 'tool. The first argument is the option which selects the tool ' 17 | '(advertising, config, or test) and must be separated from the ' 18 | 'subsequent tool options, to be placed in other arguments.', 19 | epilog='atc_mi_interface tools') 20 | config_group = parser.add_mutually_exclusive_group(required=True) 21 | config_group.add_argument( 22 | '-a', 23 | '--advertising', 24 | dest='advertising', 25 | action='store_true', 26 | help='Run the atc_mi_advertising tool') 27 | config_group.add_argument( 28 | '-c', 29 | "--config", 30 | dest='config', 31 | action='store_true', 32 | help="Run the atc_mi_config tool") 33 | config_group.add_argument( 34 | '-t', 35 | "--test", 36 | dest='test', 37 | action='store_true', 38 | help="Run the atc_mi_format_test tool") 39 | parser.add_argument( 40 | '-H', 41 | "--help-option", 42 | dest='subhelp', 43 | action='store_true', 44 | help="Invoke the specific help of the selected tool") 45 | parser.add_argument( 46 | '-V', 47 | "--version", 48 | dest='version', 49 | action='store_true', 50 | help="Print version and exit") 51 | 52 | args, unknown = parser.parse_known_args() 53 | if args.version: 54 | print(f'atc_mi_interface version {__version__}') 55 | sys.exit(0) 56 | if len(sys.argv) > 1: 57 | sys.argv.pop(1) 58 | if args.subhelp: 59 | sys.argv.append("--help") 60 | if args.advertising: 61 | atc_mi_advertising.main() 62 | if args.config: 63 | atc_mi_config.main() 64 | if args.test: 65 | atc_mi_format_test.main() 66 | 67 | 68 | if __name__ == "__main__": 69 | main() 70 | -------------------------------------------------------------------------------- /python-interface/atc_mi_interface/__version__.py: -------------------------------------------------------------------------------- 1 | __version__ = "2.0.0" # Format: A.B.C.postN 2 | -------------------------------------------------------------------------------- /python-interface/atc_mi_interface/atc_mi_adv_format.py: -------------------------------------------------------------------------------- 1 | gatt_dict = { 2 | "atc1441": { 3 | "gatt": '0000181a-0000-1000-8000-00805f9b34fb', # Environmental Sensing 4 | "length": 13, 5 | "header": bytes.fromhex("161a18"), 6 | }, 7 | "custom": { 8 | "gatt": '0000181a-0000-1000-8000-00805f9b34fb', 9 | "length": 15, 10 | "header": bytes.fromhex("161a18"), 11 | }, 12 | "custom_enc": { 13 | "gatt": '0000181a-0000-1000-8000-00805f9b34fb', 14 | "length": 11, 15 | "header": bytes.fromhex("161a18"), 16 | }, 17 | "atc1441_enc": { 18 | "gatt": '0000181a-0000-1000-8000-00805f9b34fb', 19 | "length": 8, 20 | "header": bytes.fromhex("161a18"), 21 | }, 22 | "mi_like": { 23 | "gatt": '0000fe95-0000-1000-8000-00805f9b34fb', # Xiaomi Inc. 24 | "length": None, 25 | "header": bytes.fromhex("1695fe"), 26 | }, 27 | "bt_home": { 28 | "gatt": '0000181c-0000-1000-8000-00805f9b34fb', # SERVICE_UUID_USER_DATA, HA_BLE, no security 29 | "length": None, 30 | "header": bytes.fromhex("161c18"), 31 | }, 32 | "bt_home_enc": { 33 | "gatt": '0000181e-0000-1000-8000-00805f9b34fb', 34 | "length": None, 35 | "header": bytes.fromhex("161e18"), 36 | }, 37 | "bt_home_v2": { 38 | "gatt": '0000fcd2-0000-1000-8000-00805f9b34fb', 39 | "length": None, 40 | "header": bytes.fromhex("16d2fc"), 41 | } 42 | } 43 | 44 | 45 | def atc_mi_advertising_format(advertisement_data): 46 | if not advertisement_data.service_data: 47 | return "", "" 48 | invalid_length = None 49 | for t in gatt_dict.keys(): 50 | gatt_d = gatt_dict[t] 51 | if gatt_d["gatt"] in advertisement_data.service_data: 52 | payload = advertisement_data.service_data[gatt_d["gatt"]] 53 | if gatt_d["length"] and len(payload) != gatt_d["length"]: 54 | invalid_length = len(payload) 55 | continue 56 | header = gatt_d["header"] 57 | return t, bytes([len(header) + len(payload)]) + header + payload 58 | if invalid_length is not None: 59 | return "Unknown-length-" + str(invalid_length), "" 60 | return "Unknown", "" 61 | -------------------------------------------------------------------------------- /python-interface/atc_mi_interface/construct_module.py: -------------------------------------------------------------------------------- 1 | # Library module used by atc_mi_advertising.py 2 | 3 | # This module shall be reloadable, including relevant "construct" submodules 4 | 5 | from importlib import reload 6 | import construct_editor.core.custom as custom 7 | from construct_gallery import GalleryItem 8 | from . import atc_mi_construct 9 | 10 | # Allow reloading submodules (load_construct_selector) 11 | from . import atc_mi_construct_adapters 12 | reload(atc_mi_construct_adapters) 13 | reload(atc_mi_construct) 14 | 15 | # Set custom adapters in construct_editor 16 | custom.add_custom_tunnel(atc_mi_construct.BtHomeCodec, "BtHomeCodec") 17 | custom.add_custom_tunnel(atc_mi_construct.BtHomeV2Codec, "BtHomeV2Codec") 18 | custom.add_custom_tunnel(atc_mi_construct.AtcMiCodec, "AtcMiCodec") 19 | custom.add_custom_tunnel(atc_mi_construct.MiLikeCodec, "MiLikeCodec") 20 | custom.add_custom_adapter( 21 | atc_mi_construct.ExprAdapter, 22 | "Value", 23 | custom.AdapterObjEditorType.String) 24 | custom.add_custom_adapter( 25 | atc_mi_construct.ReversedMacAddress, 26 | "ReversedMacAddress", 27 | custom.AdapterObjEditorType.String) 28 | custom.add_custom_adapter( 29 | atc_mi_construct.MacAddress, 30 | "MacAddress", 31 | custom.AdapterObjEditorType.String) 32 | 33 | # Set construct_gallery 34 | gallery_descriptor = { 35 | "general_format": GalleryItem( 36 | construct=atc_mi_construct.general_format, 37 | ), 38 | "custom_format": GalleryItem( 39 | construct=atc_mi_construct.custom_format, 40 | ), 41 | "custom_enc_format": GalleryItem( 42 | construct=atc_mi_construct.custom_enc_format, 43 | ), 44 | "mi_like_format": GalleryItem( 45 | construct=atc_mi_construct.mi_like_format, 46 | ), 47 | "atc1441_format": GalleryItem( 48 | construct=atc_mi_construct.atc1441_format, 49 | ), 50 | "atc1441_enc_format": GalleryItem( 51 | construct=atc_mi_construct.atc1441_enc_format, 52 | ), 53 | "bt_home_format": GalleryItem( 54 | construct=atc_mi_construct.bt_home_format, 55 | ), 56 | "bt_home_enc_format": GalleryItem( 57 | construct=atc_mi_construct.bt_home_enc_format, 58 | ), 59 | "bt_home_v2_format": GalleryItem( 60 | construct=atc_mi_construct.bt_home_v2_format, 61 | ), 62 | } 63 | -------------------------------------------------------------------------------- /python-interface/gui-requirements.txt: -------------------------------------------------------------------------------- 1 | # Additional requirements if GUI is used (requirements.txt is also needed): 2 | wxPython 3 | construct-gallery>=1.1.0 4 | construct-editor 5 | -------------------------------------------------------------------------------- /python-interface/images/atc_mi_config.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/python-interface/images/atc_mi_config.gif -------------------------------------------------------------------------------- /python-interface/images/ble_browser.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/python-interface/images/ble_browser.gif -------------------------------------------------------------------------------- /python-interface/requirements.txt: -------------------------------------------------------------------------------- 1 | # Base requirements: 2 | construct 3 | bleak 4 | pycryptodome 5 | arrow 6 | -------------------------------------------------------------------------------- /signfiles/sign_2.1.1_0159c.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/signfiles/sign_2.1.1_0159c.bin -------------------------------------------------------------------------------- /src/TlsrRetMemAddr.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | ### TlsrMemInfo.py ### 4 | ### Autor: pvvx ### 5 | 6 | import sys 7 | import signal 8 | import struct 9 | import platform 10 | import time 11 | import argparse 12 | import subprocess 13 | import os 14 | import io 15 | 16 | __progname__ = "TLSR825x Check RetentionMem Address" 17 | __filename__ = "TlsrRetMemAddr" 18 | __version__ = "20.11.20" 19 | 20 | SRAM_BASE_ADDR = 0x840000 21 | 22 | class FatalError(RuntimeError): 23 | def __init__(self, message): 24 | RuntimeError.__init__(self, message) 25 | 26 | @staticmethod 27 | def WithResult(message, result): 28 | message += " (result was %s)" % hexify(result) 29 | return FatalError(message) 30 | 31 | def signal_handler(signal, frame): 32 | print() 33 | print('Keyboard Break!') 34 | sys.exit(0) 35 | 36 | def arg_auto_int(x): 37 | return int(x, 0) 38 | 39 | class ELFFile: 40 | 41 | def __init__(self, name, tool_nm): 42 | self.name = name 43 | self.tool_nm = tool_nm 44 | self.symbols = {} 45 | try: 46 | #if sys.platform == 'linux2': 47 | # tool_nm = "tc32-elf-nm" 48 | proc = subprocess.Popen([self.tool_nm, self.name], stdout=subprocess.PIPE) 49 | except OSError: 50 | print("Error calling " + self.tool_nm + ", do you have toolchain in PATH?") 51 | sys.exit(1) 52 | for l in proc.stdout: 53 | fields = l.strip().split() 54 | try: 55 | if fields[0] == b"U": 56 | #print("Warning: Undefined symbol '%s'!" %(fields[1].decode('ASCII'))) 57 | continue 58 | if fields[0] == b"w": 59 | continue # can skip weak symbols 60 | self.symbols[fields[2]] = int(fields[0], 16) 61 | except ValueError: 62 | raise FatalError("Failed to strip symbol output from nm: %s" % fields) 63 | 64 | def get_symbol_addr(self, sym, default = 0): 65 | try: 66 | x = self.symbols[sym] 67 | except: 68 | return default 69 | return x 70 | 71 | def main(): 72 | 73 | signal.signal(signal.SIGINT, signal_handler); 74 | parser = argparse.ArgumentParser(description='%s version %s' % (__progname__, __version__), prog=__filename__); 75 | parser.add_argument('-e','--elffile', help='Name of elf file', default = 'out.elf'); 76 | parser.add_argument('-t','--tools', help='Path and name tc32-elf-nm', default = 'tc32-elf-nm'); 77 | args = parser.parse_args(); 78 | 79 | e = ELFFile(args.elffile, args.tools); 80 | rrs = e.get_symbol_addr(b"_retention_data_end_"); 81 | if rrs == 0: 82 | rrs = e.get_symbol_addr(b"_ictag_start_"); 83 | if rrs > 0: 84 | rrs = (rrs + 255) & 0x0001ff00; 85 | print("0x%x" % rrs); 86 | else: 87 | print("0x8000"); 88 | sys.exit(0); 89 | 90 | 91 | if __name__ == '__main__': 92 | main() 93 | -------------------------------------------------------------------------------- /src/battery.h: -------------------------------------------------------------------------------- 1 | #ifndef _BATTERY_H_ 2 | #define _BATTERY_H_ 3 | 4 | 5 | #define MAX_VBAT_MV 3000 // 3100 mV - > battery = 100% no load, 2950 at load (during measurement) 6 | #define MIN_VBAT_MV 2200 // 2200 mV - > battery = 0% 7 | 8 | #define LOW_VBAT_MV 2800 // level set LOW_CONNECT_LATENCY 9 | #define END_VBAT_MV 2000 // It is not recommended to write Flash below 2V, go to deep-sleep 10 | 11 | u16 get_adc_mv(u32 p_ain); 12 | 13 | #define get_battery_mv() get_adc_mv(SHL_ADC_VBAT) // Channel B0P/B5P 14 | 15 | u8 get_battery_level(u16 battery_mv); 16 | 17 | #endif // _BATTERY_H_ 18 | -------------------------------------------------------------------------------- /src/boot.mk: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Automatically-generated file. Do not edit! 3 | ################################################################################ 4 | 5 | # Add inputs and outputs from these tool invocations to the build variables 6 | OUT_DIR += /src 7 | 8 | OBJS += \ 9 | $(OUT_PATH)/src/cstartup_825x.o 10 | 11 | BOOT_FLAG := -DMCU_STARTUP_825X 12 | 13 | ifeq ($(USE_FREE_RTOS), 1) 14 | BOOT_FLAG += -DUSE_FREE_RTOS 15 | endif 16 | 17 | # Each subdirectory must supply rules for building sources it contributes 18 | $(OUT_PATH)/src/%.o: ./src/%.S 19 | @echo 'Building file: $<' 20 | @$(TC32_PATH)tc32-elf-gcc $(BOOT_FLAG) $(GCC_FLAGS) -c -o"$@" "$<" 21 | -------------------------------------------------------------------------------- /src/div_mod.mk: -------------------------------------------------------------------------------- 1 | 2 | OUT_DIR += /drivers 3 | 4 | OBJS += $(OUT_PATH)/drivers/div_mod.o 5 | 6 | # Each subdirectory must supply rules for building sources it contributes 7 | $(OUT_PATH)/drivers/%.o: $(TEL_PATH)/components/boot/%.S 8 | @echo 'Building file: $<' 9 | @$(TC32_PATH)tc32-elf-gcc $(BOOT_FLAG) -c -o"$@" "$<" 10 | -------------------------------------------------------------------------------- /src/drivers_8258.mk: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Automatically-generated file. Do not edit! 3 | ################################################################################ 4 | 5 | # Add inputs and outputs from these tool invocations to the build variables 6 | 7 | OUT_DIR += /drivers/8258 8 | 9 | OBJS += \ 10 | $(OUT_PATH)/drivers/8258/adc.o \ 11 | $(OUT_PATH)/drivers/8258/aes.o \ 12 | $(OUT_PATH)/drivers/8258/analog.o \ 13 | $(OUT_PATH)/drivers/8258/audio.o \ 14 | $(OUT_PATH)/drivers/8258/bsp.o \ 15 | $(OUT_PATH)/drivers/8258/clock.o \ 16 | $(OUT_PATH)/drivers/8258/emi.o \ 17 | $(OUT_PATH)/drivers/8258/flash.o \ 18 | $(OUT_PATH)/drivers/8258/gpio_8258.o \ 19 | $(OUT_PATH)/drivers/8258/i2c.o \ 20 | $(OUT_PATH)/drivers/8258/lpc.o \ 21 | $(OUT_PATH)/drivers/8258/qdec.o \ 22 | $(OUT_PATH)/drivers/8258/rf_pa.o \ 23 | $(OUT_PATH)/drivers/8258/s7816.o \ 24 | $(OUT_PATH)/drivers/8258/spi.o \ 25 | $(OUT_PATH)/drivers/8258/timer.o \ 26 | $(OUT_PATH)/drivers/8258/uart.o \ 27 | $(OUT_PATH)/drivers/8258/watchdog.o 28 | 29 | # Each subdirectory must supply rules for building sources it contributes 30 | $(OUT_PATH)/drivers/8258/%.o: $(TEL_PATH)/components/drivers/8258/%.c 31 | @echo 'Building file: $<' 32 | @$(TC32_PATH)tc32-elf-gcc $(GCC_FLAGS) $(INCLUDE_PATHS) -c -o"$@" "$<" 33 | -------------------------------------------------------------------------------- /src/ens160.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ens160.h 3 | * 4 | * Created on: 4 мар. 2025 г. 5 | * Author: pvvx 6 | */ 7 | 8 | #ifndef _ENS160_H_ 9 | #define _ENS160_H_ 10 | 11 | #if !SENSOR_SLEEP_MEASURE 12 | #define USE_ENS160_INT 1 13 | #endif 14 | 15 | // Possible Operating Mode defines: 16 | #define ENS160_MODE_DEEP_SLEEP 0x00 17 | #define ENS160_MODE_IDLE 0x01 18 | #define ENS160_MODE_STANDARD 0x02 19 | #define ENS160_MODE_RESET 0xF0 20 | 21 | typedef struct { 22 | u8 i2c_address; 23 | u8 mode; // Deep Sleep (0x00), Idle (0x01), Standard (0x02), Reset (0xF0) 24 | u8 status; // Register DEVICE_STATUS 25 | // [0] new data is available in the GPR_READx registers 26 | // [1] new data is available in the DATA_x registers 27 | // [2:3] 0: Normal operation 28 | // 1: Warm-Up phase 29 | // 2: Initial Start-Up phase 30 | // 3: Invalid output 31 | // [6] Invalid Operating Mode has been selected 32 | // [7] OPMODE is running 33 | u8 aqi; // 1 - Excellent, 2 - Good, 3 - Moderate, 4 - Poor, 5 - Unhealthy. 34 | u16 tvoc; // 35 | u16 co2; // ppm 36 | u8 flg; 37 | #if USE_ENS160_INT 38 | u16 cnt; 39 | u32 co2_sum; 40 | u32 tvoc_sum; 41 | #endif 42 | } ens160_wrk_t; 43 | 44 | extern ens160_wrk_t ens160; 45 | 46 | int init_ens160(void); 47 | int read_ens160(void); 48 | int set_th_ens160(s16 tx100, u16 hx100); 49 | 50 | #endif /* _ENS160_H_ */ 51 | -------------------------------------------------------------------------------- /src/epd.h: -------------------------------------------------------------------------------- 1 | #ifndef _EPD_H_ 2 | #define _EPD_H_ 3 | /* Based on source: https://github.com/znanev/ATC_MiThermometer */ 4 | 5 | //---------------------------------- 6 | // define some constants 7 | //---------------------------------- 8 | #define LOW 0 9 | #define HIGH 1 10 | 11 | //---------------------------------- 12 | // define display commands 13 | //---------------------------------- 14 | #define PANEL_SETTING 0x00 15 | #define POWER_SETTING 0x01 16 | #define POWER_OFF 0x02 17 | #define POWER_OFF_SEQUENCE_SETTING 0x03 18 | #define POWER_ON 0x04 19 | #define DISPLAY_REFRESH 0x12 20 | #define PARTIAL_DISPLAY_REFRESH 0x15 21 | #define DATA_START_TRANSMISSION_1 0x18 22 | #define DATA_START_TRANSMISSION_2 0x1c 23 | #define LUT_FOR_VCOM 0x20 24 | #define LUT_CMD_0x23 0x23 25 | #define LUT_CMD_0x24 0x24 26 | #define LUT_CMD_0x25 0x25 27 | #define LUT_CMD_0x26 0x26 28 | #define PLL_CONTROL 0x30 29 | 30 | //---------------------------------- 31 | // define groups of segments into logical shapes 32 | //---------------------------------- 33 | #define TOP_LEFT_1 1 34 | #define TOP_LEFT 2 35 | #define TOP_MIDDLE 3 36 | #define TOP_RIGHT 4 37 | #define BOTTOM_LEFT 5 38 | #define BOTTOM_RIGHT 6 39 | #define BACKGROUND 7 40 | #define BATTERY_LOW 8 41 | #define DASHES 9 42 | #define FACE 10 43 | #define FACE_SMILE 11 44 | #define FACE_FROWN 12 45 | #define FACE_NEUTRAL 13 46 | #define SUN 14 47 | #define FIXED 15 48 | #define FIXED_DEG_C 16 49 | #define FIXED_DEG_F 17 50 | #define MINUS 18 51 | #define ATC 19 52 | 53 | #endif // _EPD_H_ 54 | -------------------------------------------------------------------------------- /src/ext_ota.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ext_ota.h 3 | * 4 | * Created on: 12.03.2023 5 | * Author: pvvx 6 | */ 7 | 8 | #ifndef EXT_OTA_H_ 9 | #define EXT_OTA_H_ 10 | 11 | #include "app_config.h" 12 | 13 | #define ID_BOOTABLE 0x544c4e4b 14 | 15 | #if ZIGBEE_TUYA_OTA 16 | void tuya_zigbee_ota(void); 17 | #else 18 | void big_to_low_ota(void); 19 | #endif 20 | 21 | #if defined(MI_HW_VER_FADDR) && (MI_HW_VER_FADDR) 22 | u32 get_mi_hw_version(void); 23 | void set_SerialStr(void); 24 | #endif 25 | 26 | 27 | #if (DEV_SERVICES & SERVICE_OTA_EXT) // Compatible BigOTA 28 | 29 | // Ext.OTA return code 30 | enum { 31 | EXT_OTA_OK = 0, //0 32 | EXT_OTA_WORKS, //1 33 | EXT_OTA_BUSY, //2 34 | EXT_OTA_READY, //3 35 | EXT_OTA_EVENT, //4 36 | EXT_OTA_ERR_PARM = 0xfe 37 | } EXT_OTA_ENUM; 38 | 39 | typedef struct _ext_ota_t { 40 | u32 start_addr; 41 | u32 ota_size; // in kbytes 42 | u32 check_addr; 43 | } ext_ota_t; 44 | 45 | extern ext_ota_t ext_ota; 46 | 47 | u8 check_ext_ota(u32 ota_addr, u32 ota_size); 48 | void clear_ota_area(void); 49 | 50 | #endif // (DEV_SERVICES & SERVICE_OTA_EXT) 51 | 52 | #endif /* EXT_OTA_H_ */ 53 | -------------------------------------------------------------------------------- /src/hx71x.h: -------------------------------------------------------------------------------- 1 | /* 2 | * hx71X.h 3 | * For HX711/HX710 4 | * Created on: 26.12.2019 5 | * Author: pvvx 6 | */ 7 | 8 | #ifndef HX71X_H_ 9 | #define HX71X_H_ 10 | 11 | #ifndef USE_SENSOR_HX71X 12 | #define USE_SENSOR_HX71X 0 13 | #endif // USE_SENSOR_HX71X 14 | 15 | #if USE_SENSOR_HX71X 16 | // Set X71X Output Data Rate 10 sps (pin RATE to "0") 17 | 18 | #define MAX_TANK_VOLUME_10ML 32768 // 327 liters 19 | 20 | #define SENSOR_HX71X_WAKEAP 1 // =0 - wakeap HX71X disable (LOW POWER), =1 - wakeap enable (HX71X read measure: 10 Hz) 21 | // HX71x выдает сигнал занятости при каждом авто-измерении 10 или 40Hz. 22 | // Пока идет измерение - считываемые данные не верны! 23 | // Решение только одно - читать сразу по фронту готовности (set SENSOR_HX71X_WAKEAP = 1), пока идет пауза до следующего измерения 24 | // Иначе будут сбои в показаниях, которые не отследить 25 | 26 | typedef struct _hx71x_cfg_t { 27 | u32 zero; 28 | u32 coef; 29 | u32 volume_10ml; // volume in the tank when the overflow sensor is triggered (in 10 milliliters) 30 | } hx71x_cfg_t; 31 | 32 | typedef struct _hx71x_t { 33 | hx71x_cfg_t cfg; 34 | u32 adc; 35 | u32 value; 36 | u32 summator; 37 | u32 count; 38 | u32 calcoef; 39 | } hx71x_t; 40 | 41 | 42 | typedef enum { 43 | HX71XMODE_A128 = 25, 44 | HX71XMODE_B32, 45 | HX71XMODE_A64 46 | } hx71x_mode_t; 47 | 48 | 49 | extern hx71x_t hx71x; 50 | 51 | extern hx71x_cfg_t def_hx71x_cfg; 52 | 53 | /* 54 | * HX71XMODE_A128 - Period: 94 ms, Pulse (1): 81.5 us 55 | */ 56 | int hx71x_get_data(hx71x_mode_t mode); 57 | void hx71x_calibration(void); 58 | u16 hx71x_get_volume(void); // in 10 milliliters 59 | // void hx71x_suspend(void); 60 | void hx71x_task(void); 61 | 62 | inline void hx711_go_sleep(void) { 63 | gpio_setup_up_down_resistor(GPIO_HX71X_SCK, PM_PIN_PULLUP_1M); 64 | } 65 | 66 | inline void hx711_gpio_wakeup(void) { 67 | gpio_setup_up_down_resistor(GPIO_HX71X_SCK, PM_PIN_PULLDOWN_100K); 68 | } 69 | 70 | #endif // USE_SENSOR_HX71X 71 | 72 | #endif /* HX71X_H_ */ 73 | -------------------------------------------------------------------------------- /src/i2c.h: -------------------------------------------------------------------------------- 1 | #ifndef _I2C_H_ 2 | #define _I2C_H_ 3 | 4 | #ifndef I2C_GROUP 5 | #define init_i2c() soft_i2c_stop() 6 | #else 7 | void init_i2c(); 8 | int send_i2c_addr_word(u8 i2c_addr, u32 ra_w); 9 | #endif 10 | //void send_i2c(u8 device_id, u8 *buffer, int dataLen); 11 | int scan_i2c_addr(int address); 12 | int send_i2c_byte(u8 i2c_addr, u8 cmd); 13 | int send_i2c_word(u8 i2c_addr, u16 cmd); 14 | int send_i2c_buf(u8 i2c_addr, u8 * dataBuf, u32 dataLen); 15 | int read_i2c_buf(u8 i2c_addr, u8 * dataBuf, u32 dataLen); 16 | int read_i2c_byte_addr(u8 i2c_addr, u8 reg_addr, u8 * dataBuf, u32 dataLen); 17 | 18 | /* Universal I2C/SMBUS read-write transaction struct */ 19 | typedef struct _i2c_utr_t { 20 | unsigned char mode; // bit0..6: The byte number of the record for the new START (bit7: =1 - generate STOP/START) 21 | unsigned char rdlen; // bit0..6: Number of bytes read (bit7: =0 - the last byte read generates NACK, =1 - ACK) 22 | unsigned char wrdata[1]; // Array, the first byte is the address, then the bytes to write to the bus: i2c_addr_wr, wr_byte1, wr_byte2, wr_byte3, ... wr_byte126 23 | } i2c_utr_t; 24 | int I2CBusUtr(void * outdata, i2c_utr_t * tr, u32 wrlen); 25 | 26 | #endif //_I2C_H_ 27 | -------------------------------------------------------------------------------- /src/logger.h: -------------------------------------------------------------------------------- 1 | /* 2 | * logger.h 3 | * 4 | * Created on: 29.01.2021 5 | * Author: pvvx 6 | */ 7 | 8 | #ifndef _LOGGER_H_ 9 | #define _LOGGER_H_ 10 | #include "app_config.h" 11 | 12 | #if (DEV_SERVICES & SERVICE_HISTORY) 13 | 14 | #ifndef USE_MEMO_1M 15 | #define USE_MEMO_1M 1 16 | #endif 17 | 18 | #define MEMO_SEC_ID 0x55AAC0DE // sector head 19 | #define FLASH_ADDR_START_MEMO 0x40000 20 | #define FLASH_ADDR_END_MEMO 0x74000 // 49 sectors 21 | 22 | #define FLASH1M_ADDR_START_MEMO 0x80000 23 | #define FLASH1M_ADDR_END_MEMO 0x100000 // 128 sectors 24 | 25 | typedef struct _memo_blk_t { 26 | u32 time; // time (UTC) 27 | s16 val1; // temp; // x0.01 C 28 | u16 val2; // humi; // x0.01 % 29 | u16 val0; // vbat; // mV 30 | }memo_blk_t, * pmemo_blk_t; 31 | 32 | typedef struct _memo_inf_t { 33 | u32 faddr; 34 | u32 cnt_cur_sec; 35 | #if USE_MEMO_1M 36 | u32 sectors; 37 | u32 start_addr; 38 | u32 end_addr; 39 | #endif 40 | }memo_inf_t; 41 | 42 | typedef struct _memo_rd_t { 43 | memo_inf_t saved; 44 | u32 cnt; 45 | u32 cur; 46 | }memo_rd_t; 47 | 48 | typedef struct _memo_head_t { 49 | u32 id; // = 0x55AAC0DE (MEMO_SEC_ID) 50 | u16 flg; // = 0xffff - new sector, = 0 close sector 51 | }memo_head_t; 52 | 53 | extern memo_rd_t rd_memo; 54 | extern memo_inf_t memo; 55 | 56 | void memo_init(void); 57 | void clear_memo(void); 58 | unsigned get_memo(u32 bnum, pmemo_blk_t p); 59 | void write_memo(void); 60 | 61 | #endif // #if (DEV_SERVICES & SERVICE_HISTORY) 62 | #endif /* _LOGGER_H_ */ 63 | -------------------------------------------------------------------------------- /src/my18b20.h: -------------------------------------------------------------------------------- 1 | /* 2 | * my18b20.h 3 | * 4 | * Created on: 3 авг. 2024 г. 5 | * Author: pvvx 6 | */ 7 | 8 | #ifndef _MY18B20_H_ 9 | #define _MY18B20_H_ 10 | 11 | typedef struct _my18b20_coef_t { 12 | u32 val1_k; // temp_k / current_k 13 | #if USE_SENSOR_MY18B20 == 2 14 | u32 val2_k; // humi_k / voltage_k 15 | #endif 16 | s16 val1_z; // temp_z / current_z 17 | #if USE_SENSOR_MY18B20 == 2 18 | s16 val2_z; // humi_z / voltage_z 19 | #endif 20 | } my18b20_coef_t; // [12] 21 | 22 | // extern my18b20_coef_t def_coef_my18b20; 23 | 24 | typedef struct { 25 | my18b20_coef_t coef; 26 | u32 id; 27 | u8 res; 28 | u8 type; 29 | u8 rd_ok; 30 | u8 stage; 31 | u32 tick; 32 | u32 timeout; 33 | s16 temp[USE_SENSOR_MY18B20]; 34 | } my18b20_t; 35 | 36 | extern my18b20_t my18b20; 37 | #define my18b20_send_size (sizeof(my18b20.coef) + 6) 38 | 39 | void init_my18b20(void); 40 | void task_my18b20(void); 41 | int read_sensor_cb(void); 42 | 43 | #endif /* _MY18B20_H_ */ 44 | -------------------------------------------------------------------------------- /src/project.mk: -------------------------------------------------------------------------------- 1 | 2 | OUT_DIR += /src 3 | 4 | OBJS += \ 5 | $(OUT_PATH)/src/utils.o \ 6 | $(OUT_PATH)/src/app.o \ 7 | $(OUT_PATH)/src/lcd.o \ 8 | $(OUT_PATH)/src/lcd_lywsd03mmc.o \ 9 | $(OUT_PATH)/src/lcd_cgdk2.o \ 10 | $(OUT_PATH)/src/lcd_mjwsd05mmc.o \ 11 | $(OUT_PATH)/src/lcd_mjwsd05mmc_en.o \ 12 | $(OUT_PATH)/src/lcd_mjwsd06mmc.o \ 13 | $(OUT_PATH)/src/lcd_mho_c122.o \ 14 | $(OUT_PATH)/src/lcd_zth03.o \ 15 | $(OUT_PATH)/src/lcd_lktmzl02.o \ 16 | $(OUT_PATH)/src/lcd_zy_zth02pro.o \ 17 | $(OUT_PATH)/src/lcd_zth05z.o \ 18 | $(OUT_PATH)/src/epd_cgg1.o \ 19 | $(OUT_PATH)/src/epd_cgg1n.o \ 20 | $(OUT_PATH)/src/epd_mho_c401.o \ 21 | $(OUT_PATH)/src/epd_mho_c401n.o \ 22 | $(OUT_PATH)/src/sensors.o \ 23 | $(OUT_PATH)/src/ens160.o \ 24 | $(OUT_PATH)/src/scd41.o \ 25 | $(OUT_PATH)/src/ina226.o \ 26 | $(OUT_PATH)/src/ina3221.o \ 27 | $(OUT_PATH)/src/my18b20.o \ 28 | $(OUT_PATH)/src/hx71x.o \ 29 | $(OUT_PATH)/src/rtc_pcf85163.o \ 30 | $(OUT_PATH)/src/bme280.o \ 31 | $(OUT_PATH)/src/sdm_out.o \ 32 | $(OUT_PATH)/src/trigger.o \ 33 | $(OUT_PATH)/src/rds_count.o \ 34 | $(OUT_PATH)/src/app_att.o \ 35 | $(OUT_PATH)/src/battery.o \ 36 | $(OUT_PATH)/src/rh.o \ 37 | $(OUT_PATH)/src/ble.o \ 38 | $(OUT_PATH)/src/i2c.o \ 39 | $(OUT_PATH)/src/cmd_parser.o \ 40 | $(OUT_PATH)/src/ext_ota.o \ 41 | $(OUT_PATH)/src/flash_eep.o \ 42 | $(OUT_PATH)/src/logger.o \ 43 | $(OUT_PATH)/src/blt_common.o\ 44 | $(OUT_PATH)/src/ccm.o \ 45 | $(OUT_PATH)/src/custom_beacon.o \ 46 | $(OUT_PATH)/src/mi_beacon.o \ 47 | $(OUT_PATH)/src/bthome_beacon.o \ 48 | $(OUT_PATH)/src/scanning.o \ 49 | $(OUT_PATH)/src/main.o 50 | 51 | 52 | # Each subdirectory must supply rules for building sources it contributes 53 | $(OUT_PATH)/src/%.o: $(PROJECT_PATH)/%.c 54 | @echo 'Building file: $<' 55 | @$(TC32_PATH)tc32-elf-gcc $(GCC_FLAGS) $(INCLUDE_PATHS) -c -o"$@" "$<" -------------------------------------------------------------------------------- /src/rds_count.h: -------------------------------------------------------------------------------- 1 | /* 2 | * rds_count.h 3 | * 4 | * Created on: 20.02.2022 5 | * Author: pvvx 6 | */ 7 | 8 | #ifndef RDS_COUNT_H_ 9 | #define RDS_COUNT_H_ 10 | 11 | #include "app_config.h" 12 | 13 | #if (DEV_SERVICES & SERVICE_RDS) 14 | 15 | //#include "mi_beacon.h" 16 | 17 | #ifndef RDS1_PULLUP 18 | #define RDS1_PULLUP PM_PIN_PULLUP_1M 19 | #endif 20 | 21 | #ifndef RDS2_PULLUP 22 | #define RDS2_PULLUP PM_PIN_PULLUP_1M 23 | #endif 24 | 25 | enum { 26 | RDS_NONE = 0, 27 | RDS_SWITCH, 28 | RDS_COUNTER, 29 | RDS_CONNECT // version 4.2+ 30 | } RDS_TYPES; 31 | 32 | typedef struct _rds_count_t { 33 | u32 report_tick; // timer reed switch count report interval (wrk.utc_time_sec) 34 | union { // rs1 counter pulses 35 | u8 count1_byte[4]; 36 | u16 count1_short[2]; 37 | u32 count1; 38 | }; 39 | /* 40 | #ifdef GPIO_RDS2 41 | union { // rs2 counter pulses 42 | u8 count2_byte[4]; 43 | u16 count2_short[2]; 44 | u32 count2; 45 | }; 46 | #endif 47 | */ 48 | u8 event; // Reed Switch event 49 | } rds_count_t; 50 | extern rds_count_t rds; // Reed switch pulse counter 51 | 52 | #ifdef GPIO_RDS1 53 | static inline u8 get_rds1_input(void) { 54 | u8 r = BM_IS_SET(reg_gpio_in(GPIO_RDS1), GPIO_RDS1 & 0xff)? 1 : 0; 55 | if(trg.rds.rs1_invert) 56 | r ^= 1; 57 | return r; 58 | } 59 | 60 | static inline void rds1_input_on(void) { 61 | gpio_setup_up_down_resistor(GPIO_RDS1, RDS1_PULLUP); 62 | } 63 | 64 | static inline void rds1_input_off(void) { 65 | gpio_setup_up_down_resistor(GPIO_RDS1, PM_PIN_UP_DOWN_FLOAT); 66 | } 67 | 68 | #endif 69 | 70 | #ifdef GPIO_RDS2 71 | static inline u8 get_rds2_input(void) { 72 | u8 r = BM_IS_SET(reg_gpio_in(GPIO_RDS2), GPIO_RDS2 & 0xff)? 1 : 0; 73 | if(trg.rds.rs2_invert) 74 | r ^= 1; 75 | return r; 76 | } 77 | 78 | static inline void rds2_input_off(void) { 79 | gpio_setup_up_down_resistor(GPIO_RDS2, PM_PIN_UP_DOWN_FLOAT); 80 | } 81 | 82 | static inline void rds2_input_on(void) { 83 | gpio_setup_up_down_resistor(GPIO_RDS2, RDS2_PULLUP); 84 | } 85 | #endif 86 | 87 | 88 | static inline void rds_input_on(void) { 89 | #ifdef GPIO_RDS1 90 | gpio_setup_up_down_resistor(GPIO_RDS1, RDS1_PULLUP); 91 | #endif 92 | #ifdef GPIO_RDS2 93 | gpio_setup_up_down_resistor(GPIO_RDS2, RDS2_PULLUP); 94 | #endif 95 | } 96 | 97 | 98 | void rds_init(void); 99 | void rds_suspend(void); 100 | void rds_task(void); 101 | 102 | #endif // (DEV_SERVICES & SERVICE_RDS) 103 | 104 | #endif /* RDS_COUNT_H_ */ 105 | -------------------------------------------------------------------------------- /src/rh.h: -------------------------------------------------------------------------------- 1 | /* 2 | * rh.h 3 | * 4 | * Created on: 24 июл. 2024 г. 5 | * Author: pvvx 6 | */ 7 | 8 | #ifndef _RH_H_ 9 | #define _RH_H_ 10 | 11 | // R = 7.5 kOm, КД521 (BAV99), C 4.7 nF 12 | 13 | /********************************************************************************* 14 | PWM0 : PA2. PC1. PC2. PD5 15 | PWM1 : PA3. PC3. 16 | PWM2 : PA4. PC4. 17 | PWM3 : PB0. PD2. 18 | PWM4 : PB1. PB4. 19 | PWM5 : PB2. PB5. 20 | PWM0_N : PA0. PB3. PC4 PD5 21 | PWM1_N : PC1. PD3. 22 | PWM2_N : PD4. 23 | PWM3_N : PC5. 24 | PWM4_N : PC0. PC6. 25 | PWM5_N : PC7. 26 | *********************************************************************************/ 27 | 28 | /* 29 | // PWM 30 | #define PWM_PIN GPIO_PB4 31 | #define AS_PWMx AS_PWM4 32 | #define PWM_ID PWM4_ID 33 | // ADC 34 | #define GPIO_RHI GPIO_PB5 35 | #define CHNL_RHI B5P 36 | */ 37 | #if (DEV_SERVICES & SERVICE_PLM) 38 | 39 | typedef struct _thsensor_coef_t { 40 | u32 val1_k; // temp_k / current_k 41 | u32 val2_k; // humi_k / voltage_k 42 | s16 val1_z; // temp_z / current_z 43 | s16 val2_z; // humi_z / voltage_z 44 | } sensor_coef_t; // [12] 45 | 46 | /* 47 | typedef struct _sensor_def_cfg_t { 48 | sensor_coef_t coef; 49 | u32 measure_timeout; 50 | u8 sensor_type; // SENSOR_TYPES 51 | } sensor_def_cfg_t; 52 | */ 53 | 54 | typedef struct _sensor_cfg_t { 55 | sensor_coef_t coef; 56 | u32 id; 57 | u8 i2c_addr; 58 | u8 sensor_type; // SENSOR_TYPES 59 | // not saved, send for debug 60 | u16 adc_rh; 61 | u16 adc_ntc; 62 | #ifdef USE_AVERAGE_TH_SHL 63 | u16 cnt_summ; 64 | u32 summ_rh; 65 | u32 summ_ntc; 66 | #endif 67 | } sensor_cfg_t; 68 | 69 | extern sensor_cfg_t sensor_cfg; 70 | #define sensor_cfg_send_size 18 //max 19 71 | 72 | #endif 73 | 74 | #ifdef USE_AVERAGE_TH_SHL 75 | void clr_rh_summ(void); 76 | #endif 77 | void init_sensor(void); 78 | int calibrate_rh_0(void); 79 | int calibrate_rh_100(void); 80 | int read_sensor_cb(void); 81 | 82 | #endif /* RH_H_ */ 83 | -------------------------------------------------------------------------------- /src/rtc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * rtc.h 3 | * 4 | * Created on: 02.03.2023 5 | * Author: pvvx 6 | */ 7 | 8 | #ifndef RTC_H_ 9 | #define RTC_H_ 10 | 11 | #if (DEV_SERVICES & SERVICE_HARD_CLOCK) 12 | 13 | typedef struct { 14 | u8 hours; // RTC Time Hours: 0-12 / 0-23 range if H12 (AM/PM) 15 | u8 minutes; // RTC Time Minutes: 0-59 range. 16 | u8 seconds; // RTC Time Seconds: 0-59 range. 17 | u8 weekday; // RTC Date WeekDay: 0-6 range. 18 | u8 month; // RTC Date Month 19 | u8 days; // RTC Date Days: 1-31 range. 20 | u8 year; // RTC Date Year: 0-99 range. 21 | } rtc_time_t; 22 | 23 | 24 | typedef struct _rtc_pcf_reg_t{ 25 | u8 sec; 26 | u8 min; 27 | u8 hrs; 28 | u8 days; 29 | u8 wkds; 30 | u8 cmnths; 31 | u8 years; 32 | } rtc_pcf_reg_t; 33 | 34 | typedef union _rtc_registers_t{ 35 | rtc_pcf_reg_t r; 36 | u8 uc[7]; 37 | } rtc_registers_t; 38 | 39 | typedef struct __attribute__((packed)) _rtc_regs_t { 40 | u8 reg_addr; 41 | rtc_registers_t reg; 42 | } rtc_regs_t; 43 | 44 | extern u8 rtc_i2c_addr; 45 | extern rtc_regs_t rtc_reg; 46 | extern rtc_time_t rtc; 47 | extern u32 rtc_sync_utime; 48 | 49 | void init_rtc(void); 50 | int rtc_read_all(void); 51 | u32 rtc_get_utime(void); 52 | void rtc_set_utime(u32 ut); 53 | 54 | // Conversion Utilities 55 | u32 rtc_to_utime(rtc_time_t *r); // convert RTC date/time structures to unix time (sec) 56 | void utime_to_rtc(u32 ut, rtc_time_t *r); // convert unix time to RTC date/time 57 | u8 bcd_to_byte(u8 bcd); 58 | u8 byte_to_bcd(u8 b); 59 | void rtc_to_regs(rtc_time_t *r); 60 | void rtc_regs(rtc_time_t *r); 61 | 62 | #endif // (DEV_SERVICES & SERVICE_HARD_CLOCK) 63 | 64 | #endif /* RTC_H_ */ 65 | -------------------------------------------------------------------------------- /src/scanning.h: -------------------------------------------------------------------------------- 1 | /* 2 | * scanning.h 3 | * 4 | * Created on: 31 янв. 2025 г. 5 | * Author: pvvx 6 | */ 7 | 8 | #ifndef _SCANING_H_ 9 | #define _SCANING_H_ 10 | 11 | #define SCAN_USE_BINDKEY 0 12 | 13 | // saved to EEP_ID_SCN 14 | typedef struct { 15 | u32 interval; // интервал вызова в сек, =0 - отключено 16 | u8 MAC[6]; // MAC сервера [0] - lo, .. [6] - hi digits 17 | #if SCAN_USE_BINDKEY 18 | u8 bindkey[16]; // for ext dev MAC 19 | #endif 20 | } scan_cfg_t; 21 | 22 | typedef struct { 23 | u32 start_tik; // = 0 - сканирование отключено (разрешить sleep), !=0 - штамп времени старта сканирования 24 | u32 start_time; // = wrk.utc_time_sec при старте каждого интервала 25 | scan_cfg_t cfg; 26 | u8 enabled; 27 | } scan_wrk_t; 28 | 29 | extern scan_wrk_t scan; 30 | 31 | ////////////////////////////////////////////////////////// 32 | // scan stop 33 | ////////////////////////////////////////////////////////// 34 | inline void scan_stop(void) { 35 | scan.enabled = 0; // stop scan 36 | scan.start_tik = 0; 37 | } 38 | 39 | void scan_init(void); 40 | void scan_wakeup(void); 41 | void scan_start(void); 42 | void scan_task(void); 43 | 44 | #endif /* _SCANNING_H_ */ 45 | -------------------------------------------------------------------------------- /src/sdm_out.h: -------------------------------------------------------------------------------- 1 | /* 2 | * sdm_out.h 3 | * 4 | * Created on: 17 апр. 2025 г. 5 | * Author: pvvx 6 | */ 7 | 8 | #ifndef SDM_OUT_H_ 9 | #define SDM_OUT_H_ 10 | typedef struct { 11 | s16 in_min; 12 | s16 in_max; 13 | u16 out_min; 14 | u16 out_max; 15 | } cfg_dac_t; 16 | 17 | typedef struct { 18 | cfg_dac_t cfg; 19 | s32 k; 20 | } cfg_sdmdac_t; 21 | 22 | extern cfg_sdmdac_t sdmdac; 23 | 24 | void set_dac(void); 25 | void init_dac(void); 26 | //void sdm_out(signed short value_dac0, signed short value_dac1); 27 | 28 | 29 | #endif /* SDM_OUT_H_ */ 30 | -------------------------------------------------------------------------------- /src/trigger.h: -------------------------------------------------------------------------------- 1 | /* 2 | * tigger.h 3 | * 4 | * Created on: 02.01.2021 5 | * Author: pvvx 6 | */ 7 | 8 | #ifndef _TIGGER_H_ 9 | #define _TIGGER_H_ 10 | 11 | #include "app_config.h" 12 | 13 | #if (DEV_SERVICES & SERVICE_TH_TRG) || (DEV_SERVICES & SERVICE_RDS) 14 | 15 | typedef struct __attribute__((packed)) _trigger_flg_t { 16 | u8 rds1_input : 1; // Reed Switch, input 17 | u8 trg_output : 1; // GPIO_TRG pin output value (pull Up/Down) 18 | u8 trigger_on : 1; // Output GPIO_TRG pin is controlled according to the set parameters threshold temperature or humidity 19 | u8 temp_out_on : 1; // Temperature trigger event 20 | u8 humi_out_on : 1; // Humidity trigger event 21 | u8 key_pressed : 1; // key2 pressed (Connect/Reset) 22 | u8 rds2_input : 1; // Reed Switch 2, input 23 | }trigger_flg_t; 24 | 25 | #if (DEV_SERVICES & SERVICE_RDS) 26 | 27 | typedef struct __attribute__((packed)) _rds_type_t { 28 | u8 type1 : 2; // RDS_TYPES, Reed switch 1 types: 0 - none, 1 - switch, 2 - counter [3 - connect] 29 | u8 type2 : 2; // RDS_TYPES, Reed switch 2 types: 0 - none, 1 - switch, 2 - counter [3 - connect] 30 | // version 3.9+ 31 | u8 rs1_invert : 1; // GPIO events (Reed switch 1): 0 - rising, 1 - falling 32 | u8 rs2_invert : 1; // GPIO events (Reed switch 2): 0 - rising, 1 - falling 33 | }rds_type_t; 34 | 35 | #endif 36 | 37 | typedef struct __attribute__((packed)) _trigger_t { 38 | #if (DEV_SERVICES & SERVICE_TH_TRG) 39 | s16 temp_threshold; // x0.01°, Set temp threshold 40 | s16 humi_threshold; // x0.01%, Set humi threshold 41 | s16 temp_hysteresis; // Set temp hysteresis, -327.67..327.67 ° 42 | s16 humi_hysteresis; // Set humi hysteresis, -327.67..327.67 % 43 | #endif 44 | #if (DEV_SERVICES & SERVICE_RDS) 45 | // version 3.6+ 46 | u16 rds_time_report; // Reed switch count report interval (sec) 47 | rds_type_t rds; // type Reed switch 48 | #endif 49 | union { 50 | trigger_flg_t flg; 51 | u8 flg_byte; 52 | }; 53 | }trigger_t; 54 | 55 | #define FEEP_SAVE_SIZE_TRG (sizeof(trg)-1) 56 | 57 | extern trigger_t trg; 58 | extern const trigger_t def_trg; 59 | 60 | #if (DEV_SERVICES & SERVICE_TH_TRG) 61 | void set_trigger_out(void); 62 | void test_trg_on(void); 63 | #endif 64 | 65 | #endif // (DEV_SERVICES & SERVICE_TH_TRG) || (DEV_SERVICES & SERVICE_RDS) 66 | 67 | #endif /* _TIGGER_H_ */ 68 | -------------------------------------------------------------------------------- /src/uprintf.mk: -------------------------------------------------------------------------------- 1 | 2 | OUT_DIR += /application/print 3 | 4 | OBJS += \ 5 | $(OUT_PATH)/application/print/putchar.o \ 6 | $(OUT_PATH)/application/print/u_printf.o \ 7 | 8 | # Each subdirectory must supply rules for building sources it contributes 9 | $(OUT_PATH)/application/%.o: $(TEL_PATH)/components/application/%.c 10 | @echo 'Building file: $<' 11 | @$(TC32_PATH)tc32-elf-gcc $(GCC_FLAGS) $(INCLUDE_PATHS) -c -o"$@" "$<" 12 | -------------------------------------------------------------------------------- /utils/check_fw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/utils/check_fw -------------------------------------------------------------------------------- /utils/tl_check_fw.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | import binascii 3 | import sys 4 | # https://github.com/pvvx/ATC_MiThermometer/issues/186#issuecomment-1030410603 5 | with open(sys.argv[1], 'rb') as f: 6 | firmware = bytearray(f.read(-1)) 7 | 8 | if firmware[6:8] != b'\x5d\x02': 9 | # Ensure FW size is multiple of 16 10 | padding = 16 - len(firmware) % 16 11 | if padding < 16: 12 | firmware += b'\xFF' * padding 13 | # Fix FW length 14 | firmware[0x18:0x1c] = (len(firmware)+4).to_bytes(4, byteorder='little') 15 | # Add magic constant 16 | firmware[6:8] = b'\x5d\x02' 17 | # Add CRC 18 | crc = binascii.crc32(firmware) ^ 0xffffffff 19 | firmware += crc.to_bytes(4, byteorder='little') 20 | # Write the new firwmare back to the file 21 | with open(sys.argv[1], 'wb') as f: 22 | f.write(firmware) 23 | print(f"Firmware patched!") 24 | else: 25 | print(f"Firmware already patched!") -------------------------------------------------------------------------------- /utils/tl_check_fw2.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/utils/tl_check_fw2.exe -------------------------------------------------------------------------------- /zigbee_ota/1002-0203-60993001-ZYZTH02BLE_v51.zigbee: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/zigbee_ota/1002-0203-60993001-ZYZTH02BLE_v51.zigbee -------------------------------------------------------------------------------- /zigbee_ota/1002-0203-60993001-ZYZTH02BLE_v52.zigbee: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/zigbee_ota/1002-0203-60993001-ZYZTH02BLE_v52.zigbee -------------------------------------------------------------------------------- /zigbee_ota/1002-0203-60993001-ZYZTH02PBLE_v51.zigbee: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/zigbee_ota/1002-0203-60993001-ZYZTH02PBLE_v51.zigbee -------------------------------------------------------------------------------- /zigbee_ota/1002-0203-60993001-ZYZTH02PBLE_v52.zigbee: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/zigbee_ota/1002-0203-60993001-ZYZTH02PBLE_v52.zigbee -------------------------------------------------------------------------------- /zigbee_ota/1141-0201-99993001-MHO_C401_v51.zigbee: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/zigbee_ota/1141-0201-99993001-MHO_C401_v51.zigbee -------------------------------------------------------------------------------- /zigbee_ota/1141-0201-99993001-MHO_C401_v52.zigbee: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/zigbee_ota/1141-0201-99993001-MHO_C401_v52.zigbee -------------------------------------------------------------------------------- /zigbee_ota/1141-0202-99993001-CGG1_v51.zigbee: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/zigbee_ota/1141-0202-99993001-CGG1_v51.zigbee -------------------------------------------------------------------------------- /zigbee_ota/1141-0202-99993001-CGG1_v52.zigbee: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/zigbee_ota/1141-0202-99993001-CGG1_v52.zigbee -------------------------------------------------------------------------------- /zigbee_ota/1141-0203-99993001-ATC_v51.zigbee: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/zigbee_ota/1141-0203-99993001-ATC_v51.zigbee -------------------------------------------------------------------------------- /zigbee_ota/1141-0203-99993001-ATC_v52.zigbee: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/zigbee_ota/1141-0203-99993001-ATC_v52.zigbee -------------------------------------------------------------------------------- /zigbee_ota/1141-0206-99993001-CGDK2_v51.zigbee: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/zigbee_ota/1141-0206-99993001-CGDK2_v51.zigbee -------------------------------------------------------------------------------- /zigbee_ota/1141-0206-99993001-CGDK2_v52.zigbee: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/zigbee_ota/1141-0206-99993001-CGDK2_v52.zigbee -------------------------------------------------------------------------------- /zigbee_ota/1141-0207-99993001-CGG1M_v51.zigbee: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/zigbee_ota/1141-0207-99993001-CGG1M_v51.zigbee -------------------------------------------------------------------------------- /zigbee_ota/1141-0207-99993001-CGG1M_v52.zigbee: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/zigbee_ota/1141-0207-99993001-CGG1M_v52.zigbee -------------------------------------------------------------------------------- /zigbee_ota/1141-0208-99993001-MHO_C401N_v51.zigbee: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/zigbee_ota/1141-0208-99993001-MHO_C401N_v51.zigbee -------------------------------------------------------------------------------- /zigbee_ota/1141-0208-99993001-MHO_C401N_v52.zigbee: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/zigbee_ota/1141-0208-99993001-MHO_C401N_v52.zigbee -------------------------------------------------------------------------------- /zigbee_ota/1141-0209-99993001-BTH_v51.zigbee: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/zigbee_ota/1141-0209-99993001-BTH_v51.zigbee -------------------------------------------------------------------------------- /zigbee_ota/1141-0209-99993001-BTH_v52.zigbee: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/zigbee_ota/1141-0209-99993001-BTH_v52.zigbee -------------------------------------------------------------------------------- /zigbee_ota/1141-020a-99993001-ATC_v51.zigbee: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/zigbee_ota/1141-020a-99993001-ATC_v51.zigbee -------------------------------------------------------------------------------- /zigbee_ota/1141-020a-99993001-ATC_v52.zigbee: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/zigbee_ota/1141-020a-99993001-ATC_v52.zigbee -------------------------------------------------------------------------------- /zigbee_ota/1141-020b-99993001-MHO_C122_v51.zigbee: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/zigbee_ota/1141-020b-99993001-MHO_C122_v51.zigbee -------------------------------------------------------------------------------- /zigbee_ota/1141-020b-99993001-MHO_C122_v52.zigbee: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/zigbee_ota/1141-020b-99993001-MHO_C122_v52.zigbee -------------------------------------------------------------------------------- /zigbee_ota/1141-020c-99993001-BTE_v51.zigbee: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/zigbee_ota/1141-020c-99993001-BTE_v51.zigbee -------------------------------------------------------------------------------- /zigbee_ota/1141-020c-99993001-BTE_v52.zigbee: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/zigbee_ota/1141-020c-99993001-BTE_v52.zigbee -------------------------------------------------------------------------------- /zigbee_ota/1141-020d-99993001-MJ6_v51.zigbee: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/zigbee_ota/1141-020d-99993001-MJ6_v51.zigbee -------------------------------------------------------------------------------- /zigbee_ota/1141-020d-99993001-MJ6_v52.zigbee: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/zigbee_ota/1141-020d-99993001-MJ6_v52.zigbee -------------------------------------------------------------------------------- /zigbee_ota/1141-0210-99993001-TB03F_v51.zigbee: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/zigbee_ota/1141-0210-99993001-TB03F_v51.zigbee -------------------------------------------------------------------------------- /zigbee_ota/1141-0210-99993001-TB03F_v52.zigbee: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/zigbee_ota/1141-0210-99993001-TB03F_v52.zigbee -------------------------------------------------------------------------------- /zigbee_ota/1141-0210-99993001-TB_BME280_v52.zigbee: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/zigbee_ota/1141-0210-99993001-TB_BME280_v52.zigbee -------------------------------------------------------------------------------- /zigbee_ota/1141-0210-99993001-TB_ENS160_v52.zigbee: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/zigbee_ota/1141-0210-99993001-TB_ENS160_v52.zigbee -------------------------------------------------------------------------------- /zigbee_ota/1141-0210-99993001-TB_INA226_v52.zigbee: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/zigbee_ota/1141-0210-99993001-TB_INA226_v52.zigbee -------------------------------------------------------------------------------- /zigbee_ota/1141-0210-99993001-TB_INA3221_v52.zigbee: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/zigbee_ota/1141-0210-99993001-TB_INA3221_v52.zigbee -------------------------------------------------------------------------------- /zigbee_ota/1141-0210-99993001-TB_SCD41_v52.zigbee: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/zigbee_ota/1141-0210-99993001-TB_SCD41_v52.zigbee -------------------------------------------------------------------------------- /zigbee_ota/1141-0211-99993001-TS0201S1_v51.zigbee: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/zigbee_ota/1141-0211-99993001-TS0201S1_v51.zigbee -------------------------------------------------------------------------------- /zigbee_ota/1141-0211-99993001-TS0201S1_v52.zigbee: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/zigbee_ota/1141-0211-99993001-TS0201S1_v52.zigbee -------------------------------------------------------------------------------- /zigbee_ota/1141-0211-99993001-TS0201S2_v51.zigbee: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/zigbee_ota/1141-0211-99993001-TS0201S2_v51.zigbee -------------------------------------------------------------------------------- /zigbee_ota/1141-0211-99993001-TS0201S2_v52.zigbee: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/zigbee_ota/1141-0211-99993001-TS0201S2_v52.zigbee -------------------------------------------------------------------------------- /zigbee_ota/1141-0211-99993001-TS0201_v51.zigbee: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/zigbee_ota/1141-0211-99993001-TS0201_v51.zigbee -------------------------------------------------------------------------------- /zigbee_ota/1141-0211-99993001-TS0201_v52.zigbee: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/zigbee_ota/1141-0211-99993001-TS0201_v52.zigbee -------------------------------------------------------------------------------- /zigbee_ota/1141-0212-99993001-TNK01_v51.zigbee: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/zigbee_ota/1141-0212-99993001-TNK01_v51.zigbee -------------------------------------------------------------------------------- /zigbee_ota/1141-0212-99993001-TNK01_v52.zigbee: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/zigbee_ota/1141-0212-99993001-TNK01_v52.zigbee -------------------------------------------------------------------------------- /zigbee_ota/1141-0216-99993001-TH03Z_v51.zigbee: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/zigbee_ota/1141-0216-99993001-TH03Z_v51.zigbee -------------------------------------------------------------------------------- /zigbee_ota/1141-0216-99993001-TH03Z_v52.zigbee: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/zigbee_ota/1141-0216-99993001-TH03Z_v52.zigbee -------------------------------------------------------------------------------- /zigbee_ota/1141-021b-99993001-ZTH01S1_v51.zigbee: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/zigbee_ota/1141-021b-99993001-ZTH01S1_v51.zigbee -------------------------------------------------------------------------------- /zigbee_ota/1141-021b-99993001-ZTH01S1_v52.zigbee: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/zigbee_ota/1141-021b-99993001-ZTH01S1_v52.zigbee -------------------------------------------------------------------------------- /zigbee_ota/1141-021b-99993001-ZTH01S2_v51.zigbee: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/zigbee_ota/1141-021b-99993001-ZTH01S2_v51.zigbee -------------------------------------------------------------------------------- /zigbee_ota/1141-021b-99993001-ZTH01S2_v52.zigbee: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/zigbee_ota/1141-021b-99993001-ZTH01S2_v52.zigbee -------------------------------------------------------------------------------- /zigbee_ota/1141-021b-99993001-ZTH01_v51.zigbee: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/zigbee_ota/1141-021b-99993001-ZTH01_v51.zigbee -------------------------------------------------------------------------------- /zigbee_ota/1141-021b-99993001-ZTH01_v52.zigbee: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/zigbee_ota/1141-021b-99993001-ZTH01_v52.zigbee -------------------------------------------------------------------------------- /zigbee_ota/1141-021c-99993001-ZTH02_v51.zigbee: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/zigbee_ota/1141-021c-99993001-ZTH02_v51.zigbee -------------------------------------------------------------------------------- /zigbee_ota/1141-021c-99993001-ZTH02_v52.zigbee: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/zigbee_ota/1141-021c-99993001-ZTH02_v52.zigbee -------------------------------------------------------------------------------- /zigbee_ota/1141-021d-99993001-PLM1_v52.zigbee: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/zigbee_ota/1141-021d-99993001-PLM1_v52.zigbee -------------------------------------------------------------------------------- /zigbee_ota/1141-021d-99993001-TB_PLM_v52.zigbee: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/zigbee_ota/1141-021d-99993001-TB_PLM_v52.zigbee -------------------------------------------------------------------------------- /zigbee_ota/1141-021e-99993001-TH03_v51.zigbee: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/zigbee_ota/1141-021e-99993001-TH03_v51.zigbee -------------------------------------------------------------------------------- /zigbee_ota/1141-021e-99993001-TH03_v52.zigbee: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/zigbee_ota/1141-021e-99993001-TH03_v52.zigbee -------------------------------------------------------------------------------- /zigbee_ota/1141-021f-99993001-LKTMZL02_v51.zigbee: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/zigbee_ota/1141-021f-99993001-LKTMZL02_v51.zigbee -------------------------------------------------------------------------------- /zigbee_ota/1141-021f-99993001-LKTMZL02_v52.zigbee: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/zigbee_ota/1141-021f-99993001-LKTMZL02_v52.zigbee -------------------------------------------------------------------------------- /zigbee_ota/1141-0221-99993001-ZTH05_v51.zigbee: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/zigbee_ota/1141-0221-99993001-ZTH05_v51.zigbee -------------------------------------------------------------------------------- /zigbee_ota/1141-0221-99993001-ZTH05_v52.zigbee: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/zigbee_ota/1141-0221-99993001-ZTH05_v52.zigbee -------------------------------------------------------------------------------- /zigbee_ota/1141-0225-99993001-ZYZTH02S1_v51.zigbee: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/zigbee_ota/1141-0225-99993001-ZYZTH02S1_v51.zigbee -------------------------------------------------------------------------------- /zigbee_ota/1141-0225-99993001-ZYZTH02S1_v52.zigbee: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/zigbee_ota/1141-0225-99993001-ZYZTH02S1_v52.zigbee -------------------------------------------------------------------------------- /zigbee_ota/1141-0225-99993001-ZYZTH02S2_v51.zigbee: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/zigbee_ota/1141-0225-99993001-ZYZTH02S2_v51.zigbee -------------------------------------------------------------------------------- /zigbee_ota/1141-0225-99993001-ZYZTH02S2_v52.zigbee: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/zigbee_ota/1141-0225-99993001-ZYZTH02S2_v52.zigbee -------------------------------------------------------------------------------- /zigbee_ota/1141-0225-99993001-ZYZTH02_v51.zigbee: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/zigbee_ota/1141-0225-99993001-ZYZTH02_v51.zigbee -------------------------------------------------------------------------------- /zigbee_ota/1141-0225-99993001-ZYZTH02_v52.zigbee: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/zigbee_ota/1141-0225-99993001-ZYZTH02_v52.zigbee -------------------------------------------------------------------------------- /zigbee_ota/1141-0226-99993001-ZYZTH02P_v51.zigbee: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/zigbee_ota/1141-0226-99993001-ZYZTH02P_v51.zigbee -------------------------------------------------------------------------------- /zigbee_ota/1141-0226-99993001-ZYZTH02P_v52.zigbee: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/zigbee_ota/1141-0226-99993001-ZYZTH02P_v52.zigbee -------------------------------------------------------------------------------- /zigbee_ota/1141-0227-99993001-ZG227Z_v51.zigbee: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/zigbee_ota/1141-0227-99993001-ZG227Z_v51.zigbee -------------------------------------------------------------------------------- /zigbee_ota/1141-0227-99993001-ZG227Z_v52.zigbee: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/zigbee_ota/1141-0227-99993001-ZG227Z_v52.zigbee -------------------------------------------------------------------------------- /zigbee_ota/1141-d3a3-01983001-LKTMZL02BLE_v51.zigbee: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/zigbee_ota/1141-d3a3-01983001-LKTMZL02BLE_v51.zigbee -------------------------------------------------------------------------------- /zigbee_ota/1141-d3a3-01983001-LKTMZL02BLE_v52.zigbee: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/zigbee_ota/1141-d3a3-01983001-LKTMZL02BLE_v52.zigbee -------------------------------------------------------------------------------- /zigbee_ota/1141-d3a3-01983001-TS0201BLE_v51.zigbee: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/zigbee_ota/1141-d3a3-01983001-TS0201BLE_v51.zigbee -------------------------------------------------------------------------------- /zigbee_ota/1141-d3a3-01983001-TS0201BLE_v52.zigbee: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/zigbee_ota/1141-d3a3-01983001-TS0201BLE_v52.zigbee -------------------------------------------------------------------------------- /zigbee_ota/1286-0202-10993607-TH03BLE_v51.zigbee: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/zigbee_ota/1286-0202-10993607-TH03BLE_v51.zigbee -------------------------------------------------------------------------------- /zigbee_ota/1286-0202-10993607-TH03BLE_v52.zigbee: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/zigbee_ota/1286-0202-10993607-TH03BLE_v52.zigbee -------------------------------------------------------------------------------- /zigbee_ota/1286-0203-10983001-ZG227ZBLE_v51.zigbee: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/zigbee_ota/1286-0203-10983001-ZG227ZBLE_v51.zigbee -------------------------------------------------------------------------------- /zigbee_ota/1286-0203-10983001-ZG227ZBLE_v52.zigbee: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/zigbee_ota/1286-0203-10983001-ZG227ZBLE_v52.zigbee -------------------------------------------------------------------------------- /zigbee_ota/db15-0203-99993001-ATC_v51.zigbee: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/zigbee_ota/db15-0203-99993001-ATC_v51.zigbee -------------------------------------------------------------------------------- /zigbee_ota/db15-0203-99993001-ATC_v52.zigbee: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/ATC_MiThermometer/96d1abda5205e570190cb8f595c3044c23acbe76/zigbee_ota/db15-0203-99993001-ATC_v52.zigbee -------------------------------------------------------------------------------- /zigbee_ota/devbis2ble.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "fileVersion": 2576953345, 4 | "fileSize": 86386, 5 | "manufacturerCode": 56085, 6 | "imageType": 515, 7 | "sha512": "3ebe99a6c14d775d83f4238de596f81b65c06037a79f1a2f16cafa356cf310108fc59da0a620d7250e0c663b285a9fc9158a9e4404bb01ec13afa1e5c810bfca", 8 | "url": "https://github.com/pvvx/ATC_MiThermometer/raw/master/zigbee_ota/db15-0203-99993001-ATC_v52.zigbee" 9 | } 10 | ] -------------------------------------------------------------------------------- /zigbee_ota/lktml02_tuya2ble.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "fileVersion": 26750977, 4 | "fileSize": 80802, 5 | "manufacturerCode": 4417, 6 | "imageType": 54179, 7 | "sha512": "c14f5c1ecb8d903790b5d6cc37173a853d6f595d03f034982c81e26f75a4b25aac894f945a4aaba2460fc8f50b4226922b4cc651beaf5f5ec8f53f681ec75874", 8 | "url": "https://github.com/pvvx/ATC_MiThermometer/raw/master/zigbee_ota/1141-d3a3-01983001-LKTMZL02BLE_v52.zigbee" 9 | } 10 | ] -------------------------------------------------------------------------------- /zigbee_ota/th03_tuya2ble.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "fileVersion": 278476295, 4 | "fileSize": 80498, 5 | "manufacturerCode": 4742, 6 | "imageType": 514, 7 | "sha512": "19774dbeba42224d4b53c872bce1493a2d0a7806f85123b64ad1e5125478652f2d31806dbb90ffadca0c7782112db91c5780dcabca730187ab3a76ae380c43f0", 8 | "url": "https://github.com/pvvx/ATC_MiThermometer/raw/master/zigbee_ota/1286-0202-10993607-TH03BLE_v52.zigbee" 9 | } 10 | ] -------------------------------------------------------------------------------- /zigbee_ota/ts0201_tuya2ble.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "fileVersion": 26750977, 4 | "fileSize": 79554, 5 | "manufacturerCode": 4417, 6 | "imageType": 54179, 7 | "sha512": "beca93bd86f81bdd9c97b29d47f6c7122ff1d89b7f72986788016c9be7f17a76e583b54e2cd9536c8ab55f1c3307c63fc098c12b74f76f92539c88cfc2ed3f29", 8 | "url": "https://github.com/pvvx/ATC_MiThermometer/raw/master/zigbee_ota/1141-d3a3-01983001-TS0201BLE_v52.zigbee" 9 | } 10 | ] -------------------------------------------------------------------------------- /zigbee_ota/zg227z_tuya2ble.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "fileVersion": 278409217, 4 | "fileSize": 75554, 5 | "manufacturerCode": 4742, 6 | "imageType": 515, 7 | "sha512": "bdee86f921019e7f7e7e393493c2ff9fa9d6ea4a19cb6d67eec050ca37e2e84ecd4277aca7b589814466174f53f797bab395df2998dfac6ff2820940d8cd2888", 8 | "url": "https://github.com/pvvx/ATC_MiThermometer/raw/master/zigbee_ota/1286-0203-10983001-ZG227ZBLE_v52.zigbee" 9 | } 10 | ] -------------------------------------------------------------------------------- /zigbee_ota/zigpy_ota/add.cmd: -------------------------------------------------------------------------------- 1 | echo [] > index.json 2 | for %%a in (../bin/*.zigbee) do ( 3 | start /wait node scripts/add.js ../bin/%%a 4 | ) 5 | del *.zigbee 6 | -------------------------------------------------------------------------------- /zigbee_ota/zigpy_ota/cacerts.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIBwDCCAWagAwIBAgIJAJtrMkoTxs+WMAoGCCqGSM49BAMCMDIxCzAJBgNVBAYT 3 | Ak5MMRQwEgYDVQQKDAtQaGlsaXBzIEh1ZTENMAsGA1UEAwwEcm9vdDAgFw0xNjA4 4 | MjUwNzU5NDNaGA8yMDY4MDEwNTA3NTk0M1owMjELMAkGA1UEBhMCTkwxFDASBgNV 5 | BAoMC1BoaWxpcHMgSHVlMQ0wCwYDVQQDDARyb290MFkwEwYHKoZIzj0CAQYIKoZI 6 | zj0DAQcDQgAEENC1JOl6BxJrwCb+YK655zlM57VKFSi5OHDsmlCaF/EfTGGgU08/ 7 | JUtkCyMlHUUoYBZyzCBKXqRKkrT512evEKNjMGEwHQYDVR0OBBYEFAlkFYACVzir 8 | qTr++cWia8AKH/fOMB8GA1UdIwQYMBaAFAlkFYACVzirqTr++cWia8AKH/fOMA8G 9 | A1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgGGMAoGCCqGSM49BAMCA0gAMEUC 10 | IQDcGfyXaUl5hjr5YE8m2piXhMcDzHTNbO1RvGgz4r9IswIgFTTw/R85KyfIiW+E 11 | clwJRVSsq8EApeFREenCkRM0EIk= 12 | -----END CERTIFICATE----- 13 | -------------------------------------------------------------------------------- /zigbee_ota/zigpy_ota/cacerts/otau.meethue.com.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIBwDCCAWagAwIBAgIJAJtrMkoTxs+WMAoGCCqGSM49BAMCMDIxCzAJBgNVBAYT 3 | Ak5MMRQwEgYDVQQKDAtQaGlsaXBzIEh1ZTENMAsGA1UEAwwEcm9vdDAgFw0xNjA4 4 | MjUwNzU5NDNaGA8yMDY4MDEwNTA3NTk0M1owMjELMAkGA1UEBhMCTkwxFDASBgNV 5 | BAoMC1BoaWxpcHMgSHVlMQ0wCwYDVQQDDARyb290MFkwEwYHKoZIzj0CAQYIKoZI 6 | zj0DAQcDQgAEENC1JOl6BxJrwCb+YK655zlM57VKFSi5OHDsmlCaF/EfTGGgU08/ 7 | JUtkCyMlHUUoYBZyzCBKXqRKkrT512evEKNjMGEwHQYDVR0OBBYEFAlkFYACVzir 8 | qTr++cWia8AKH/fOMB8GA1UdIwQYMBaAFAlkFYACVzirqTr++cWia8AKH/fOMA8G 9 | A1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgGGMAoGCCqGSM49BAMCA0gAMEUC 10 | IQDcGfyXaUl5hjr5YE8m2piXhMcDzHTNbO1RvGgz4r9IswIgFTTw/R85KyfIiW+E 11 | clwJRVSsq8EApeFREenCkRM0EIk= 12 | -----END CERTIFICATE----- -------------------------------------------------------------------------------- /zigbee_ota/zigpy_ota/lib/ota.js: -------------------------------------------------------------------------------- 1 | const assert = require('assert'); 2 | const upgradeFileIdentifier = Buffer.from([0x1E, 0xF1, 0xEE, 0x0B]); 3 | 4 | function parseSubElement(buffer, position) { 5 | const tagID = buffer.readUInt16LE(position); 6 | const length = buffer.readUInt32LE(position + 2); 7 | const data = buffer.slice(position + 6, position + 6 + length); 8 | return {tagID, length, data}; 9 | } 10 | 11 | function parseImage(rawBuffer) { 12 | const start = rawBuffer.indexOf(upgradeFileIdentifier); 13 | const buffer = rawBuffer.slice(start); 14 | 15 | const header = { 16 | otaUpgradeFileIdentifier: buffer.subarray(0, 4), 17 | otaHeaderVersion: buffer.readUInt16LE(4), 18 | otaHeaderLength: buffer.readUInt16LE(6), 19 | otaHeaderFieldControl: buffer.readUInt16LE(8), 20 | manufacturerCode: buffer.readUInt16LE(10), 21 | imageType: buffer.readUInt16LE(12), 22 | fileVersion: buffer.readUInt32LE(14), 23 | zigbeeStackVersion: buffer.readUInt16LE(18), 24 | otaHeaderString: buffer.toString('utf8', 20, 52), 25 | totalImageSize: buffer.readUInt32LE(52), 26 | }; 27 | let headerPos = 56; 28 | if (header.otaHeaderFieldControl & 1) { 29 | header.securityCredentialVersion = buffer.readUInt8(headerPos); 30 | headerPos += 1; 31 | } 32 | if (header.otaHeaderFieldControl & 2) { 33 | header.upgradeFileDestination = buffer.subarray(headerPos, headerPos + 8); 34 | headerPos += 8; 35 | } 36 | if (header.otaHeaderFieldControl & 4) { 37 | header.minimumHardwareVersion = buffer.readUInt16LE(headerPos); 38 | headerPos += 2; 39 | header.maximumHardwareVersion = buffer.readUInt16LE(headerPos); 40 | headerPos += 2; 41 | } 42 | 43 | const raw = buffer.slice(0, header.totalImageSize); 44 | 45 | assert(Buffer.compare(header.otaUpgradeFileIdentifier, upgradeFileIdentifier) === 0, 'Not an OTA file'); 46 | 47 | let position = header.otaHeaderLength; 48 | const elements = []; 49 | while (position < header.totalImageSize) { 50 | const element = parseSubElement(buffer, position); 51 | elements.push(element); 52 | position += element.data.length + 6; 53 | } 54 | 55 | assert(position === header.totalImageSize, 'Size mismatch'); 56 | return {header, elements, raw}; 57 | } 58 | 59 | module.exports = { 60 | parseImage 61 | }; 62 | -------------------------------------------------------------------------------- /zigbee_ota/zigpy_ota/scripts/updateall.js: -------------------------------------------------------------------------------- 1 | const child_process = require('child_process'); 2 | const fs = require('fs'); 3 | const path = require('path'); 4 | 5 | const concatCaCerts = (folder = 'cacerts', outputFilename = 'cacerts.pem') => { 6 | const files = fs.readdirSync(folder); 7 | 8 | const caCertFiles = files.filter((file) => path.extname(file) === '.pem'); 9 | const outputFile = fs.openSync(outputFilename, 'w'); 10 | 11 | caCertFiles.forEach((caCert) => { 12 | const filePath = path.join(folder, caCert); 13 | const fileContent = fs.readFileSync(filePath, 'utf8'); 14 | fs.appendFileSync(outputFile, fileContent + '\n'); 15 | }); 16 | }; 17 | 18 | const main = async () => { 19 | concatCaCerts(); 20 | const indexJSON = JSON.parse(fs.readFileSync('index.json')); 21 | indexJSON.forEach(entry => { 22 | const result = child_process.execSync(`node ./scripts/add.js "${entry.path || entry.url}" "${entry.modelId || ''}"`, { 23 | cwd: path.dirname(__dirname) 24 | }) 25 | console.log(result.toString()) 26 | }) 27 | } 28 | 29 | return main(); 30 | -------------------------------------------------------------------------------- /zigbee_ota/zigpy_ota/update.cmd: -------------------------------------------------------------------------------- 1 | echo [] > index.json 2 | for %%a in (../1141-????-99993001-*.zigbee) do ( 3 | start /wait node scripts/add.js ../%%a 4 | ) 5 | copy /Y index.json ..\index%1.json 6 | 7 | echo [] > index.json 8 | for %%a in (../1286-0202-10993607-*.zigbee) do ( 9 | start /wait node scripts/add.js ../%%a 10 | ) 11 | copy /Y index.json ..\th03_tuya2ble.json 12 | 13 | echo [] > index.json 14 | for %%a in (../1286-0203-10983001-*.zigbee) do ( 15 | start /wait node scripts/add.js ../%%a 16 | ) 17 | copy /Y index.json ..\zg227z_tuya2ble.json 18 | 19 | echo [] > index.json 20 | for %%a in (../db15-0203-99993001-*.zigbee) do ( 21 | start /wait node scripts/add.js ../%%a 22 | ) 23 | copy /Y index.json ..\devbis2ble.json 24 | 25 | echo [] > index.json 26 | for %%a in (../1141-d3a3-01983001-LKTMZL02BLE*.zigbee) do ( 27 | start /wait node scripts/add.js ../%%a 28 | ) 29 | copy /Y index.json ..\lktml02_tuya2ble.json 30 | 31 | echo [] > index.json 32 | for %%a in (../1141-d3a3-01983001-TS0201BLE*.zigbee) do ( 33 | start /wait node scripts/add.js ../%%a 34 | ) 35 | copy /Y index.json ..\ts0201_tuya2ble.json 36 | 37 | echo [] > index.json 38 | for %%a in (../1002-0203-60993001-ZYZTH02BLE_*.zigbee) do ( 39 | start /wait node scripts/add.js ../%%a 40 | ) 41 | copy /Y index.json ..\zyzth02_tuya2ble.json 42 | 43 | echo [] > index.json 44 | for %%a in (../1002-0203-60993001-ZYZTH02PBLE_*.zigbee) do ( 45 | start /wait node scripts/add.js ../%%a 46 | ) 47 | copy /Y index.json ..\zyzth02p_tuya2ble.json 48 | 49 | del *.zigbee 50 | del index.json 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /zigbee_ota/zyzth02_tuya2ble.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "fileVersion": 1620652033, 4 | "fileSize": 77218, 5 | "manufacturerCode": 4098, 6 | "imageType": 515, 7 | "sha512": "4787ba4dab247be031b352c95ebc5e775b0a6eeec87973bad0d6911024671a5ab823aa3842c08ee3771a2a76133eb2246722c09de27b9b8254f2cfccf248af4e", 8 | "url": "https://github.com/pvvx/ATC_MiThermometer/raw/master/zigbee_ota/1002-0203-60993001-ZYZTH02BLE_v52.zigbee" 9 | } 10 | ] -------------------------------------------------------------------------------- /zigbee_ota/zyzth02p_tuya2ble.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "fileVersion": 1620652033, 4 | "fileSize": 79666, 5 | "manufacturerCode": 4098, 6 | "imageType": 515, 7 | "sha512": "faa04414afc12aa64b384dcfed5ffd681437e317686b42d30d9d302d69a7369833b1c3342f30942fa1150ce2a63b2ea742147579f22f64aa1d8d8e6053d055d1", 8 | "url": "https://github.com/pvvx/ATC_MiThermometer/raw/master/zigbee_ota/1002-0203-60993001-ZYZTH02PBLE_v52.zigbee" 9 | } 10 | ] --------------------------------------------------------------------------------