<commit_before>//
//  MeshSetupFraming.swift
//  Particle Mesh
//
//  Created by <NAME> on 5/1/18.
//  Copyright © 2018 Nordic Semiconductor. All rights reserved.
//

import Foundation


public enum ControlRequestMessageType: UInt16 {
    case Auth = 1001
    case GetDeviceId = 20
    case SetClaimCode = 200
    case GetSerialNumber = 21
    case GetConnectionStatus = 300
    case IsClaimed = 201
    case SetSecurityKey = 210
    case GetSecurityKey = 211
    case CreateNetwork = 1002
    case StartCommissioner = 1003
    case StopCommissioner = 1004
    case StartListening = 70
    case StopListening = 71
    case DeviceSetupDone = 73
    case IsDeviceSetupDone = 74
    case PrepareJoiner = 1005
    case AddJoiner = 1006
    case RemoveJoiner = 1007
    case JoinNetwork = 1008
    case LeaveNetwork = 1009
    case GetNetworkInfo = 1010
    case ScanNetworks = 1011
    case Test = 1111
    
}

public enum ControlRequestErrorType: Int32 {
    case NONE = 0
    case UNKNOWN = -100
    case BUSY = -110
    case NOT_SUPPORTED = -120
    case NOT_ALLOWED = -130
    case CANCELLED = -140
    case ABORTED = -150
    case TIMEOUT = -160
    case NOT_FOUND = -170
    case ALREADY_EXISTS = -180
    case TOO_LARGE = -190
    case LIMIT_EXCEEDED = -200
    case INVALID_STATE = -210
    case IO = -220
    case NETWORK = -230
    case PROTOCOL =  -240
    case INTERNAL = -250
    case NO_MEMORY = -260
    case INVALID_ARGUMENT = -270
    case BAD_DATA = -280
    case OUT_OF_RANGE = -290
    
    case INVALID_UNKNOWN = -9999
    
    func description() -> String {
        switch self {
            case .NONE: return "OK"
            case .INVALID_ARGUMENT: return "Invalid parameter"
            case .TIMEOUT: return "Time out"
            case .NOT_FOUND: return "Not found"
            case .ALREADY_EXISTS: return "Already exists"
            case .INVALID_STATE: return "Invalid state"
            case .NO_MEMORY: return "No memory"
            case .NOT_ALLOWED: return "Not allowed"
            default: return "Unknown error"
        }
    }
    
}



public struct RequestMessage {
    static let FRAME_EXTRA_BYTES: Int16 = 16

    var id: UInt16
    var type: ControlRequestMessageType
    var data: Data
}



public struct ReplyMessage {
    static let FRAME_EXTRA_BYTES: Int16 = 16

    var id: UInt16
    var result: ControlRequestErrorType
    var data: Data?
}<commit_msg>delete not used request types<commit_after>//
//  MeshSetupFraming.swift
//  Particle Mesh
//
//  Created by <NAME> on 5/1/18.
//  Maintained by <NAME>
//  Copyright © 2018 Particle. All rights reserved.
//

import Foundation


public enum ControlRequestMessageType: UInt16 {
    case Auth = 1001
    case GetDeviceId = 20
    case SetClaimCode = 200
    case GetSerialNumber = 21
    case GetConnectionStatus = 300
    case IsClaimed = 201
    case CreateNetwork = 1002
    case StartCommissioner = 1003
    case StopCommissioner = 1004
    case StartListening = 70
    case StopListening = 71
    case DeviceSetupDone = 73
    case IsDeviceSetupDone = 74
    case PrepareJoiner = 1005
    case AddJoiner = 1006
    case RemoveJoiner = 1007
    case JoinNetwork = 1008
    case LeaveNetwork = 1009
    case GetNetworkInfo = 1010
    case ScanNetworks = 1011
}

public enum ControlReplyErrorType: Int32 {
    case NONE = 0
    case UNKNOWN = -100
    case BUSY = -110
    case NOT_SUPPORTED = -120
    case NOT_ALLOWED = -130
    case CANCELLED = -140
    case ABORTED = -150
    case TIMEOUT = -160
    case NOT_FOUND = -170
    case ALREADY_EXISTS = -180
    case TOO_LARGE = -190
    case LIMIT_EXCEEDED = -200
    case INVALID_STATE = -210
    case IO = -220
    case NETWORK = -230
    case PROTOCOL =  -240
    case INTERNAL = -250
    case NO_MEMORY = -260
    case INVALID_ARGUMENT = -270
    case BAD_DATA = -280
    case OUT_OF_RANGE = -290
    
    case INVALID_UNKNOWN = -9999
    
    func description() -> String {
        switch self {
            case .NONE: return "OK"
            case .INVALID_ARGUMENT: return "Invalid parameter"
            case .TIMEOUT: return "Time out"
            case .NOT_FOUND: return "Not found"
            case .ALREADY_EXISTS: return "Already exists"
            case .INVALID_STATE: return "Invalid state"
            case .NO_MEMORY: return "No memory"
            case .NOT_ALLOWED: return "Not allowed"
            default: return "Unknown error"
        }
    }
    
}



public struct RequestMessage {
    static let FRAME_EXTRA_BYTES: Int16 = 16

    var id: UInt16
    var type: ControlRequestMessageType
    var data: Data
}



public struct ReplyMessage {
    static let FRAME_EXTRA_BYTES: Int16 = 16

    var id: UInt16
    var result: ControlReplyErrorType
    var data: Data
}
{'fraction_non_alphanumeric': 0.06582278481012659, 'fraction_numerical': 0.0670886075949367, 'mean_word_length': 2.2428180574555405, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6942480', 'n_tokens_mistral': 1742, 'n_tokens_neox': 1472, 'n_words': 485}