// Author: NiuJiuRu
// Email: niujiuru@qq.com

package air530z

import (
	"time"

	"hnyfkj.com.cn/rtu/linux/baseapp"
)

const MODULE_NAME = "Air530Z"

func ModuleInit() {
	var err error
	var ret int
	for range 5 {
		if baseapp.IsExit1() {
			return
		}
		ret, err = air530Z_ComInit()
		if ret == -1 {
			time.Sleep(1 * time.Second)
			continue
		} else {
			break
		}
	}
	if err != nil {
		baseapp.Logger.Errorf("[%s] 错误: %v!!", MODULE_NAME, err)
	}
}

func ModuleInit2() error {
	var err error
	var ret int
	for range 5 {
		if baseapp.IsExit1() {
			return nil
		}
		ret, err = air530Z_ComInit()
		if ret == -1 {
			time.Sleep(1 * time.Second)
			continue
		} else {
			break
		}
	}
	return err
}

func ModuleExit() {
	air530Z_ComExit()
}

func Get2DPosition() (lat string, lon string, err error) {
	return air530Z_Get2DPosition()
}
