Permalink
Browse files

Added light to list of services

  • Loading branch information...
1 parent 101ddf5 commit d23a3c26e79b8ab0d48f101e4b54d6778d704976 @CHIPkitReadonly CHIPkitReadonly committed Mar 2, 2012
Showing with 32 additions and 20 deletions.
  1. +21 −12 applilet3_src/CG_main.c
  2. +3 −2 settings/RS-RL78G132200CCDEMO.dni
  3. +4 −4 settings/RS-RL78G132200CCDEMO.wsdt
  4. +4 −2 swarm_libs/swarm.c
View
@@ -90,7 +90,7 @@ __root const UCHAR secuid[10] =
* Adjust with care and an eye on a swarm console.
* NOTE - this isn't a precise value, it does not take into effect the time
* spent retrieving the sample and sending it out to swarm.*/
-#define UPDATE_PERIOD 1000
+#define UPDATE_PERIOD 2000
/* The number of messages to wait until sending out a swarm capabilities message
*/
#define ANNOUNCE_INTERVAL 10
@@ -299,10 +299,11 @@ void main(void)
// Scale accelerometer data:
// -Intentionally concatenate integer divided value
// -Absolute value, so that we can add our own negative sign
+ getAccelSample();
int dataxRounded = abs(datax/ACCEL_SCALE);
int datayRounded = abs(datay/ACCEL_SCALE);
memset(tempbuff, '\0', sizeof(tempbuff));
- // Create swarm payload, and load it into tempbuff.
+ // Create swarm payload for acceleration, and load it into tempbuff.
// Integer math to compensate for lack fo floating point formatter:
// -%c is used to display a negative sign if number is negative
// -%d. is the whole part of the number
@@ -314,14 +315,8 @@ void main(void)
abs((int)((((long)datay*10000L)/ACCEL_SCALE)-((long)datayRounded*10000L))));
// Send data to swarm and toggle LED2
swarm_produce(tempbuff,outsock);
- LED2 = !LED2;
-
- getAccelSample();
- // Clear the lower half of the LCD screen and repaint it with data
- LCDClearLine(5);
- LCDClearLine(6);
- LCDClearLine(7);
- memset(tempbuff, '\0', sizeof(tempbuff));
+ mydelay(100);
+ /*
// Format accelerometer data for the LCD screen.
// the same integer math as above with the SWARM payload.
sprintf(tempbuff, "X: %c%d.%04d",(datax < 0)?'-':' ', dataxRounded,
@@ -331,11 +326,25 @@ void main(void)
sprintf(tempbuff, "Y: %c%d.%04d",(datay < 0)?'-':' ', datayRounded,
abs((int)((((long)datay*10000L)/270)-((long)datayRounded*10000L))));
LCDString(tempbuff, LCDRight(8)-55, 51);
+ */
+
+ memset(tempbuff, '\0', sizeof(tempbuff));
+ // Create swarm payload for light
+ sprintf(tempbuff, "{\"Light\":{\"value\":%d}}", getLightSample());
+ swarm_produce(tempbuff,outsock);
+ mydelay(500);
+
+ // Clear the lower half of the LCD screen and repaint it with data
+ LCDClearLine(5);
+ LCDClearLine(6);
+ LCDClearLine(7);
+ memset(tempbuff, '\0', sizeof(tempbuff));
+
+ LED2 = !LED2;
mydelay(UPDATE_PERIOD);
if (++loopcount%ANNOUNCE_INTERVAL == 0){
capabilities_announce(outsock);
- //small delay just to make sure we don't rush the next sample going out
- mydelay(100);
+ mydelay(500);
}
}
@@ -1,7 +1,8 @@
[DebugChecksum]
-Checksum=-701997164
+Checksum=1716028095
[DisAssemblyWindow]
-NumStates=_ 0
+NumStates=_ 1
+State 1=_ 1
[InstructionProfiling]
Enabled=_ 0
[CodeCoverage]
@@ -17,7 +17,7 @@
<Build><ColumnWidth0>20</ColumnWidth0><ColumnWidth1>915</ColumnWidth1><ColumnWidth2>163</ColumnWidth2><ColumnWidth3>61</ColumnWidth3></Build><Find-in-Files><ColumnWidth0>496</ColumnWidth0><ColumnWidth1>70</ColumnWidth1><ColumnWidth2>850</ColumnWidth2></Find-in-Files><TerminalIO/><Debug-Log><ColumnWidth0>20</ColumnWidth0><ColumnWidth1>1381</ColumnWidth1></Debug-Log></Static>
<Windows>
- <Wnd0>
+ <Wnd2>
<Tabs>
<Tab>
<Identity>TabID-30837-20174</Identity>
@@ -29,20 +29,20 @@
</Tab>
</Tabs>
- <SelectedTab>0</SelectedTab></Wnd0><Wnd1><Tabs><Tab><Identity>TabID-10219-25883</Identity><TabName>Build</TabName><Factory>Build</Factory><Session/></Tab><Tab><Identity>TabID-21600-27903</Identity><TabName>Find in Files</TabName><Factory>Find-in-Files</Factory><Session/></Tab><Tab><Identity>TabID-13600-2237</Identity><TabName>Debug Log</TabName><Factory>Debug-Log</Factory><Session/></Tab></Tabs><SelectedTab>0</SelectedTab></Wnd1></Windows>
+ <SelectedTab>0</SelectedTab></Wnd2><Wnd3><Tabs><Tab><Identity>TabID-10219-25883</Identity><TabName>Build</TabName><Factory>Build</Factory><Session/></Tab><Tab><Identity>TabID-21600-27903</Identity><TabName>Find in Files</TabName><Factory>Find-in-Files</Factory><Session/></Tab><Tab><Identity>TabID-13600-2237</Identity><TabName>Debug Log</TabName><Factory>Debug-Log</Factory><Session/></Tab></Tabs><SelectedTab>0</SelectedTab></Wnd3></Windows>
<Editor>
- <Pane><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\user_src\app_wifi_init.c</Filename><XPos>0</XPos><YPos>90</YPos><SelStart>3</SelStart><SelEnd>3</SelEnd></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\user_src\rsi_demo_app.c</Filename><XPos>0</XPos><YPos>114</YPos><SelStart>4802</SelStart><SelEnd>4802</SelEnd></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\wlan\rsi_global.h</Filename><XPos>0</XPos><YPos>93</YPos><SelStart>2240</SelStart><SelEnd>2240</SelEnd></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\swarm_libs\swarm.c</Filename><XPos>0</XPos><YPos>9</YPos><SelStart>469</SelStart><SelEnd>547</SelEnd></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\swarm_libs\swarm.h</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>276</SelStart><SelEnd>276</SelEnd></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\wifi_uart_hal\rsi_hal_timers.c</Filename><XPos>0</XPos><YPos>9</YPos><SelStart>786</SelStart><SelEnd>797</SelEnd></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\applilet3_src\CG_main.c</Filename><XPos>0</XPos><YPos>142</YPos><SelStart>5844</SelStart><SelEnd>5844</SelEnd></Tab><ActiveTab>6</ActiveTab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\applilet3_src\CG_serial_user.c</Filename><XPos>0</XPos><YPos>472</YPos><SelStart>12178</SelStart><SelEnd>12178</SelEnd></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\applilet3_src\CG_system_user.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>1202</SelStart><SelEnd>1202</SelEnd></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\applilet3_src\CG_serial.c</Filename><XPos>0</XPos><YPos>754</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd></Tab></Pane><ActivePane>0</ActivePane><Sizes><Pane><X>1000000</X><Y>1000000</Y></Pane></Sizes><SplitMode>1</SplitMode></Editor>
+ <Pane><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\user_src\app_wifi_init.c</Filename><XPos>0</XPos><YPos>90</YPos><SelStart>3</SelStart><SelEnd>3</SelEnd></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\user_src\rsi_demo_app.c</Filename><XPos>0</XPos><YPos>114</YPos><SelStart>4802</SelStart><SelEnd>4802</SelEnd></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\wlan\rsi_global.h</Filename><XPos>0</XPos><YPos>75</YPos><SelStart>2417</SelStart><SelEnd>2417</SelEnd></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\swarm_libs\swarm.c</Filename><XPos>0</XPos><YPos>9</YPos><SelStart>1389</SelStart><SelEnd>1389</SelEnd></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\swarm_libs\swarm.h</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>276</SelStart><SelEnd>276</SelEnd></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\wifi_uart_hal\rsi_hal_timers.c</Filename><XPos>0</XPos><YPos>9</YPos><SelStart>786</SelStart><SelEnd>797</SelEnd></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\applilet3_src\CG_main.c</Filename><XPos>0</XPos><YPos>169</YPos><SelStart>6594</SelStart><SelEnd>6594</SelEnd></Tab><ActiveTab>6</ActiveTab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\applilet3_src\CG_serial_user.c</Filename><XPos>0</XPos><YPos>472</YPos><SelStart>12178</SelStart><SelEnd>12178</SelEnd></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\applilet3_src\CG_system_user.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>1202</SelStart><SelEnd>1202</SelEnd></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\applilet3_src\CG_serial.c</Filename><XPos>0</XPos><YPos>754</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd></Tab></Pane><ActivePane>0</ActivePane><Sizes><Pane><X>1000000</X><Y>1000000</Y></Pane></Sizes><SplitMode>1</SplitMode></Editor>
<Positions>
- <Top><Row0><Sizes><Toolbar-00d92e00><key>iaridepm.enu1</key></Toolbar-00d92e00></Sizes></Row0><Row1><Sizes/></Row1><Row2><Sizes/></Row2><Row3><Sizes/></Row3><Row4><Sizes/></Row4><Row5><Sizes/></Row5><Row6><Sizes/></Row6><Row7><Sizes/></Row7><Row8><Sizes/></Row8><Row9><Sizes/></Row9><Row10><Sizes/></Row10><Row11><Sizes/></Row11><Row12><Sizes/></Row12><Row13><Sizes/></Row13><Row14><Sizes/></Row14><Row15><Sizes/></Row15><Row16><Sizes/></Row16><Row17><Sizes/></Row17><Row18><Sizes/></Row18><Row19><Sizes/></Row19><Row20><Sizes/></Row20><Row21><Sizes/></Row21><Row22><Sizes/></Row22><Row23><Sizes/></Row23><Row24><Sizes/></Row24><Row25><Sizes/></Row25><Row26><Sizes/></Row26><Row27><Sizes/></Row27><Row28><Sizes/></Row28><Row29><Sizes/></Row29><Row30><Sizes/></Row30><Row31><Sizes/></Row31><Row32><Sizes/></Row32><Row33><Sizes/></Row33><Row34><Sizes/></Row34><Row35><Sizes/></Row35><Row36><Sizes/></Row36><Row37><Sizes/></Row37><Row38><Sizes/></Row38><Row39><Sizes/></Row39><Row40><Sizes/></Row40><Row41><Sizes/></Row41><Row42><Sizes/></Row42><Row43><Sizes/></Row43><Row44><Sizes/></Row44><Row45><Sizes/></Row45><Row46><Sizes/></Row46><Row47><Sizes/></Row47><Row48><Sizes/></Row48><Row49><Sizes/></Row49><Row50><Sizes/></Row50><Row51><Sizes/></Row51><Row52><Sizes/></Row52><Row53><Sizes/></Row53><Row54><Sizes/></Row54><Row55><Sizes/></Row55><Row56><Sizes/></Row56><Row57><Sizes/></Row57><Row58><Sizes/></Row58><Row59><Sizes/></Row59><Row60><Sizes/></Row60><Row61><Sizes/></Row61><Row62><Sizes/></Row62><Row63><Sizes/></Row63><Row64><Sizes/></Row64><Row65><Sizes/></Row65><Row66><Sizes/></Row66><Row67><Sizes/></Row67><Row68><Sizes/></Row68><Row69><Sizes/></Row69><Row70><Sizes/></Row70><Row71><Sizes/></Row71><Row72><Sizes/></Row72><Row73><Sizes/></Row73><Row74><Sizes/></Row74><Row75><Sizes/></Row75><Row76><Sizes/></Row76></Top><Left><Row0><Sizes><Wnd0><Rect><Top>-2</Top><Left>-2</Left><Bottom>707</Bottom><Right>281</Right><x>-2</x><y>-2</y><xscreen>132</xscreen><yscreen>162</yscreen><sizeHorzCX>103125</sizeHorzCX><sizeHorzCY>169811</sizeHorzCY><sizeVertCX>221094</sizeVertCX><sizeVertCY>743187</sizeVertCY></Rect></Wnd0></Sizes></Row0></Left><Right><Row0><Sizes/></Row0></Right><Bottom><Row0><Sizes><Wnd1><Rect><Top>-2</Top><Left>-2</Left><Bottom>202</Bottom><Right>1282</Right><x>-2</x><y>-2</y><xscreen>1284</xscreen><yscreen>204</yscreen><sizeHorzCX>1003125</sizeHorzCX><sizeHorzCY>213836</sizeHorzCY><sizeVertCX>116406</sizeVertCX><sizeVertCY>146751</sizeVertCY></Rect></Wnd1></Sizes></Row0></Bottom><Float><Sizes/></Float></Positions>
+ <Top><Row0><Sizes><Toolbar-00d92e00><key>iaridepm.enu1</key></Toolbar-00d92e00></Sizes></Row0><Row1><Sizes/></Row1><Row2><Sizes/></Row2><Row3><Sizes/></Row3><Row4><Sizes/></Row4><Row5><Sizes/></Row5><Row6><Sizes/></Row6><Row7><Sizes/></Row7><Row8><Sizes/></Row8><Row9><Sizes/></Row9><Row10><Sizes/></Row10><Row11><Sizes/></Row11><Row12><Sizes/></Row12><Row13><Sizes/></Row13><Row14><Sizes/></Row14><Row15><Sizes/></Row15><Row16><Sizes/></Row16><Row17><Sizes/></Row17><Row18><Sizes/></Row18><Row19><Sizes/></Row19><Row20><Sizes/></Row20><Row21><Sizes/></Row21><Row22><Sizes/></Row22><Row23><Sizes/></Row23><Row24><Sizes/></Row24><Row25><Sizes/></Row25><Row26><Sizes/></Row26><Row27><Sizes/></Row27><Row28><Sizes/></Row28><Row29><Sizes/></Row29><Row30><Sizes/></Row30><Row31><Sizes/></Row31><Row32><Sizes/></Row32><Row33><Sizes/></Row33><Row34><Sizes/></Row34><Row35><Sizes/></Row35><Row36><Sizes/></Row36><Row37><Sizes/></Row37><Row38><Sizes/></Row38><Row39><Sizes/></Row39><Row40><Sizes/></Row40><Row41><Sizes/></Row41><Row42><Sizes/></Row42><Row43><Sizes/></Row43><Row44><Sizes/></Row44><Row45><Sizes/></Row45><Row46><Sizes/></Row46><Row47><Sizes/></Row47><Row48><Sizes/></Row48><Row49><Sizes/></Row49><Row50><Sizes/></Row50><Row51><Sizes/></Row51><Row52><Sizes/></Row52><Row53><Sizes/></Row53><Row54><Sizes/></Row54><Row55><Sizes/></Row55><Row56><Sizes/></Row56><Row57><Sizes/></Row57><Row58><Sizes/></Row58><Row59><Sizes/></Row59><Row60><Sizes/></Row60><Row61><Sizes/></Row61><Row62><Sizes/></Row62><Row63><Sizes/></Row63><Row64><Sizes/></Row64><Row65><Sizes/></Row65><Row66><Sizes/></Row66><Row67><Sizes/></Row67><Row68><Sizes/></Row68><Row69><Sizes/></Row69><Row70><Sizes/></Row70><Row71><Sizes/></Row71><Row72><Sizes/></Row72><Row73><Sizes/></Row73><Row74><Sizes/></Row74><Row75><Sizes/></Row75><Row76><Sizes/></Row76><Row77><Sizes/></Row77><Row78><Sizes/></Row78><Row79><Sizes/></Row79><Row80><Sizes/></Row80><Row81><Sizes/></Row81><Row82><Sizes/></Row82><Row83><Sizes/></Row83><Row84><Sizes/></Row84><Row85><Sizes/></Row85><Row86><Sizes/></Row86><Row87><Sizes/></Row87><Row88><Sizes/></Row88><Row89><Sizes/></Row89><Row90><Sizes/></Row90><Row91><Sizes/></Row91><Row92><Sizes/></Row92><Row93><Sizes/></Row93><Row94><Sizes/></Row94><Row95><Sizes/></Row95><Row96><Sizes/></Row96><Row97><Sizes/></Row97><Row98><Sizes/></Row98><Row99><Sizes/></Row99><Row100><Sizes/></Row100><Row101><Sizes/></Row101><Row102><Sizes/></Row102><Row103><Sizes/></Row103><Row104><Sizes/></Row104><Row105><Sizes/></Row105><Row106><Sizes/></Row106><Row107><Sizes/></Row107><Row108><Sizes/></Row108><Row109><Sizes/></Row109><Row110><Sizes/></Row110><Row111><Sizes/></Row111><Row112><Sizes/></Row112></Top><Left><Row0><Sizes><Wnd2><Rect><Top>-2</Top><Left>-2</Left><Bottom>707</Bottom><Right>281</Right><x>-2</x><y>-2</y><xscreen>132</xscreen><yscreen>162</yscreen><sizeHorzCX>103125</sizeHorzCX><sizeHorzCY>169811</sizeHorzCY><sizeVertCX>221094</sizeVertCX><sizeVertCY>743187</sizeVertCY></Rect></Wnd2></Sizes></Row0></Left><Right><Row0><Sizes/></Row0></Right><Bottom><Row0><Sizes><Wnd3><Rect><Top>-2</Top><Left>-2</Left><Bottom>202</Bottom><Right>1282</Right><x>-2</x><y>-2</y><xscreen>1284</xscreen><yscreen>204</yscreen><sizeHorzCX>1003125</sizeHorzCX><sizeHorzCY>213836</sizeHorzCY><sizeVertCX>116406</sizeVertCX><sizeVertCY>146751</sizeVertCY></Rect></Wnd3></Sizes></Row0></Bottom><Float><Sizes/></Float></Positions>
</Desktop>
</Workspace>
View
@@ -14,10 +14,11 @@ const char produce_header[] = "POST /stream?swarm_id=%s&"
"resource_id=%s HTTP/1.1\r\nHost:api.bugswarm.com\r\n"
"x-bugswarmapikey:%s\r\ntransfer-encoding:chunked\r\nConnection:keep-alive"
"\r\nContent-Type: application/json\r\n\r\n1\r\n\n\r\n\r\n";
-const char feed_request[] = "{\"capabilities\": {\"feeds\": [\"Acceleration\"], \"modules\": {\"slot1\":\"LCD\"}}}";
+const char feed_request[] = "{\"capabilities\": {\"feeds\": [\"Acceleration\",\"Light\"], \"modules\": {\"slot1\":\"LCD\"}}}";
const char message_header[] = "%x\r\n{\"message\": {\"payload\":%s}}\r\n\r\n\r\n";
char pktbuff[500];
+int pktlen;
void swarm_init(){
@@ -33,7 +34,8 @@ void swarm_send_produce(const char *swarm_id, const char *resource_id, const cha
void swarm_produce(char *message, struct rsi_socketFrame_s *sock){
memset(pktbuff, '\0', sizeof(pktbuff));
- sprintf(pktbuff,message_header,strlen(message)+sizeof(message_header)-11,message);
+ pktlen = strlen(message)+sizeof(message_header)-11;
+ sprintf(pktbuff,message_header,pktlen,message);
sock->buf = (uint8 *)pktbuff;
sock->buf_len = strlen((const char *)sock->buf);
rsi_send(sock);

0 comments on commit d23a3c2

Please sign in to comment.