Master and Client both work with MMDVM/BrandMeister
If you find problems, please e-mail me. I seem to mess up merging pulls as I always have stuff already updated but not pushed.
This commit is contained in:
		
							parent
							
								
									d9e601524d
								
							
						
					
					
						commit
						7c2e4ce49c
					
				
							
								
								
									
										20
									
								
								hblink.py
									
									
									
									
									
								
							
							
						
						
									
										20
									
								
								hblink.py
									
									
									
									
									
								
							| @ -125,18 +125,13 @@ class HBMASTER(DatagramProtocol): | |||||||
|         self._master_maintenance_loop = self._master_maintenance.start(CONFIG['GLOBAL']['PING_TIME']) |         self._master_maintenance_loop = self._master_maintenance.start(CONFIG['GLOBAL']['PING_TIME']) | ||||||
|      |      | ||||||
|     def master_maintenance_loop(self): |     def master_maintenance_loop(self): | ||||||
|         logger.debug('Master maintenance loop started') |         logger.debug('(%s) Master maintenance loop started', self._master) | ||||||
|         for client in self._clients: |         for client in self._clients.keys(): | ||||||
|             _this_client = self._clients[client] |             _this_client = self._clients[client] | ||||||
|             print(_this_client['LAST_PING']) |  | ||||||
|             print(time()) |  | ||||||
|             print(CONFIG['GLOBAL']['PING_TIME']) |  | ||||||
|             print(CONFIG['GLOBAL']['MAX_MISSED']) |  | ||||||
|              |              | ||||||
|             if _this_client['LAST_PING']+CONFIG['GLOBAL']['PING_TIME']*CONFIG['GLOBAL']['MAX_MISSED'] < time(): |             if _this_client['LAST_PING']+CONFIG['GLOBAL']['PING_TIME']*CONFIG['GLOBAL']['MAX_MISSED'] < time(): | ||||||
|                 logger.info('(%s) Client %s has timed out', self._master, _this_client['RADIO_ID']) |                 logger.info('(%s) Client %s has timed out', self._master, _this_client['RADIO_ID']) | ||||||
|                 del _this_client |                 del CONFIG['MASTERS'][self._master]['CLIENTS'][client] | ||||||
|                 pprint(_this_client) |  | ||||||
|                  |                  | ||||||
|     def send_packet(self, _client, _packet): |     def send_packet(self, _client, _packet): | ||||||
|         self.transport.write(_packet, (self._clients[_client]['IP'], self._clients[_client]['PORT'])) |         self.transport.write(_packet, (self._clients[_client]['IP'], self._clients[_client]['PORT'])) | ||||||
| @ -198,7 +193,7 @@ class HBMASTER(DatagramProtocol): | |||||||
|                     logger.info('(%s) Client %s has completed the login exchange successfully', self._master, _this_client['RADIO_ID']) |                     logger.info('(%s) Client %s has completed the login exchange successfully', self._master, _this_client['RADIO_ID']) | ||||||
|                 else: |                 else: | ||||||
|                     logger.info('(%s) Client %s has FAILED the login exchange successfully', self._master, _this_client['RADIO_ID']) |                     logger.info('(%s) Client %s has FAILED the login exchange successfully', self._master, _this_client['RADIO_ID']) | ||||||
|                     del _this_client |                     # Add removal of client here... | ||||||
|                      |                      | ||||||
|                  |                  | ||||||
|             else: |             else: | ||||||
| @ -234,8 +229,9 @@ class HBMASTER(DatagramProtocol): | |||||||
| 
 | 
 | ||||||
|         elif _command == 'RPTP':    # RPTPing -- client is pinging us |         elif _command == 'RPTP':    # RPTPing -- client is pinging us | ||||||
|                 _radio_id = _data[7:11] |                 _radio_id = _data[7:11] | ||||||
|                 print(h(_radio_id)) |                 if _radio_id in self._clients and self._clients[_radio_id]['CONNECTION'] == "YES": | ||||||
|         #print(h(_data)) |                     self.send_packet(_radio_id, 'MSTPONG'+_radio_id) | ||||||
|  |                     logger.info('(%s) Received and answered RPTPING from client %s', self._master, h(_radio_id)) | ||||||
|              |              | ||||||
| #************************************************ | #************************************************ | ||||||
| #     HB CLIENT CLASS | #     HB CLIENT CLASS | ||||||
| @ -258,7 +254,7 @@ class HBCLIENT(DatagramProtocol): | |||||||
|         self._client_maintenance_loop = self._client_maintenance.start(CONFIG['GLOBAL']['PING_TIME']) |         self._client_maintenance_loop = self._client_maintenance.start(CONFIG['GLOBAL']['PING_TIME']) | ||||||
|          |          | ||||||
|     def client_maintenance_loop(self): |     def client_maintenance_loop(self): | ||||||
|         logger.debug('Client maintenance loop started') |         logger.debug('(%s) Client maintenance loop started', self._client) | ||||||
|         if self._stats['CONNECTION'] == 'NO': |         if self._stats['CONNECTION'] == 'NO': | ||||||
|             self._stats['PINGS_SENT'] = 0 |             self._stats['PINGS_SENT'] = 0 | ||||||
|             self._stats['PINGS_ACKD'] = 0 |             self._stats['PINGS_ACKD'] = 0 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user