public void OnItemClick(AdapterView parent, View view, int position, long id) { // Set the selected Beacon to the Static Object Console.WriteLine("Clicked on Position: " + position); SelectedBeacon = BeaconList[position]; // Open an Activity // Setup a new Intent var intent = new Intent(this, typeof(BeaconDetailActivity)); StartActivity(intent); }
onData(Interest interest, Data data) { ++callbackCount_; var content = data.getContent().buf(); var contentString = ""; for (int i = content.position(); i < content.limit(); ++i) { contentString += (char)content.get(i); } Console.WriteLine("Recieved Data: " + data.getName().toUri() + "\n\n" + contentString); // Create a Beacon Object for each one in the data string[] beaconNames = contentString.Split("\n".ToCharArray()); // This puts the string to NAME,ADDRESS MainActivity.BeaconList.Clear(); foreach (string beacon in beaconNames) { string beaconName = ""; string beaconAddr = ""; // beacon is in the format of NAME,ADDRESS string[] beaconData = beacon.split(","); if (beaconData.Length == 2) { // First array item will be the name, second will be the address beaconName = beaconData[0].Replace("Device name: ", string.Empty); beaconAddr = beaconData[1].Replace("Device Address: ", string.Empty); } else { //Something went wrong } // Create a new Beacon with the Name Beacon newBeacon = new Beacon(beaconName); // Set the MAC Address newBeacon.ChangeMACAdress(beaconAddr); // Add the Beacon to the Master List MainActivity.BeaconList.Add(newBeacon); // Log Console.WriteLine("Added a Beacon, Name: " + newBeacon.Name + ", MAC Addr: " + newBeacon.Mac_Address); } }
public override bool Equals(object obj) { Beacon compare = obj as Beacon; return(mac_address.Equals(compare.Mac_Address)); }
private void eraseSelectedBeacon() { // Populate the Dummy Beacon - This information should never be seen by the User SelectedBeacon = new Beacon("Invalid Beacon"); SelectedBeacon.ChangeMACAdress("Invalid MAC Address"); }