We are moving! We are currently migrating our community to the new Bosch Connected Industry Online Portal. The community will be available latest in the new year again, until then it will be in read-only mode. Click here for more information.
07-15-2022 06:52 PM - edited 07-15-2022 09:47 PM
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
07-29-2022 01:52 AM
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.