5.3综合案例-阿里云控制一次性塑封模块

本文详细介绍了如何使用阿里云物模型与一次性塑封模块进行RS485通信,包括数据帧格式、通信测试、数据上传至阿里云以及设备更换绑定产品的步骤。通过HAAS开发板,实现了从设备读取入口传感器状态并上传至云端,同时展示了如何通过云端控制设备出票。此外,还涵盖了设备动态注册、网络连接、OTA升级和物联网平台的交互过程。
摘要由CSDN通过智能技术生成

1、了解一次性塑封模块

  • 这个模块用来发送一次性塑料袋,内部已有封装的程序,需要通过RS485串口进行交互。

1、物理接口

  • 电源
    在这里插入图片描述

  • RS485
    在这里插入图片描述

2、通讯交互方式

SQ800-01出票模块采用交互采用一问一答方式,即所有通讯的发起方为上位机指令,设备只响应上层指令,动作或返回数据。
每台设备有自己的通讯地址,一对多通讯时,需要通过该地址选择要通讯的设备。当选择为无效地址时设备不应答,无返回。
1.3数据帧
上位机与设备之间采用字符帧方式传输。当上位机与设备通信时,所有数据必须以规定的数据的帧格式方式进行通讯,否者设备不应答,无返回。

3、数据帧格式

  • 数据帧分为发送数据帧和返还数据帧。发送数据帧:由上位机端下发数据到设备端;返回数据帧:由设备端上传数据到上位机端。

在这里插入图片描述

  • 数据帧格式说明
    在这里插入图片描述
    在这里插入图片描述
  • 本案例测试的入口传感器状态及出票命令格式如下
    • 例子:读入口传感器状态
      0x1F 0x0F addr 0x01 0x01 0x00 crc_h crc_l
    • 例子:返回入口传感器状态(无纸状态)
      0x1F 0x0F addr 0x01 0x01 0x01 0x01 crc_h crc_l
    • 例子:出4寸长的票命令
      0x1F 0x0F addr 0x04 0x01 0x01 0x04 crc_h crc_l

2、通信测试

使用电脑串口工具尝试通信
电脑USB直接连接模块

 - 例子:出4寸长的票命令
	0x1F 0x0F addr 0x04 0x01 0x01 0x04 crc_h crc_l
 - 地址0x00,
 - 检验码需要根据前7位计算,结果是 0xE0 0xF0
发送数据如下
1F 0F 00 04 01 01 04 E0 F0
  • 打开串口工具,16进制输出与显示,发送数据通信成功。模块电机转动,并返回数值,如下图。
    在这里插入图片描述

3、数据上传阿里云

案例说明:开机启动时,将模块的入口状态数据反馈到阿里云,如下图
在这里插入图片描述

1、入口传感器状态数据通信

	  例子:读入口传感器状态  
		0x1F 0x0F addr 0x01 0x01 0x00 crc_h crc_l
 	对应数据
 1F 0F 00 01 01 00 AC A1

发送结果如下,会收到模块返还数据,第7个数据 00 就是当前入口的状态
在这里插入图片描述

2、通过haas开发板上传数据

  1. 开发板TTL连接电脑,开发板RS485串口与模块连接

  2. 将数据上传阿里云需要配置阿里云信息,将productKey,productSecret填入程序对应位置

    具体可以参考文章haas506开发教程-高级组件库-linksdk

  3. 添加物模型,用来显示上传阿里云的入口传感器数值
    在这里插入图片描述
    功能定义–编辑草稿
    在这里插入图片描述
    添加自定义功能:属性、功能名称、标识符、数据类型、数据长度、读写类型
    在这里插入图片描述
    编辑完成,发布上线
    在这里插入图片描述

  4. 添加设备
    在产品下,添加一个设备:选择产品名、填写DeviceName(自定义,最好将设备的IMEI作为该名称)
    在这里插入图片描述

  5. 注意更改productKey,productSecret,标识符(代码168、169、242行)
    mian.py

# -*- coding: UTF-8 -*-
import network
import ujson
import utime as time
import modem
from  linksdk import Device
import ota
from driver import KV
import sntp
from driver import GPIO
from driver import UART


# ota 消息推送的接受函数
def on_trigger(data):
    global info
    # 保存服务端推送的ota信息
    info['url'] = data['url']
    info['length'] = data['length']
    info['module_name'] = data['module_name']
    info['version'] = data['version']
    info['hash'] = data['hash']
    info['hash_type'] = data['hash_type']
    # 开始ota 包下载
    dl_data = {}
    dl_data['url'] = info['url']
    dl_data['store_path'] = info['store_path']
    ota.download(dl_data)

# ota 升级包下载结果回调函数
def on_download(data):
    global info
    if data >= 0:
        print('Ota download succeed')
    # 开始ota包校验
        param = {}
        param['length'] = info['length']
        param['store_path'] = info['store_path']
        param['hash_type'] = info['hash_type']
        param['hash'] = info['hash']
        ota.verify(param)

# ota 升级包校验结果回调函数
def on_verify(data):
    global info
    print(data)
    if data >= 0 :
        print('Ota verify succeed')
        print('Start Upgrade')
    # 开始ota升级
        param = {}
        param['length'] = info['length']
        param['store_path'] = info['store_path']
        param['install_path'] = info['install_path']
        ota.upgrade(param)

# ota 升级包结果回调函数
def on_upgrade(data):
    if data >= 0 :
        print('Ota succeed')
        #ota升完级后 重启设备
        reboot()

#当iot设备连接到物联网平台的时候触发'connect' 事件
def on_connect(data):
    global module_name,default_ver,productKey,deviceName,deviceSecret,on_trigger,on_download,on_verify,on_upgrade
    print('***** connect lp succeed****')
    data_handle = {}
    data_handle['device_handle'] = data['handle']

# 初始化ota服务
    ota.init(data_handle)

# ota 回调函数注册
    ota.on(1,on_trigger)
    ota.on(2,on_download)
    ota.on(3,on_verify)
    ota.on(4,on_upgrade)
    report_info = {
        "device_handle": data['handle'] ,
        "product_key": productKey ,
        "device_name": deviceName ,
        "module_name": module_name ,
        "version": default_ver
        }
# 上报本机ota相关信息,上报版本信息返回以后程序返回,知道后台推送ota升级包,才会调用on_trigger函数
    ota.report(report_info)


#当连接断开时,触发'disconnect'事件
def on_disconnect():
    print('linkkit is disconnected')

#当iot云端下发属性设置时,触发'props'事件
def on_props(request):
    print('clound req data is {}'.format(request))

#当iot云端调用设备service时,触发'service'事件
def on_service(id,request):
    print('clound req id  is {} , req is {}'.format(id,request))
#当设备跟iot平台通信过程中遇到错误时,触发'error'事件
def on_error(err):
    print('err msg is {} '.format(err))

#网络连接的回调函数
def on_4g_cb(args):
    global g_connect_status
    pdp = args[0]
    netwk_sta = args[1]
    if netwk_sta == 1:
        g_connect_status = True
    else:
        g_connect_status = False

#网络连接
def connect_network():
    global net,on_4g_cb,g_connect_status
    #NetWorkClient该类是一个单例类,实现网络管理相关的功能,包括初始化,联网,状态信息等.
    net = network.NetWorkClient()
    g_register_network = False
    if net._stagecode is not None and net._stagecode == 3 and net._subcode == 1:
        g_register_network = True
    else:
        g_register_network = False
    if g_register_network:
    #注册网络连接的回调函数on(self,id,func);  1代表连接,func 回调函数  ;return 0 成功
        net.on(1,on_4g_cb)
        net.connect(None)
    else:
        print('网络注册失败')
    while True:
        if g_connect_status:
            print('网络连接成功')
            break
        time.sleep_ms(20)

#动态注册回调函数
def on_dynreg_cb(data):
    global deviceSecret,device_dyn_resigter_succed
    deviceSecret = data
    device_dyn_resigter_succed = True

# 连接物联网平台
def dyn_register_device(productKey,productSecret,deviceName):
    global on_dynreg_cb,device,deviceSecret
    kv = KV()
    key = '_amp_customer_devicesecret'
    deviceSecretdict = kv.getStorageSync(key)
    if deviceSecretdict is not None:
        deviceSecret = deviceSecretdict[key]

    if deviceSecretdict is None or deviceSecret is None:
        key_info = {
            'productKey': productKey  ,
            'productSecret': productSecret ,
            'deviceName': deviceName
        }
        # 动态注册一个设备,获取设备的deviceSecret
        device.register(key_info,on_dynreg_cb)

if __name__ == '__main__':
    ICCID=None
    g_connect_status = False
    net = None
    device = None
    deviceSecret = None
    deviceName = None
    productKey = "a1aNr1wef2c"
    productSecret = "Jppqfgx4tHeZh1Zi"
    device_dyn_resigter_succed = False
    # 定义需要升级的模块和版本号
    module_name = 'default'
    default_ver = '1.0.0'
    
# 定义升级包的下载和安装路径,其中url,hash_type和hash 会通过服务端推送被保存下来

    info = {
        'url': '',
        'store_path': '/data/pyamp/app.zip',
        'install_path': '/data/pyamp/',
        'length': 0,
        'hash_type': '',
        'hash': ''
    }

    # 连接网络
    connect_network()
    #sntp 校时

    sntp.settime()
     # 获取设备的IMEI 作为deviceName 进行动态注册
    deviceName = modem.getDevImei()
    #获取设备的ICCID
    ICCID=modem.sim.getIccid()
    #初始化物联网平台Device类,获取device实例
    device = Device()
    if deviceName is not None and len(deviceName) > 0 :
     #动态注册一个设备
        dyn_register_device(productKey,productSecret,deviceName)
    else:
        print("获取设备IMEI失败,无法进行动态注册")
    while deviceSecret is None:
        time.sleep(0.2)
    print('动态注册成功:' + deviceSecret)

    key_info = {
        'region' : 'cn-shanghai' ,
        'productKey': productKey ,
        'deviceName': deviceName ,
        'deviceSecret': deviceSecret ,
        'keepaliveSec': 60,
        }
    #打印设备信息
    print(key_info)

    #device.ON_CONNECT 是事件,on_connect是事件处理函数/回调函数
    device.on(device.ON_CONNECT,on_connect)
    device.on(device.ON_DISCONNECT,on_disconnect)
    device.on(device.ON_PROPS,on_props)
    device.on(device.ON_SERVICE,on_service)
    device.on(device.ON_ERROR,on_error)
    device.connect(key_info)

    global flag1
    flag1=1
    uart2=UART()
    uart2.open("serial3")
    #创建一个readBuf字节数组,用于存放串口读取到的数据
    readBuf2=bytearray(9)
    writeBuf2=bytearray(9)
    #串口读
    readSize2=uart2.read(readBuf2)
    #发送命令给模块  
    writeBuf2 = bytearray([0X1F,0X0F,0X00,0X01,0X01,0X00,0XAC,0XA1])
    uart2.write(writeBuf2)
    time.sleep(1)
    #获取模块返回数值  
    readSize2=uart2.read(readBuf2) 
    print(readBuf2)
    #将数据上传阿里云
    readBuf2_data={}
    readBuf2_data["input"]=str(readBuf2[6])
    readBuf2_data_str=ujson.dumps(readBuf2_data)
    data0={
        'param':readBuf2_data_str
        }
    device.postProps(data0)
  1. board.json文件中serial3中的波特率位9600。

    board.json

{
  "name": "haas506",
 "version": "1.0.0",
 "io": {
   "serial1":{
     "type":"UART",
     "port":0,
     "dataWidth":8,
     "baudRate":115200,
     "stopBits":1,
     "flowControl":"disable",
     "parity":"none"
   },
   "serial2":{
     "type":"UART",
     "port":1,
     "dataWidth":8,
     "baudRate":115200,
     "stopBits":1,
     "flowControl":"disable",
     "parity":"none"
   },
   "serial3":{
     "type":"UART",
     "port":2,
     "dataWidth":8,
     "baudRate":9600,
     "stopBits":1,
     "flowControl":"disable",
     "parity":"none"
   },
   "KEY1": {
    "type": "GPIO",
    "port": 44,
    "dir": "irq",
    "pull": "pullup",
    "intMode": "falling"
    }
 },
 "debugLevel": "ERROR"
 }
 
  1. 阿里云平台配置完成,程序烧录后运行程序。查看物模型,结果如下

在这里插入图片描述

  1. 串口输出如下
    在这里插入图片描述

4、阿里云控制出票

1、添加可读写物模型

添加出票开关及出票信息两个物模型,设置两个不同标识符(上传阿里云需要对应标识符)
在这里插入图片描述
发布上线
在这里插入图片描述

2、设置云端开关

  1. 添加开关的回调函数,并将开关当前状态上传阿里云(代码第14行)
  2. 更改’props’事件,实现云端控制(代码第154行)
    main.py
# -*- coding: UTF-8 -*-
import network
import ujson
import utime as time
import modem
from  linksdk import Device
import ota
from driver import KV
import sntp
from driver import GPIO
from driver import UART

#中断回调函数
def key1_callback(args):
    global flag1
    global readBuf
    global readBuf_data
    global readkey_data
    if flag1==1:
        keyValue['switch']=1
        keyValue_str=ujson.dumps(keyValue)
        data1={
            'param':keyValue_str
        }
        time.sleep_ms(1000)
        device.postProps(data1)   
        flag1=2     

        #发送指令
        # 
        uart2.write(writeBuf)
        #串口读
        time.sleep(4)
        readSize = uart2.read(readBuf) 
        print(readBuf)
        readBuf_data={}
        readBuf_data["command"]=str(readBuf[6])
        readBuf_data_str=ujson.dumps(readBuf_data)
        data1={
            'param':readBuf_data_str
            }
        time.sleep(1)
        device.postProps(data1)
        # 读取发回来的值
        # 
        #    
        readkey = key1.read()
        print("level of readkey:",readkey)
        print("type of readkey:",type(readkey))
        readkey_data={}
        readkey_data["switch"]= readkey
        readkey_data_str=ujson.dumps(readkey_data)
        data2={
            'param':readkey_data_str
            }  
        time.sleep(1)      
        device.postProps(data2)



    elif flag1==2:
        keyValue['switch']=0
        keyValue_str=ujson.dumps(keyValue)
        data2={
            'param':keyValue_str
        }
        time.sleep_ms(1000)
        device.postProps(data2)         
        flag1=1  
    print("keyValue:",keyValue)    
    key1.disableIrq()
    key1.clearIrq()

# ota 消息推送的接受函数
def on_trigger(data):
    global info
    # 保存服务端推送的ota信息
    info['url'] = data['url']
    info['length'] = data['length']
    info['module_name'] = data['module_name']
    info['version'] = data['version']
    info['hash'] = data['hash']
    info['hash_type'] = data['hash_type']
    # 开始ota 包下载
    dl_data = {}
    dl_data['url'] = info['url']
    dl_data['store_path'] = info['store_path']
    ota.download(dl_data)

# ota 升级包下载结果回调函数
def on_download(data):
    global info
    if data >= 0:
        print('Ota download succeed')
    # 开始ota包校验
        param = {}
        param['length'] = info['length']
        param['store_path'] = info['store_path']
        param['hash_type'] = info['hash_type']
        param['hash'] = info['hash']
        ota.verify(param)

# ota 升级包校验结果回调函数
def on_verify(data):
    global info
    print(data)
    if data >= 0 :
        print('Ota verify succeed')
        print('Start Upgrade')
    # 开始ota升级
        param = {}
        param['length'] = info['length']
        param['store_path'] = info['store_path']
        param['install_path'] = info['install_path']
        ota.upgrade(param)

# ota 升级包结果回调函数
def on_upgrade(data):
    if data >= 0 :
        print('Ota succeed')
        #ota升完级后 重启设备
        reboot()

#当iot设备连接到物联网平台的时候触发'connect' 事件
def on_connect(data):
    global module_name,default_ver,productKey,deviceName,deviceSecret,on_trigger,on_download,on_verify,on_upgrade
    print('***** connect lp succeed****')
    data_handle = {}
    data_handle['device_handle'] = data['handle']

# 初始化ota服务
    ota.init(data_handle)

# ota 回调函数注册
    ota.on(1,on_trigger)
    ota.on(2,on_download)
    ota.on(3,on_verify)
    ota.on(4,on_upgrade)
    report_info = {
        "device_handle": data['handle'] ,
        "product_key": productKey ,
        "device_name": deviceName ,
        "module_name": module_name ,
        "version": default_ver
        }
# 上报本机ota相关信息,上报版本信息返回以后程序返回,知道后台推送ota升级包,才会调用on_trigger函数
    ota.report(report_info)


#当连接断开时,触发'disconnect'事件
def on_disconnect():
    print('linkkit is disconnected')

#当iot云端下发属性设置时,触发'props'事件
def on_props(request):
    global readkey_data
    print('clound req data is {}'.format(request))
    params=request['params']
    params=eval(params)
    switch=params["switch"]
    if switch==0:
        #这里执行关的操作
        readkey = key1.read()
        print("level of readkey:",readkey)
        print("type of readkey:",type(readkey))
        readkey_data={}
        readkey_data["switch"]= readkey
        readkey_data_str=ujson.dumps(readkey_data)
        data2={
            'param':readkey_data_str
            }  
        time.sleep(1)      
        device.postProps(data2)


    elif switch==1:
        #开的操作
        #发送指令
        # 
        uart2.write(writeBuf)
        #串口读
        time.sleep(4)
        readSize = uart2.read(readBuf) 
        print(readBuf)
        readBuf_data={}
        readBuf_data["command"]=str(readBuf[6])
        readBuf_data_str=ujson.dumps(readBuf_data)
        data1={
            'param':readBuf_data_str
            }
        time.sleep(1)
        device.postProps(data1)
        # 读取发回来的值
        # 
        #    
        readkey = key1.read()
        print("level of readkey:",readkey)
        print("type of readkey:",type(readkey))
        readkey_data={}
        readkey_data["switch"]= readkey
        readkey_data_str=ujson.dumps(readkey_data)
        data2={
            'param':readkey_data_str
            }  
        time.sleep(1)      
        device.postProps(data2)



#当iot云端调用设备service时,触发'service'事件
def on_service(id,request):
    print('clound req id  is {} , req is {}'.format(id,request))
#当设备跟iot平台通信过程中遇到错误时,触发'error'事件
def on_error(err):
    print('err msg is {} '.format(err))

#网络连接的回调函数
def on_4g_cb(args):
    global g_connect_status
    pdp = args[0]
    netwk_sta = args[1]
    if netwk_sta == 1:
        g_connect_status = True
    else:
        g_connect_status = False

#网络连接
def connect_network():
    global net,on_4g_cb,g_connect_status
    #NetWorkClient该类是一个单例类,实现网络管理相关的功能,包括初始化,联网,状态信息等.
    net = network.NetWorkClient()
    g_register_network = False
    if net._stagecode is not None and net._stagecode == 3 and net._subcode == 1:
        g_register_network = True
    else:
        g_register_network = False
    if g_register_network:
    #注册网络连接的回调函数on(self,id,func);  1代表连接,func 回调函数  ;return 0 成功
        net.on(1,on_4g_cb)
        net.connect(None)
    else:
        print('网络注册失败')
    while True:
        if g_connect_status:
            print('网络连接成功')
            break
        time.sleep_ms(20)

#动态注册回调函数
def on_dynreg_cb(data):
    global deviceSecret,device_dyn_resigter_succed
    deviceSecret = data
    device_dyn_resigter_succed = True

# 连接物联网平台
def dyn_register_device(productKey,productSecret,deviceName):
    global on_dynreg_cb,device,deviceSecret
    kv = KV()
    key = '_amp_customer_devicesecret'
    deviceSecretdict = kv.getStorageSync(key)
    if deviceSecretdict is not None:
        deviceSecret = deviceSecretdict[key]

    if deviceSecretdict is None or deviceSecret is None:
        key_info = {
            'productKey': productKey  ,
            'productSecret': productSecret ,
            'deviceName': deviceName
        }
        # 动态注册一个设备,获取设备的deviceSecret
        device.register(key_info,on_dynreg_cb)

if __name__ == '__main__':
    ICCID=None
    g_connect_status = False
    net = None
    device = None
    deviceSecret = None
    deviceName = None
    productKey = "a1aNr1wef2c"
    productSecret = "Jppqfgx4tHeZh1Zi"
    device_dyn_resigter_succed = False
    # 定义需要升级的模块和版本号
    module_name = 'default'
    default_ver = '1.0.0'
    
# 定义升级包的下载和安装路径,其中url,hash_type和hash 会通过服务端推送被保存下来

    info = {
        'url': '',
        'store_path': '/data/pyamp/app.zip',
        'install_path': '/data/pyamp/',
        'length': 0,
        'hash_type': '',
        'hash': ''
    }

    # 连接网络
    connect_network()
    #sntp 校时

    sntp.settime()
     # 获取设备的IMEI 作为deviceName 进行动态注册
    deviceName = modem.getDevImei()
    #获取设备的ICCID
    ICCID=modem.sim.getIccid()
    #初始化物联网平台Device类,获取device实例
    device = Device()
    if deviceName is not None and len(deviceName) > 0 :
     #动态注册一个设备
        dyn_register_device(productKey,productSecret,deviceName)
    else:
        print("获取设备IMEI失败,无法进行动态注册")
    while deviceSecret is None:
        time.sleep(0.2)
    print('动态注册成功:' + deviceSecret)

    key_info = {
        'region' : 'cn-shanghai' ,
        'productKey': productKey ,
        'deviceName': deviceName ,
        'deviceSecret': deviceSecret ,
        'keepaliveSec': 60,
        }
    #打印设备信息
    print(key_info)

    #device.ON_CONNECT 是事件,on_connect是事件处理函数/回调函数
    device.on(device.ON_CONNECT,on_connect)
    device.on(device.ON_DISCONNECT,on_disconnect)
    device.on(device.ON_PROPS,on_props)
    device.on(device.ON_SERVICE,on_service)
    device.on(device.ON_ERROR,on_error)
    device.connect(key_info)

    global flag1
    flag1=1
    uart2=UART()
    uart2.open("serial3")
    #创建一个readBuf字节数组,用于存放串口读取到的数据
    readBuf=bytearray(9)
    readBuf2=bytearray(9)
    writeBuf=bytearray(9)
    writeBuf2=bytearray(9)
    #串口读
    readSize2=uart2.read(readBuf2)
    writeBuf = bytearray([0x1F,0x0F,0x00,0x04,0x01,0x01,0x04,0xE0,0xF0])
    writeBuf2 = bytearray([0X1F,0X0F,0X00,0X01,0X01,0X00,0XAC,0XA1])
    uart2.write(writeBuf2)
    time.sleep(1)
    readSize2=uart2.read(readBuf2) 
    print(readBuf2)
    readBuf2_data={}
    readBuf2_data["input"]=str(readBuf2[6])
    readBuf2_data_str=ujson.dumps(readBuf2_data)
    data0={
        'param':readBuf2_data_str
        }
    device.postProps(data0)


    #实例化key1
    key1=GPIO(10,10)
    #打开key1
    key1.open("key1")
    keyValue={}
    # keyValue["switch"]=key1.read()
    # #将字典转换为字符串
    # keyValue_str=ujson.dumps(keyValue)
    # data1={
    #     'param':keyValue_str
    # }
    # #1S上报一次
    # time.sleep_ms(1000)
    # device.postProps(data1)
    #打开按键使能
    while True:
        time.sleep(1)
        key1.enableIrq(key1_callback)


board.json


{
    "name": "haas506",
    "version": "1.0.0",
    "io": {
        "key1": {
            "type": "GPIO",
            "port": 44,
            "dir": "irq",
            "pull": "pullup",
            "intMode":"falling"
            },   
      "serial1":{
        "type":"UART",
        "port":0,
        "dataWidth":8,
        "baudRate":115200,
        "stopBits":1,
        "flowControl":"disable",
        "parity":"none"
      },
      "serial2":{
        "type":"UART",
        "port":1,
        "dataWidth":8,
        "baudRate":115200,
        "stopBits":1,
        "flowControl":"disable",
        "parity":"none"
      },
      "serial3":{
        "type":"UART",
        "port":2,
        "dataWidth":8,
        "baudRate":9600,
        "stopBits":1,
        "flowControl":"disable",
        "parity":"none"
      }
    },
    "debugLevel": "ERROR"
  }
  1. 在线调试控制出票

在线调试–更改出单开关参数–点击设置。开-1可以控制模块电机转动,在产品物模型中数据也会相应改变。
在这里插入图片描述

5.关于设备更换绑定产品

操作说明:

  1. 一型一密认证后,同一产品下所有设备会烧录相同的设备标志信息,即所有设备包含相同的产品证书(ProductKey和ProductSecret)。设备内会保存该设备对应的DeviceSecret,也就是说同一产品下不同设备ProductKey和ProductSecret相同,DeviceSecret不同。
  2. 这种情况下,一个设备要换到另一个产品下,需要对阿里云平台和设备分别进行操作。

1、产品删除绑定设备

1、产品下找到对应设备删除

在这里插入图片描述

2、删除设备中的DeviceSecret

1、连接好设备打开串口工具与设备进行交互,删除储存在设备里储存的DeviceSecret。操作如下
from driver import KV
kv=KV()
#查看对应键值对
kv.getStorageSync('_amp_customer_devicesecret')
#删除对应键值对
kv.removeStorageSync('_amp_customer_devicesecret')
2、指令前不要加空格,当删除后返回数值0,就说明删除成功。

在这里插入图片描述
完成这两步设备就可以添加到其他产品下了。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值