mackrackit's ConnectOne example code


Results 1 to 40 of 92

Threaded View

  1. #11
    Join Date
    Mar 2009
    Location
    Colorado
    Posts
    378

    Default Re: mackrackit's ConnectOne example code

    Dave, I finally got it all working...or I should say almost all. Still troubleshooting one statement I want to add to the FTP process that is posting the wrong HH:MM values used from the RTC...for which I will describe and ask for help at end of this posting..

    First of all, I made what I think are some good changes to the approach which I will share below for benefit of anyone else monitoring this thread that is trying to use the ConnectOne iWiFi MiniSocket module. I broke a lot of your sample code into some callable subroutines which I will list and explain below. I am posting all this code because I discovered that the ConnectOne programmers manual for the MiniSocket doesn't have any examples so it is somewhat difficult to get the syntax just right. Since these routines are tested and work it should save others from having this problem. Although I should say that the TechSupport people at ConnectOne have been very helpful and also say they are going to add examples to each command reference in their next publish of the programmers manual for the very reason I pointed out to them.

    You will see a lot of WRITE to EEPROM statements embedded in this code which you can comment out or ignore...I use them to debug the AT+i command sequences so I know where the hangups are in the code by reading the EEPROM of the MCU after each run of the code when programming the MiniSocket module. I also have embedded a lot of variable duration, blinking LED statements to make use of a GREEN/ RED LED on my board to help see what is happening when the code is running.

    From your mainloop when you want to use the MiniSocket module you first need to call this subroutine (BOOT) to initialize the module. You will have to substitue your own router SSID name in the iWLSI statement.
    Code:
    BOOT:   'Subroutine for setting up ConnectOne MiniSocket iWiFi module
        ' Blink Green LED 2x short at start of BOOT routine...for test only
          FOR I = 0 TO 1
            HIGH LED_GRN
            PAUSE 250
            LOW LED_GRN
            PAUSE 250
          NEXT
          PAUSE 1000      'Initialize iWiFi MiniSocket Module
          HIGH _RES_PD     ' Set high for normal ops
          PAUSE 500           ' Delay to stabilize if coming out of power up mode
    WRITE 48,2      'EEPROM test to see if program executes to here..it does.
          SEROUT2 TX,84,["AT+iBDRA",$d,$a]          ' FORCE ICHIP TO AUTO BAUD
          SERIN2 RX ,84,2500,BOOT,[WAIT("I/OK")]  ' SETTING BAUD TO 9600
          PAUSE 100
    WRITE 49,3      'EEPROM test to see if program executes to here..it does.
          SEROUT2 TX,84,["AT+iRPG=booger",$d ,$a] ' SETS REMOTE PASSWORD
          SERIN2 RX ,84,2500,BOOT,[WAIT("I/OK")]
          PAUSE 100
           ' Commented out until WPA setup on wireless router
                'SEROUT2 TX,84,["AT+iWSEC=0",$d ,$a]     ' WPA-TKIP PROTOCAL
                'SERIN2 RX ,84,2500,BOOT,[WAIT("I/OK")]
          PAUSE 100
    WRITE 50,4      'EEPROM test to see if program executes to here..it does!
        SEROUT2 TX,84,["AT+iWLSI=EllisOfficeNetwork",$d,$a]' SET SSID WE ARE LOOKING FOR
        SERIN2 RX ,84,2500,BOOT,[WAIT("I/OK")]  '
        PAUSE 100
        ' Commented out until WPA setup on wireless router
              'SEROUT2 TX,84,["AT+iWLPP=passphrase",$d,$a]        ' SET PASS-PHRASE
             'SERIN2 RX ,84,2500,BOOT,[WAIT("I/OK")]
             'PAUSE 100
    WRITE 51,5      'EEPROM test to see if program executes to here..it does!
        SEROUT2 TX ,84, [ "AT+iIPA?" , $d , $a ] 'Report the current IP address
        SERIN2 RX ,84, 2500 ,BOOT , [ DEC ADR[0] , DEC ADR[1] , DEC ADR[2] , DEC ADR[3] ] 'Store IP in array
    WRITE 52,6      'EEPROM test to see if program executes to here..it does!
        GOSUB DIP      ' If IP address is empty, report not connected
        PAUSE 1000
        WRITE 32,ADR[0]      ' Write the IP to EEPROM for post run identify...for test only
        WRITE 33,ADR[1]
        WRITE 34,ADR[2]
        WRITE 35,ADR[3]
    WRITE 53,7      'EEPROM test to see if program executes to here..it does!
    RETURN
    For completeness I will also list a couple of other routines that are called by BOOT (BROKE and DIP):
    Code:
    BROKE:      ' Executes when iChip not working...blinks LED_RED
    WRITE 5, "B"     'Record in EEPROM as test if Broke!
         ' Blink LED_RED 3X long to indicate iChip not working
         FOR I = 0 TO 2
             TOGGLE LED_RED
             PAUSE 1000
             TOGGLE LED_RED
             PAUSE 1000
         NEXT
         PAUSE 2000
    GOTO BOOT
    Code:
    DIP:    ' Check whether IP is valid, blink LED_RED if not
    '===
          IF (!ADR[0]) AND (!ADR[1]) AND (!ADR[2]) AND (!ADR[3]) THEN
            ' Blink LED_RED 4X short to indicate iChip not working
               FOR I = 0 TO 3
                   TOGGLE LED_RED
                   PAUSE 250
                   TOGGLE LED_RED
                   PAUSE 250
               NEXT
               PAUSE 2000
          ENDIF
          PAUSE 1000
    RETURN
    Then after the BOOT routine has been executed you can call the EMAIL routine listed below to send an email to wherever you want (by changing some of the permanent AT+i parameters you must have previously programmed per the inital comments in the start of the EMAIL routine):
    Code:
    Email: ' Sends email via ConnectOne iWifi MiniSocket module
    '=====
    'This subroutine assumes user has previously programmed the MiniSocket module
    'with permanent entries for following email paramaters...see the programmer's
    'manual at http://www.connectone.com/support.asp?did=42 for following commands:
    '       AT+iTO,AT+iREA,AT+iFRM,AT+iSMTP,AT+iSMA=1,AT+iSMP,AT+iSMU,
    ' Blink Green LED 1x long at start of Email routine
    TOGGLE LED_GRN
    PAUSE 1000
    TOGGLE LED_GRN
    PAUSE 2000
    WRITE 54,8 'EEPROM test to see if program executes to here..it does!
    ' Put code here to email low temperature warning via WiFi
    SEROUT2 TX,84,["AT+iEMA:",$d,$a] 'Defines a plain text e-mail body
    SEROUT2 TX,84,["Hi, this is from 206 N Veterans.",$d,$a]
    SEROUT2 TX,84,["The inside temperature is:",$d,$a]
    SEROUT2 TX,84,[DEC temp," F Inside.",$d,$a]
    SEROUT2 TX,84,["GO TO:",$d,$a]
    SEROUT2 TX,84,["http://www.lodestarassoc.com/ichip/ichip.php",$d,$a]
    SEROUT2 TX,84,["for an hourly update.",$d,$a]
    SEROUT2 TX,84,[$d,$a,".",$d,$a]
    SERIN2 RX,84,[WAIT("I/ONLINE")]
    WRITE 55,9 'EEPROM test to see if program executes to here..it does!
    GOSUB Blink_GRN ' Short blink LED_GRN 2x after email sent
    GOSUB Blink_GRN
    PAUSE 1000
    Sent:
    ' Blink Green LED 2x long after email sent
    FOR I = 0 TO 1
    TOGGLE LED_GRN
    PAUSE 1000
    TOGGLE LED_GRN
    PAUSE 1000
    NEXT
    RETURN
    Alternatively you can call the FTP routine to FTP data to a website of your choice for which you will have to modify the domain, username and password in the iFOPN statement, the directory name (iChip) in the iFCWD statement, and the file name (include-3.txt) in the iFSTO statement. In my application I have a folder on the website named "iChip" which contains a text file named "include-3.txt" to which this code writes the information in the iFSND statements. The website uses a PHP script to automatically update the web page by reading and displaying the text file every 2 minutes so it dynamically keeps up with the updates that may be coming from the MiniSocket module at rate faster than 2 minutes. If anyone wants this PHP script for use on their website, send me a PM.
    Code:
    FTP: 'FTP temperature data to internet based website
    '===
        SEROUT2 TX,84,["AT+i",$d,$a]
        SEROUT2 TX,84,["AT+i!FCLS:000",$d,$a] 'CLOSE SESSION
        SEROUT2 TX,84,["AT+iFOPN:lodestarassoc.com,username,password$d,$a]'OPEN SESSION
        SERIN2 RX,84,1000,FTP,[WAIT("I/000")] :PAUSE 100
        SEROUT2 TX,84,["AT+iFCWD:000,iChip",$d,$a]
        SERIN2 RX,84,[WAIT("I/OK")]
        SEROUT2 TX,84,["AT+iFSTO:000,",$22,"include-3.txt",$22,$d,$a]
        SERIN2 RX,84,[WAIT("I/OK")]
        SEROUT2 TX,84,["AT+iFSND:000,19:"," The temperature is",$d,$a]:PAUSE 100
        SEROUT2 TX,84,["AT+iFSND:000,2:",$d,$a]:PAUSE 100
        SEROUT2 TX,84,["AT+iFSND:000,13:",DEC temp," F Outside",$d,$a]:PAUSE 100
        SEROUT2 TX,84,["AT+iFSND:000,2:",$d,$a]:PAUSE 100
    WRITE 56,10      'EEPROM test to see if program executes to here..it does!
        SEROUT2 TX,84, ["AT+iFCLF:000",$d,$a] : PAUSE 100    ' Close file
        SEROUT2 TX,84,["AT+i!FCLS:000",$d,$a] 'CLOSE SESSION
        PAUSE 100
    WRITE 57,11      'EEPROM test to see if program executes to here..it does!
        SEROUT2 TX,84,["AT+i",$d,$a]':PAUSE 100
        SERIN2 RX,84,100,BOOT,[WAIT("I/OK")] :PAUSE 100
    RETURN
    I hope the above routines will help people that are using the ConnectOne MiniSocket avoid the learning curve I had to go thru.

    Now for a request for help to solve a remaining problem I am trying to solve in using the MiniSocket with PICBASICPro.
    Since my application has an embedded RTC, I want to include in the FTP routine a sequence that will send a message as a time stamp so that whoever logs into the website can see when the data was posted. To do this I am trying to use the following added iFSND statements to append a time stamp to the rest of the posted data:
    Code:
    'FTP the time stamp of the temperature measurement
        SEROUT2 TX,84,["AT+iFOPN:lodestarassoc.com:jellis00,Kevin111#",$d,$a]'OPEN SESSION
        SERIN2 RX,84,1000,FTP,[WAIT("I/000")] :PAUSE 100
        SEROUT2 TX,84,["AT+iFCWD:000,iChip",$d,$a]
        SERIN2 RX,84,[WAIT("I/OK")]
        SEROUT2 TX,84,["AT+iFSTO:000,","include-4.txt",$d,$a]
        SERIN2 RX,84,[WAIT("I/OK")]
        SEROUT2 TX,84,["AT+iFSND:000,5:",HEX2 hr,":",HEX2 MINs,$d,$a]:PAUSE 100
        SEROUT2 TX,84,["AT+iFSND:000,2:",$d,$a]:PAUSE 100
        IF (test=1) THEN
           WRITE 59,14  'EEPROM test to see if program executes to here..it does.
        ENDIF
        'SEROUT2 TX,84,["AT+iFSND:000,3:",DEC CNT,$d,$a]:PAUSE 100
        SEROUT2 TX,84,["AT+iFCLF:000",$d,$a]  'Close file
        SERIN2 RX,84,[WAIT("I/OK")]:PAUSE 100
        SEROUT2 TX,84,["AT+i!FCLS:000",$d,$a] 'Close Session
        SERIN2 RX,84,100,BOOT,[WAIT("I/ONLINE")]:PAUSE 100
        SEROUT2 TX,84,["AT+i",$d,$a]
        SERIN2 RX,84,100,BOOT,[WAIT("I/OK")]
    My problem centers around the statement: SEROUT2 TX,84,["AT+iFSND:000,5:",HEX2 hr,":",HEX2 MINs,$d,$a]:PAUSE 100
    For some reason the displayed values in the website always show up as constant 4:32 in all FTP postings rather than as the actual HH:MM values from the RTC at the time of the posting. Can anyone tell me why this is happening? I have spent a couple of days trying to figure this out with no success and any help would be appreciated.
    Last edited by jellis00; - 11th November 2011 at 00:41.

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts