kopia lustrzana https://github.com/meshtastic/firmware
				
				
				
			Merge pull request #56 from geeksville/master
misc changes as kevin bangs through the post illness bug-queuepull/58/head 0.1.9
						commit
						9075501917
					
				
							
								
								
									
										64
									
								
								README.md
								
								
								
								
							
							
						
						
									
										64
									
								
								README.md
								
								
								
								
							|  | @ -51,31 +51,77 @@ Warning: ESP32 has no Chip ID. Reading MAC instead. | |||
| MAC: 24:6f:28:b5:36:71 | ||||
| Hard resetting via RTS pin... | ||||
| ``` | ||||
| 6. Install the correct firmware for your board with "esptool.py write_flash 0x10000 firmware-_board_-_country_.bin".  For instance "esptool.py write_flash 0x10000 release/firmware-HELTEC-US-0.0.3.bin". You should see something like this: | ||||
| 6. cd into the directory where the release zip file was expanded. | ||||
| 7. Install the correct firmware for your board with "device-install.sh firmware-_board_-_country_.bin".  For instance "./device-install.sh firmware-HELTEC-US-0.0.3.bin".  | ||||
| 
 | ||||
| Note: If you have previously installed meshtastic, you don't need to run this full script instead just run "esptool.py --baud 921600 write_flash 0x10000 firmware-_board_-_country_.bin".  This will be faster, also all of your current preferences will be preserved. | ||||
| 
 | ||||
| You should see something like this: | ||||
| ``` | ||||
| ~/development/meshtastic/meshtastic-esp32$ esptool.py write_flash 0x10000 release/firmware-HELTEC-US-0.0.3.bin  | ||||
| kevinh@kevin-server:~/development/meshtastic/meshtastic-esp32/release/latest$ ./device-install.sh firmware-TBEAM-US-0.1.8.bin  | ||||
| Trying to flash firmware-TBEAM-US-0.1.8.bin, but first erasing and writing system information | ||||
| esptool.py v2.6 | ||||
| Found 2 serial ports | ||||
| Serial port /dev/ttyUSB0 | ||||
| Connecting...... | ||||
| Connecting........____ | ||||
| Detecting chip type... ESP32 | ||||
| Chip is ESP32D0WDQ6 (revision 1) | ||||
| Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None | ||||
| MAC: 24:6f:28:b5:36:71 | ||||
| MAC: 24:6f:28:b2:01:6c | ||||
| Uploading stub... | ||||
| Running stub... | ||||
| Stub running... | ||||
| Changing baud rate to 921600 | ||||
| Changed. | ||||
| Erasing flash (this may take a while)... | ||||
| Chip erase completed successfully in 6.1s | ||||
| Hard resetting via RTS pin... | ||||
| esptool.py v2.6 | ||||
| Found 2 serial ports | ||||
| Serial port /dev/ttyUSB0 | ||||
| Connecting....... | ||||
| Detecting chip type... ESP32 | ||||
| Chip is ESP32D0WDQ6 (revision 1) | ||||
| Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None | ||||
| MAC: 24:6f:28:b2:01:6c | ||||
| Uploading stub... | ||||
| Running stub... | ||||
| Stub running... | ||||
| Changing baud rate to 921600 | ||||
| Changed. | ||||
| Configuring flash size... | ||||
| Auto-detected Flash size: 8MB | ||||
| Compressed 1184800 bytes to 652635... | ||||
| Wrote 1184800 bytes (652635 compressed) at 0x00010000 in 57.6 seconds (effective 164.5 kbit/s)... | ||||
| Auto-detected Flash size: 4MB | ||||
| Flash params set to 0x0220 | ||||
| Compressed 61440 bytes to 11950... | ||||
| Wrote 61440 bytes (11950 compressed) at 0x00001000 in 0.2 seconds (effective 3092.4 kbit/s)... | ||||
| Hash of data verified. | ||||
| 
 | ||||
| Leaving... | ||||
| Hard resetting via RTS pin... | ||||
| esptool.py v2.6 | ||||
| Found 2 serial ports | ||||
| Serial port /dev/ttyUSB0 | ||||
| Connecting..... | ||||
| Detecting chip type... ESP32 | ||||
| Chip is ESP32D0WDQ6 (revision 1) | ||||
| Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None | ||||
| MAC: 24:6f:28:b2:01:6c | ||||
| Uploading stub... | ||||
| Running stub... | ||||
| Stub running... | ||||
| Changing baud rate to 921600 | ||||
| Changed. | ||||
| Configuring flash size... | ||||
| Auto-detected Flash size: 4MB | ||||
| Compressed 1223568 bytes to 678412... | ||||
| Wrote 1223568 bytes (678412 compressed) at 0x00010000 in 10.7 seconds (effective 912.0 kbit/s)... | ||||
| Hash of data verified. | ||||
| 
 | ||||
| Leaving... | ||||
| Hard resetting via RTS pin... | ||||
| ``` | ||||
| 7. The board will boot and show the Meshtastic logo. | ||||
| 8. Please post a comment on our chat so we know if these instructions worked for you ;-).  If you find bugs/have-questions post there also - we will be rapidly iterating over the next few weeks. | ||||
| 8. The board will boot and show the Meshtastic logo. | ||||
| 9. Please post a comment on our chat so we know if these instructions worked for you ;-).  If you find bugs/have-questions post there also - we will be rapidly iterating over the next few weeks. | ||||
| 
 | ||||
| ## Meshtastic Android app | ||||
| The source code for the (optional) Meshtastic Android app is [here](https://github.com/meshtastic/Meshtastic-Android).   | ||||
|  |  | |||
|  | @ -9,6 +9,7 @@ COUNTRIES="US EU433 EU865 CN JP" | |||
| 
 | ||||
| SRCMAP=.pio/build/esp32/output.map | ||||
| SRCBIN=.pio/build/esp32/firmware.bin | ||||
| SRCELF=.pio/build/esp32/firmware.elf | ||||
| OUTDIR=release/latest | ||||
| 
 | ||||
| # We keep all old builds (and their map files in the archive dir) | ||||
|  | @ -26,12 +27,14 @@ for COUNTRY in $COUNTRIES; do | |||
|     rm -f $SRCBIN $SRCMAP | ||||
|     pio run # -v | ||||
|     cp $SRCBIN $OUTDIR/firmware-TBEAM-$COUNTRY-$VERSION.bin | ||||
|     cp $SRCELF $OUTDIR/firmware-TBEAM-$COUNTRY-$VERSION.elf     | ||||
|     #cp $SRCMAP $ARCHIVEDIR/firmware-TBEAM-$COUNTRY-$VERSION.map | ||||
| 
 | ||||
|     export PLATFORMIO_BUILD_FLAGS="-DHELTEC_LORA32 $COMMONOPTS" | ||||
|     rm -f $SRCBIN $SRCMAP | ||||
|     pio run # -v | ||||
|     cp $SRCBIN $OUTDIR/firmware-HELTEC-$COUNTRY-$VERSION.bin | ||||
|     cp $SRCELF $OUTDIR/firmware-HELTEC-$COUNTRY-$VERSION.elf | ||||
|     #cp $SRCMAP $ARCHIVEDIR/firmware-HELTEC-$COUNTRY-$VERSION.map | ||||
| done | ||||
| 
 | ||||
|  | @ -51,6 +54,6 @@ Generated by bin/buildall.sh --> | |||
| XML | ||||
| 
 | ||||
| rm -f $ARCHIVEDIR/firmware-$VERSION.zip | ||||
| zip $ARCHIVEDIR/firmware-$VERSION.zip $OUTDIR/firmware-*-$VERSION.bin | ||||
| zip --junk-paths $ARCHIVEDIR/firmware-$VERSION.zip $OUTDIR/firmware-*-$VERSION.* images/system-info.bin bin/device-install.sh | ||||
| 
 | ||||
| echo BUILT ALL | ||||
|  | @ -0,0 +1,11 @@ | |||
| #!/bin/bash | ||||
| 
 | ||||
| set -e | ||||
| 
 | ||||
| FILENAME=$1 | ||||
| 
 | ||||
| echo "Trying to flash $FILENAME, but first erasing and writing system information" | ||||
| esptool.py --baud 921600 erase_flash | ||||
| esptool.py --baud 921600 write_flash 0x1000 system-info.bin | ||||
| esptool.py --baud 921600 write_flash 0x10000 $FILENAME | ||||
| 
 | ||||
|  | @ -1,3 +1,3 @@ | |||
| 
 | ||||
| 
 | ||||
| export VERSION=0.1.8 | ||||
| export VERSION=0.1.9 | ||||
							
								
								
									
										2
									
								
								proto
								
								
								
								
							
							
								
								
								
								
								
								
							
						
						
									
										2
									
								
								proto
								
								
								
								
							|  | @ -1 +1 @@ | |||
| Subproject commit 398fdf362518e9d6869247cef09f2e071b715639 | ||||
| Subproject commit 1b2449b50d11f66d90511559e94cdf40f525fafb | ||||
|  | @ -1,3 +1,4 @@ | |||
| *.elf | ||||
| *.bin | ||||
| *.map | ||||
| *.zip | ||||
|  | @ -107,11 +107,7 @@ class RadioCharacteristic : public ProtobufCharacteristic | |||
|     void onRead(BLECharacteristic *c) | ||||
|     { | ||||
|         DEBUG_MSG("Reading radio config\n"); | ||||
| 
 | ||||
|         // update gps connection state
 | ||||
|         devicestate.has_radio = gps.isConnected; | ||||
| 
 | ||||
|         BLEKeepAliveCallbacks::onRead(c); | ||||
|         ProtobufCharacteristic::onRead(c); | ||||
|     } | ||||
| 
 | ||||
|     void onWrite(BLECharacteristic *c) | ||||
|  | @ -224,6 +220,27 @@ class FromNumCharacteristic : public CallbackCharacteristic | |||
|     } | ||||
| }; | ||||
| 
 | ||||
| class MyNodeInfoCharacteristic : public ProtobufCharacteristic | ||||
| { | ||||
|   public: | ||||
|     MyNodeInfoCharacteristic() | ||||
|         : ProtobufCharacteristic("ea9f3f82-8dc4-4733-9452-1f6da28892a2", BLECharacteristic::PROPERTY_READ, MyNodeInfo_fields, | ||||
|                                  &myNodeInfo) | ||||
|     { | ||||
|     } | ||||
| 
 | ||||
|     void onRead(BLECharacteristic *c) | ||||
|     { | ||||
|         // update gps connection state
 | ||||
|         myNodeInfo.has_gps = gps.isConnected; | ||||
| 
 | ||||
|         ProtobufCharacteristic::onRead(c); | ||||
| 
 | ||||
|         myNodeInfo.error_code = 0; // The phone just read us, so throw it away
 | ||||
|         myNodeInfo.error_address = 0; | ||||
|     } | ||||
| }; | ||||
| 
 | ||||
| FromNumCharacteristic *meshFromNumCharacteristic; | ||||
| 
 | ||||
| /**
 | ||||
|  | @ -254,11 +271,7 @@ BLEService *createMeshBluetoothService(BLEServer *server) | |||
|     addWithDesc(service, meshFromNumCharacteristic, "fromRadio"); | ||||
|     addWithDesc(service, new ToRadioCharacteristic, "toRadio"); | ||||
|     addWithDesc(service, new FromRadioCharacteristic, "fromNum"); | ||||
| 
 | ||||
|     addWithDesc(service, | ||||
|                 new ProtobufCharacteristic("ea9f3f82-8dc4-4733-9452-1f6da28892a2", BLECharacteristic::PROPERTY_READ, | ||||
|                                            MyNodeInfo_fields, &myNodeInfo), | ||||
|                 "myNode"); | ||||
|     addWithDesc(service, new MyNodeInfoCharacteristic, "myNode"); | ||||
|     addWithDesc(service, new RadioCharacteristic, "radio"); | ||||
|     addWithDesc(service, new OwnerCharacteristic, "owner"); | ||||
|     addWithDesc(service, new NodeInfoCharacteristic, "nodeinfo"); | ||||
|  |  | |||
|  | @ -1,4 +1,5 @@ | |||
| #include "RH_RF95.h" | ||||
| #include "error.h" | ||||
| #include <RHMesh.h> | ||||
| #include <SPI.h> | ||||
| #include <assert.h> | ||||
|  | @ -130,6 +131,8 @@ void MeshRadio::reloadConfig() | |||
| 
 | ||||
| ErrorCode MeshRadio::send(MeshPacket *p) | ||||
| { | ||||
|     lastTxStart = millis(); | ||||
| 
 | ||||
|     if (useHardware) | ||||
|         return rf95.send(p); | ||||
|     else { | ||||
|  | @ -138,7 +141,16 @@ ErrorCode MeshRadio::send(MeshPacket *p) | |||
|     } | ||||
| } | ||||
| 
 | ||||
| #define TX_WATCHDOG_TIMEOUT 30 * 1000 | ||||
| 
 | ||||
| void MeshRadio::loop() | ||||
| { | ||||
|     // Currently does nothing, since we do it all in ISRs now
 | ||||
|     // It should never take us more than 30 secs to send a packet, if it does, we have a bug
 | ||||
|     uint32_t now = millis(); | ||||
|     if (lastTxStart != 0 && (now - lastTxStart) > TX_WATCHDOG_TIMEOUT && rf95.mode() == RHGenericDriver::RHModeTx) { | ||||
|         DEBUG_MSG("ERROR! Bug! Tx packet took too long to send, forcing radio into rx mode"); | ||||
|         rf95.setModeRx(); | ||||
|         recordCriticalError(ErrTxWatchdog); | ||||
|         lastTxStart = 0; // Stop checking for now, because we just warned the developer
 | ||||
|     } | ||||
| } | ||||
|  |  | |||
|  | @ -87,10 +87,11 @@ class MeshRadio | |||
|     void reloadConfig(); | ||||
| 
 | ||||
|   private: | ||||
|     // RHDatagram manager;
 | ||||
|     // RHReliableDatagram manager; // don't use mesh yet
 | ||||
|     RHMesh manager; | ||||
|     // MeshRXHandler rxHandler;
 | ||||
| 
 | ||||
|     /// Used for the tx timer watchdog, to check for bugs in our transmit code, msec of last time we did a send
 | ||||
|     uint32_t lastTxStart = 0; | ||||
| 
 | ||||
|     /// low level send, might block for mutiple seconds
 | ||||
|     ErrorCode sendTo(NodeNum dest, const uint8_t *buf, size_t len); | ||||
|  |  | |||
|  | @ -9,6 +9,7 @@ | |||
| #include "NodeDB.h" | ||||
| #include "PowerFSM.h" | ||||
| #include "configuration.h" | ||||
| #include "error.h" | ||||
| #include "mesh-pb-constants.h" | ||||
| #include <pb_decode.h> | ||||
| #include <pb_encode.h> | ||||
|  | @ -328,3 +329,11 @@ NodeInfo *NodeDB::getOrCreateNode(NodeNum n) | |||
| 
 | ||||
|     return info; | ||||
| } | ||||
| 
 | ||||
| /// Record an error that should be reported via analytics
 | ||||
| void recordCriticalError(CriticalErrorCode code, uint32_t address) | ||||
| { | ||||
|     myNodeInfo.error_code = code; | ||||
|     myNodeInfo.error_address = address; | ||||
|     myNodeInfo.error_count++; | ||||
| } | ||||
|  |  | |||
|  | @ -0,0 +1,7 @@ | |||
| #pragma once | ||||
| 
 | ||||
| /// Error codes for critical error
 | ||||
| enum CriticalErrorCode { NoError, ErrTxWatchdog }; | ||||
| 
 | ||||
| /// Record an error that should be reported via analytics
 | ||||
| void recordCriticalError(CriticalErrorCode code, uint32_t address = 0); | ||||
|  | @ -52,6 +52,9 @@ typedef struct _MyNodeInfo { | |||
|     char region[12]; | ||||
|     char hw_model[12]; | ||||
|     char firmware_version[12]; | ||||
|     uint32_t error_code; | ||||
|     uint32_t error_address; | ||||
|     uint32_t error_count; | ||||
| } MyNodeInfo; | ||||
| 
 | ||||
| typedef struct _Position { | ||||
|  | @ -176,7 +179,7 @@ typedef struct _ToRadio { | |||
| #define RadioConfig_init_default                 {false, RadioConfig_UserPreferences_init_default, false, ChannelSettings_init_default} | ||||
| #define RadioConfig_UserPreferences_init_default {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} | ||||
| #define NodeInfo_init_default                    {0, false, User_init_default, false, Position_init_default, 0, 0} | ||||
| #define MyNodeInfo_init_default                  {0, 0, 0, "", "", ""} | ||||
| #define MyNodeInfo_init_default                  {0, 0, 0, "", "", "", 0, 0, 0} | ||||
| #define DeviceState_init_default                 {false, RadioConfig_init_default, false, MyNodeInfo_init_default, false, User_init_default, 0, {NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default}, 0, {MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default}, false, MeshPacket_init_default, 0} | ||||
| #define FromRadio_init_default                   {0, 0, {MeshPacket_init_default}} | ||||
| #define ToRadio_init_default                     {0, {MeshPacket_init_default}} | ||||
|  | @ -189,7 +192,7 @@ typedef struct _ToRadio { | |||
| #define RadioConfig_init_zero                    {false, RadioConfig_UserPreferences_init_zero, false, ChannelSettings_init_zero} | ||||
| #define RadioConfig_UserPreferences_init_zero    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} | ||||
| #define NodeInfo_init_zero                       {0, false, User_init_zero, false, Position_init_zero, 0, 0} | ||||
| #define MyNodeInfo_init_zero                     {0, 0, 0, "", "", ""} | ||||
| #define MyNodeInfo_init_zero                     {0, 0, 0, "", "", "", 0, 0, 0} | ||||
| #define DeviceState_init_zero                    {false, RadioConfig_init_zero, false, MyNodeInfo_init_zero, false, User_init_zero, 0, {NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero}, 0, {MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero}, false, MeshPacket_init_zero, 0} | ||||
| #define FromRadio_init_zero                      {0, 0, {MeshPacket_init_zero}} | ||||
| #define ToRadio_init_zero                        {0, {MeshPacket_init_zero}} | ||||
|  | @ -207,6 +210,9 @@ typedef struct _ToRadio { | |||
| #define MyNodeInfo_region_tag                    4 | ||||
| #define MyNodeInfo_hw_model_tag                  5 | ||||
| #define MyNodeInfo_firmware_version_tag          6 | ||||
| #define MyNodeInfo_error_code_tag                7 | ||||
| #define MyNodeInfo_error_address_tag             8 | ||||
| #define MyNodeInfo_error_count_tag               9 | ||||
| #define Position_latitude_tag                    1 | ||||
| #define Position_longitude_tag                   2 | ||||
| #define Position_altitude_tag                    3 | ||||
|  | @ -349,7 +355,10 @@ X(a, STATIC,   SINGULAR, BOOL,     has_gps,           2) \ | |||
| X(a, STATIC,   SINGULAR, INT32,    num_channels,      3) \ | ||||
| X(a, STATIC,   SINGULAR, STRING,   region,            4) \ | ||||
| X(a, STATIC,   SINGULAR, STRING,   hw_model,          5) \ | ||||
| X(a, STATIC,   SINGULAR, STRING,   firmware_version,   6) | ||||
| X(a, STATIC,   SINGULAR, STRING,   firmware_version,   6) \ | ||||
| X(a, STATIC,   SINGULAR, UINT32,   error_code,        7) \ | ||||
| X(a, STATIC,   SINGULAR, UINT32,   error_address,     8) \ | ||||
| X(a, STATIC,   SINGULAR, UINT32,   error_count,       9) | ||||
| #define MyNodeInfo_CALLBACK NULL | ||||
| #define MyNodeInfo_DEFAULT NULL | ||||
| 
 | ||||
|  | @ -422,8 +431,8 @@ extern const pb_msgdesc_t ToRadio_msg; | |||
| #define RadioConfig_size                         120 | ||||
| #define RadioConfig_UserPreferences_size         72 | ||||
| #define NodeInfo_size                            155 | ||||
| #define MyNodeInfo_size                          63 | ||||
| #define DeviceState_size                         15058 | ||||
| #define MyNodeInfo_size                          81 | ||||
| #define DeviceState_size                         15076 | ||||
| #define FromRadio_size                           301 | ||||
| #define ToRadio_size                             295 | ||||
| 
 | ||||
|  |  | |||
		Ładowanie…
	
		Reference in New Issue
	
	 Kevin Hester
						Kevin Hester