尊龙凯时人生就是搏

ÉèÖÃLinuxϵͳÒÔÖ§³Ö±ßÑØÍø¹ØºÍÎïÁªÍøÍø¹Ø¿ª·¢

ÉèÖÃlinuxϵͳÒÔÖ§³Ö±ßÑØÍø¹ØºÍÎïÁªÍøÍø¹Ø¿ª·¢

ÔÚÎïÁªÍøµÄÉú³¤ÖУ¬±ßÑØÅÌËãºÍÎïÁªÍøÍø¹ØÊÎÑÝ×ÅÖÁ¹ØÖ÷ÒªµÄ½ÇÉ«¡£±ßÑØÍø¹Ø×÷ΪÊý¾Ý´«ÊäºÍ´¦ÀíµÄÖÐÐļþ£¬ÅþÁ¬×°±¸ºÍÔƶËϵͳ£¬ÎªÎïÁªÍøÌṩ¸ßЧ¡¢Çå¾²µÄͨѶЧÀÍ¡£±¾ÎĽ«ÏÈÈÝÔõÑùÉèÖÃLinuxϵͳ£¬ÒÔÖ§³Ö±ßÑØÍø¹ØºÍÎïÁªÍøÍø¹ØµÄ¿ª·¢¡£

Ò»¡¢×°ÖÃLinuxϵͳ

Ê×ÏÈ£¬ÎÒÃÇÐèÒªÔÚÄ¿µÄ×°±¸ÉÏ×°ÖÃÊʺϵÄLinux¿¯Ðаæ¡£³£¼ûµÄLinux¿¯ÐаæÓÐUbuntu¡¢Debian¡¢CentOSµÈ£¬Ñ¡ÔñÆäÖÐÒ»¿î²¢Æ¾Ö¤¹Ù·½Îĵµ¾ÙÐÐ×°Öá£

¶þ¡¢×°ÖÃÐëÒªµÄÈí¼þ°ü

ΪÁËÖ§³Ö±ßÑØÍø¹ØºÍÎïÁªÍøÍø¹Ø¿ª·¢£¬ÎÒÃÇÐèҪװÖÃһЩÐëÒªµÄÈí¼þ°ü¡£·­¿ªÖնˣ¬Ö´ÐÐÒÔÏÂÏÂÁî×°ÖÃÈí¼þ°ü£º

sudo apt-get update
sudo apt-get install make gcc git

µÇ¼ºó¸´ÖÆ

Õ⽫װÖñàÒ빤¾ßºÍ°æ±¾¿ØÖƹ¤¾ß£¬ÎªºóÐøµÄ¿ª·¢×¼±¸ÇéÐΡ£

Èý¡¢ÉèÖÃÍøÂçÅþÁ¬

±ßÑØÍø¹ØºÍÎïÁªÍøÍø¹ØÐèÒªÓë×°±¸ºÍÔƶËϵͳ¾ÙÐÐͨѶ¡£ÎªÁËʵÏÖÕâһĿµÄ£¬ÎÒÃÇÐèÒªÉèÖÃÍøÂçÅþÁ¬¡£ÒÔÌ«ÍøÊÇ×î³£¼ûµÄÅþÁ¬·½·¨£¬ÎÒÃÇ¿ÉÒÔͨ¹ýÒÔÏ°취ÉèÖÃÍøÂçÅþÁ¬£º

·­¿ªÖնˣ¬Ö´ÐÐÒÔÏÂÏÂÁî±à¼­ÍøÂçÉèÖÃÎļþ£º

sudo vim /etc/network/interfaces

µÇ¼ºó¸´ÖÆ

ÔÚÎļþÖÐÌí¼ÓÒÔÏÂÄÚÈÝ£º

auto eth0
iface eth0 inet static
    address [Íø¹ØIPµØµã]
    netmask [×ÓÍøÑÚÂë]
    gateway [Íø¹ØIPµØµã]
   dns-nameservers [DNSЧÀÍÆ÷IPµØµã]

µÇ¼ºó¸´ÖÆ

Ç뽫[Íø¹ØIPµØµã]¡¢[×ÓÍøÑÚÂë]ºÍ[DNSЧÀÍÆ÷IPµØµã]Ì滻ΪÏÖʵµÄÊýÖµ¡£

ÉúÑÄÎļþ²¢Í˳ö±à¼­Æ÷¡£

ÖØÆôÍøÂçЧÀÍ£¬Ê¹ÉèÖÃÉúЧ£º

sudo systemctl restart networking

µÇ¼ºó¸´ÖÆ

ËÄ¡¢×°ÖñßÑØÍø¹ØºÍÎïÁªÍøÍø¹ØÈí¼þ

±ßÑØÍø¹ØºÍÎïÁªÍøÍø¹ØµÄ¿ª·¢Í¨³£»ùÓÚ¿ªÔ´Èí¼þ¡£ÒÔEclipse KuraΪÀý£¬ÎÒÃǽ«ÑÝʾÔõÑù×°ÖÃKura×÷Ϊ±ßÑØÍø¹ØºÍÎïÁªÍøÍø¹ØÈí¼þ£º

·­¿ªÖնˣ¬Ö´ÐÐÒÔÏÂÏÂÁîÏÂÔØKura×°Öðü£º

wget https://github.com/eclipse/kura/releases/download/v4.3.0/kura_4.3.0_raspberry-pi-2-3.img.gz

µÇ¼ºó¸´ÖÆ

½âѹװÖðü£º

gunzip kura_4.3.0_raspberry-pi-2-3.img.gz

µÇ¼ºó¸´ÖÆ

ʹÓÃddÏÂÁ¾µÏñÎļþÉÕ¼ÖÁSD¿¨£º

sudo dd bs=4M if=kura_4.3.0_raspberry-pi-2-3.img of=/dev/sdX conv=fsync

µÇ¼ºó¸´ÖÆ

Ç뽫/sdXÌ滻ΪSD¿¨×°±¸½Úµã£¬ÀýÈç/dev/sdb¡£

ÆÚ´ýÉÕ¼Íê³É£¬²¢½«SD¿¨²åÈëÄ¿µÄ×°±¸ÖС£

Æô¶¯×°±¸²¢ÅþÁ¬ÖÁÖնˣ¬Æ¾Ö¤KuraµÄ¹Ù·½Îĵµ¾ÙÐгõʼ»¯ºÍÉèÖá£

Îå¡¢¿ª·¢±ßÑØÍø¹ØºÍÎïÁªÍøÍø¹ØÓ¦ÓÃ

Ò»µ©×°ÖÃÉèÖÃÍê³É£¬ÎÒÃÇ¿ÉÒÔ×îÏÈ¿ª·¢±ßÑØÍø¹ØºÍÎïÁªÍøÍø¹ØµÄÓ¦ÓóÌÐò¡£ÒÔ»ùÓÚCÓïÑÔµÄMQTT¿Í»§¶ËΪÀý£¬ÎÒÃǽ«ÑÝʾÔõÑùʹÓÃPaho MQTT¿â¾ÙÐпª·¢£º

·­¿ªÖնˣ¬Ö´ÐÐÒÔÏÂÏÂÁîÏÂÔØPaho MQTT¿â£º

git clone https://github.com/eclipse/paho.mqtt.c.git

µÇ¼ºó¸´ÖÆ

½øÈëÏÂÔصÄĿ¼²¢±àÒë×°Öÿ⣺

cd paho.mqtt.c
make
sudo make install

µÇ¼ºó¸´ÖÆ

½¨ÉèÒ»¸öMQTT¿Í»§¶ËÓ¦ÓóÌÐò²¢Ìí¼ÓÒÔÏ´úÂ룺

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <MQTTClient.h>

#define ADDRESS "tcp://[MQTTЧÀÍÆ÷IPµØµã]:[MQTTЧÀÍÆ÷¶Ë¿ÚºÅ]"
#define CLIENTID "ExampleClientPub"
#define TOPIC "test"
#define PAYLOAD "Hello, MQTT!"

int main(int argc, char* argv[])
{
    MQTTClient client;
    MQTTClient_connectOptions conn_opts = MQTTClient_connectOptions_initializer;
    int rc;

    MQTTClient_create(&client, ADDRESS, CLIENTID, MQTTCLIENT_PERSISTENCE_DEFAULT, NULL);
    conn_opts.keepAliveInterval = 20;
    conn_opts.cleansession = 1;

    MQTTClient_connect(client, &conn_opts);

    MQTTClient_message pubmsg = MQTTClient_message_initializer;
    MQTTClient_deliveryToken token;
    pubmsg.payload = PAYLOAD;
    pubmsg.payloadlen = strlen(PAYLOAD);
    pubmsg.qos = 0;
    pubmsg.retained = 0;
    MQTTClient_publishMessage(client, TOPIC, &pubmsg, &token);

    sleep(1);

    MQTTClient_disconnect(client, 10000);
    MQTTClient_destroy(&client);

    return rc;
}

µÇ¼ºó¸´ÖÆ

Ç뽫[MQTTЧÀÍÆ÷IPµØµã]ºÍ[MQTTЧÀÍÆ÷¶Ë¿ÚºÅ]Ì滻ΪÏÖʵµÄÊýÖµ¡£

±àÒë²¢ÔËÐÐÓ¦ÓóÌÐò£º

gcc -o mqtt_client mqtt_client.c -lpaho-mqtt3c
./mqtt_client

µÇ¼ºó¸´ÖÆ

Áù¡¢×ܽá

ͨ¹ý׼ȷÉèÖÃLinuxϵͳ£¬×°ÖÃÐëÒªµÄÈí¼þ°ü£¬ÉèÖÃÍøÂçÅþÁ¬£¬×°ÖñßÑØÍø¹ØºÍÎïÁªÍøÍø¹ØÈí¼þ£¬²¢Ê¹ÓÃÏìÓ¦µÄ¿ª·¢¹¤¾ßºÍ¿â¾ÙÐпª·¢£¬ÎÒÃÇ¿ÉÒÔÇáËɵØʵÏÖ±ßÑØÍø¹ØºÍÎïÁªÍøÍø¹ØµÄ¿ª·¢¡£Õ⽫ΪÎïÁªÍøµÄÓ¦ÓÃÌṩ¸üÇ¿Ê¢µÄÄÜÁ¦ºÍÎÞаÐÔ¡£

ÒÔÉÏÊǹØÓÚÉèÖÃlinuxϵͳÒÔÖ§³Ö±ßÑØÍø¹ØºÍÎïÁªÍøÍø¹Ø¿ª·¢µÄÎÄÕ¡£Í¨¹ýÕâЩ°ì·¨£¬ÎÒÃÇ¿ÉÒÔ×îÏȹ¹½¨Çå¾²¡¢¸ßЧµÄÎïÁªÍøÓ¦Ó㬲¢ÎªÎïÁªÍøµÄÉú³¤×ö³öТ˳¡£×£Ô¸ÄúÈ¡µÃÀֳɣ¡

ÒÔÉϾÍÊÇÉèÖÃLinuxϵͳÒÔÖ§³Ö±ßÑØÍø¹ØºÍÎïÁªÍøÍø¹Ø¿ª·¢µÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí£¬°æȨÕùÒéÓë±¾Õ¾Î޹أ¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í尊龙凯时人生就是搏ÂËÓÍ»úÍø¹Ù·½Ì¬¶È£¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ£¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢£¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢£¬ÇëÄúÁ¬Ã¦ÁªÏµ尊龙凯时人生就是搏ʵʱÐÞÕý»òɾ³ý¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ尊龙凯时人生就是搏

18523999891

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎ壬9:30-18:30£¬½ÚãåÈÕÐÝÏ¢

QR code
sitemap¡¢ÍøÕ¾µØͼ