File tree Expand file tree Collapse file tree 1 file changed +44
-0
lines changed Expand file tree Collapse file tree 1 file changed +44
-0
lines changed Original file line number Diff line number Diff line change 1+ #include  < Arduino.h> 
2+ #include  < AltSoftSerial.h> 
3+ #include  " BC95Udp.h" 
4+ #include  " CoAP.h" 
5+ 
6+ AltSoftSerial bc95serial;
7+ 
8+ BC95UDP udp;
9+ Coap coap (udp);
10+ 
11+ void  responseHandler (CoapPacket *packet, IPAddress remoteIP, int  remotePort) {
12+     char  buff[6 ];
13+ 
14+     Serial.print (" CoAP Response Code: " 
15+     sprintf (buff, " %d.%02d \n " code  >> 5 , packet->code  & 0b00011111 );
16+     Serial.print (buff);
17+ 
18+     for  (int  i=0 ; i< packet->payloadlen ; i++) {
19+         Serial.print ((char ) (packet->payload [i]));
20+     }
21+ }
22+ 
23+ void  setup () {
24+     bc95serial.begin (9600 );
25+     BC95.begin (bc95serial);
26+     BC95.reset ();
27+ 
28+     Serial.begin (9600 );
29+     Serial.println (F (" Starting..." 
30+ 
31+     while  (!BC95.attachNetwork ()) {
32+         Serial.println (" ..." 
33+         delay (1000 );
34+     }
35+     Serial.println (F (" NB-IOT attached.." 
36+ 
37+     coap.response (responseHandler);
38+     coap.start ();
39+     coap.get (" coap.me" 5683 , " /hello" 
40+ }
41+ 
42+ void  loop () {
43+     coap.loop ();
44+ }
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments