kopia lustrzana https://github.com/meshtastic/firmware
				
				
				
			report hw vendor and sw version via BLE
							rodzic
							
								
									d4284ba95d
								
							
						
					
					
						commit
						df2b40f5a1
					
				| 
						 | 
				
			
			@ -13,7 +13,7 @@ static BLECharacteristic HardwareVersionCharacteristic(BLEUUID((uint16_t) ESP_GA
 | 
			
		|||
/**
 | 
			
		||||
 * Create standard device info service
 | 
			
		||||
 **/
 | 
			
		||||
BLEService *createDeviceInfomationService(BLEServer* server) {
 | 
			
		||||
BLEService *createDeviceInfomationService(BLEServer* server, std::string hwVendor, std::string swVersion) {
 | 
			
		||||
    BLEService *deviceInfoService = server->createService(BLEUUID((uint16_t) ESP_GATT_UUID_DEVICE_INFO_SVC));
 | 
			
		||||
 | 
			
		||||
    /*
 | 
			
		||||
| 
						 | 
				
			
			@ -25,9 +25,9 @@ BLEService *createDeviceInfomationService(BLEServer* server) {
 | 
			
		|||
	uint8_t pnp[] = { sig, (uint8_t) (vid >> 8), (uint8_t) vid, (uint8_t) (pid >> 8), (uint8_t) pid, (uint8_t) (version >> 8), (uint8_t) version };
 | 
			
		||||
	m_pnpCharacteristic->setValue(pnp, sizeof(pnp));
 | 
			
		||||
    */
 | 
			
		||||
    SWVersionCharacteristic.setValue("0.1");
 | 
			
		||||
    SWVersionCharacteristic.setValue(swVersion);
 | 
			
		||||
    deviceInfoService->addCharacteristic(&SWVersionCharacteristic);
 | 
			
		||||
    ManufacturerCharacteristic.setValue("TTGO");
 | 
			
		||||
    ManufacturerCharacteristic.setValue(hwVendor);
 | 
			
		||||
    deviceInfoService->addCharacteristic(&ManufacturerCharacteristic);
 | 
			
		||||
    HardwareVersionCharacteristic.setValue("1.0");
 | 
			
		||||
    deviceInfoService->addCharacteristic(&HardwareVersionCharacteristic); 
 | 
			
		||||
| 
						 | 
				
			
			@ -122,13 +122,13 @@ uint32_t getValue32(BLECharacteristic *c, uint32_t defaultValue) {
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
BLEServer *initBLE(std::string deviceName) {
 | 
			
		||||
BLEServer *initBLE(std::string deviceName, std::string hwVendor, std::string swVersion) {
 | 
			
		||||
    BLEDevice::init(deviceName);
 | 
			
		||||
    // Create the BLE Server
 | 
			
		||||
    BLEServer *pServer = BLEDevice::createServer();
 | 
			
		||||
    pServer->setCallbacks(new MyServerCallbacks());
 | 
			
		||||
 | 
			
		||||
    BLEService *pDevInfo = createDeviceInfomationService(pServer);
 | 
			
		||||
    BLEService *pDevInfo = createDeviceInfomationService(pServer, hwVendor, swVersion);
 | 
			
		||||
 | 
			
		||||
    // We now let users create the battery service only if they really want (not all devices have a battery)
 | 
			
		||||
    // BLEService *pBattery = createBatteryService(pServer);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -18,4 +18,4 @@ void dumpCharacteristic(BLECharacteristic *c);
 | 
			
		|||
uint32_t getValue32(BLECharacteristic *c, uint32_t defaultValue);
 | 
			
		||||
 | 
			
		||||
void loopBLE();
 | 
			
		||||
BLEServer *initBLE(std::string devName);
 | 
			
		||||
BLEServer *initBLE(std::string devName, std::string hwVendor, std::string swVersion);
 | 
			
		||||
| 
						 | 
				
			
			@ -40,6 +40,9 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
			
		|||
// #define T_BEAM_V10  // AKA Rev1 (second board released)
 | 
			
		||||
#define HELTEC_LORA32
 | 
			
		||||
 | 
			
		||||
// If we are using the JTAG port for debugging, some pins must be left free for that (and things like GPS have to be disabled)
 | 
			
		||||
#define USE_JTAG
 | 
			
		||||
 | 
			
		||||
#define DEBUG_PORT              Serial      // Serial debug port
 | 
			
		||||
#define SERIAL_BAUD             115200      // Serial debug baud rate
 | 
			
		||||
#define SLEEP_MSECS             (30 * 24 * 60 * 60 * 1000LL) // Sleep for these many millis (or a button press or a lora msg?)
 | 
			
		||||
| 
						 | 
				
			
			@ -93,12 +96,15 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
			
		|||
 | 
			
		||||
#define GPS_SERIAL_NUM  1
 | 
			
		||||
#define GPS_BAUDRATE    9600
 | 
			
		||||
#define USE_GPS         1
 | 
			
		||||
 | 
			
		||||
#if defined(T_BEAM_V10)
 | 
			
		||||
#define GPS_RX_PIN      34
 | 
			
		||||
#ifdef USE_JTAG
 | 
			
		||||
#define GPS_TX_PIN      -1 // We can't send bytes to the GPS while using JTAG (not a big deal)
 | 
			
		||||
#else
 | 
			
		||||
#define GPS_TX_PIN      12
 | 
			
		||||
#endif
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
// -----------------------------------------------------------------------------
 | 
			
		||||
// LoRa SPI
 | 
			
		||||
| 
						 | 
				
			
			@ -110,6 +116,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
			
		|||
#define NSS_GPIO        18
 | 
			
		||||
 | 
			
		||||
#if defined(T_BEAM_V10)
 | 
			
		||||
#define HW_VENDOR       "TTGO"
 | 
			
		||||
 | 
			
		||||
#define I2C_SDA         21
 | 
			
		||||
#define I2C_SCL         22
 | 
			
		||||
| 
						 | 
				
			
			@ -123,6 +130,8 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
			
		|||
#define PMU_IRQ         35
 | 
			
		||||
 | 
			
		||||
#elif defined(HELTEC_LORA32)
 | 
			
		||||
#define HW_VENDOR       "Heltec"
 | 
			
		||||
 | 
			
		||||
#define I2C_SDA         4
 | 
			
		||||
#define I2C_SCL         15
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -361,7 +361,7 @@ void setup()
 | 
			
		|||
  //}
 | 
			
		||||
 | 
			
		||||
  service.init();
 | 
			
		||||
  BLEServer *serve = initBLE(getDeviceName()); // FIXME, use a real name based on the macaddr
 | 
			
		||||
  BLEServer *serve = initBLE(getDeviceName(), HW_VENDOR, APP_VERSION); // FIXME, use a real name based on the macaddr
 | 
			
		||||
  createMeshBluetoothService(serve);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Ładowanie…
	
		Reference in New Issue