El código de ejemplo de C# se adjunta para la configuración de TNA con 'TNA required' y por usuario.

La prueba de código se realiza con 2.6.3.16 y 2.6.3.19 + N2 FW 1.2.0.

 

Para obtener más información, consulte el enlace - BS2_SetTNAConfig 



 public void TNAConfigTest(IntPtr sdkContext, UInt32 deviceID, bool isMasterDevice)        {
            string ipAddress = "192.168.13.201";// "192.168.13.195";            IntPtr ptrIPAddr = Marshal.StringToHGlobalAnsi(ipAddress);            ushort port = 51211;            uint deviceId = 0;
            IntPtr versionPtr = API.BS2_Version();            Console.WriteLine("SDK version : {0}" + Marshal.PtrToStringAnsi(versionPtr));
             IntPtr context = IntPtr.Zero;            context = API.BS2_AllocateContext();            if (context == null) //Returns NULL when there is not enough system memory            {
                //textBox1.Text = "No memory!";
                Console.WriteLine("No memory!");            }            else // if not, returns the allocated Context.            {                //textBox1.Text = "Allocate context successfully";
                Console.WriteLine("Allocate context successfully");
            }            BS2ErrorCode result = (BS2ErrorCode)API.BS2_Initialize(context);            if (result == BS2ErrorCode.BS_SDK_SUCCESS)            {                Console.WriteLine("Initialization succeeded");
            }            else            {                Console.WriteLine("failed to initialize error code");                //textBox1.Text = "failed to initialize error code";
            }            result = (BS2ErrorCode)API.BS2_ConnectDeviceViaIP(context, ptrIPAddr, port, out deviceId);
            if (result == BS2ErrorCode.BS_SDK_SUCCESS)            {                Console.WriteLine("Connecting to device succeeded");                Console.ReadKey();
            }            else            {                Console.WriteLine("Connecting to device failed : {0}", result);                Console.ReadKey();            }
             BS2TNAConfig tnaConfig = Util.AllocateStructure<BS2TNAConfig>();            tnaConfig.tnaInfo.tnaMode = 1; // by user            tnaConfig.tnaInfo.tnaKey = 0; // not specified because of tnaMode = by user            tnaConfig.tnaInfo.tnaRequired = 1;
             //label name - 2
            Array.Clear(tnaConfig.tnaExtInfo.tnaLabel, 0, BS2Environment.BS2_MAX_TNA_KEY * BS2Environment.BS2_MAX_TNA_LABEL_LEN);
             Console.WriteLine("Do you want to set 1st lebel name? [Y/n]");            Console.Write(">>>> ");            if (Util.IsYes())            {                Console.WriteLine("Enter the 1st label name");                Console.Write(">>>> ");                string lebelname = Console.ReadLine();                if (lebelname.Length == 0)                {                    Console.WriteLine("[Warning] label name will be displayed as empty.");                }                else if (lebelname.Length > BS2Environment.BS2_MAX_TNA_LABEL_LEN)                {                    Console.WriteLine("The label name should less than {0} words.", BS2Environment.BS2_MAX_TNA_LABEL_LEN);                    return;                }                else                {                    byte[] LabelNameArray = Encoding.UTF8.GetBytes(lebelname);                    Array.Copy(LabelNameArray, tnaConfig.tnaExtInfo.tnaLabel, LabelNameArray.Length);                }            }
             result = (BS2ErrorCode)API.BS2_SetTNAConfig(context, deviceId, ref tnaConfig);            if (result != BS2ErrorCode.BS_SDK_SUCCESS)            {                Console.WriteLine("Got error({0}).", result);
            }            else            {                Console.WriteLine("TNA is configured successfully", result);            }        }