Announcement

Collapse
No announcement yet.

.ASPX to HSP Object Connection (HS-Phone)

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    .ASPX to HSP Object Connection (HS-Phone)

    I've been trying to figure this out for several hours now with tons of forum searches, and I can't find the answer. I know I'm missing something really simple. My method of programming is old-fashioned, so please don't suggest Tenscripting as a solution

    I can't get a reference to the HSP object in my .ASPX pages to work. I've tried every variation of the following code that I can think of. None of them allow me to use something like "hsp.MBSort()" in my webpage. I know the following code won't work as presented, but I've tried just about every variation of what you see. In every case I end up getting one of the following errors:
    1) "System.Runtime.Serialization.SerializationException: Type 'Scheduler.PhoneApp' " error when trying to define (Dim or Public) the hsp object. This happens when I "Public hsp as Scheduler.hsp" and then try to set "hsp=hs.GetHSPRef()"
    -OR-
    2) "System.NullReferenceException: Object reference not set to an instance of an object." on every use of the hsp object (like in a hsp.MBSort() command) -- when I do everything necessary to avoid error #1

    The global (Public) reference to the hs object seems to be OK. Can anyone tell me what I need to do so that the hsp object is available to all the sub(routines) in my .ASPX page?

    Code:
    <%@ Page Language="VB" Debug="true" %>
    <%@ Import Namespace="System" %>
    <%@ Import Namespace="System.Data" %>
    <%@ Import Namespace="Scheduler" %>
    <%@ Import Namespace="HomeSeerAPI" %>
    <%@ Import Namespace="HSCF" %>
    
    <script runat="server">
    
    Public hs As Scheduler.hsapplication = Context.Items("Content")
    Public hsp As Scheduler.hsp
    
    
    Sub Page_Load(Sender As Object, E As EventArgs)
    
      Dim hsp As Scheduler.hsp = CType(hs.GetHSPRef(), Scheduler.hsp)
      hsp = CType(hs.GetHSPRef(), Scheduler.hsp)
    
      hsp.MBSort()
      ....
      ....
    End Sub
    </script>

    #2
    Try this:

    PHP Code:
    <%@ Page Language="VB" Debug="true" %>
    <
    script runat="server">

    Public 
    hs As Scheduler.hsapplication Context.Items("Content")
    Public 
    hsp As New Scheduler.hsp
     
    Protected Sub Page_Load(ByVal sender As ObjectByVal e As System.EventArgs)
      
    hsp.MBSort()
      ....
      ....
    End Sub

    </script
    Jon

    Comment


      #3
      That worked perfectly!

      Thanks jon00!!

      Comment


        #4
        Well, maybe not so fast...

        The next call I have is a "NumMailboxes = hsp.MBCount()" which always returns 0. I have 2 mailboxes set up.

        Also, I tried a "hsp.LastCallerInfo(0)" (tried both 0 and 1) and get a "System.NullReferenceException: Object reference not set to an instance of an object."

        It looks like this might be pointing to an empty hsp object?


        Thanks,
        --Doug

        Comment


          #5
          Originally posted by dwoolridge View Post
          It looks like this might be pointing to an empty hsp object?
          I don't believe so. I tested with the hsp.WaitMS command:

          Code:
          Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
            hs.speak("Hello")
            hsp.waitms(5000)
            hs.speak("world")
          End Sub
          It waited 5 seconds as expected.
          Attached Files
          Jon

          Comment


            #6
            Thanks for the reply.

            The waitms works on my end too, but any attempt to get information from the hsp object gives the SystemNullReference error or returns zero data.

            Comment


              #7
              It looks like you may need to request support from HST.

              Alternatively, you could pull the data via a script using hs.runscriptfunc (messy I know).
              Jon

              Comment


                #8
                HSPhone is pretty much dead at this point and will be pulled out of HS in some future version.

                But to answer your question, it looks like HSPhone is not initialized. Make sure its enabled in setup and is connected to a phone device. If its not initialized, the mailbox call you are making will return 0.
                website | buy now | support | youtube

                Comment


                  #9
                  Originally posted by rjh View Post
                  HSPhone is pretty much dead at this point and will be pulled out of HS in some future version.

                  But to answer your question, it looks like HSPhone is not initialized. Make sure its enabled in setup and is connected to a phone device. If its not initialized, the mailbox call you are making will return 0.

                  Is there any possibility of it being moved into a separate plugin? Some of us still have a land line.
                  --
                  Jeff Farmer
                  HS 3, HSPhone
                  My HS3 Plugins: CFHSExtras, Random, Restart, Tracker, WeatherXML, PanaBluRay
                  Other Plugins In Use: APCUPSD, BLOnkyo, Device History, EasyTrigger, HSTouch Server, PHLocation2, Pushover, RFXCom, UltraGCIR3, UltraMon3, UltraPioneerAVR3, X10, Z-Wave

                  Hardware: GoControl Irrigation Controler, Schlage Lever Lock, Schlage Deadbolt, Way2Call Hi-Phone, RFXCom RFXrec433 Receiver, WGL 800, TI-103, Z-Net, Pioneer 1120, Pioneer 1021, Pioneer LX302, Panasonic BDT-110, Panasonic BDT-210 x2

                  Comment


                    #10
                    I gave the source to Ultrajones, but I don't think he did anything with it.

                    I will give out the source to anyone who wants it. We certainly won't be doing anything with it. In the last 3 years I think we sold maybe 2 way2call units (the only thing that works with it), so there certainly isn't a market for it!

                    Originally posted by CFGuy View Post
                    Is there any possibility of it being moved into a separate plugin? Some of us still have a land line.
                    website | buy now | support | youtube

                    Comment


                      #11
                      Go for it Jeff!

                      Originally posted by rjh View Post
                      I gave the source to Ultrajones, but I don't think he did anything with it.

                      I will give out the source to anyone who wants it. We certainly won't be doing anything with it. In the last 3 years I think we sold maybe 2 way2call units (the only thing that works with it), so there certainly isn't a market for it!
                      Don

                      Comment


                        #12
                        Rich,

                        Thanks for the reply. HS-Phone is initialized, answering, and recording voice messages. The closest code to working was as follows. The MBCount returns 0, even though there are 2 mailboxes set up and the LastCallerInfo results in "System.NullReferenceException: Object reference not set to an instance of an object."

                        I might try calling a ScriptFunction from the ASPX page as a workaround.


                        Code:
                        <%@ Page Language="VB" Debug="true" %> 
                        <script runat="server"> 
                        
                        Public hs As Scheduler.hsapplication = Context.Items("Content") 
                        Public hsp As New Scheduler.hsp 
                          
                        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) 
                          Dim numMB as Integer
                          Dim InfoTemp as String
                        
                          hsp.MBSort()
                          numMB = hsp.MBCount()
                          InfoTemp = hsp.LastCallerInfo(0)
                        End Sub 
                        
                        </script>

                        Comment


                          #13
                          You are creating a new HSP object, you have to get a reference to the real one with:

                          hsp = hs.GetHSPRef

                          But I am not sure that the hsp object can be remoted over the asp.net interface, but you can try it.

                          Originally posted by dwoolridge View Post
                          Rich,

                          Thanks for the reply. HS-Phone is initialized, answering, and recording voice messages. The closest code to working was as follows. The MBCount returns 0, even though there are 2 mailboxes set up and the LastCallerInfo results in "System.NullReferenceException: Object reference not set to an instance of an object."

                          I might try calling a ScriptFunction from the ASPX page as a workaround.


                          Code:
                          <%@ Page Language="VB" Debug="true" %> 
                          <script runat="server"> 
                          
                          Public hs As Scheduler.hsapplication = Context.Items("Content") 
                          Public hsp As New Scheduler.hsp 
                            
                          Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) 
                            Dim numMB as Integer
                            Dim InfoTemp as String
                          
                            hsp.MBSort()
                            numMB = hsp.MBCount()
                            InfoTemp = hsp.LastCallerInfo(0)
                          End Sub 
                          
                          </script>
                          website | buy now | support | youtube

                          Comment


                            #14
                            Originally posted by rjh View Post
                            You are creating a new HSP object, you have to get a reference to the real one with:

                            hsp = hs.GetHSPRef

                            But I am not sure that the hsp object can be remoted over the asp.net interface, but you can try it.
                            I think when I tried that, there was an error stating that hs.GetHSPRef was not serialized.
                            Jon

                            Comment


                              #15
                              Originally posted by rjh View Post
                              ... In the last 3 years I think we sold maybe 2 way2call units (the only thing that works with it), so there certainly isn't a market for it!
                              Rich - don't be so fast! The Way2Call unit I bought from you guys YEARS ago is still plugging along just fine. I've never had any trouble with the hardware, maybe that's why no one has bought a new one recently?

                              FWIW

                              P.S. Maybe you would send me a copy of the source so that I can have it around if need be? Thanks
                              Steve

                              (System configuration is in my profile)

                              Comment

                              Working...
                              X