File tree Expand file tree Collapse file tree
Example/Source/View Controllers/Proxy Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -195,13 +195,33 @@ private extension AddAddressViewController {
195195extension AddAddressViewController : ProxyFilterDelegate {
196196
197197 func proxyFilterUpdated( type: ProxyFilerType , addresses: Set < Address > ) {
198- done {
199- self . dismiss ( animated: true )
200- }
198+ // As we want different behavior when the list was acknowledged
199+ // or the list limit was reached, to nothing here.
201200 }
202201
203202 func proxyFilterUpdateAcknowledged( type: ProxyFilerType , listSize: UInt16 ) {
204- // TODO: dismiss here?
203+ // This method is also called when the Proxy Node gets disconnected.
204+ // In that case, the list size is equal to 0.
205+ if listSize > 0 {
206+ done {
207+ self . dismiss ( animated: true )
208+ }
209+ }
210+ }
211+
212+ func proxyFilterLimitReached( type: ProxyFilerType , maxSize: UInt16 ) {
213+ done {
214+ self . presentAlert (
215+ title: " Maximum filter size reached " ,
216+ message: """
217+ The connected proxy node supports only \( maxSize) addresses on its Proxy Filter list.
218+
219+ Some addresses were not added.
220+ """
221+ ) { _ in
222+ self . dismiss ( animated: true )
223+ }
224+ }
205225 }
206226
207227}
Original file line number Diff line number Diff line change @@ -45,7 +45,6 @@ class ProxySelectorViewController: UITableViewController {
4545
4646 // MARK: - Properties
4747
48- weak var delegate : ProvisioningViewDelegate ?
4948 var meshNetwork : MeshNetwork ?
5049
5150 private var centralManager : CBCentralManager !
@@ -189,9 +188,20 @@ extension ProxySelectorViewController: GattBearerDelegate {
189188
190189 func bearerDidOpen( _ bearer: Bearer ) {
191190 MeshNetworkManager . bearer. use ( proxy: bearer as! GattBearer )
191+ MeshNetworkManager . instance. proxyFilter. proxyDidDisconnect ( )
192+
192193 DispatchQueue . main. async { [ weak self] in
193194 self ? . alert? . dismiss ( animated: true ) { [ weak self] in
194- self ? . dismiss ( animated: true )
195+ self ? . dismiss ( animated: true ) {
196+ // Set up the Proxy Filter when the view controller is no
197+ // longer visible. This action may end up reaching the Proxy
198+ // Filter list limit, which will result in showing an alert
199+ // from the ProxyViewController. Having 2 child view controllers
200+ // won't work.
201+ if let provisioner = self ? . meshNetwork? . localProvisioner {
202+ MeshNetworkManager . instance. proxyFilter. setup ( for: provisioner)
203+ }
204+ }
195205 }
196206 self ? . alert = nil
197207 }
Original file line number Diff line number Diff line change @@ -222,15 +222,36 @@ extension ProxyViewController: ProxyFilterTypeDelegate {
222222extension ProxyViewController : ProxyFilterDelegate {
223223
224224 func proxyFilterUpdated( type: ProxyFilerType , addresses: Set < Address > ) {
225+ // As we want different behavior when the list was acknowledged
226+ // or the list limit was reached, to nothing here.
227+ }
228+
229+ func proxyFilterUpdateAcknowledged( type: ProxyFilerType , listSize: UInt16 ) {
230+ // This method is also called when the Proxy Node gets disconnected.
231+ // In that case, the list size is equal to 0.
225232 done {
226233 self . tableView. reloadData ( )
227234 }
228235 }
229236
230- func proxyFilterUpdateAcknowledged( type: ProxyFilerType , listSize: UInt16 ) {
231- // TODO: dismiss here?
237+ func proxyFilterLimitReached( type: ProxyFilerType , maxSize: UInt16 ) {
238+ done {
239+ self . tableView. reloadData ( )
240+ let setRejectList = UIAlertAction ( title: " Use Reject List " , style: . destructive) { _ in
241+ let proxyFilter = MeshNetworkManager . instance. proxyFilter
242+ proxyFilter. setType ( . rejectList)
243+ }
244+ self . presentAlert (
245+ title: " Maximum filter size reached " ,
246+ message: """
247+ The connected proxy node supports only \( maxSize) addresses on its Proxy Filter list.
248+
249+ Use Reject List or add addresses manually.
250+ """ ,
251+ option: setRejectList
252+ )
253+ }
232254 }
233-
234255}
235256
236257private extension ProxyViewController {
You can’t perform that action at this time.
0 commit comments