1 /* Bluetooth Mesh */ 2 3 /* 4 * Copyright (c) 2017 Intel Corporation 5 * 6 * SPDX-License-Identifier: Apache-2.0 7 */ 8 #ifndef __LPN_H__ 9 #define __LPN_H__ 10 11 #include "mesh/mesh.h" 12 13 int bt_mesh_lpn_friend_update(struct bt_mesh_net_rx *rx, 14 struct os_mbuf *buf); 15 int bt_mesh_lpn_friend_offer(struct bt_mesh_net_rx *rx, 16 struct os_mbuf *buf); 17 int bt_mesh_lpn_friend_clear_cfm(struct bt_mesh_net_rx *rx, 18 struct os_mbuf *buf); 19 int bt_mesh_lpn_friend_sub_cfm(struct bt_mesh_net_rx *rx, 20 struct os_mbuf *buf); 21 bt_mesh_lpn_established(void)22static inline bool bt_mesh_lpn_established(void) 23 { 24 #if (MYNEWT_VAL(BLE_MESH_LOW_POWER)) 25 return bt_mesh.lpn.established; 26 #else 27 return false; 28 #endif 29 } 30 bt_mesh_lpn_match(u16_t addr)31static inline bool bt_mesh_lpn_match(u16_t addr) 32 { 33 #if (MYNEWT_VAL(BLE_MESH_LOW_POWER)) 34 35 if (bt_mesh_lpn_established()) { 36 return (addr == bt_mesh.lpn.frnd); 37 } 38 39 #endif 40 return false; 41 } 42 bt_mesh_lpn_waiting_update(void)43static inline bool bt_mesh_lpn_waiting_update(void) 44 { 45 #if (MYNEWT_VAL(BLE_MESH_LOW_POWER)) 46 return (bt_mesh.lpn.state == BT_MESH_LPN_WAIT_UPDATE); 47 #else 48 return false; 49 #endif 50 } 51 bt_mesh_lpn_timer(void)52static inline bool bt_mesh_lpn_timer(void) 53 { 54 #if MYNEWT_VAL(BLE_MESH_LOW_POWER) && MYNEWT_VAL(BLE_MESH_LPN_AUTO) 55 return (bt_mesh.lpn.state == BT_MESH_LPN_TIMER); 56 #else 57 return false; 58 #endif 59 } 60 61 void bt_mesh_lpn_msg_received(struct bt_mesh_net_rx *rx); 62 63 void bt_mesh_lpn_group_add(u16_t group); 64 void bt_mesh_lpn_group_del(u16_t *groups, size_t group_count); 65 66 void bt_mesh_lpn_disable(bool force); 67 68 int bt_mesh_lpn_init(void); 69 70 #endif 71