2766| 5
|
[项目] 懒癌福利——懒得开微信 |
关于我掌控板看微信的项目————他死了好久 现在,我又来了 —————————————————————— 宅在沙发上太舒服了 然而手机响了o((>ω< ))o w(゚Д゚)w又要爬起来->走过去->开机->走回来->爬下来 多麻烦 因为作者(我)很懒 掌控板没有配备二维码功能 登入要在电脑 —————————————————————— 代码: (python电脑) import itchat import paho.mqtt.client as mqtt @itchat.msg_register(TEXT, isFriendChat=True, isGroupChat=True, isMpChat=True) def simple_reply(msg): client.publish("chat",msg['FromUserName'],2) client.publish("chat",msg['Text'],2) @itchat.msg_register([PICTURE, RECORDING, ATTACHMENT, VIDEO]) def download_files(msg): client.publish("chat","get "+msg['Type']+" "+msg['FileName'],2) itchat.auto_login() itchat.run() MQTTHOST = "ip" mqttClient = mqtt.Client() def onMqtt(): mqttClient.connect(MQTTHOST, 1883, 2) client.username_pw_set(username, password = passwd) mqttClient.loop_start() onMQtt() client.publish("chat","hello",2) (MIND-) /*! * MindPlus * mpython * */ #include <MPython.h> #include <DFRobot_Iot.h> // 函数声明 void obloqMqttEventT0(String& message); // 静态常量 const String topics[5] = {"(chat端口)","","","",""}; const MsgHandleCb msgHandles[5] = {obloqMqttEventT0,NULL,NULL,NULL,NULL}; // 创建对象 DFRobot_Iot myIot; // 主程序开始 void setup() { myIot.setMqttCallback(msgHandles); mPython.begin(); } void loop() { myIot.init("iot.dfrobot.com.cn","","","",topics,1883); myIot.connect(); } // 事件回调函数 void obloqMqttEventT0(String& message) { display.setCursorXY(0, 0); display.print(message); while (!(buttonA.isPressed())) {yield();} display.fillScreen(0); } 欢迎检查 我没有检查过 python装itchat文件和 paho-mqtt |
© 2013-2024 Comsenz Inc. Powered by Discuz! X3.4 Licensed