Developer Portal Community

    cancel
    Showing results for 
    Search instead for 
    Did you mean: 

    only first packet from MTProtocol for GLM165-27C

    Sergem
    New Poster

    only first packet from MTProtocol for GLM165-27C

    I used DeviceConnect sample code from "The Bosch GLM/PLR Bluetooth App Kit" to add BoschGLM support into my framework.

    I connected CBPeripheral (save it strong var), created MTDataExchengeService:

     

     

    fileprivate func createDataExchangeService(peripheral: CBPeripheral) -> Bool {
            guard let dataExchangeService = MTDataExchangeService.dataExchangeService(with: peripheral) as? MTDataExchangeService else {
                return false
            }
            self.dataExchangeService = dataExchangeService
            dataExchangeService.delegate = self
            dataExchangeService.isConnectedToGLM = isGLM
            dataExchangeService.serviceUUID = type(of: self).dataServiceUUID.uuidString
            dataExchangeService.charectristicsRXUUID = type(of: self).receiveCharacteristicUUID?.uuidString
            dataExchangeService.charectristicsTXUUID = type(of: self).sendCharacteristicUUID?.uuidString
            dataExchangeService.initialize()
            return true
        }

     

     

     and added MTProtocol

     

     

    func dataExchangeService(_ service: MTDataExchangeService!, didInitilizeWithError error: Error!) {
            if let error = error {
                dlog("[Bosch] Initializitaion callback: \(error)")
                disconnect { _ in }
            } else {
                dlog("[Bosch] Initializitaion callback: init completed, no error.")
                self.mtProtocol = MTProtocol.`protocol`() as! MTProtocol
                self.mtProtocol.connection = service
                self.mtProtocol.delegate = self
                service.delegate = self.mtProtocol
                
                dlog("[Bosch] MTProtocol ready ... \(mtProtocol.isReady)")
                turnOnAutoSync()
            }
        }

     

     

    turnOnAutoSync is method from AppKit sample and for GLM165 it send the following request:

     

                let message = MTExchangeDataOutputMessage.message() as! MTExchangeDataOutputMessage
                message.syncControl = MODE_AUTOSYNC_CONTROL_ON
                self.mtProtocol.sendRequest(message)

     

     But into MTProtocolDelegate:

     

     

    func `protocol`(_ protocol: MTProtocol!, didReceive message: MTMessage!) {
            dlog("[Bosch] MMProtocol didReceiveMessage: \(message.description)")
            ....
    }

     

    I got only 1 packet for 1st measurement after connect, and no more - other measurement nothing posting

    [10:01:50.110] [Bosch] MMProtocol didReceiveMessage: MTExchangeDataInputMessage
    mode: 0
    distReference: 0
    errorStatus: 0
    laserOn: 0
    temperatureWarning: 0
    batteryWarning: 0
    measurementId: 25
    result: 0.000000
    component1: 0.000000
    component2: 0.000000

    When testings DeviceConnect with the same GLM165-27C, I get 2 packets for each measurement, like:

    [15:07:19.196] MMProtocol didReceiveMessage: MTExchangeDataInputMessage
    mode: 1
    distReference: 0
    errorStatus: 0
    laserOn: 0
    temperatureWarning: 0
    batteryWarning: 0
    measurementId: 17
    result: 3.278450
    component1: 0.000000
    component2: 0.000000
    [15:07:23.336] MMProtocol didReceiveMessage: MTExchangeDataInputMessage
    mode: 0
    distReference: 0
    errorStatus: 0
    laserOn: 1
    temperatureWarning: 0
    batteryWarning: 0
    measurementId: 17
    result: 0.000000
    component1: 0.000000
    component2: 0.000000

    What could be the reason for this problem?

    UPD: it looks like first packet with mode, laserOn and resultValue set to zeros is response on turnOnAutoSync (MODE_AUTOSYNC_CONTROL_ON), so my app doesn't get measurements at all

    1 REPLY 1
    pdo
    Community Manager
    Community Manager

    Re: only first packet from MTProtocol for GLM165-27C

    Hi Sergem, sorry for the delay, I checked on this question,

    Answer was: Only triggered measurements (with button on device or remote trigger) are transmitted, even if GLM 165-27 C/CG devices are initially in continuous mode by default (Continuous mode: When GLM is on, currently measured distance is always displayed on the GLM). This could give the impression that these values are actually measured and should be automatically transmitted. However, this is not the case - measurements must be triggered and are only then transmitted accordingly.

    Icon--AD-black-48x48Icon--address-consumer-data-black-48x48Icon--appointment-black-48x48Icon--back-left-black-48x48Icon--calendar-black-48x48Icon--center-alignedIcon--Checkbox-checkIcon--clock-black-48x48Icon--close-black-48x48Icon--compare-black-48x48Icon--confirmation-black-48x48Icon--dealer-details-black-48x48Icon--delete-black-48x48Icon--delivery-black-48x48Icon--down-black-48x48Icon--download-black-48x48Ic-OverlayAlertIcon--externallink-black-48x48Icon-Filledforward-right_adjustedIcon--grid-view-black-48x48IC_gd_Check-Circle170821_Icons_Community170823_Bosch_Icons170823_Bosch_Icons170821_Icons_CommunityIC-logout170821_Icons_Community170825_Bosch_Icons170821_Icons_CommunityIC-shopping-cart2170821_Icons_CommunityIC-upIC_UserIcon--imageIcon--info-i-black-48x48Icon--left-alignedIcon--Less-minimize-black-48x48Icon-FilledIcon--List-Check-grennIcon--List-Check-blackIcon--List-Cross-blackIcon--list-view-mobile-black-48x48Icon--list-view-black-48x48Icon--More-Maximize-black-48x48Icon--my-product-black-48x48Icon--newsletter-black-48x48Icon--payment-black-48x48Icon--print-black-48x48Icon--promotion-black-48x48Icon--registration-black-48x48Icon--Reset-black-48x48Icon--right-alignedshare-circle1Icon--share-black-48x48Icon--shopping-bag-black-48x48Icon-shopping-cartIcon--start-play-black-48x48Icon--store-locator-black-48x48Ic-OverlayAlertIcon--summary-black-48x48tumblrIcon-FilledvineIc-OverlayAlertwhishlist