text: '''
  # file pub_sub_with_timer.py
  
  # brief         Set 'SERVER','CLIENT_ID'(this can be null),'IOT_pubTopic','IOT_UserName','IOT_PassWord'
  #               download into mpython and run the file
  #               You will send the message by seconds and receive the message from server
  # Copyright     Copyright (c) 2010 DFRobot Co.Ltd (http://www.dfrobot.com)
  # licence       The MIT License (MIT)
  # author        [LuoYufeng](yufeng.luo@dfrobot.com)
  # version       V1.0
  # date          2019-10-8
  '''
  
  from siot import iot
  from machine import Timer 
  import time
  
  SERVER = "192.168.2.107"        #MQTT服务器IP
  CLIENT_ID = ""                  #在SIoT上，CLIENT_ID可以留空
  IOT_pubTopic  = 'xzr/001'       #“topic”为“项目名称/设备名称”
  IOT_UserName ='siot'            #用户名
  IOT_PassWord ='dfrobot'         #密码
  siot = iot(CLIENT_ID, SERVER, user=IOT_UserName, password=IOT_PassWord)
  
  def WIFIconnect():
      import network
      ssid = "dfrobotYanfa"
      password =  "hidfrobot"
      station = network.WLAN(network.STA_IF)
      if station.isconnected() == True:
          print("Wifi already connected")
          return
      station.active(True)
      station.connect(ssid, password)
      while station.isconnected() == False:
          pass
      print("Connection successful")
      print(station.ifconfig())
  
  
  def sub_cb(topic, msg):
      print((topic, msg))
      
  def timer_cb(msg):
      siot.check_msg()
    
  
  WIFIconnect()
  siot.connect()
  siot.set_callback(sub_cb)
  siot.getsubscribe(IOT_pubTopic)
  
  
  timer = Timer(1)
  timer.init(period=50,mode=Timer.PERIODIC, callback=timer_cb)
  
  tick = 0
  
  try:
    while True:
      siot.publish(IOT_pubTopic, "value %d"%tick)
      time.sleep(1) 
      tick = tick+1
  except:
    siot.stop()
    timer.deinit()
    print("disconnect seccused")
  
  