kopia lustrzana https://github.com/meshtastic/firmware
				
				
				
			add support for reporting device errors up through the phone to analytics
related to https://github.com/meshtastic/Meshtastic-esp32/issues/53pull/56/head
							rodzic
							
								
									3f1161b68b
								
							
						
					
					
						commit
						34ead2d68e
					
				
							
								
								
									
										2
									
								
								proto
								
								
								
								
							
							
								
								
								
								
								
								
							
						
						
									
										2
									
								
								proto
								
								
								
								
							|  | @ -1 +1 @@ | |||
| Subproject commit 398fdf362518e9d6869247cef09f2e071b715639 | ||||
| Subproject commit 1b2449b50d11f66d90511559e94cdf40f525fafb | ||||
|  | @ -224,6 +224,24 @@ 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) | ||||
|     { | ||||
|         ProtobufCharacteristic::onRead(c); | ||||
| 
 | ||||
|         myNodeInfo.error_code = 0; // The phone just read us, so throw it away
 | ||||
|         myNodeInfo.error_address = 0; | ||||
|     } | ||||
| }; | ||||
| 
 | ||||
| FromNumCharacteristic *meshFromNumCharacteristic; | ||||
| 
 | ||||
| /**
 | ||||
|  | @ -254,11 +272,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> | ||||
|  | @ -149,6 +150,7 @@ void MeshRadio::loop() | |||
|     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
 | ||||
|     } | ||||
| } | ||||
|  |  | |||
|  | @ -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
	
	 geeksville
						geeksville