88 *
99 * - LED blink test;
1010 *
11- * - WIFI join and scan test;
11+ * - WIFI connect and scan test;
1212 *
13- * - LoRa Ping-Pong test(DIO0 -- GPIO26 interrup check the new incoming messages;
13+ * - LoRa Ping-Pong test (DIO0 -- GPIO26 interrup check the new incoming messages) ;
1414 *
1515 * - Timer test and some other Arduino basic functions.
1616 *
1717 * by Aaron.Lee from HelTec AutoMation, ChengDu, China
1818 * 成都惠利特自动化科技有限公司
19- * www. heltec.cn
19+ * https:// heltec.org
2020 *
2121 * this project also realess in GitHub:
2222 * https://github.com/HelTecAutomation/Heltec_ESP32
2323*/
2424
2525#include " Arduino.h"
2626#include " heltec.h"
27- #include " LoRa.h"
2827#include " WiFi.h"
2928#include " images.h"
3029
@@ -40,6 +39,7 @@ bool receiveflag = false; // software flag for LoRa receiver, received data make
4039
4140long lastSendTime = 0 ; // last send time
4241int interval = 1000 ; // interval between sends
42+ uint64_t chipid;
4343
4444void logo (){
4545 Heltec.display -> clear ();
@@ -51,10 +51,10 @@ void WIFISetUp(void)
5151{
5252 // Set WiFi to station mode and disconnect from an AP if it was previously connected
5353 WiFi.disconnect (true );
54- delay (1000 );
54+ delay (100 );
5555 WiFi.mode (WIFI_STA);
5656 WiFi.setAutoConnect (true );
57- WiFi.begin (" Your WiFi SSID" ," Your Password" );// fill in "Your WiFi SSID","Your Password"
57+ WiFi.begin (" Your WiFi SSID" ," Your Password" );// fill in "Your WiFi SSID","Your Password"
5858 delay (100 );
5959
6060 byte count = 0 ;
@@ -88,10 +88,8 @@ void WIFISetUp(void)
8888void WIFIScan (unsigned int value)
8989{
9090 unsigned int i;
91- if (WiFi.status () != WL_CONNECTED)
92- {
93- WiFi.mode (WIFI_MODE_NULL);
94- }
91+ WiFi.mode (WIFI_STA);
92+
9593 for (i=0 ;i<value;i++)
9694 {
9795 Heltec.display -> drawString (0 , 20 , " Scan start..." );
@@ -152,7 +150,6 @@ void interrupt_GPIO0()
152150 }
153151}
154152
155-
156153void setup ()
157154{
158155 Heltec.begin (true /* DisplayEnable Enable*/ , true /* LoRa Enable*/ , true /* Serial Enable*/ , true /* LoRa use PABOOST*/ , BAND /* LoRa RF working band*/ );
@@ -162,18 +159,21 @@ void setup()
162159 Heltec.display -> clear ();
163160
164161 WIFISetUp ();
165- WiFi.disconnect (true ); // 重新初始化WIFI
166- delay (1000 );
167- WiFi.mode (WIFI_STA);
168- WiFi.setAutoConnect (true );
169-
162+ WiFi.disconnect (); // 重新初始化WIFI
163+ WiFi.mode (WIFI_STA);
164+ delay (100 );
165+
170166 WIFIScan (1 );
171-
172- attachInterrupt (0 ,interrupt_GPIO0,FALLING);
167+
168+ chipid=ESP.getEfuseMac ();// The chip ID is essentially its MAC address(length: 6 bytes).
169+ Serial.printf (" ESP32ChipID=%04X" ,(uint16_t )(chipid>>32 ));// print High 2 bytes
170+ Serial.printf (" %08X\n " ,(uint32_t )chipid);// print Low 4bytes.
171+
172+ attachInterrupt (0 ,interrupt_GPIO0,FALLING);
173173 LoRa.onReceive (onReceive);
174- send ();
175- LoRa.receive ();
176- displaySendReceive ();
174+ send ();
175+ LoRa.receive ();
176+ displaySendReceive ();
177177}
178178
179179
@@ -238,7 +238,7 @@ void onReceive(int packetSize)//LoRa receiver interrupt service
238238{
239239 // if (packetSize == 0) return;
240240
241- packet = " " ;
241+ packet = " " ;
242242 packSize = String (packetSize,DEC);
243243
244244 while (LoRa.available ())
0 commit comments