11using Kveer . XBeeApi . Utils ;
22using System ;
33using System . Collections . Generic ;
4+ using System . Diagnostics . Contracts ;
45using System . Linq ;
56
67namespace Kveer . XBeeApi . Packet
@@ -28,6 +29,7 @@ public enum APIFrameType : byte
2829 IO_DATA_SAMPLE_RX_INDICATOR = 0x92 ,
2930 REMOTE_AT_COMMAND_RESPONSE = 0x97 ,
3031 GENERIC = 0xFF ,
32+ UNKNOWN = 0xfe
3133 }
3234
3335 public static class APIFrameTypeExtensions
@@ -69,14 +71,15 @@ public static APIFrameType Get(this APIFrameType dumb, byte value)
6971 if ( values . Cast < byte > ( ) . Contains ( value ) )
7072 return ( APIFrameType ) value ;
7173
72- return APIFrameType . GENERIC ;
74+ return APIFrameType . UNKNOWN ;
7375 }
7476
7577 /// <summary>
7678 /// Gets the API frame type value.
7779 /// </summary>
7880 /// <param name="source"></param>
7981 /// <returns>The API frame type value.</returns>
82+ [ Pure ]
8083 public static byte GetValue ( this APIFrameType source )
8184 {
8285 return ( byte ) source ;
@@ -89,7 +92,7 @@ public static byte GetValue(this APIFrameType source)
8992 /// <returns>The API frame type name.</returns>
9093 public static string GetName ( this APIFrameType source )
9194 {
92- return lookupTable [ source ] ;
95+ return lookupTable . ContainsKey ( source ) ? lookupTable [ source ] : source . ToString ( ) ;
9396 }
9497
9598 public static string ToDisplayString ( this APIFrameType source )
0 commit comments