Browse Source
			
			
			Merge pull request #2 from tbnobody/dev
			
				Added possibility to connect to MqTT Broker with username and password
			
			
				pull/3/head
			
			
		 
		
			
				
					
						 grindylow
					
					4 years ago
						grindylow
					
					4 years ago
					
						
							committed by
							
								 GitHub
								GitHub
							
						 
					
				 
				
			 
		 
		
			
				
					
					No known key found for this signature in database
					
						
							GPG Key ID: 4AEE18F83AFDEB23
						
					
				
			
		
		
		
	
		
			
				 2 changed files with 
5 additions and 
0 deletions
			 
			
		 
		
			
				- 
					
					
					 
					tools/rpi/ahoy.conf.example
				
- 
					
					
					 
					tools/rpi/ahoy.py
				
				
				
					
						
							
								
									
	
		
		
			
				
					|  | @ -1,6 +1,8 @@ | 
			
		
	
		
		
			
				
					|  |  | [mqtt] |  |  | [mqtt] | 
			
		
	
		
		
			
				
					|  |  | host = 192.168.84.2 |  |  | host = 192.168.84.2 | 
			
		
	
		
		
			
				
					|  |  | port = 1883 |  |  | port = 1883 | 
			
		
	
		
		
			
				
					|  |  |  |  |  | user = bla | 
			
		
	
		
		
			
				
					|  |  |  |  |  | password = blub | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  | [dtu] |  |  | [dtu] | 
			
		
	
		
		
			
				
					|  |  | serial = 99978563412 |  |  | serial = 99978563412 | 
			
		
	
	
		
		
			
				
					|  | 
 | 
			
		
	
								
							
						
					 
					
				 
			 
		
			
			
			
			
			
			
				
				
					
						
							
								
									
	
		
		
			
				
					|  | @ -18,9 +18,12 @@ cfg = ConfigParser() | 
			
		
	
		
		
			
				
					|  |  | cfg.read('ahoy.conf') |  |  | cfg.read('ahoy.conf') | 
			
		
	
		
		
			
				
					|  |  | mqtt_host = cfg.get('mqtt', 'host', fallback='192.168.1.1') |  |  | mqtt_host = cfg.get('mqtt', 'host', fallback='192.168.1.1') | 
			
		
	
		
		
			
				
					|  |  | mqtt_port = cfg.getint('mqtt', 'port', fallback=1883) |  |  | mqtt_port = cfg.getint('mqtt', 'port', fallback=1883) | 
			
		
	
		
		
			
				
					|  |  |  |  |  | mqtt_user = cfg.get('mqtt', 'user', fallback='') | 
			
		
	
		
		
			
				
					|  |  |  |  |  | mqtt_password = cfg.get('mqtt', 'password', fallback='') | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  | radio = RF24(22, 0, 1000000) |  |  | radio = RF24(22, 0, 1000000) | 
			
		
	
		
		
			
				
					|  |  | mqtt_client = paho.mqtt.client.Client() |  |  | mqtt_client = paho.mqtt.client.Client() | 
			
		
	
		
		
			
				
					|  |  |  |  |  | mqtt_client.username_pw_set(mqtt_user, mqtt_password) | 
			
		
	
		
		
			
				
					|  |  | mqtt_client.connect(mqtt_host, mqtt_port) |  |  | mqtt_client.connect(mqtt_host, mqtt_port) | 
			
		
	
		
		
			
				
					|  |  | mqtt_client.loop_start() |  |  | mqtt_client.loop_start() | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
	
		
		
			
				
					|  | 
 |