csa = bleChannelSelection (“算法”2);
csa。AccessAddress =“8 e89bed6”;
csa。UsedChannels = (0:36);
numConnectionEvents = 10;
为我= 1:numConnectionEvents
频道= csa ();
流(“事件计数器:% d,所选频道:% d \ n ',csa。EventCounter、通道);
结束
函数channelIndex = nextHop (obj)
channelIndex = 0;
obj。EventCounter = obj。EventCounter + 1;
如果(obj。EventCounter > intmax (“uint16”))
obj。EventCounter = 1;
结束
开关(obj.Algorithm)
情况下1
unmappedChannel =国防部((…
obj。pLastUnmappedChannel + obj.HopIncrement), 37);
如果~ obj。ChannelMap (unmappedChannel + 1)
remapTable =找到(obj.ChannelMap) - 1;
remapIndex =国防部(unmappedChannel nnz (obj.ChannelMap)) + 1;
channelIndex = remapTable (remapIndex);
其他的
channelIndex = unmappedChannel;
结束
obj。pLastUnmappedChannel = unmappedChannel;
obj。ChannelIndex = ChannelIndex;
情况下2
binAccessAddress = comm.internal.utilities.de2biBase2RightMSB (…
hex2dec (obj.AccessAddress), 32);
channelID = xor (binAccessAddress (1:16), binAccessAddress (17:32));
randomNumber = obj.generatePseudoRandomNumber (…
comm.internal.utilities.de2biBase2RightMSB (…
obj。EventCounter、16) channelID);
unmappedChannel = mod (randomNumber, 37);
如果~ obj。ChannelMap (unmappedChannel + 1)
remapTable =找到(obj.ChannelMap) - 1;
remapIndex =地板(…
(nnz (obj.ChannelMap) * randomNumber) / (2 ^ 16)) + 1;
channelIndex = remapTable (remapIndex);
其他的
channelIndex = unmappedChannel;
结束
obj。ChannelIndex = ChannelIndex;
结束
结束