private void StartAdvertising() { if (isAdvertisementRegistred) { return; } var adapter_properties = GetObject <Adapter1>(SERVICE, adapterFoundPath); adapter_properties.Powered = true; advertisement = new Advertisement(busConnection.System, 0, "peripheral"); advertisementPath = (advertisement as Advertisement).GetPath(); var options = new Dictionary <string, object>(); try { advertisementManager.RegisterAdvertisement(advertisementPath, options); isAdvertisementRegistred = true; } catch (Exception e) { isAdvertisementRegistred = false; System.Console.WriteLine("Couldn't register advertisement: " + e); } }
public void RegisterAdvertisement(MainAdvertisement advertisement) { if (advertisements.Count < MAX_ADVERTISEMENTS) { LEAdvertisingManager1 advertisingManager = systemBus.GetObject <LEAdvertisingManager1>(Service, GetAdapterPath()); advertisingManager.RegisterAdvertisement(advertisement.GetPath(), new Dictionary <string, object>()); advertisements.Add(advertisement); Console.WriteLine("[INFO] Register Advertisement successful"); } }