CAT1_SERVICE_HEAD = 'FE' #固定head
PROJECT_NAME = "Cat1SlipUDPService"
-PROJECT_VERSION = "PY_SRV_V30"
+PROJECT_VERSION = "PY_SRV_V31"
CONFIG_JSON="/usr/system_config.json"
CURRENT_APP_TYPE="pysrv"
-
+ENABLE_CTS_RTS_PIN = 1
#设置通话音量
# level - 引脚电平,int类型,0 - 设置引脚为低电平, 1- 设置引脚为高电平。
# recvDataPin = Pin(Pin.GPIO53, Pin.IN, Pin.PULL_PU, 0)
+# G_gpioCTS = Pin(Pin.GPIO30, Pin.OUT, Pin.PULL_DISABLE, 1)
+# cts = G_gpioCTS.read()
+
+# G_gpioRTS = Pin(Pin.GPIO31, Pin.OUT, Pin.PULL_DISABLE, 1)
+# rts = G_gpioRTS.read()
+# # clog.error('slip ',G_gpioCTS)
+# clog.info('### slip cts {} rts {}'.format(cts,rts)) # args[0]:gpio号 args[1]:上升沿或下降沿
+# if cts==1 and rts==1:
+# ENABLE_CTS_RTS_PIN=1
+# elif cts & rts ==0:
+# ENABLE_CTS_RTS_PIN=0
+G_gpioCTS = Pin(Pin.GPIO3, Pin.IN, Pin.PULL_PD, 1)
+flow_ctr = G_gpioCTS.read()
+clog.info('###************************************************************* slip flow_ctr{}'.format(flow_ctr)) # args[0]:gpio号 args[1]:上升沿或下降沿
+if flow_ctr==1:
+ ENABLE_CTS_RTS_PIN=0
+G_gpioCTS = Pin(Pin.GPIO3, Pin.IN, Pin.PULL_DISABLE, 1)
+
+
+
+
def ExtIntfun(args):
# clog.info('### interrupt {} ###'.format(args)) # args[0]:gpio号 args[1]:上升沿或下降沿
if args[1] == 0:
pm.wakelock_unlock(lpm_fd)
# pm.autosleep(1)
# clog.info("recvDataPin={}".format(recvDataPin.read()))
-extint = ExtInt(ExtInt.GPIO30, ExtInt.IRQ_RISING_FALLING, ExtInt.PULL_DISABLE, ExtIntfun)
-extint.enable()
-
-
-# 创建gpio对象
-gpioWakeBT = Pin(Pin.GPIO31, Pin.OUT, Pin.PULL_DISABLE, 1)
-# 设置输入输出模式
-gpioWakeBT.set_dir(Pin.OUT)
-
-# 设置引脚电平
-gpioWakeBT.write(1)
-
+if ENABLE_CTS_RTS_PIN == 0:
+ extint = ExtInt(ExtInt.GPIO30, ExtInt.IRQ_RISING_FALLING, ExtInt.PULL_DISABLE, ExtIntfun)
+ extint.enable()
+ # 创建gpio对象
+ gpioWakeBT = Pin(Pin.GPIO31, Pin.OUT, Pin.PULL_DISABLE, 1)
+ # 设置输入输出模式
+ gpioWakeBT.set_dir(Pin.OUT)
+
+ # 设置引脚电平
+ gpioWakeBT.write(1)
+else:
+ # 创建gpio对象
+ gpioRTS = Pin(Pin.GPIO31, Pin.OUT, Pin.PULL_DISABLE, 1)
+ # 设置输入输出模式
+ gpioRTS.set_dir(Pin.OUT)
+
+ # 设置引脚电平
+ gpioRTS.write(0)
+ # 创建gpio对象
+ gpioCTS = Pin(Pin.GPIO30, Pin.OUT, Pin.PULL_DISABLE, 1)
+ # 设置输入输出模式
+ gpioCTS.set_dir(Pin.OUT)
+
+ # 设置引脚电平
+ gpioCTS.write(0)
UDP_CMD_GET_CAT1VER = '0' #获取 Cat1 版本号
UDP_CMD_DIAL_NUMB = '1' #拨打电话
UDP_CMD_HUNGUP = '2' #挂断电话
STA = 1 # SLIP_OUTER
def __init__(self, uart=UART.UART2, mode=AP):
+
self.__uart = uart
self.__mode = mode
self.__waiting_netstat = 0
slip.destroy()
clog.info('slip uart={0}'.format (self.__uart))
- ret = slip.construct(self.__uart, self.__mode,'',921600,8,0,1,0)
+ # construct parameters:
+ # 1. uart: UART对象
+ # 2. mode: SLIP模式
+ # 3. name: 名称
+ # 4. baudrate: 波特率
+ # 5. data_bits: 数据位
+ # 6. stop_bits: 停止位
+ # 7. parity: 奇偶校验
+ # 8. flow_control: 流控制
+ if ENABLE_CTS_RTS_PIN == 0:
+ ret = slip.construct(self.__uart, self.__mode,'',921600,8,0,1,0)
+ else:
+
+ ret = slip.construct(self.__uart, self.__mode,'',921600,8,0,1,1)
if ret != 0:
clog.error('slip netif construct fail')
return None
try:
##self.head = head
# self.content = content
- gpioWakeBT.write(0)
- utime.sleep_ms(2)
- gpioWakeBT.write(1)
- utime.sleep_ms(20)
+ if ENABLE_CTS_RTS_PIN == 0:
+ gpioWakeBT.write(0)
+ utime.sleep_ms(2)
+ gpioWakeBT.write(1)
+ utime.sleep_ms(20)
+ else:
+ utime.sleep_ms(20)
# 消息处理
msg = self.__pack_tlv_format(head, content)
def __Socket_UDP_noreply_write(self, head, content):
# self.head = head
# self.content = content
- gpioWakeBT.write(0)
- utime.sleep_ms(2)
- gpioWakeBT.write(1)
- utime.sleep_ms(20)
+ if ENABLE_CTS_RTS_PIN == 0:
+ gpioWakeBT.write(0)
+ utime.sleep_ms(2)
+ gpioWakeBT.write(1)
+ utime.sleep_ms(20)
+ else:
+ utime.sleep_ms(20)
# 消息处理
msg = self.__pack_tlv_format(head, content)