Exemplo n.º 1
0
def report(timestamp, vin, data):
    logger.info('Tracking Callback Server: Report request: Time: %s, VIN: %s, Data: %s.', timestamp, vin, data)

    # get the vehicle record from the database
    try:
        vehicle = Vehicle.objects.get(veh_vin = vin)
    except Exception as e:
        logger.error("Tracking Callback Server: Cannot retrieve vehicle '%s' from database. Error: %s", vin, e)
        return {u'status': 0}

    location = Location()
    location.loc_vehicle = vehicle
    location.loc_time = timestamp

    for channel in data:
        key = channel['channel']
        value = channel['value']
        if key == 'location':
            location.loc_latitude = value['lat']
            location.loc_longitude = value['lon']
            location.loc_altitude = value['alt']
        elif key == 'speed':
            location.loc_speed = float(value)
        elif key == 'odometer':
            location.loc_odometer = float(value)

    location.save()

    return {u'status': 0}
Exemplo n.º 2
0
def report(timestamp, vin, data):
        """
        Log the location record
        """
        conf = get_settings()
        
        kafka = None
        logger.info('Kafka MQ Server: Report Request: Time: %s, VIN: %s, Data: %s.', timestamp, vin, data)
        payload = {}
        payload['timestamp'] = timestamp
        payload['vin'] = vin
        payload['data'] = data
        # Connect to Kafka Message Queue Server
       
        try:
            kafka = KafkaClient(conf['TRACKING_MQ_URL'])
        except:
            logger.error("%s: Kafka Message Queue Server unavailable:", conf['TRACKING_MQ_URL'])
            kafka = None
            return False
                
        producer = SimpleProducer(kafka)
        producer.send_messages(conf['TRACKING_MQ_TOPIC'], json.dumps(payload))
        logger.info("%s: Report data published to message queue.", conf['TRACKING_MQ_URL'])
        return True
Exemplo n.º 3
0
def cancel_download(retry):
    rvi_logger.info("SOTA Callback Server: Cancel download request: retry: %s.", retry)
    retry_obj = None
    update_obj = None
    try:
        retry_obj = sota.models.Retry.objects.filter(pk=retry)[0]
        update_obj = retry_obj.ret_update
    except:
        rvi_logger.error("SOTA Callback Server: Cancel downlaod request: Cannot access database object: %s", retry)
        return {u"status": 0}
    retry_obj.set_status(sota.models.Status.REJECTED)
    update_obj.set_status(sota.models.Status.REJECTED)
    sota_logger.info("SOTA Callback Server: Cancel download request: %s.", retry_obj)
    return {u"status": 0}
Exemplo n.º 4
0
def cancel_download(retry):
    rvi_logger.info(
        'SOTA Callback Server: Cancel download request: retry: %s.', retry)
    retry_obj = None
    update_obj = None
    try:
        retry_obj = sota.models.Retry.objects.filter(pk=retry)[0]
        update_obj = retry_obj.ret_update
    except:
        rvi_logger.error(
            'SOTA Callback Server: Cancel downlaod request: Cannot access database object: %s',
            retry)
        return {u'status': 0}
    retry_obj.set_status(sota.models.Status.REJECTED)
    update_obj.set_status(sota.models.Status.REJECTED)
    sota_logger.info('SOTA Callback Server: Cancel download request: %s.',
                     retry_obj)
    return {u'status': 0}
Exemplo n.º 5
0
def download_complete(status, retry):
    rvi_logger.info("SOTA Callback Server: Download complete: retry: %s, status: %s.", retry, status)
    retry_obj = None
    update_obj = None
    try:
        retry_obj = sota.models.Retry.objects.filter(pk=retry)[0]
        update_obj = retry_obj.ret_update
    except:
        rvi_logger.error("SOTA Callback Server: Download complete: Cannot access database object: %s", retry)
        return {u"status": 0}
    if int(status) == 0:
        retry_obj.set_status(sota.models.Status.SUCCESS)
        update_obj.set_status(sota.models.Status.SUCCESS)
    else:
        retry_obj.set_status(sota.models.Status.FAILED)
        update_obj.set_status(sota.models.Status.FAILED)
    sota_logger.info("SOTA Callback Server: Download complete: retry: %s, status: %s.", retry_obj, status)
    return {u"status": 0}
Exemplo n.º 6
0
def report(timestamp, vin, data):
    logger.info(
        'Tracking Callback Server: Report request: Time: %s, VIN: %s, Data: %s.',
        timestamp, vin, data)

    # get the vehicle record from the database
    try:
        vehicle = Vehicle.objects.get(veh_vin=vin)
    except Exception as e:
        logger.error(
            "Tracking Callback Server: Cannot retrieve vehicle '%s' from database. Error: %s",
            vin, e)
        return {u'status': 0}

    location = Location()
    location.loc_vehicle = vehicle
    try:
        location.loc_time = datetime.fromtimestamp(float(timestamp))
    except:
        location.loc_time = timestamp

    if isinstance(data, str) or isinstance(data, unicode):
        logger.info('data is string')
        data = ast.literal_eval(data)

    for channel in data:
        key = channel['channel']
        value = channel['value']
        logger.info('%s: %s', key, value)
        if key == 'location':
            location.loc_latitude = value['lat']
            location.loc_longitude = value['lon']
            location.loc_altitude = value['alt']
        elif key == 'speed':
            location.loc_speed = float(value)
        elif key == 'odometer':
            location.loc_odometer = float(value)

    print 'Saving', location
    location.save()
    logger.info('Saved')

    return {u'status': 0}
Exemplo n.º 7
0
def download_complete(status, retry):
    rvi_logger.info(
        'SOTA Callback Server: Download complete: retry: %s, status: %s.',
        retry, status)
    retry_obj = None
    update_obj = None
    try:
        retry_obj = sota.models.Retry.objects.filter(pk=retry)[0]
        update_obj = retry_obj.ret_update
    except:
        rvi_logger.error(
            'SOTA Callback Server: Download complete: Cannot access database object: %s',
            retry)
        return {u'status': 0}
    if int(status) == 0:
        retry_obj.set_status(sota.models.Status.SUCCESS)
        update_obj.set_status(sota.models.Status.SUCCESS)
    else:
        retry_obj.set_status(sota.models.Status.FAILED)
        update_obj.set_status(sota.models.Status.FAILED)
    sota_logger.info(
        'SOTA Callback Server: Download complete: retry: %s, status: %s.',
        retry_obj, status)
    return {u'status': 0}
Exemplo n.º 8
0
    def run(self):
        while True:
            [package, destination, retry] = package_queue.get()
            rvi_logger.info(
                'SOTA Transmission Server: Sending package %s to %s', package,
                destination)

            # accessing database objects
            retry_obj = None
            update_obj = None
            package_obj = None
            try:
                retry_obj = sota.models.Retry.objects.filter(pk=retry)[0]
                update_obj = retry_obj.ret_update
                package_obj = update_obj.upd_package
            except Exception as e:
                rvi_logger.error(
                    'SOTA Transmission Server: Cannot access database object: %s, Error: %s',
                    retry, e)
                continue

            try:
                f = open(package_obj.pac_file.path)
            except Exception as e:
                sota_logger.error(
                    'SOTA Transmission Server: %s: Cannot open file: %s',
                    retry_obj, package_obj.pac_file.path)
                retry_obj.set_status(sota.models.Status.FAILED)
                update_obj.set_status(sota.models.Status.FAILED)
                continue

            retry_obj.set_status(sota.models.Status.RUNNING)
            update_obj.set_status(sota.models.Status.RUNNING)

            f_stat = os.stat(package_obj.pac_file.path)

            self.transaction_id += 1
            self.service_edge.message(calling_service=self.service_id,
                                      service_name=destination + "/start",
                                      transaction_id=str(self.transaction_id),
                                      timeout=int(
                                          retry_obj.get_timeout_epoch()),
                                      parameters=[{
                                          u'package': package,
                                          u'chunk_size': self.chunk_size,
                                          u'total_size': f_stat.st_size
                                      }])

            index = 0
            while True:
                msg = f.read(self.chunk_size)
                if msg == "":
                    break
                sota_logger.debug(
                    'SOTA Transmission Server: %s: Sending package: %s, chunk: %d, message size: %s',
                    retry_obj, package, index, len(msg))
                self.transaction_id += 1
                self.service_edge.message(
                    calling_service=self.service_id,
                    service_name=destination + "/chunk",
                    transaction_id=str(self.transaction_id),
                    timeout=int(retry_obj.get_timeout_epoch()),
                    parameters=[{
                        u'index': index
                    }, {
                        u'msg': base64.b64encode(msg)
                    }])
                time.sleep(0.05)
                index += 1

            f.close()

            time.sleep(1.0)

            sota_logger.info(
                'SOTA Transmission Server: %s: Finishing package: %s',
                retry_obj, package)
            self.transaction_id += 1
            self.service_edge.message(calling_service=self.service_id,
                                      service_name=destination + "/finish",
                                      transaction_id=str(self.transaction_id),
                                      timeout=int(
                                          retry_obj.get_timeout_epoch()),
                                      parameters=[{
                                          u'dummy': 0
                                      }])
Exemplo n.º 9
0
    def run(self):
        # Execution starts here
        rvi_logger.info('RVI Server: Starting...')

        conf = get_settings()

        rvi_logger.info('RVI Server: General Configuration: ' + 
            'RVI_SERVICE_EDGE_URL: '  + conf['SERVICE_EDGE_URL']  + ', ' +
            'MEDIA_ROOT: '            + conf['MEDIA_ROOT']
            )

        # setup RVI Service Edge
        rvi_logger.info('RVI Server: Setting up outbound connection to RVI Service Edge at %s', conf['SERVICE_EDGE_URL'])
        self.rvi_service_edge = jsonrpclib.Server(conf['SERVICE_EDGE_URL'])

        # SOTA Startup
        if conf['SOTA_ENABLE'] == True:
            # log SOTA configuration
            rvi_logger.info('RVI Server: SOTA Configuration: ' + 
                'RVI_SOTA_CALLBACK_URL: ' + conf['SOTA_CALLBACK_URL'] + ', ' +
                'RVI_SOTA_SERVICE_ID: '   + conf['SOTA_SERVICE_ID']   + ', ' +
                'RVI_SOTA_CHUNK_SIZE: '   + str(conf['SOTA_CHUNK_SIZE'])
                )
            # start the SOTA callback server
            try:
                rvi_logger.info('RVI Server: Starting SOTA Callback Server on %s with service id %s.', conf['SOTA_CALLBACK_URL'], conf['SOTA_SERVICE_ID'])
                self.sota_cb_server = SOTACallbackServer(self.rvi_service_edge, conf['SOTA_CALLBACK_URL'], conf['SOTA_SERVICE_ID'])
                self.sota_cb_server.start()
                rvi_logger.info('RVI Server: SOTA Callback Server started.')
            except Exception as e:
                rvi_logger.error('RVI Server: Cannot start SOTA Callback Server: %s', e)
                sys.exit(1)

            # wait for SOTA callback server to come up    
            time.sleep(0.5)

            # start SOTA Transmission Server
            try:
                rvi_logger.info('RVI Server: Starting SOTA Transmission Server.')
                self.sota_tx_server = SOTATransmissionServer(self.rvi_service_edge, conf['SOTA_SERVICE_ID'], conf['SOTA_CHUNK_SIZE'])
                self.sota_tx_server.start()
                rvi_logger.info('RVI Server: SOTA Transmission Server started.')
            except Exception as e:
                rvi_logger.error('RVI Server: Cannot start SOTA Transmission Server: %s', e)
                sys.exit(1)
    
            # wait for SOTA transmission server to come up    
            time.sleep(0.5)
            
        # Tracking Startup
        if conf['TRACKING_ENABLE'] == True:
            # log Tracking configuration
            rvi_logger.info('RVI Server: Tracking Configuration: ' + 
                'RVI_TRACKING_CALLBACK_URL: ' + conf['TRACKING_CALLBACK_URL'] + ', ' +
                'RVI_TRACKING_SERVICE_ID: '   + conf['TRACKING_SERVICE_ID']
                )
            # start the Tracking callback server
            try:
                rvi_logger.info('RVI Server: Starting Tracking Callback Server on %s with service id %s.', conf['TRACKING_CALLBACK_URL'], conf['TRACKING_SERVICE_ID'])
                self.tracking_cb_server = TrackingCallbackServer(self.rvi_service_edge, conf['TRACKING_CALLBACK_URL'], conf['TRACKING_SERVICE_ID'])
                self.tracking_cb_server.start()
                rvi_logger.info('RVI Server: Tracking Callback Server started.')
            except Exception as e:
                rvi_logger.error('RVI Server: Cannot start Tracking Callback Server: %s', e)
                sys.exit(1)

            # wait for SOTA callback server to come up    
            time.sleep(0.5)

        else:
            rvi_logger.info('RVI Server: Tracking not enabled')
        
        # Publish to Kafka Message Queue
        if conf['TRACKING_MQ_PUBLISH'] == True:
            #log kafka configuration
            rvi_logger.info('RVI Server: Publishing to Kafka Message Queue: ' + conf['TRACKING_MQ_URL'] + ' , with topic: ' + conf['TRACKING_MQ_TOPIC'])

            #Start the Kafka message queue forwarding server
            try:
                rvi_logger.info('%s: Publishing to message queue enabled.', self.__class__.__name__)
                self.mq_sink_server = MQSinkServer(self.rvi_service_edge, conf['TRACKING_CALLBACK_URL'], conf['TRACKING_SERVICE_ID'])
                self.mq_sink_server.start()
                rvi_logger.info('RVI Server: Message Queue Server started.')
            except Exception as e:
                rvi_logger.error('RVI Server: Cannot start Message Queue Server: %s', e)
                sys.exit(1)

        else:
            rvi_logger.info('RVI Server: MQ Publish not enabled')

        # Save message Queue contents into HBase
        if conf['TRACKING_MQ_HBASE'] == True:
            rvi_logger.info('RVI Server: Saving to HBase: ' + conf['TRACKING_MQ_HBASE_URL'])
           
            #Start HBase Server thread
            try:
                rvi_logger.info('%s: Saving messages to HBase enabled.', self.__class__.__name__)
                self.hbase_server = HBaseServer(conf['TRACKING_MQ_URL'],conf['TRACKING_MQ_TOPIC'],conf['TRACKING_MQ_HBASE_URL'], conf['TRACKING_MQ_HBASE_PORT'], conf['TRACKING_MQ_HBASE_TABLE']) 
                self.hbase_server.start()
                rvi_logger.info('RVI Server: Kafka -> HBase consumer started.')
            except Exception as e:
                rvi_logger.error('RVI Server: Cannot start HBase Server: %s', e)
                sys.exit(1)
        else:
            rvi_logger.info('RVI Server: HBase server storage not enabled')
        
        # catch signals for proper shutdown
        for sig in (SIGABRT, SIGTERM, SIGINT):
            signal(sig, self.cleanup)

        # main execution loop
        timeout = conf['DB_CLOSE_TIMEOUT']
        while True:
            try:
                time.sleep(conf['DB_PING_INTERVAL'])
                # If we are idle too long the database server may
                # close the connection on us, ping the server to check if
                # the connection is still up.
                if (connection.connection is not None):
                    if (connection.is_usable() == True): 
                        rvi_logger.debug('RVI Server: Database connection is up.')
                        # Close connection if open longer than the timeout
                        timeout -= conf['DB_PING_INTERVAL']
                        if (timeout <= 0):
                            connection.close()
                            timeout = conf['DB_CLOSE_TIMEOUT']
                            rvi_logger.info('RVI Server: Idle Timeout: closed database connection.')
                    else:
                        rvi_logger.error('RVI Server: Database connection is down.')
                        connection.close()
                elif (conf['TRACKING_MQ_PUBLISH'] == True and conf['TRACKING_ENABLE'] == False):
                    pass
                else:    
                    rvi_logger.error('RVI Server: Database connection is closed.')
                    # As long as the connection is closed reset the timeout
                    timeout = conf['DB_CLOSE_TIMEOUT']
                    
            except KeyboardInterrupt:
                print ('\n')
                break
Exemplo n.º 10
0
    def run(self):
        # Execution starts here
        rvi_logger.info('RVI Server: Starting...')

        conf = get_settings()

        rvi_logger.info('RVI Server: General Configuration: ' +
                        'RVI_SERVICE_EDGE_URL: ' + conf['SERVICE_EDGE_URL'] +
                        ', ' + 'MEDIA_ROOT: ' + conf['MEDIA_ROOT'])

        # setup RVI Service Edge
        rvi_logger.info(
            'RVI Server: Setting up outbound connection to RVI Service Edge at %s',
            conf['SERVICE_EDGE_URL'])
        self.rvi_service_edge = jsonrpclib.Server(conf['SERVICE_EDGE_URL'])

        # SOTA Startup
        if conf['SOTA_ENABLE'] == True:
            # log SOTA configuration
            rvi_logger.info('RVI Server: SOTA Configuration: ' +
                            'RVI_SOTA_CALLBACK_URL: ' +
                            conf['SOTA_CALLBACK_URL'] + ', ' +
                            'RVI_SOTA_SERVICE_ID: ' + conf['SOTA_SERVICE_ID'] +
                            ', ' + 'RVI_SOTA_CHUNK_SIZE: ' +
                            str(conf['SOTA_CHUNK_SIZE']))
            # start the SOTA callback server
            try:
                rvi_logger.info(
                    'RVI Server: Starting SOTA Callback Server on %s with service id %s.',
                    conf['SOTA_CALLBACK_URL'], conf['SOTA_SERVICE_ID'])
                self.sota_cb_server = SOTACallbackServer(
                    self.rvi_service_edge, conf['SOTA_CALLBACK_URL'],
                    conf['SOTA_SERVICE_ID'])
                self.sota_cb_server.start()
                rvi_logger.info('RVI Server: SOTA Callback Server started.')
            except Exception as e:
                rvi_logger.error(
                    'RVI Server: Cannot start SOTA Callback Server: %s', e)
                sys.exit(1)

            # wait for SOTA callback server to come up
            time.sleep(0.5)

            # start SOTA Transmission Server
            try:
                rvi_logger.info(
                    'RVI Server: Starting SOTA Transmission Server.')
                self.sota_tx_server = SOTATransmissionServer(
                    self.rvi_service_edge, conf['SOTA_SERVICE_ID'],
                    conf['SOTA_CHUNK_SIZE'])
                self.sota_tx_server.start()
                rvi_logger.info(
                    'RVI Server: SOTA Transmission Server started.')
            except Exception as e:
                rvi_logger.error(
                    'RVI Server: Cannot start SOTA Transmission Server: %s', e)
                sys.exit(1)

            # wait for SOTA transmission server to come up
            time.sleep(0.5)

        # Tracking Startup
        if conf['TRACKING_ENABLE'] == True:
            # log Tracking configuration
            rvi_logger.info('RVI Server: Tracking Configuration: ' +
                            'RVI_TRACKING_CALLBACK_URL: ' +
                            conf['TRACKING_CALLBACK_URL'] + ', ' +
                            'RVI_TRACKING_SERVICE_ID: ' +
                            conf['TRACKING_SERVICE_ID'])
            # start the Tracking callback server
            try:
                rvi_logger.info(
                    'RVI Server: Starting Tracking Callback Server on %s with service id %s.',
                    conf['TRACKING_CALLBACK_URL'], conf['TRACKING_SERVICE_ID'])
                self.tracking_cb_server = TrackingCallbackServer(
                    self.rvi_service_edge, conf['TRACKING_CALLBACK_URL'],
                    conf['TRACKING_SERVICE_ID'])
                self.tracking_cb_server.start()
                rvi_logger.info(
                    'RVI Server: Tracking Callback Server started.')
            except Exception as e:
                rvi_logger.error(
                    'RVI Server: Cannot start Tracking Callback Server: %s', e)
                sys.exit(1)

            # wait for SOTA callback server to come up
            time.sleep(0.5)

        else:
            rvi_logger.info('RVI Server: Tracking not enabled')

        # Publish to Kafka Message Queue
        if conf['TRACKING_MQ_PUBLISH'] == True:
            #log kafka configuration
            rvi_logger.info('RVI Server: Publishing to Kafka Message Queue: ' +
                            conf['TRACKING_MQ_URL'] + ' , with topic: ' +
                            conf['TRACKING_MQ_TOPIC'])

            #Start the Kafka message queue forwarding server
            try:
                rvi_logger.info('%s: Publishing to message queue enabled.',
                                self.__class__.__name__)
                self.mq_sink_server = MQSinkServer(
                    self.rvi_service_edge, conf['TRACKING_CALLBACK_URL'],
                    conf['TRACKING_SERVICE_ID'])
                self.mq_sink_server.start()
                rvi_logger.info('RVI Server: Message Queue Server started.')
            except Exception as e:
                rvi_logger.error(
                    'RVI Server: Cannot start Message Queue Server: %s', e)
                sys.exit(1)

        else:
            rvi_logger.info('RVI Server: MQ Publish not enabled')

        # Save message Queue contents into HBase
        if conf['TRACKING_MQ_HBASE'] == True:
            rvi_logger.info('RVI Server: Saving to HBase: ' +
                            conf['TRACKING_MQ_HBASE_URL'])

            #Start HBase Server thread
            try:
                rvi_logger.info('%s: Saving messages to HBase enabled.',
                                self.__class__.__name__)
                self.hbase_server = HBaseServer(
                    conf['TRACKING_MQ_URL'], conf['TRACKING_MQ_TOPIC'],
                    conf['TRACKING_MQ_HBASE_URL'],
                    conf['TRACKING_MQ_HBASE_PORT'],
                    conf['TRACKING_MQ_HBASE_TABLE'])
                self.hbase_server.start()
                rvi_logger.info('RVI Server: Kafka -> HBase consumer started.')
            except Exception as e:
                rvi_logger.error('RVI Server: Cannot start HBase Server: %s',
                                 e)
                sys.exit(1)
        else:
            rvi_logger.info('RVI Server: HBase server storage not enabled')

        # catch signals for proper shutdown
        for sig in (SIGABRT, SIGTERM, SIGINT):
            signal(sig, self.cleanup)

        # main execution loop
        timeout = conf['DB_CLOSE_TIMEOUT']
        while True:
            try:
                time.sleep(conf['DB_PING_INTERVAL'])
                # If we are idle too long the database server may
                # close the connection on us, ping the server to check if
                # the connection is still up.
                if (connection.connection is not None):
                    if (connection.is_usable() == True):
                        rvi_logger.debug(
                            'RVI Server: Database connection is up.')
                        # Close connection if open longer than the timeout
                        timeout -= conf['DB_PING_INTERVAL']
                        if (timeout <= 0):
                            connection.close()
                            timeout = conf['DB_CLOSE_TIMEOUT']
                            rvi_logger.info(
                                'RVI Server: Idle Timeout: closed database connection.'
                            )
                    else:
                        rvi_logger.error(
                            'RVI Server: Database connection is down.')
                        connection.close()
                elif (conf['TRACKING_MQ_PUBLISH'] == True
                      and conf['TRACKING_ENABLE'] == False):
                    pass
                else:
                    rvi_logger.error(
                        'RVI Server: Database connection is closed.')
                    # As long as the connection is closed reset the timeout
                    timeout = conf['DB_CLOSE_TIMEOUT']

            except KeyboardInterrupt:
                print('\n')
                break
Exemplo n.º 11
0
    def run(self):
        while True:
            [package, destination, retry] = package_queue.get()
            rvi_logger.info("SOTA Transmission Server: Sending package %s to %s", package, destination)

            # accessing database objects
            retry_obj = None
            update_obj = None
            package_obj = None
            try:
                retry_obj = sota.models.Retry.objects.filter(pk=retry)[0]
                update_obj = retry_obj.ret_update
                package_obj = update_obj.upd_package
            except Exception as e:
                rvi_logger.error("SOTA Transmission Server: Cannot access database object: %s, Error: %s", retry, e)
                continue

            try:
                f = open(package_obj.pac_file.path)
            except Exception as e:
                sota_logger.error(
                    "SOTA Transmission Server: %s: Cannot open file: %s", retry_obj, package_obj.pac_file.path
                )
                retry_obj.set_status(sota.models.Status.FAILED)
                update_obj.set_status(sota.models.Status.FAILED)
                continue

            retry_obj.set_status(sota.models.Status.RUNNING)
            update_obj.set_status(sota.models.Status.RUNNING)

            f_stat = os.stat(package_obj.pac_file.path)

            self.transaction_id += 1
            self.service_edge.message(
                calling_service=self.service_id,
                service_name=destination + "/start",
                transaction_id=str(self.transaction_id),
                timeout=int(retry_obj.get_timeout_epoch()),
                parameters=[{u"package": package, u"chunk_size": self.chunk_size, u"total_size": f_stat.st_size}],
            )

            index = 0
            while True:
                msg = f.read(self.chunk_size)
                if msg == "":
                    break
                sota_logger.debug(
                    "SOTA Transmission Server: %s: Sending package: %s, chunk: %d, message size: %s",
                    retry_obj,
                    package,
                    index,
                    len(msg),
                )
                self.transaction_id += 1
                self.service_edge.message(
                    calling_service=self.service_id,
                    service_name=destination + "/chunk",
                    transaction_id=str(self.transaction_id),
                    timeout=int(retry_obj.get_timeout_epoch()),
                    parameters=[{u"index": index}, {u"msg": base64.b64encode(msg)}],
                )
                time.sleep(0.05)
                index += 1

            f.close()

            time.sleep(1.0)

            sota_logger.info("SOTA Transmission Server: %s: Finishing package: %s", retry_obj, package)
            self.transaction_id += 1
            self.service_edge.message(
                calling_service=self.service_id,
                service_name=destination + "/finish",
                transaction_id=str(self.transaction_id),
                timeout=int(retry_obj.get_timeout_epoch()),
                parameters=[{u"dummy": 0}],
            )