1*2c4f9bbbSMatthias Ringwald /******************************************************************************* 2*2c4f9bbbSMatthias Ringwald * 3*2c4f9bbbSMatthias Ringwald * queue 4*2c4f9bbbSMatthias Ringwald * 5*2c4f9bbbSMatthias Ringwald * Copyright (c) 2018, Raccon BLE Sniffer 6*2c4f9bbbSMatthias Ringwald * All rights reserved. 7*2c4f9bbbSMatthias Ringwald * 8*2c4f9bbbSMatthias Ringwald * Redistribution and use in source and binary forms, with or without 9*2c4f9bbbSMatthias Ringwald * modification, are permitted provided that the following conditions are 10*2c4f9bbbSMatthias Ringwald * met: 11*2c4f9bbbSMatthias Ringwald * 12*2c4f9bbbSMatthias Ringwald * * Redistributions of source code must retain the above copyright 13*2c4f9bbbSMatthias Ringwald * notice, this list of conditions and the following disclaimer. 14*2c4f9bbbSMatthias Ringwald * * Redistributions in binary form must reproduce the above 15*2c4f9bbbSMatthias Ringwald * copyright notice, this list of conditions and the following disclaimer 16*2c4f9bbbSMatthias Ringwald * in the documentation and/or other materials provided with the 17*2c4f9bbbSMatthias Ringwald * distribution. 18*2c4f9bbbSMatthias Ringwald * * Neither the name of "btlejack2" nor the names of its 19*2c4f9bbbSMatthias Ringwald * contributors may be used to endorse or promote products derived from 20*2c4f9bbbSMatthias Ringwald * this software without specific prior written permission. 21*2c4f9bbbSMatthias Ringwald * 22*2c4f9bbbSMatthias Ringwald * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23*2c4f9bbbSMatthias Ringwald * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24*2c4f9bbbSMatthias Ringwald * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 25*2c4f9bbbSMatthias Ringwald * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 26*2c4f9bbbSMatthias Ringwald * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 27*2c4f9bbbSMatthias Ringwald * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 28*2c4f9bbbSMatthias Ringwald * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 29*2c4f9bbbSMatthias Ringwald * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 30*2c4f9bbbSMatthias Ringwald * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31*2c4f9bbbSMatthias Ringwald * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 32*2c4f9bbbSMatthias Ringwald * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33*2c4f9bbbSMatthias Ringwald * 34*2c4f9bbbSMatthias Ringwald *******************************************************************************/ 35*2c4f9bbbSMatthias Ringwald 36*2c4f9bbbSMatthias Ringwald #include <stdint.h> 37*2c4f9bbbSMatthias Ringwald 38*2c4f9bbbSMatthias Ringwald 39*2c4f9bbbSMatthias Ringwald typedef struct { 40*2c4f9bbbSMatthias Ringwald uint8_t chMap[5]; 41*2c4f9bbbSMatthias Ringwald uint8_t hopIncrement; 42*2c4f9bbbSMatthias Ringwald uint8_t chRemap[37]; 43*2c4f9bbbSMatthias Ringwald uint8_t chCnt; 44*2c4f9bbbSMatthias Ringwald // csa1 45*2c4f9bbbSMatthias Ringwald uint8_t currentCh; 46*2c4f9bbbSMatthias Ringwald // csa2 47*2c4f9bbbSMatthias Ringwald uint16_t channelIdentifier; 48*2c4f9bbbSMatthias Ringwald } hopping_t; 49*2c4f9bbbSMatthias Ringwald 50*2c4f9bbbSMatthias Ringwald 51*2c4f9bbbSMatthias Ringwald /** 52*2c4f9bbbSMatthias Ringwald * @brief init hopping instance 53*2c4f9bbbSMatthias Ringwald */ 54*2c4f9bbbSMatthias Ringwald void hopping_init( hopping_t *c ); 55*2c4f9bbbSMatthias Ringwald 56*2c4f9bbbSMatthias Ringwald /* 57*2c4f9bbbSMatthias Ringwald * @brief set list of used channels 58*2c4f9bbbSMatthias Ringwald * @param channel_map 59*2c4f9bbbSMatthias Ringwald */ 60*2c4f9bbbSMatthias Ringwald void hopping_set_channel_map( hopping_t *c, const uint8_t *chm); 61*2c4f9bbbSMatthias Ringwald 62*2c4f9bbbSMatthias Ringwald // Channel Selection Algorithm #1 63*2c4f9bbbSMatthias Ringwald 64*2c4f9bbbSMatthias Ringwald /* 65*2c4f9bbbSMatthias Ringwald * @brief set hop increment 66*2c4f9bbbSMatthias Ringwald */ 67*2c4f9bbbSMatthias Ringwald void hopping_csa1_set_hop_increment( hopping_t *c, uint8_t hopIncrement ); 68*2c4f9bbbSMatthias Ringwald 69*2c4f9bbbSMatthias Ringwald /** 70*2c4f9bbbSMatthias Ringwald * @brief get next channel 71*2c4f9bbbSMatthias Ringwald */ 72*2c4f9bbbSMatthias Ringwald uint8_t hopping_csa1_get_next_channel( hopping_t *c ); 73*2c4f9bbbSMatthias Ringwald 74*2c4f9bbbSMatthias Ringwald // Channel Selection Algorithm #2 75*2c4f9bbbSMatthias Ringwald 76*2c4f9bbbSMatthias Ringwald /* 77*2c4f9bbbSMatthias Ringwald * @brief init csa 2 algorithm 78*2c4f9bbbSMatthias Ringwald */ 79*2c4f9bbbSMatthias Ringwald void hopping_csa2_set_access_address( hopping_t *c, uint32_t accessAddress ); 80*2c4f9bbbSMatthias Ringwald 81*2c4f9bbbSMatthias Ringwald /** 82*2c4f9bbbSMatthias Ringwald * @brief get next channel 83*2c4f9bbbSMatthias Ringwald */ 84*2c4f9bbbSMatthias Ringwald uint8_t hopping_csa2_get_channel_for_counter( hopping_t *c, uint16_t counter ); 85*2c4f9bbbSMatthias Ringwald 86