Author Topic: Device.Uid  (Read 812 times)

bdevlin

  • Newbie
  • *
  • Posts: 38
    • View Profile
Device.Uid
« on: April 05, 2017, 06:26:19 pm »
Device.Uid does not seem to be available in the IDE. I want to create a generic script for a standard task across 5 units and update code in one place. With the Uid , I can simply cross join a lookup table for data visualization. Uid is not available though.

16.34. Device Structure Inherits Object
Shared Function BatteryVoltage() As Short
Shared Function GarbageCollection() As Integer
Shared Function MemoryAvailable() As Integer
Shared Sub OpampEnable(enable As Boolean)
Shared Function TempDie() As Float
Shared Sub TempSensorEnable(enable As Boolean)
Shared Function Uid() As Integer
Shared Function Uptime() As Integer
Shared Function GetTimeSpan() As Integer

Share on Facebook Share on Twitter

Like Like x 1 View List

bdevlin

  • Newbie
  • *
  • Posts: 38
    • View Profile
Re: Device.Uid
« Reply #1 on: April 05, 2017, 06:30:24 pm »
AGHHHH!

Found it... It's "Device.mcUID" for anyone else looking.

bdevlin

  • Newbie
  • *
  • Posts: 38
    • View Profile
Re: Device.Uid
« Reply #2 on: April 05, 2017, 07:08:36 pm »
How do I convert the Device.mcUid to a proper string... I am getting 65673, but my device id is 00010089. Don't worry, I'm moving to MQTT soon ... I just need to set up the Mosquitto.

Dim ID As Float = Device.mcUID
                       
        Lplan.IFTTT(------------------------", "Devlin_Temperature", tempstring, ID.ToString)

kristofferis

  • Sr. Member
  • ****
  • Posts: 287
  • Location: Sweden
    • View Profile
Re: Device.Uid
« Reply #3 on: April 06, 2017, 12:07:42 am »
Hello.
I think this is what you are looking for.
Code: [Select]
Device.mcUID().ToString("X8")

bdevlin

  • Newbie
  • *
  • Posts: 38
    • View Profile
Re: Device.Uid
« Reply #4 on: April 06, 2017, 04:57:49 pm »
Thanks, but that returns "1199588480"

kristofferis

  • Sr. Member
  • ****
  • Posts: 287
  • Location: Sweden
    • View Profile
Re: Device.Uid
« Reply #5 on: April 07, 2017, 12:23:29 am »
Did you put that in your Float?

Code: [Select]
Dim test As String
test = Device.mcUID().ToString("X8")

bdevlin

  • Newbie
  • *
  • Posts: 38
    • View Profile
Re: Device.Uid
« Reply #6 on: April 11, 2017, 08:05:30 pm »
It finally works. Also I had to use ("x8") not ("X8") when it finally worked.

Also I was initializing as a float, but the docs say it's an INT. Shouldn't make a difference but I changed it anyway. All good now:

        Dim mcID As Integer = Device.mcUID
        Dim ID As String = mcID.ToString("x8")
       
        Lplan.IFTTT("xxxxxxxxxxxxxxxxxxxxx", "Devlin_Temperature", tempstring, "", ID)

kristofferis

  • Sr. Member
  • ****
  • Posts: 287
  • Location: Sweden
    • View Profile
Re: Device.Uid
« Reply #7 on: April 12, 2017, 04:49:04 am »
Its good that it works now for you but you do not have to do it like that, and no need to use x instead of X.

Here is a working solution from one of my projects:

Code: [Select]
Dim deviceUid As String = Device.mcUID().ToString("X8")
Like Like x 1 View List

bdevlin

  • Newbie
  • *
  • Posts: 38
    • View Profile
Re: Device.Uid
« Reply #8 on: April 12, 2017, 02:03:10 pm »
Aha! I was missing the brackets after mcUid... did I mention I am an awful coder?

Thank you!
Funny Funny x 1 View List

kristofferis

  • Sr. Member
  • ****
  • Posts: 287
  • Location: Sweden
    • View Profile
Re: Device.Uid
« Reply #9 on: April 12, 2017, 02:58:50 pm »
No problem.
Just let us know if you need any more help.