| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- package mcu_ctrl_board
- /*
- #include "mcu_ctrl_board.h"
- */
- import "C"
- import (
- "fmt"
- )
- type WorkState byte
- const (
- Idle WorkState = 0x00 // 空闲(默认)
- AppUpgrading WorkState = 0x01 // 应用程序-升级中
- TakingPhoto WorkState = 0x01 // 相机数据-拍照中
- PhotoUploading WorkState = 0x10 // 相机数据-上传中
- ParsingEnvData WorkState = 0x01 // 环境数据-收集中
- EnvDataUploading WorkState = 0x10 // 环境数据-上传中
- )
- // 打开与MCU控制板的串口通讯
- func mcuCtrlBoard_ComInit() (int, error) {
- ret := int(C.MCBComInit())
- if ret != 0 {
- return ret, fmt.Errorf("an error occurred while calling the C.MCBComInit function(%d)", ret)
- }
- return 0, nil
- }
- // 关闭与MCU控制板的串口通讯
- func mcuCtrlBoard_ComExit() error {
- ret := int(C.MCBComExit())
- if ret != 0 {
- return fmt.Errorf("an error occurred while calling the C.MCBComExit function(%d)", ret)
- }
- return nil
- }
- // 配置单片机控制板-运行参数
- func mcuCtrlBoard_ConfParameters(version uint32, ctrl_mode uint8, light_duration uint8, start_hour uint8, end_hour uint8, tp_intvl_min uint16) {
- C.MCBConfParameters(C.uint32_t(version), C.uint8_t(ctrl_mode), C.uint8_t(light_duration), C.uint8_t(start_hour), C.uint8_t(end_hour), C.uint16_t(tp_intvl_min))
- }
- // 设置工作状态位图-固件运维
- func MCBSetMNTStateBit(state WorkState) error {
- ret := int(C.MCBSetMNTStateBit(C.uint8_t(state)))
- if ret != 0 {
- return fmt.Errorf("an error occurred while calling the C.MCBSetMNTState function(%d)", ret)
- }
- return nil
- }
- // 设置工作状态位图-相机拍照
- func MCBSetCamStateBit(state WorkState) error {
- ret := int(C.MCBSetCamStateBit(C.uint8_t(state)))
- if ret != 0 {
- return fmt.Errorf("an error occurred while calling the C.MCBSetCamState function(%d)", ret)
- }
- return nil
- }
- // 设置工作状态位图-环境数据
- func MCBSetEnvStateBit(state WorkState) error {
- ret := int(C.MCBSetEnvStateBit(C.uint8_t(state)))
- if ret != 0 {
- return fmt.Errorf("an error occurred while calling the C.MCBSetEnvState function(%d)", ret)
- }
- return nil
- }
- // 请求获取当前实时-环境数据
- func MCBReqEnvCurData() error {
- ret := int(C.MCBReqEnvCurData())
- if ret != 0 {
- return fmt.Errorf("an error occurred while calling the C.MCBReqEnvCurData function(%d)", ret)
- }
- return nil
- }
|