labpack/location/find.py
def publish(self, user_id, wifi_fingerprint, action='track', location_id='', port=1883):

        '''
            a method to publish wifi fingerprint data to a mosquitto server
            
        :param user_id: string with id of user
        :param wifi_fingerprint: list of dictionaries with wifi fields mac and rssi 
        :param action: string with type of action to perform with data (track or learn)
        :param location_id: [optional] string with classifier to add to learning data
        :param port: [optional] integer with port to connect to
        :return: True
        '''
        
        title = '%s.publish' % self.__class__.__name__
    
    # validate inputs
        input_fields = {
            'user_id': user_id,
            'wifi_fingerprint': wifi_fingerprint,
            'action': action,
            'location_id': location_id,
            'port': port
        }
        for key, value in input_fields.items():
            object_title = '%s(%s=%s)' % (title, key, str(value))
            self.fields.validate(value, '.%s' % key, object_title)
            
    # compose message
        fingerprint_string = ''
        for signal in wifi_fingerprint:
            fingerprint_string += signal['mac'].replace(':','')
            rssi_string = str(signal['rssi']).replace('-','')
            if len(rssi_string) > 2:
                fingerprint_string += ' '
            fingerprint_string += rssi_string

    # compose channel
        topic_string = '%s/track/%s' % (self.group_name, user_id)
        if action == 'learn':
            topic_string = '%s/learn/%s/%s' % (self.group_name, user_id, location_id)

    # send a single message to server
        import paho.mqtt.publish as mqtt_publish
        mqtt_publish.single(
            topic=topic_string,
            payload=fingerprint_string,
            auth={ 'username': self.group_name, 'password': self.password },
            hostname=self.server_url,
            port=port
        )

        return True

            a method to publish wifi fingerprint data to a mosquitto server
            
        :param user_id: string with id of user
        :param wifi_fingerprint: list of dictionaries with wifi fields mac and rssi 
        :param action: string with type of action to perform with data (track or learn)
        :param location_id: [optional] string with classifier to add to learning data
        :param port: [optional] integer with port to connect to
        :return: True
        
a method to publish wifi fingerprint data to a mosquitto server
a method to publish wifi fingerprint data to a mosquitto server
def publish(self, user_id, wifi_fingerprint, action='track', location_id='', port=1883):
        title = '%s.publish' % self.__class__.__name__
        input_fields = {
            'user_id': user_id,
            'wifi_fingerprint': wifi_fingerprint,
            'action': action,
            'location_id': location_id,
            'port': port
        }
        for key, value in input_fields.items():
            object_title = '%s(%s=%s)' % (title, key, str(value))
            self.fields.validate(value, '.%s' % key, object_title)
        fingerprint_string = ''
        for signal in wifi_fingerprint:
            fingerprint_string += signal['mac'].replace(':','')
            rssi_string = str(signal['rssi']).replace('-','')
            if len(rssi_string) > 2:
                fingerprint_string += ' '
            fingerprint_string += rssi_string
        topic_string = '%s/track/%s' % (self.group_name, user_id)
        if action == 'learn':
            topic_string = '%s/learn/%s/%s' % (self.group_name, user_id, location_id)
        import paho.mqtt.publish as mqtt_publish
        mqtt_publish.single(
            topic=topic_string,
            payload=fingerprint_string,
            auth={ 'username': self.group_name, 'password': self.password },
            hostname=self.server_url,
            port=port
        )
        return True
def publish ( self , user_id , wifi_fingerprint , action = 'track' , location_id = '' , port = 1883 ) : title = '%s.publish' % self . __class__ . __name__ input_fields = { 'user_id' : user_id , 'wifi_fingerprint' : wifi_fingerprint , 'action' : action , 'location_id' : location_id , 'port' : port } for key , value in input_fields . items ( ) : object_title = '%s(%s=%s)' % ( title , key , str ( value ) ) self . fields . validate ( value , '.%s' % key , object_title ) fingerprint_string = '' for signal in wifi_fingerprint : fingerprint_string += signal [ 'mac' ] . replace ( ':' , '' ) rssi_string = str ( signal [ 'rssi' ] ) . replace ( '-' , '' ) if len ( rssi_string ) > 2 : fingerprint_string += ' ' fingerprint_string += rssi_string topic_string = '%s/track/%s' % ( self . group_name , user_id ) if action == 'learn' : topic_string = '%s/learn/%s/%s' % ( self . group_name , user_id , location_id ) import paho . mqtt . publish as mqtt_publish mqtt_publish . single ( topic = topic_string , payload = fingerprint_string , auth = { 'username' : self . group_name , 'password' : self . password } , hostname = self . server_url , port = port ) return True
a method to publish wifi fingerprint data to a mosquitto server
a method to publish wifi fingerprint data to a mosquitto server
'''
            a method to publish wifi fingerprint data to a mosquitto server
            
        :param user_id: string with id of user
        :param wifi_fingerprint: list of dictionaries with wifi fields mac and rssi 
        :param action: string with type of action to perform with data (track or learn)
        :param location_id: [optional] string with classifier to add to learning data
        :param port: [optional] integer with port to connect to
        :return: True
        ''' # validate inputs # compose message # compose channel # send a single message to server
None
self
user_id
string with id of user
string with id of user
wifi_fingerprint
list of dictionaries with wifi fields mac and rssi
list of dictionaries with wifi fields mac and rssi
action
string with type of action to perform with data (track or learn)
string with type of action to perform with data ( track or learn )
location_id
[optional] string with classifier to add to learning data
[ optional ] string with classifier to add to learning data
port
[optional] integer with port to connect to
[ optional ] integer with port to connect to