Skip to content

17 Megnet (Angle Correction) ​

The mobile phone sends a sesame5 angle correction command. After the correction is completed, it responds successfully, and the sesame5 actively sends mechstatus (mechanical status)

For details on mechStatus, please refer to the 80_mechStatus description

Sequence Diagram ​

Mobile Sends Data ​

Byte0
Dataitem code

item code: SSM2_ITEM_CODE_MAGNET (17)

ssm5 Response Content ​

Byte210
Dataresitem_codetype
DescriptionCommand Handling StatusInstruction NumberPush Type

type: SSM2_OP_CODE_RESPONSE (0x07)

item code: SSM2_ITEM_CODE_MAGNET (17)

res: CMD_RESULT_SUCCESS (0x00)

iOS, Android, ESP32 Examples ​

Android Example ​

java
    override fun magnet(result: CHResult<CHEmpty>) {
        if (checkBle(result)) return
        sendCommand(SesameOS3Payload(SesameItemCode.magnet.value, byteArrayOf()), DeviceSegmentType.cipher) { res ->
            result.invoke(Result.success(CHResultState.CHResultStateBLE(CHEmpty())))
        }
    }

iOS Example ​

jsx
    func magnet(result: @escaping (CHResult<CHEmpty>)) {
        if(checkBle(result)){return}

        sendCommand(.init(.magnet)) { responsePayload in
            if responsePayload.cmdResultCode == .success {
                result(.success(CHResultStateBLE(input: CHEmpty())))
            } else {
                result(.failure(self.errorFromResultCode(responsePayload.cmdResultCode)))
            }
        }
    }

ESP Example ​

jsx
if (src_id == SSM2_ITEM_CODE_MAGNET) {
        app_ss5_magnet();// measure and update magnet angle
        tell_device_status_to_mobile();// announce the angle again
    }
if (cmd_it_code == SSM2_ITEM_CODE_MAGNET) {
    talk_to_mobile(mobile, SSM2_SEG_PARSING_TYPE_CIPHERTEXT, (uint8_t *) ss5_res,
                                   offsetof(ss5_response, payload));
}