2022-08-03 00:11:49 +00:00
# include <furi.h>
# include <furi_hal_console.h>
# include <furi_hal_gpio.h>
# include <furi_hal_power.h>
# include <furi_hal_uart.h>
# include <gui/canvas_i.h>
# include <gui/gui.h>
# include <input/input.h>
# include <math.h>
# include <notification/notification.h>
# include <notification/notification_messages.h>
# include <stdlib.h>
2022-10-07 18:05:16 +00:00
2022-08-03 00:11:49 +00:00
# include "FlipperZeroWiFiModuleDefines.h"
# define WIFI_APP_DEBUG 0
# if WIFI_APP_DEBUG
# define APP_NAME_TAG "WiFi_Scanner"
# define WIFI_APP_LOG_I(format, ...) FURI_LOG_I(APP_NAME_TAG, format, ##__VA_ARGS__)
# define WIFI_APP_LOG_D(format, ...) FURI_LOG_D(APP_NAME_TAG, format, ##__VA_ARGS__)
# define WIFI_APP_LOG_E(format, ...) FURI_LOG_E(APP_NAME_TAG, format, ##__VA_ARGS__)
# else
# define WIFI_APP_LOG_I(format, ...)
# define WIFI_APP_LOG_D(format, ...)
# define WIFI_APP_LOG_E(format, ...)
# endif // WIFI_APP_DEBUG
# define DISABLE_CONSOLE !WIFI_APP_DEBUG
# define ENABLE_MODULE_POWER 1
# define ENABLE_MODULE_DETECTION 1
# define ANIMATION_TIME 350
typedef enum EChunkArrayData {
EChunkArrayData_Context = 0 ,
EChunkArrayData_SSID ,
EChunkArrayData_EncryptionType ,
EChunkArrayData_RSSI ,
EChunkArrayData_BSSID ,
EChunkArrayData_Channel ,
EChunkArrayData_IsHidden ,
EChunkArrayData_CurrentAPIndex ,
EChunkArrayData_TotalAps ,
EChunkArrayData_ENUM_MAX
} EChunkArrayData ;
typedef enum EEventType // app internally defined event types
{ EventTypeKey // flipper input.h type
} EEventType ;
typedef struct SPluginEvent {
EEventType m_type ;
InputEvent m_input ;
} SPluginEvent ;
typedef struct EAccessPointDesc {
2022-10-05 18:27:13 +00:00
FuriString * m_accessPointName ;
2022-08-03 00:11:49 +00:00
int16_t m_rssi ;
2022-10-05 18:27:13 +00:00
FuriString * m_secType ;
FuriString * m_bssid ;
2022-08-03 00:11:49 +00:00
unsigned short m_channel ;
bool m_isHidden ;
} EAccessPointDesc ;
typedef enum EAppContext {
Undefined ,
WaitingForModule ,
Initializing ,
ScanMode ,
MonitorMode ,
ScanAnimation ,
MonitorAnimation
} EAppContext ;
typedef enum EWorkerEventFlags {
WorkerEventReserved = ( 1 < < 0 ) , // Reserved for StreamBuffer internal event
WorkerEventStop = ( 1 < < 1 ) ,
WorkerEventRx = ( 1 < < 2 ) ,
} EWorkerEventFlags ;
typedef struct SWiFiScannerApp {
2023-03-07 21:18:23 +00:00
FuriMutex * mutex ;
2022-08-03 00:11:49 +00:00
Gui * m_gui ;
FuriThread * m_worker_thread ;
NotificationApp * m_notification ;
2022-10-07 18:05:16 +00:00
FuriStreamBuffer * m_rx_stream ;
2022-08-03 00:11:49 +00:00
bool m_wifiModuleInitialized ;
bool m_wifiModuleAttached ;
EAppContext m_context ;
EAccessPointDesc m_currentAccesspointDescription ;
unsigned short m_totalAccessPoints ;
unsigned short m_currentIndexAccessPoint ;
uint32_t m_prevAnimationTime ;
uint32_t m_animationTime ;
uint8_t m_animtaionCounter ;
} SWiFiScannerApp ;
2023-05-21 23:54:04 +00:00
/*
Fontname : - FreeType - Inconsolata LGC - Bold - R - Normal - - 36 - 360 - 72 - 72 - P - 176 - ISO10646 - 1
Copyright : Original Roman version created by Raph Levien using his own tools and FontForge . Copyright 2006 Raph Levien . Hellenisation of the Roman font , by Dimosthenis Kaponis , using FontForge . Hellenic glyphs Copyright 2010 - 2012 Dimosthenis Kaponis . Released under the SIL Open Font License , http : //scripts.sil.org/OFL. Cyrillic glyphs added by MihailJP, using FontForge. Cyrillic glyphs Copyright 2012 MihailJP. Released under the SIL Open Font License, http://scripts.sil.org/OFL. Emboldened by MihailJP. Some glyphs modified by Greg Omelaenko, using FontForge.
Glyphs : 95 / 658
BBX Build Mode : 2
*/
const uint8_t u8g2_font_inb27_mr [ 4414 ] =
" _ \2 \5 \4 \5 \6 \1 \4 \6 \26 % \0 \370 \33 \371 \35 \371 \5 e \13 \313 \21 ! \13 \266 \14 \366 \207 \377 \377 \377 "
" \20 \0 ! \30 \266 \14 \366 \7 ` \310 \22 \353 E \42 \351 \177 r|( \220 h \240 - \222 \17 \37 \42 % \266 \14 v \37 "
" d, \62 \310 \42 \203 , \62 \310 \42 \203 , \62 \310 \42 \203 , \62 \310 \42 \203 , \62 \310 \42 \203 | \370 \377 \307 \1 # "
" M \266 \14 \366 \7 u \220 \261 \310 \213 \14 \262 \310 \213 \14 \262 \310 k \20 b \36 \343 \1 \62 \36 \3 ; "
" d \220 E \6 Yd \220 \65 \10 Y \203 \220 \365 \306 \3 c<@ \306 \3 \344 \220 A \26 \31 d \221 A \326 d \15 "
" \62 \330 \203 \15 \62 \26 ! \343 \303 \63 \0 $A \266 \14 \366 \7 \200 H \352 \251 \325 \320 ;$ \220 P \14 \21 d \210 "
" C \4 \31 \1 \21 AX \11 \244 e. \271 \325 \64 F \202 YD \224 E \6 Yd \20 \23 \10 \31 \244 \214 AD! "
" & \220 P \314 Cm \251 G$ \365 \341 \42 \0 %I \266 \14 \366 \7 \261 \34 RN!% \21 B \226 \205 \14 \42 "
" H! \203 \4 b \310 H \346 ! \227 N \253 \204 \22 I, \221 \222 d \10 F \302 Q \15 \221 \220 N \32 \304 \220 @ "
" \6 )% \220 A \12 \21 d \20 R \304 \42 \204 $R \312 ) \344 \224 \17 / \3 &F \266 \14 \366 \7 \264 \274 \304 \326 "
" b \251 \214 \222 H! \211 \24 \222 H! \212 \14 \262 \310 \214 \4 \322 \220 ; \16 \65 E \302 ! \202 \220 A \250 A \221 "
" \22 \310 & \15 r \16 ! \250 \224 bL) \5 \225 \7 Fa \241 \224 \64 \310 \61 F|x \30 \0 ' \17 \266 \14 "
" \366 \7 aH \372 \357 \303 \377 \177 \1 \0 (( \266 \14 v \14 sD \363 \216 \63 \317 @ \22 \13 , \221 \304 \22 \211 $ "
" \261 D \42 \351 \223 ER \262 \304 \42 K, \262 \212 v \261 L \241 \1 )$ \266 \14 \266 \26 \263 D \233 \254 \305 \42 K "
" , \222 \310 \42 \351 _$ \222 \304 \22 I, \260 \304 \2 \313 \263 \301 \22 \307 \7 \7 \0 */ \266 \14 \366 \207 \207 \210 \244 "
" \261 PH \11 \205 \14 \62 F \61 a \10 C \36 \30 \306 \261 \2 \317 C \215 \10 \262 \310 ( \251 \20 \202 \212 !h \234 \261 "
" \2 \12 \37 \376 , \0 + \33 \266 \14 \366 \207 \207 \210 \244 \267 \36 \30 \344 \201 A \36 \30 \344 \201 \261 \210 \244 \337 \207 \277 \14 "
" \0 , \30 \266 \14 \366 \207 \377 \377 \300 \220 % \32 hI \42 \307 \34 rH \42 \7 \15 \15 \0 - \26 \266 \14 \366 \207 \177 "
" \352 \201 ` \36 \10 \346 \201 ` \36 \10 \37 \376 \277 \4 \0 . \21 \266 \14 \366 \207 \377 \377 \0 \211 \6 \332 \42 \371 p \22 \0 "
" /. \266 \14 \366 \33 \223 \304 \22 I, \221 H \22 \211 $ \221 H \22 \211 $ \221 H \22 K$ \261 D \22 K$ \261 "
" D \42 I$ \222 D \42 \211 \34 \65 |x \17 \0 \60 I \266 \14 \366 \7 \266 < \324 \324 b \251 \220 \202 \210 ! \247 \230 "
" b \310 ) \206 \30 SJA \204 \24 \22 \10 !e \10 B \10 \31 \203 \20 \62 (B \306 \224 \30 \205 \20 \22 \206 ! "
" \4 \31 R \214 ) \245 \34 b \312 ! \247 \224 r \12 ) \211 - \325 \20 , \37 ^ \7 \61 \26 \266 \14 \366 \7 \226 @ \363 "
" NKL \265 ! \210 \244 \377 \377 \367 \341 y \0 \62 ' \266 \14 \366 \7 \325 \70 \265 Xr \247 \24 s \306 )($ \42 "
" i \261 D \22 \13 \254 \277 H \311 g \36 \10 \346 \201 ` \36 \10 \37 \36 \6 \63 - \266 \14 \366 \7 \324 \70 \265 Xri "
" \230 \222 \2 \42 \222 \26 \313 \63 , \265 \363 RS \261 \310 \42 i) \202 \304 ) \207 \224 r \36 jj \265 \363 \341 y "
" \0 \64 \65 \266 \14 \366 \7 \232 H \22 \13 \264 \336 q \310 \215 @ \32 \11 \204 \21 A \330 \30 d \221 A \24 !$ \221 B "
" \22 ) \4 \21 C \316 \3 \203 < \60 \310 \3 \203 < \60 \36 \221 \364 }x \32 \0 \65 * \266 \14 \366 \7 \361 \235 \337 ! "
" \222 N \20 \306 TK \16 \25 b \316 \70 % \5 T$ \275 #P) \4 \21 cJ \61 \17 \265 \245 \234 \371 \360 : \0 "
" \66 > \266 \14 \366 \7 \327 \70 \265 Xj \250 \224 \221 \310 \11 \211 H \22 K$ \243 ( \22 \22 z \347 \201 `L) \246 "
" \234 R \10 * \205 $RH \42 \205 $R \12 \42 \206 \234 b \212 ! \250 \220 \202 \232 b+= \363 \341 q \0 \67 - "
" \266 \14 \366 \7 \360 \201 ` \36 \10 \346 \201 ` \236 $ \261 D \22 K$ \222 \304 \22 I, \221 H \22 K$ \222 \304 \22 "
" I \254 \42 \211 U$ \261 | \370 \4 \0 \70 ; \266 \14 \366 \7 \325 \70 \265 Xj \250 \224 r \212 ! \207 \356 \24 C \20 "
" )$ \225 Q \324 b \251 )U \204 I \244 \224 C \31 \202 J! \211 \24 \222 H! \211 \224 r \212 ) \245 \234 \207 \232 "
" Z \355 |x \35 \0 \71 \71 \266 \14 \366 \7 \265 \274 \304 \326 b \251 \220 \202 \210 ! \247 \230 b \10 \42 \206 b \10 \42 "
" \206 b \312 \241 L \71 \205 \30 \344 \251 \23 \10 \33 \203 H \42 \207 $* \34 \222 D) \251 % \266 \322 + \37 >: "
" \27 \266 \14 \366 \207 \77 A \242 \201 \266 H>| \210 D \3 m \221 | \70 \11 \0 ; \34 \266 \14 \366 \207 \77 A \242 \201 "
" \266 H>| \210 D \3 \255 X$ \221 C \222 HM \361 \1 \1 < \266 \14 \366 \207 \271 \60 G, \357 \264 \304 \360 "
" \265 \363 J< \20 \301 \23 / \210 \301 \3 \215 $T| \370 \25 \0 = \266 \14 \366 \207 \317 = \60 \310 \3 \203 < \60 "
" \310 \3 \343 \303 \352 \3 \203 < \60 \310 \3 \203 < \60 > \374 g \1 > \36 \266 \14 \366 \207 \266 \240 D \32 \210 \37 < \261 "
" \274 \323 \20 \303 \332 \325 P; \257 \304 \61 \305 \207 \277 \6 \0 \77 % \266 \14 \266 \67 N \251 \206 \236 \61 \245 \34 r \312 \21 "
" \211 H* \226 Hb \201 u \221 H \352 C \226 D \3 m \221 |x \36 \0 @G \266 \14 \366 \7 \266 \274 \264 \32 r "
" \247 \230 b \10 \42 \205 (B \306 Ad \24 \65 \6 ac \20 \66 \306 ( \204 \214 \61 H!c \14 R \310 \30 \203 \24 "
" \62 \306 \250 \306 \30 m \220 \301 \310 \213 \20 R \2 !d \222 YNH. \265 \245 \234 \371 \360 \70 \0 A< \266 \14 "
" \366 \7 \67 PA \307 \34 \262 \304 \2 \15 < \357 \70 \22 H# \201 \264 ! \10 # \203 , \62 \310 \32 e(RHj "
" \311 \235 \357 \220 S \12 I \244 \220 T \6 Yd \220 E \6 Y% \220 F>< \13 \0 BD \266 \14 \366 \7 \217 ) "
" \207 \36 \10 \346 \201 ` \310 \61 \205 \240 RH \42 \205 $RH \42 \205 \240 R \310 ) \346 \201 ` \336 \371 @ \60 \4 \225 "
" BR!D \21 B \24 !D \21 B \24 !$ \25 B \220 ! \17 \210 \362 @ \60 \357 \264 \17 \217 \3 C/ \266 \14 "
" \366 \7 \327 \264 \245 \32 z \306 \24 S \312 ) \244 $B \210 \22 \206 \304 \22 \211 \244 'K, \222 \310 \22 \213 \12 \247 \240 "
" a \214 ) \346 \241 \246 V \63 \37 \36 \7 DC \266 \14 \366 \7 o \255 \226 \336 y \207 \30 c \10 * \205 \240 RH \42 "
" \205 \244 B \210 \42 \204 (B \210 \42 \204 (B \210 \42 \204 (B \210 \42 \204 (B \210 \42 \204 \244 BH \42 \205 \240 "
" R \10 \42 \206 \30 c \336 q \250 \245 \365 \341 y \0 E' \266 \14 \366 \7 \357 \1 Q \36 \20 \345 \1 Q \36 \20 \205 H "
" \372 \344 ; \277 C$ \375 \344 \3 \242 < \312 \3 \242 < >< \14 \0 F \35 \266 \14 \366 \7 \360 \201 ` \36 \10 "
" \346 \201 ` \36 \10 \206 H \372 \244 C>D$ \375 \357 \303 W \0 G: \266 \14 \366 \7 \326 \70 \245 \32 z \306 \24 S "
" \312 ) \244 $a \210 $ \261 D \42 i& \15 b \322 & \15 b \322 ( \212 \20 \242 \10 ! \212 \220 \222 H) \210 "
" \24 c \212 y \34 \227 \30 ; \37 \36 \7 HM \266 \14 \366 \7 \217 $RH \42 \205 $RH \42 \205 $RH "
" \42 \205 $RH \42 \205 $RH \42 \205 $R \36 \20 \345 \1 Q \36 \20 \345 \1 QH \42 \205 $RH \42 \205 "
" $RH \42 \205 $RH \42 \205 $RH \42 \205 $RH \42 \205 $ \362 \341 a \0 I \24 \266 \14 \366 \7 \320 "
" !_# \222 \376 \377 k \357 \374 > \274 \14 \0 J \33 \266 \14 \366 \7 \264 \245 \236 # \222 \376 \377 \222 \60 % \215 BR "
" S \213 \245 W>| \1 \0 KI \266 \14 \366 \7 \257 \244 \62 H* \204 \240 R \310 ) \206 \230 rH) \210 \24 \222 "
" \10 ! \212 \14 \262 \210 ( \213 \204 \302 RKM \261 \22 \312 \42 \203 , \62 \212 \42 \244 $RH \42 \245 b \312 ! "
" \247 \30 r \212 ! \250 \24 \222 \12 ! \251 \20 \242 \312 \207 g \1 L \32 \266 \14 \366 \7 \260 D \42 \351 \377 \377 \311 \7 D "
" y@ \224 \7 Dy@|x \27 \0 MU \266 \14 \366 \7 \217 , \62 \310 \42 \243 \244 \62 J* \303 \34 \63 \314 \61 "
" \343 \224 \63 N \71 \3 \33 $ \214 \61 \2 \31 $ \320 \6 \21 # \14 A \6 \21 # \14 A \6 \31 eP \243 \14 \32 ! "
" \203 \220 A \310 \213 \14 \262 \310 \213 \14 \262 \310 \213 \14 \262 \310 \213 \14 \262 \310 \213 \14 \262 \310 \207 g \1 "
" NS \266 \14 \366 \7 \217 (BJ \42 \244 $B \14 \42 \304 B \316 ! \344 \34 B \220 ! \204 \4 R \10 ! \201 "
" \24 B \210 \204 \22 \204 P \203 \42 dP \204 \22 \204 P \202 \20 RH \204 \230 \21 \10 ! \6 \21 r \16 ! \347 "
" \20 \202 \14 ! \310 \20 \222 \12 ! \251 \20 \242 \10 ! \212 |x \27 \0 OC \266 \14 \366 \7 \325 \70 \265 Xr \247 \224 "
" r \310 ) \245 RH* \204 ( \62 \212 \42 \203 , \62 \310 \42 \203 , \62 \310 \42 \203 , \62 \310 \42 \203 , \62 \212 "
" \42 \204 (BH* \244 b \310 ) \246 \224 \202 \134 bK \71 \363 \341 u \0 P \60 \266 \14 \366 \7 \257 \245 w \36 "
" \10 \346 \1 Q \10 * \205 \244 B \210 \42 \204 (B \210 \42 \204 (BH* \204 \240 R \36 \20 \345 \201 ` \34 b \212 "
" H \372 \357 \303 g \0 QJ \266 \14 \366 \7 \325 \70 \265 Xr \247 \224 r \310 ) \245 RH* \204 \244 \62 \212 \42 "
" \203 , \62 \310 \42 \203 , \62 \310 \42 \203 , \62 \310 \42 \203 , \62 \212 \42 \204 \244 BH* \244 b \310 ) \246 \224 "
" \202 \134 b+ \271 \23 \211 $R \265 \344 \20 \64 \37 @ \0 RC \266 \14 \366 \7 \217 ) \207 \336 y \30 rL! "
" \250 \24 \222 H! \211 \24 \222 H! \211 \24 \202 J! \247 \230 \7 \202 y \307 ! \246 H! \211 \24 \222 H) \210 \30 "
" \202 \210 ) \207 v \212 ! \210 \30 \202 J! \211 \24 \222 \312 \207 w \1 S \61 \266 \14 \366 \7 \365 \264 \245 \32 z \207 \230 "
" \12 \211 C \222 \70 DV \321 D \364 \262 \207 \242 \221 ER&,b \302 \42 e \244 B \214 ) \345 \1 a^b \354 "
" |x \35 \0 T \27 \266 \14 \366 \7 \356 \1 \62 \36 \343 \1 \62 \36 \212 H \372 \377 \377 >|UH \266 \14 \366 "
" \7 \257 $B \210 \42 \204 (B \210 \42 \204 (B \210 \42 \204 (B \210 \42 \204 (B \210 \42 \204 (B \210 \42 \204 "
" (B \210 \42 \204 (B \210 \42 \204 (B \210 \42 \204 (B \210 \42 \244 \240 B \12 * \245 \230 b \36 rJ \71 \363 "
" \341 u \0 V> \266 \14 \366 \7 \216 \60 \42 \10 # \203 (B \210 \42 \204 (R \10 \42 \206 b \10 \42 \207 \30 \202 "
" \210 ! \210 \30 \222 H \31 \212 \20 \242 \10 ! \213 \214 \301 \210 \214 \10 \322 H \30 \16 { \6 Z \221 H \42 \7 \25 \37 "
" >W \134 \266 \14 \366 \7 n \22 \303 \15 A \212 (D \220 \62 \10 \21 \244 \14 B \4 ! \204 \214 A \10 ! \23 )c "
" \20 \62 \312 \30 \204 \10 \63 \6 ! \302 \10 B \210 \70 \201 \20 \42 N \30 f \204 !F \30 \346 \210 \21 \206 \71 \342 \230 # "
" \216 \61 \304 \30 C \12 * \244 \240 B \12 \42 \206 b \10 \42 \206 \240 q \206 \22 H( \201 \304 \207 \247 \1 XB \266 "
" \14 \366 \7 \217 (BH \42 \206 b \212 ! \210 \224 \202 \12 ! \212 \214 \242 \212 \214 \204 \302 \222 ; \320 \300 \22 K "
" \64 \357 < \324 \24 # \202 , \62 \212 \42 \204 $R \12 \42 \206 \34 rJ) \210 \24 \222 \312 ( \252 |x \26 \0 Y "
" \60 \266 \14 \366 \7 \216 \254 \42 \212 \42 \204 \244 B \12 \42 \206 b \212 ! \210 \30 \202 \12 ! \212 \20 \242 \212 \214 \10 "
" \322 H \30 \16 \275 \363 L, \221 H \372 \357 \303 \363 \0 Z \63 \266 \14 \366 \7 \360 \1 Q \36 \20 \345 \1 Q \36 \10 \222 "
" D \22 K \244 b \211 $ \226 H \305 \22 I, \260 D \22 \13 , \261 \300 \22 \37 \20 \344 \201 A \36 \30 \344 \201 \361 \341 "
" ] \0 [ \23 \266 \14 \366 n \251 \227 \210 \244 \377 \377 \77 \331 R \357 C \10 \0 \134 + \266 \14 \66 \21 \262 H \42 \213 $ "
" \262 H \42 \213 $ \262 Hj \22 I& \221 d \22 Id \221 D \26 Id \221 D \26 IM \42 \311 \14 \37 \36 \1 "
" ] \20 \266 \14 vn \251 ' \351 \377 \377 _ \352 \373 \220 \2 ^! \266 \14 \366 \7 WL \42 I \64 \357 < \324 \210 "
" \213 \14 \262 \10 ! \211 \24 \222 \210 !I \34 \361 \341 \377 \17 \2 _ \26 \266 \14 \366 \207 \377 \377 \247 \36 \343 \1 \62 \36 "
" \343 \1 \362 ! \3 \0 ` \33 \266 \14 \266 \11 UPA \307 $ \222 \310 \22 \213 , \261 \310 \42 \251 \71 Q \361 \341 \377 "
" g \0 a \60 \266 \14 \366 \207 \217 \236 \266 \222 C. \15 S$ \325 Rj \347 \231 \7 \202 ) \207 \224 \202 H! \211 \24 "
" \202 J) \345 \230 \7 \202 y \34 \25 H \62 \203 |x \30 \0 b; \266 \14 \66 . \221 H \372 \215 \242 HH \350 "
" \235 \7 \202 \61 \305 \224 rJ! \251 \20 \222 \12 ! \212 \20 \242 \10 ! \212 \20 \242 \10 ! \212 \20 \222 \12 ) \210 \24 c "
" Jy \230 w \206 Hh \220 \362 \341 u \0 c( \266 \14 \366 \207 \257 \32 \247 \224 ; \17 \4 S \225 \202 \206 !I "
" \230 \22 \211 \244 \311 \42 \211 ,H \240 b \310 y \34 \247 \224 \63 \37 \36 \7 d; \266 \14 \366 \7 \207 H \372 \251 \62 "
" \10 J \201 \234 g \36 \10 \245 \30 S \10 * \244 \240 BH* \204 (B \210 \42 \204 (B \210 \42 \244 \240 B \12 * "
" \245 \234 R, \363 @ \70 \17 \245 @T \31 \344 \303 \273 \0 e, \266 \14 \366 \207 \217 \236 \266 TC \317 T \206 b "
" H \42 \344 \201 A \36 \30 \344 \201 A \36 \30 \204 H \42 \253 \24 \216 \61 \344 < \344 \322 r \346 \303 \343 \0 f \35 \266 \14 "
" \366 \7 \302 \70 \265 Xj \250 \230 \201 \312 \11 \211 H \312 \71 \344 cD \322 \377 \367 \341 \23 \0 g= \266 \14 \366 \207 o "
" \26 R \314 \3 \241 < \10 !j \224 R \16 } \247 \224 r \314 ( \251 \251 \265 \324 \42 a \64 \42 [z \234 \7 "
" \202 y@ \20 \222 \312 \213 \14 \262 \310 ( \251 \214 \7 Fy \34 \267 \220 \7 h< \266 \14 v. \221 H \372 \215 "
" \242 \210 @ \210 \4 u \336 \71 \244 \30 c \210 ) \207 \30 \202 \210 ! \210 \30 \202 \210 ! \210 \30 \202 \210 ! \210 \30 \202 \210 "
" ! \210 \30 \202 \210 ! \210 \30 \202 \210 ! \210 \30 \202 \310 \207 \207 \1 i \30 \266 \14 \366 \7 ` \310 \22 + \71 >$S "
" \313 I \372 \277 \326 R \357 \303 \323 \0 j \37 \266 \14 \366 \7 d \310 \22 + \71 > \364 \230 \342 I \372 \377 \227 \204 ) \210 "
" \220 \202 \134 bK \71 \363 A \0 k \71 \266 \14 v. \221 H \372 \241 R \310 ) \206 \230 rH) \210 \220 \222 \310 ( "
" \212 \210 \262 H(Lck \25 Q \24 !% \221 R \20 ) \5 \21 S \16 \71 \305 \20 T \12 A \206 \220 d> \274 "
" \12 \0 l \21 \266 \14 vVL' \351 \377 \377 \330 ; \277 \17 / \3 m@ \266 \14 \366 \207 \257 \221 PF!+ \234 "
" \361 \0 \31 \17 \24 QF \21 \325 \204 \10 B(A \10 % \10 \241 \4 ! \224 \204 \22 \204 P \202 \20 J \20 B "
" \11 B(A \10 % \10 \241 \4 ! \224 \204 \22 \204 P \37 \236 \5 n: \266 \14 \366 \207 \357 \221 Q \24 \21 \10 \275 "
" \363 \316 ! \305 \224 CL \71 \304 \20 D \14 A \304 \20 D \14 A \304 \20 D \14 A \304 \20 D \14 A \304 \20 D \14 "
" A \304 \20 D \14 A \304 \20 D>< \14 \0 o \62 \266 \14 \366 \207 \257 \32 \247 TC \357 \224 bJ \71 \245 \220 T "
" FIe \220 E \6 Yd \220 E \6 Yd \24 E \10 I \244 \224 SL) \306 < \324 \324 r \346 \303 \343 \0 p "
" = \266 \14 \366 \207 \317 \221 Q \24 \11 \11 = \20 \314 \3 \301 \230 bJ \71 \245 \220 T \10 I \205 \20 E \10 Q \204 \20 "
" E \10 Q \204 \20 E \10 I \205 \24 D \212 \61 \245 < \20 \314 ;$$DFQD \322 \367 \301 \1 q \71 \266 \14 "
" \366 \207 \217 \32 AP \12 \344 < \363 @( \305 \230 BP! \5 \25 B \24 !D \21 B \24 !D \21 B \24 ! "
" % \221 BP) \345 \224 b \231 \7 \302 y( \5 \242 \312 \222 ~ \30 \0 r \37 \266 \14 \366 \207 \17 \22 R \22 \21 "
" \351 < \20 \314 \3 \301 \34 # \216 \71 \342 \224 X \42 \221 \364 \277 \17 \37 \1 s, \266 \14 \366 \207 \217 \232 \306 \222 C \317 "
" \24 C \16 A \343 \24 \24 R \211 \351 ) \227 \340 \221 \305 \10 E \214 P \244 \224 S \312 \3 \341 \270 \304 \332 \371 \360 : \0 "
" t \35 \266 \14 \366 \207 \234 \220 \364 \332 ; \277 E$ \375 \223 \305 \4 U \212 XL \261 \245 \232 \371 \360 \66 \0 u; \266 "
" \14 \366 \207 \317 \221 D \12 I \244 \220 D \12 I \244 \220 D \12 I \244 \220 D \12 I \244 \220 D \12 I \244 \220 D \12 "
" I \244 \220 DJ \71 \245 \224 SL) \306 < \20 \316 C) \20 U \6 \371 \360 \60 \0 v \63 \266 \14 \366 \207 \257 \25 "
" E \10 Q \204 \20 E \12 I \303 \20 DL \71 \3 \21 C \20 \61 $ \221 \62 \24 !D \21 \62 \30 \21 \204 \21 A \32 "
" \11 \303 !w \240 \201 E \22 \71 >|wH \266 \14 \366 \207 \217 Q \202 \60 \42 H \31 \204 \214 Q \6 !c \224 A "
" \310 \243 \14 j \224 A \215 \62 F \31 \303 \210 Q \206 \30 a \210 QH \230 \304 ($Lb \24 \22 \204 @ \306 \14 "
" s \314 \60 \307 \14 sJ) \247 \224 \202 H! \211 \24 \362 \341 i \0 x \63 \266 \14 \366 \207 \317 \221 DJ \71 \305 \24 "
" C \20 )D \221 QT \21 \204 % \207 \334 \201 % \232 w \36 j$ \224 U \4 Q \205 \220 DJ \71 \305 \224 R \20 "
" )$ \225 \17 \357 \2 y< \266 \14 \366 \207 \317 \225 T \10 I \244 \220 DJA \304 \220 CC \304 \20 D \12 I \205 "
" \20 E \310 Xd \20 F \4 aD \14 \67 \2 q \347 \35 h` \221 T$, \24 \262 \4 !L- \325 \320 + \37 "
" \24 \0 z& \266 \14 \366 \207 \357 = \20 \314 \3 \301 < \20 \314 \213 $ \26 X \213 $ \26 X \27 \13 |@ \220 \7 \6 "
" y` \220 \7 \306 \207 w \1 {$ \266 \14 \366 \7 \342 \264 \304 \324 Z \253 \300 \22 \211 \244 _$ \357 < \3 \15 < \262 "
" H \372 'K,r \255 \305 \224 C \32 \0 | \16 \266 \14 \366 \7 \200 H \372 \377 \377 \377 \357 \3 }# \266 \14 \266 \66 "
" \20 \271 \324 \224 , \222 \376 d \221 d \36 h \336 q \310 \221 H$ \375 \213 e) \246 Xj \347 \3 \1 \0 ~ \31 \266 "
" \14 \366 \207 / \232 \23 \214 \42 d< \60 \306 \3 \303 \210 \202 ` \371 \360 \377 \303 \0 \0 \0 \0 \4 \377 \377 \0 " ;
/*
Fontname : open_iconic_arrow_2x
Copyright : https : //github.com/iconic/open-iconic, SIL OPEN FONT LICENSE
Glyphs : 28 / 28
BBX Build Mode : 0
*/
const uint8_t u8g2_font_open_iconic_arrow_2x_t [ 644 ] =
" \34 \0 \4 \4 \5 \5 \4 \4 \6 \20 \20 \0 \0 \16 \0 \16 \0 \0 \17 \0 \0 \2 g@ \17 \352 i \302 $P \376 \221 "
" \12 \64 \246 \310 \11 \2 A \22 O% \303 \24 Z \360 X \242 \17 ^ \20 \36 -<( \0 B \22 O! \303 \32 \134 \364 "
" ` \22 \17 \236 \222 \35 ,: \20 \0 C \17 \352 ) \302 $ \216 \224 \31 \24 \212 \4 \312 \77 \2 D \37 \20 \42 \302 eP "
" \25 ! \62 \205 \212 \24 *a \210 # \304 E \17 \222 F \244 P \231 \42 \245 \24 \232 \2 E \20 \42 \302 ePU "
" \11 \63 E \216 \220 \71 Ah-a \302 e \15 \241 s \244 \310 \231 \22 \246 \24 \232 \2 F \37 \20 \42 \302 eP \225 "
" \211 \62 G \212 \234 ! \201 \310 laj \27 \221 \70 C \344 H \31 \23 \245 \24 \232 \2 G \37 \20 \42 \302 ePU \221 "
" \62 \205 \212 \20 #A \360 haD \34 \231 (T \244 P \31 B \244 \24 \232 \2 H \21 \12 . \302 C \214 \376 \215 \212 "
" $ \207 \212 \15 \14 \4 \0 I \23 P \341 \302 \25 \134 \364 ` \27 \17 \36 \204 xBz \270 P \0 J \23 P \341 \302 * "
" | \64 \221 \27 \17 \36 \204 p<Zx( \0 K \21 \12 . \302 \24 pX \241 #) \324 \20 \243 \177 \3 \0 L \16 "
" \356 d \303 \340 \202 \215 *t& \311 \12 \3 M \24 \307 u \302 \26 J \320 \30 \42 % \36 \224 \60 R \206 \320 (a \1 "
" N \25 \307 q \302 \20 L \324 \62 EL<(Q \204 \314 Q \301 \0 O \15 \356 $ \303 & \226 \244 \71 Tj "
" X \70 P \24 .% \303 !P \4 \261 D% \212 \224 Q \205 \316 $Ya \0 Q \20 \311 m \302 & \214 P \231 : "
" *UW \304 D \0 R \17 \311 m \302 ! \214 T=*SG \304 \204 \1 S \24 .% \303 & \226 \244 \71 Tj "
" \212 \224 ( \224 \214 \204 @ \21 \0 T \23 \20 \42 \302 F \230 ^ \252 Ci \226 \264 x \230 >x \0 U \23 \20 \42 "
" \302 \360 \201 x \230 \212 &k \22 \235 J \302 \364 \14 \0 V \34 \320 \241 \302 \34 \36 \200 \30 \27 / \204 \12 \21 \32 \36 \302 "
" \240 B \204 \212 x \341 F< \200 \300 \0 W \32 \220 \241 \302 & \230 \354 hq \202 \304 \221 \21 \306 L \14 \71 A \342 D "
" \217 %, \14 \0 X \37 \20 \42 \302 \302 \210 \221 @A \2 \205 K$ \314 \210 \70 \42 \344 \204 \30 \23 $ \134 BA \2 "
" \5 q \2 \0 Y$ \17 \42 \302 \34 \134 \304 \270 TF \306 \214 \20 \64 bH \260 \262 \203 \211 \226 \34 \42 $ \320 \230 \21 "
" \42 H \245 +,: \10 \0 Z \30 \220 ! \303 \32 \36 \200 \360 \321 \4 S \61 \351 \206 \324 q \202 \4 \206 \12 \17 \0 "
" [ \34 \320 \241 \302 ` \324 X \30 q&D-J!& \211 \230 `a \204 \313 P \220 @A \34 \1 \0 \0 \0 \4 "
" \377 \377 \0 " ;
/*
Fontname : - Adobe - Courier - Bold - R - Normal - - 11 - 80 - 100 - 100 - M - 60 - ISO10646 - 1
Copyright : Copyright ( c ) 1984 , 1987 Adobe Systems Incorporated . All Rights Reserved . Copyright ( c ) 1988 , 1991 Digital Equipment Corporation . All Rights Reserved .
Glyphs : 18 / 873
BBX Build Mode : 0
*/
const uint8_t u8g2_font_courB08_tn [ 199 ] =
" \22 \0 \3 \3 \3 \4 \2 \3 \4 \6 \11 \0 \376 \6 \376 \7 \377 \0 \0 \0 \0 \0 \252 \5 \0 \353 \0 * \11 $ \357 "
" \212 P$ \241 \0 + \12 - \353 \12 \206 J \301 \20 \0 , \7 \233 \345 \221 $ \1 - \5 \15 \357 (. \5 \212 \351 \20 "
" / \14 \304 \347 K \212 \205 b \241 X \14 \0 \60 \12 = \351 \231 Hx \221 L \0 \61 \10 > \351 \22 \21 u \62 \62 \11 "
" = \351 \231 \250 \211 \264 \34 \63 \14 = \351 \231 \250 I \206 \24 \311 \4 \0 \64 \14 > \351 \223 \215 \42 ZlB \11 \0 \65 "
" \12 = \351 \270 Q \324 F \26 \0 \66 \14 = \351 \231 Hh \24 \11 E \62 \1 \67 \13 = \351 \270 \310 D \62 \221 L \4 "
" \70 \15 = \351 \231 H( \222 \211 \204 \42 \231 \0 \71 \14 = \351 \231 H( \22 \32 E \62 \1 : \6 \242 \351 \20 \12 \0 "
" \0 \0 \4 \377 \377 \0 " ;
/*
Fontname : - Misc - Fixed - Bold - R - Normal - - 13 - 120 - 75 - 75 - C - 70 - ISO10646 - 1
Copyright : Public domain font . Share and enjoy .
Glyphs : 95 / 1003
BBX Build Mode : 0
*/
const uint8_t u8g2_font_7x13B_tr [ 1083 ] =
" _ \0 \3 \3 \3 \4 \3 \5 \4 \6 \15 \0 \376 \11 \376 \11 \0 \1 } \2 \330 \4 \36 \5 \0 \356 \7 ! \7 J \303 "
" \307 \241 D \42 \10 \235 \332 \207 \204 E \0 # \20 \315 \302 OR$r \230 \244 \34 &I \221 \10 \0 $ \17 N \302 \227 "
" \214 \22 \321 F \223 \250 Dh \42 \0 % \17 N \302 \307 H \22 \251 \4 e \212 \221 JD \64 & \17 N \302 \317 H \242 "
" \247 \221 $ \62 \251 \210 & \1 ' \7 \42 \327 \307 ! \0 ( \14 \314 \302 \227 D$ \21 \251 \211 d \2 ) \15 \314 \302 \207 "
" L$ \23 \251 \210 $ \42 \0 * \15 \66 \306 O(&: \224 d \241 \10 \0 + \13 \66 \306 \227 Pt( \11 E \0 "
" , \10 \244 \276 \317 \212 \22 \0 - \6 \16 \316 \207 \1 . \10 \234 \276 \217 \204 \42 \1 / \14 N \302 \247 \232 P \246 ( \23 "
" \12 \1 \60 \16 N \302 \227 , \24 \21 \361 $ \11 \305 D \0 \61 \13 N \302 \227 l \24 \21 \352 \311 \0 \62 \16 N \302 \17 "
" ED \22 \212 F \62 \241 \320 \0 \63 \15 N \302 \207 Q \246 F \25 \222 $ \24 \0 \64 \15 N \302 \247 lD \221 \220 H "
" \207 \240 \2 \65 \16 N \302 \307 !( \254 \210 \204 B \222 \204 \2 \66 \16 N \302 \17 ED \24 VDL \22 \12 \0 \67 "
" \15 N \302 \207 QM( \23 \312 \204 \62 \0 \70 \16 N \302 \17 E \304 $ \241 \210 \230 $ \24 \0 \71 \16 N \302 \17 E "
" \304 $) \12 I \22 \12 \0 : \14 \304 \276 \217 \204 \42 \207 I( \22 \0 ; \13 \304 \276 \217 \204 \42 \236 L \224 \0 < "
" \10 N \302 \247 LW \35 = \7 & \312 \207 \35 j> \11 N \302 \207 T \67 \35 \1 \77 \16 N \302 \17 ED \22 \212 "
" fr \230 P \4 @ \17 N \302 \17 % \266 R \211 L \252 \61 \11 \5 \0 A \13 N \302 \17 E \304 t \30 q \22 B "
" \14 N \302 GE \304 t \21 \61 ] \0 C \13 N \302 \17 ED \324 \223 \204 \2 D \12 N \302 GE \304 O \27 \0 "
" E \13 N \302 \307 ! \250 X \21 * \32 F \13 N \302 \307 ! \250 X \21 j \4 G \14 N \302 \17 EDT) \61 "
" I \12 H \13 N \302 \207 \210 \323 a \304 I \0 I \11 N \302 \207 I \250 O \6 J \12 N \302 \247 > \222 $ \24 \0 "
" K \17 N \302 \207 lD \221 \220 f$ \211 \22 - \0 L \10 N \302 \207 P \77 \32 M \13 N \302 Gpt \70 \210 "
" x \22 N \15 N \302 \207 \210 T \251 \34 &M$ \1 O \13 N \302 \17 E \304 O \22 \12 \0 P \13 N \302 GE "
" \304 t \21 j \4 Q \14 V \276 \17 E \304 S \205 \62 \241 \12 R \15 N \302 GE \304 t!I \224 h \1 S \16 "
" N \302 \17 ED \224 R \205 $ \11 \5 \0 T \11 N \302 \207 I \250 \237 \0 U \12 N \302 \207 \210 \77 I( \0 V "
" \15 N \302 \207 \210 I \22 \312 D \23 * \1 W \13 N \302 \207 \210 \247 \303 A \64 \14 X \17 N \302 Gp$ \11 \205 "
" h \62 R \212 h \30 Y \14 N \302 \207 \210 $! \321 \204 : \1 Z \12 N \302 \207 QMG \241 \1 [ \10 \314 \302 "
" \207 I \237 \10 \134 \14 N \302 \207 P* \224 *J \205 \2 ] \10 \314 \302 \7 I \237 \14 ^ \11 & \326 \227 \214 \42 \32 "
" \6 _ \7 \26 \276 \307 \241 \0 ` \7 \234 \336 \207 L \1 a \12 \66 \302 \17 Ur \42 I \12 b \13 N \302 \207 P \261 "
" \42 \342 t \1 c \13 \66 \302 \17 EDT \222 P \0 d \12 N \302 \247 \226 \23 'I \1 e \14 \66 \302 \17 Et "
" \30 \212 $ \24 \0 f \14 N \302 \327 H \242 ( \243 \11 \265 \1 g \16 F \272 \317 \22 IB \221 RD \22 \12 \0 h "
" \13 N \302 \207 P \261 \42 \342 I \0 i \12 N \302 \227 P \16 \32 \352 dj \14 ^ \272 \247 :L \250 #IB \1 "
" k \15 N \302 \207 P \23 EB \42 I \224 \4 l \10 N \302 \317 P \77 \31 m \12 \66 \302 \207 Dr \70 \61 \11 n "
" \11 \66 \302 GE \304 \223 \0 o \12 \66 \302 \17 E \304 IB \1 p \13 F \272 GE \304 t \21 * \2 q \12 F "
" \272 \317 \211 IR \324 \0 r \11 \66 \302 GED \324 \10 s \15 \66 \302 \17 E$ \21 KD \22 \12 \0 t \14 F "
" \302 \217 PV \22 j \21 M \0 u \11 \66 \302 \207 \210 'I \1 v \13 \66 \302 \207 \210 IB \242 \211 \0 w \13 \66 "
" \302 \207 \210 \351 p \11 E \0 x \14 \66 \302 \207 \210 $!QD$ \1 y \14 F \272 \207 \210 \223 \244 H \222 P \0 "
" z \12 \66 \302 \207 Q& \222 \11 \15 { \14 \314 \302 OI& \221 ID \262 \1 | \7 J \303 \307 \3 \1 } \15 \314 "
" \302 \307 L$ \221 Id \242 \12 \0 ~ \11 \36 \332 \217 \350 \20 \222 \0 \0 \0 \0 \4 \377 \377 \0 " ;
2022-08-03 00:11:49 +00:00
/////// INIT STATE ///////
static void wifi_scanner_app_init ( SWiFiScannerApp * const app ) {
app - > m_context = Undefined ;
app - > m_totalAccessPoints = 0 ;
app - > m_currentIndexAccessPoint = 0 ;
2022-10-05 18:27:13 +00:00
app - > m_currentAccesspointDescription . m_accessPointName = furi_string_alloc ( ) ;
furi_string_set ( app - > m_currentAccesspointDescription . m_accessPointName , " N/A \n " ) ;
2022-08-03 00:11:49 +00:00
app - > m_currentAccesspointDescription . m_channel = 0 ;
2022-10-05 18:27:13 +00:00
app - > m_currentAccesspointDescription . m_bssid = furi_string_alloc ( ) ;
furi_string_set ( app - > m_currentAccesspointDescription . m_bssid , " N/A \n " ) ;
app - > m_currentAccesspointDescription . m_secType = furi_string_alloc ( ) ;
furi_string_set ( app - > m_currentAccesspointDescription . m_secType , " N/A \n " ) ;
2022-08-03 00:11:49 +00:00
app - > m_currentAccesspointDescription . m_rssi = 0 ;
app - > m_currentAccesspointDescription . m_isHidden = false ;
app - > m_prevAnimationTime = 0 ;
app - > m_animationTime = ANIMATION_TIME ;
app - > m_animtaionCounter = 0 ;
app - > m_wifiModuleInitialized = false ;
# if ENABLE_MODULE_DETECTION
app - > m_wifiModuleAttached = false ;
# else
app - > m_wifiModuleAttached = true ;
# endif
}
int16_t dBmtoPercentage ( int16_t dBm ) {
const int16_t RSSI_MAX = - 50 ; // define maximum strength of signal in dBm
const int16_t RSSI_MIN = - 100 ; // define minimum strength of signal in dBm
int16_t quality ;
if ( dBm < = RSSI_MIN ) {
quality = 0 ;
} else if ( dBm > = RSSI_MAX ) {
quality = 100 ;
} else {
quality = 2 * ( dBm + 100 ) ;
}
return quality ;
}
void DrawSignalStrengthBar ( Canvas * canvas , int rssi , int x , int y , int width , int height ) {
int16_t percents = dBmtoPercentage ( rssi ) ;
2023-05-21 23:54:04 +00:00
//u8g2_DrawHLine(&canvas->fb, x, y, width);
//u8g2_DrawHLine(&canvas->fb, x, y + height, width);
2022-08-03 00:11:49 +00:00
if ( rssi ! = NA & & height > 0 ) {
uint8_t barHeight = floor ( ( height / 100.f ) * percents ) ;
canvas_draw_box ( canvas , x , y + height - barHeight , width , barHeight ) ;
}
}
static void wifi_module_render_callback ( Canvas * const canvas , void * ctx ) {
2023-03-07 21:18:23 +00:00
furi_assert ( ctx ) ;
SWiFiScannerApp * app = ctx ;
furi_mutex_acquire ( app - > mutex , FuriWaitForever ) ;
2022-08-03 00:11:49 +00:00
canvas_clear ( canvas ) ;
{
switch ( app - > m_context ) {
case Undefined : {
canvas_set_font ( canvas , FontPrimary ) ;
const char * strError = " Something wrong " ;
canvas_draw_str (
canvas ,
2023-05-21 23:54:04 +00:00
( 128 / 2 ) - ( canvas_string_width ( canvas , strError ) / 2 ) ,
( 64 / 2 ) /* - (canvas_current_font_height(canvas) / 2)*/ ,
2022-08-03 00:11:49 +00:00
strError ) ;
} break ;
case WaitingForModule :
# if ENABLE_MODULE_DETECTION
furi_assert ( ! app - > m_wifiModuleAttached ) ;
if ( ! app - > m_wifiModuleAttached ) {
canvas_set_font ( canvas , FontSecondary ) ;
const char * strConnectModule = " Attach WiFi scanner module " ;
canvas_draw_str (
canvas ,
2023-05-21 23:54:04 +00:00
( 128 / 2 ) - ( canvas_string_width ( canvas , strConnectModule ) / 2 ) ,
( 64 / 2 ) /* - (canvas_current_font_height(canvas) / 2)*/ ,
2022-08-03 00:11:49 +00:00
strConnectModule ) ;
}
# endif
break ;
case Initializing : {
furi_assert ( ! app - > m_wifiModuleInitialized ) ;
if ( ! app - > m_wifiModuleInitialized ) {
canvas_set_font ( canvas , FontPrimary ) ;
const char * strInitializing = " Initializing... " ;
canvas_draw_str (
canvas ,
2023-05-21 23:54:04 +00:00
( 128 / 2 ) - ( canvas_string_width ( canvas , strInitializing ) / 2 ) ,
( 64 / 2 ) - ( canvas_current_font_height ( canvas ) / 2 ) ,
2022-08-03 00:11:49 +00:00
strInitializing ) ;
}
} break ;
case ScanMode : {
uint8_t offsetY = 0 ;
uint8_t offsetX = 0 ;
2023-05-21 23:54:04 +00:00
canvas_draw_frame ( canvas , 0 , 0 , 128 , 64 ) ;
2022-08-03 00:11:49 +00:00
//canvas_set_font(canvas, FontPrimary);
2023-05-21 23:54:04 +00:00
canvas_set_custom_u8g2_font ( canvas , u8g2_font_7x13B_tr ) ;
uint8_t fontHeight = canvas_current_font_height ( canvas ) ;
2022-08-03 00:11:49 +00:00
offsetX + = 5 ;
offsetY + = fontHeight ;
canvas_draw_str (
canvas ,
offsetX ,
offsetY ,
app - > m_currentAccesspointDescription . m_isHidden ?
" (Hidden SSID) " :
2022-10-05 18:27:13 +00:00
furi_string_get_cstr ( app - > m_currentAccesspointDescription . m_accessPointName ) ) ;
2022-08-03 00:11:49 +00:00
offsetY + = fontHeight ;
canvas_draw_str (
canvas ,
offsetX ,
offsetY ,
2022-10-05 18:27:13 +00:00
furi_string_get_cstr ( app - > m_currentAccesspointDescription . m_bssid ) ) ;
2022-08-03 00:11:49 +00:00
canvas_set_font ( canvas , FontSecondary ) ;
2023-05-21 23:54:04 +00:00
//canvas_set_custom_u8g2_font(canvas, u8g2_font_tinytim_tf);
fontHeight = canvas_current_font_height ( canvas ) ;
2022-08-03 00:11:49 +00:00
offsetY + = fontHeight + 1 ;
char string [ 15 ] ;
2022-08-03 19:09:39 +00:00
snprintf (
string , sizeof ( string ) , " RSSI: %d " , app - > m_currentAccesspointDescription . m_rssi ) ;
2022-08-03 00:11:49 +00:00
canvas_draw_str ( canvas , offsetX , offsetY , string ) ;
offsetY + = fontHeight + 1 ;
2022-08-03 19:09:39 +00:00
snprintf (
string , sizeof ( string ) , " CHNL: %d " , app - > m_currentAccesspointDescription . m_channel ) ;
2022-08-03 00:11:49 +00:00
canvas_draw_str ( canvas , offsetX , offsetY , string ) ;
offsetY + = fontHeight + 1 ;
2022-08-03 19:09:39 +00:00
snprintf (
2022-08-03 00:11:49 +00:00
string ,
2022-08-03 19:09:39 +00:00
sizeof ( string ) ,
2022-08-03 00:11:49 +00:00
" ENCR: %s " ,
2022-10-05 18:27:13 +00:00
furi_string_get_cstr ( app - > m_currentAccesspointDescription . m_secType ) ) ;
2022-08-03 00:11:49 +00:00
canvas_draw_str ( canvas , offsetX , offsetY , string ) ;
offsetY + = fontHeight ;
offsetY - = fontHeight ;
2023-05-21 23:54:04 +00:00
canvas_set_custom_u8g2_font ( canvas , u8g2_font_courB08_tn ) ;
2022-08-03 19:09:39 +00:00
snprintf (
string ,
sizeof ( string ) ,
" %d/%d " ,
app - > m_currentIndexAccessPoint ,
app - > m_totalAccessPoints ) ;
2023-05-21 23:54:04 +00:00
offsetX = 128 - canvas_string_width ( canvas , string ) - 5 ;
2022-08-03 00:11:49 +00:00
canvas_draw_str ( canvas , offsetX , offsetY , string ) ;
canvas_draw_frame (
2023-05-21 23:54:04 +00:00
canvas , offsetX - 6 , offsetY - canvas_current_font_height ( canvas ) - 3 , 128 , 64 ) ;
2022-08-03 00:11:49 +00:00
2023-05-21 23:54:04 +00:00
canvas_set_custom_u8g2_font ( canvas , u8g2_font_open_iconic_arrow_2x_t ) ;
2022-08-03 00:11:49 +00:00
if ( app - > m_currentIndexAccessPoint ! = app - > m_totalAccessPoints ) {
//canvas_draw_triangle(canvas, offsetX - 5 - 20, offsetY + 5, 4, 4, CanvasDirectionBottomToTop);
canvas_draw_str ( canvas , offsetX - 0 - 35 , offsetY + 5 , " \x4C " ) ;
}
if ( app - > m_currentIndexAccessPoint ! = 1 ) {
//canvas_draw_triangle(canvas, offsetX - 6 - 35, offsetY + 5, 4, 4, CanvasDirectionTopToBottom);
canvas_draw_str ( canvas , offsetX - 4 - 20 , offsetY + 5 , " \x4F " ) ;
}
} break ;
case MonitorMode : {
uint8_t offsetY = 0 ;
uint8_t offsetX = 0 ;
2023-05-21 23:54:04 +00:00
canvas_draw_frame ( canvas , 0 , 0 , 128 , 64 ) ;
2022-08-03 00:11:49 +00:00
//canvas_set_font(canvas, FontBigNumbers);
2023-05-21 23:54:04 +00:00
//canvas_set_custom_u8g2_font(canvas, u8g2_font_inb27_mr);
canvas_set_custom_u8g2_font ( canvas , u8g2_font_inb27_mr ) ;
uint8_t fontHeight = canvas_current_font_height ( canvas ) ;
2023-05-22 00:45:17 +00:00
uint8_t fontWidth = canvas_current_font_width ( canvas ) ;
2022-08-03 00:11:49 +00:00
if ( app - > m_currentAccesspointDescription . m_rssi = = NA ) {
2023-05-21 23:54:04 +00:00
offsetX + = floor ( 128 / 2 ) - fontWidth - 10 ;
2022-08-03 00:11:49 +00:00
offsetY + = fontHeight - 5 ;
canvas_draw_str ( canvas , offsetX , offsetY , " N/A " ) ;
} else {
2023-05-21 23:54:04 +00:00
offsetX + = floor ( 128 / 2 ) - 2 * fontWidth ;
2022-08-03 00:11:49 +00:00
offsetY + = fontHeight - 5 ;
char rssi [ 8 ] ;
2022-08-03 19:09:39 +00:00
snprintf ( rssi , sizeof ( rssi ) , " %d " , app - > m_currentAccesspointDescription . m_rssi ) ;
2022-08-03 00:11:49 +00:00
canvas_draw_str ( canvas , offsetX , offsetY , rssi ) ;
}
//canvas_set_font(canvas, FontPrimary);
2023-05-21 23:54:04 +00:00
canvas_set_custom_u8g2_font ( canvas , u8g2_font_7x13B_tr ) ;
fontHeight = canvas_current_font_height ( canvas ) ;
2023-05-22 00:45:17 +00:00
fontWidth = canvas_current_font_width ( canvas ) ;
2022-08-03 00:11:49 +00:00
offsetX = 5 ;
2023-05-21 23:54:04 +00:00
offsetY = 64 - 7 - fontHeight ;
2022-08-03 00:11:49 +00:00
canvas_draw_str (
canvas ,
offsetX ,
offsetY ,
2022-10-05 18:27:13 +00:00
furi_string_get_cstr ( app - > m_currentAccesspointDescription . m_accessPointName ) ) ;
2022-08-03 00:11:49 +00:00
offsetY + = fontHeight + 2 ;
canvas_draw_str (
canvas ,
offsetX ,
offsetY ,
2022-10-05 18:27:13 +00:00
furi_string_get_cstr ( app - > m_currentAccesspointDescription . m_bssid ) ) ;
2022-08-03 00:11:49 +00:00
DrawSignalStrengthBar (
canvas , app - > m_currentAccesspointDescription . m_rssi , 5 , 5 , 12 , 25 ) ;
DrawSignalStrengthBar (
2023-05-21 23:54:04 +00:00
canvas , app - > m_currentAccesspointDescription . m_rssi , 128 - 5 - 12 , 5 , 12 , 25 ) ;
2022-08-03 00:11:49 +00:00
} break ;
case ScanAnimation : {
uint32_t currentTime = furi_get_tick ( ) ;
if ( currentTime - app - > m_prevAnimationTime > app - > m_animationTime ) {
app - > m_prevAnimationTime = currentTime ;
app - > m_animtaionCounter + = 1 ;
app - > m_animtaionCounter = app - > m_animtaionCounter % 3 ;
}
uint8_t offsetX = 10 ;
uint8_t mutliplier = 2 ;
for ( uint8_t i = 0 ; i < 3 ; + + i ) {
canvas_draw_disc (
canvas ,
offsetX + 30 + 25 * i ,
2023-05-21 23:54:04 +00:00
64 / 2 - 7 ,
2022-08-03 00:11:49 +00:00
5 * ( app - > m_animtaionCounter = = i ? mutliplier : 1 ) ) ;
}
2023-05-21 23:54:04 +00:00
canvas_set_custom_u8g2_font ( canvas , u8g2_font_7x13B_tr ) ;
2022-08-03 00:11:49 +00:00
//canvas_set_font(canvas, FontPrimary);
const char * message = " Scanning " ;
canvas_draw_str (
2023-05-21 23:54:04 +00:00
canvas , 128 / 2 - canvas_string_width ( canvas , message ) / 2 , 55 , message ) ;
2022-08-03 00:11:49 +00:00
} break ;
case MonitorAnimation : {
uint32_t currentTime = furi_get_tick ( ) ;
if ( currentTime - app - > m_prevAnimationTime > app - > m_animationTime ) {
app - > m_prevAnimationTime = currentTime ;
app - > m_animtaionCounter + = 1 ;
app - > m_animtaionCounter = app - > m_animtaionCounter % 2 ;
}
uint8_t offsetX = 10 ;
uint8_t mutliplier = 2 ;
canvas_draw_disc (
canvas ,
offsetX + 30 ,
2023-05-21 23:54:04 +00:00
64 / 2 - 7 ,
2022-08-03 00:11:49 +00:00
5 * ( app - > m_animtaionCounter = = 0 ? mutliplier : 1 ) ) ;
canvas_draw_disc (
canvas ,
offsetX + 55 ,
2023-05-21 23:54:04 +00:00
64 / 2 - 7 ,
2022-08-03 00:11:49 +00:00
5 * ( app - > m_animtaionCounter = = 1 ? mutliplier : 1 ) ) ;
canvas_draw_disc (
canvas ,
offsetX + 80 ,
2023-05-21 23:54:04 +00:00
64 / 2 - 7 ,
2022-08-03 00:11:49 +00:00
5 * ( app - > m_animtaionCounter = = 0 ? mutliplier : 1 ) ) ;
2023-05-21 23:54:04 +00:00
canvas_set_custom_u8g2_font ( canvas , u8g2_font_7x13B_tr ) ;
2022-08-03 00:11:49 +00:00
//canvas_set_font(canvas, FontPrimary);
const char * message = " Monitor Mode " ;
canvas_draw_str (
2023-05-21 23:54:04 +00:00
canvas , 128 / 2 - canvas_string_width ( canvas , message ) / 2 , 55 , message ) ;
2022-08-03 00:11:49 +00:00
} break ;
default :
break ;
}
}
2023-03-07 21:18:23 +00:00
furi_mutex_release ( app - > mutex ) ;
2022-08-03 00:11:49 +00:00
}
static void wifi_module_input_callback ( InputEvent * input_event , FuriMessageQueue * event_queue ) {
furi_assert ( event_queue ) ;
SPluginEvent event = { . m_type = EventTypeKey , . m_input = * input_event } ;
furi_message_queue_put ( event_queue , & event , FuriWaitForever ) ;
}
static void uart_on_irq_cb ( UartIrqEvent ev , uint8_t data , void * context ) {
furi_assert ( context ) ;
SWiFiScannerApp * app = context ;
WIFI_APP_LOG_I ( " uart_echo_on_irq_cb " ) ;
if ( ev = = UartIrqEventRXNE ) {
WIFI_APP_LOG_I ( " ev == UartIrqEventRXNE " ) ;
2022-10-07 18:05:16 +00:00
furi_stream_buffer_send ( app - > m_rx_stream , & data , 1 , 0 ) ;
2022-08-03 00:11:49 +00:00
furi_thread_flags_set ( furi_thread_get_id ( app - > m_worker_thread ) , WorkerEventRx ) ;
}
}
static int32_t uart_worker ( void * context ) {
furi_assert ( context ) ;
2023-03-07 21:18:23 +00:00
SWiFiScannerApp * app = context ;
furi_mutex_acquire ( app - > mutex , FuriWaitForever ) ;
2022-08-03 00:11:49 +00:00
if ( app = = NULL ) {
return 1 ;
}
2022-10-07 18:05:16 +00:00
FuriStreamBuffer * rx_stream = app - > m_rx_stream ;
2022-08-03 00:11:49 +00:00
2023-03-07 21:18:23 +00:00
furi_mutex_release ( app - > mutex ) ;
2022-08-03 00:11:49 +00:00
while ( true ) {
uint32_t events = furi_thread_flags_wait (
WorkerEventStop | WorkerEventRx , FuriFlagWaitAny , FuriWaitForever ) ;
furi_check ( ( events & FuriFlagError ) = = 0 ) ;
if ( events & WorkerEventStop ) break ;
if ( events & WorkerEventRx ) {
size_t length = 0 ;
2022-10-05 18:27:13 +00:00
FuriString * receivedString ;
receivedString = furi_string_alloc ( ) ;
2022-08-03 00:11:49 +00:00
do {
uint8_t data [ 64 ] ;
2022-10-07 18:05:16 +00:00
length = furi_stream_buffer_receive ( rx_stream , data , 64 , 25 ) ;
2022-08-03 00:11:49 +00:00
if ( length > 0 ) {
WIFI_APP_LOG_I ( " Received Data - length: %i " , length ) ;
for ( uint16_t i = 0 ; i < length ; i + + ) {
2022-10-05 18:27:13 +00:00
furi_string_push_back ( receivedString , data [ i ] ) ;
2022-08-03 00:11:49 +00:00
}
//notification_message(app->notification, &sequence_set_only_red_255);
}
} while ( length > 0 ) ;
2022-10-05 18:27:13 +00:00
if ( furi_string_size ( receivedString ) > 0 ) {
FuriString * chunk ;
chunk = furi_string_alloc ( ) ;
2022-08-03 00:11:49 +00:00
size_t begin = 0 ;
size_t end = 0 ;
2022-10-05 18:27:13 +00:00
size_t stringSize = furi_string_size ( receivedString ) ;
2022-08-03 00:11:49 +00:00
2022-10-05 18:27:13 +00:00
WIFI_APP_LOG_I ( " Received string: %s " , furi_string_get_cstr ( receivedString ) ) ;
2022-08-03 00:11:49 +00:00
2022-10-05 18:27:13 +00:00
FuriString * chunksArray [ EChunkArrayData_ENUM_MAX ] ;
2022-08-03 00:11:49 +00:00
for ( uint8_t i = 0 ; i < EChunkArrayData_ENUM_MAX ; + + i ) {
2022-10-05 18:27:13 +00:00
chunksArray [ i ] = furi_string_alloc ( ) ;
2022-08-03 00:11:49 +00:00
}
uint8_t index = 0 ;
do {
2022-10-05 18:27:13 +00:00
end = furi_string_search_char ( receivedString , ' + ' , begin ) ;
2022-08-03 00:11:49 +00:00
2022-10-05 18:27:13 +00:00
if ( end = = FURI_STRING_FAILURE ) {
2022-08-03 00:11:49 +00:00
end = stringSize ;
}
WIFI_APP_LOG_I ( " size: %i, begin: %i, end: %i " , stringSize , begin , end ) ;
2022-10-05 18:27:13 +00:00
furi_string_set_strn (
chunk , & furi_string_get_cstr ( receivedString ) [ begin ] , end - begin ) ;
2022-08-03 00:11:49 +00:00
2022-10-05 18:27:13 +00:00
WIFI_APP_LOG_I ( " String chunk: %s " , furi_string_get_cstr ( chunk ) ) ;
2022-08-03 00:11:49 +00:00
2022-10-05 18:27:13 +00:00
furi_string_set ( chunksArray [ index + + ] , chunk ) ;
2022-08-03 00:11:49 +00:00
begin = end + 1 ;
} while ( end < stringSize ) ;
2022-10-05 18:27:13 +00:00
furi_string_free ( chunk ) ;
2022-08-03 00:11:49 +00:00
2023-03-07 21:18:23 +00:00
app = context ;
furi_mutex_acquire ( app - > mutex , FuriWaitForever ) ;
2022-08-03 00:11:49 +00:00
if ( app = = NULL ) {
return 1 ;
}
if ( ! app - > m_wifiModuleInitialized ) {
2022-10-05 18:27:13 +00:00
if ( furi_string_cmp_str (
2022-08-03 00:11:49 +00:00
chunksArray [ EChunkArrayData_Context ] , MODULE_CONTEXT_INITIALIZATION ) = =
0 ) {
app - > m_wifiModuleInitialized = true ;
app - > m_context = ScanAnimation ;
}
} else {
2022-10-05 18:27:13 +00:00
if ( furi_string_cmp_str (
2022-08-03 00:11:49 +00:00
chunksArray [ EChunkArrayData_Context ] , MODULE_CONTEXT_MONITOR ) = = 0 ) {
app - > m_context = MonitorMode ;
} else if (
2022-10-05 18:27:13 +00:00
furi_string_cmp_str (
2022-08-03 00:11:49 +00:00
chunksArray [ EChunkArrayData_Context ] , MODULE_CONTEXT_SCAN ) = = 0 ) {
app - > m_context = ScanMode ;
} else if (
2022-10-05 18:27:13 +00:00
furi_string_cmp_str (
2022-08-03 00:11:49 +00:00
chunksArray [ EChunkArrayData_Context ] , MODULE_CONTEXT_SCAN_ANIMATION ) = =
0 ) {
app - > m_context = ScanAnimation ;
} else if (
2022-10-05 18:27:13 +00:00
furi_string_cmp_str (
2022-08-03 00:11:49 +00:00
chunksArray [ EChunkArrayData_Context ] ,
MODULE_CONTEXT_MONITOR_ANIMATION ) = = 0 ) {
app - > m_context = MonitorAnimation ;
}
if ( app - > m_context = = MonitorMode | | app - > m_context = = ScanMode ) {
2022-10-05 18:27:13 +00:00
furi_string_set (
2022-08-03 00:11:49 +00:00
app - > m_currentAccesspointDescription . m_accessPointName ,
chunksArray [ EChunkArrayData_SSID ] ) ;
2022-10-05 18:27:13 +00:00
furi_string_set (
2022-08-03 00:11:49 +00:00
app - > m_currentAccesspointDescription . m_secType ,
chunksArray [ EChunkArrayData_EncryptionType ] ) ;
app - > m_currentAccesspointDescription . m_rssi =
2022-10-05 18:27:13 +00:00
atoi ( furi_string_get_cstr ( chunksArray [ EChunkArrayData_RSSI ] ) ) ;
furi_string_set (
2022-08-03 00:11:49 +00:00
app - > m_currentAccesspointDescription . m_bssid ,
chunksArray [ EChunkArrayData_BSSID ] ) ;
app - > m_currentAccesspointDescription . m_channel =
2022-10-05 18:27:13 +00:00
atoi ( furi_string_get_cstr ( chunksArray [ EChunkArrayData_Channel ] ) ) ;
2022-08-03 00:11:49 +00:00
app - > m_currentAccesspointDescription . m_isHidden =
2022-10-05 18:27:13 +00:00
atoi ( furi_string_get_cstr ( chunksArray [ EChunkArrayData_IsHidden ] ) ) ;
2022-08-03 00:11:49 +00:00
2022-10-05 18:27:13 +00:00
app - > m_currentIndexAccessPoint = atoi (
furi_string_get_cstr ( chunksArray [ EChunkArrayData_CurrentAPIndex ] ) ) ;
2022-08-03 00:11:49 +00:00
app - > m_totalAccessPoints =
2022-10-05 18:27:13 +00:00
atoi ( furi_string_get_cstr ( chunksArray [ EChunkArrayData_TotalAps ] ) ) ;
2022-08-03 00:11:49 +00:00
}
}
2023-03-07 21:18:23 +00:00
furi_mutex_release ( app - > mutex ) ;
2022-08-03 00:11:49 +00:00
// Clear string array
for ( index = 0 ; index < EChunkArrayData_ENUM_MAX ; + + index ) {
2022-10-05 18:27:13 +00:00
furi_string_free ( chunksArray [ index ] ) ;
2022-08-03 00:11:49 +00:00
}
}
2022-10-05 18:27:13 +00:00
furi_string_free ( receivedString ) ;
2022-08-03 00:11:49 +00:00
}
}
return 0 ;
}
typedef enum ESerialCommand {
ESerialCommand_Next ,
ESerialCommand_Previous ,
ESerialCommand_Scan ,
ESerialCommand_MonitorMode ,
ESerialCommand_Restart
} ESerialCommand ;
void send_serial_command ( ESerialCommand command ) {
# if !DISABLE_CONSOLE
return ;
# endif
uint8_t data [ 1 ] = { 0 } ;
switch ( command ) {
case ESerialCommand_Next :
data [ 0 ] = MODULE_CONTROL_COMMAND_NEXT ;
break ;
case ESerialCommand_Previous :
data [ 0 ] = MODULE_CONTROL_COMMAND_PREVIOUS ;
break ;
case ESerialCommand_Scan :
data [ 0 ] = MODULE_CONTROL_COMMAND_SCAN ;
break ;
case ESerialCommand_MonitorMode :
data [ 0 ] = MODULE_CONTROL_COMMAND_MONITOR ;
break ;
case ESerialCommand_Restart :
data [ 0 ] = MODULE_CONTROL_COMMAND_RESTART ;
break ;
default :
return ;
} ;
furi_hal_uart_tx ( FuriHalUartIdUSART1 , data , 1 ) ;
}
int32_t wifi_scanner_app ( void * p ) {
UNUSED ( p ) ;
WIFI_APP_LOG_I ( " Init " ) ;
// FuriTimer* timer = furi_timer_alloc(blink_test_update, FuriTimerTypePeriodic, event_queue);
// furi_timer_start(timer, furi_kernel_get_tick_frequency());
FuriMessageQueue * event_queue = furi_message_queue_alloc ( 8 , sizeof ( SPluginEvent ) ) ;
SWiFiScannerApp * app = malloc ( sizeof ( SWiFiScannerApp ) ) ;
wifi_scanner_app_init ( app ) ;
# if ENABLE_MODULE_DETECTION
furi_hal_gpio_init (
& gpio_ext_pc0 ,
GpioModeInput ,
GpioPullUp ,
GpioSpeedLow ) ; // Connect to the Flipper's ground just to be sure
//furi_hal_gpio_add_int_callback(pinD0, input_isr_d0, this);
app - > m_context = WaitingForModule ;
# else
app - > m_context = Initializing ;
# if ENABLE_MODULE_POWER
2023-03-15 21:07:37 +00:00
uint8_t attempts = 0 ;
while ( ! furi_hal_power_is_otg_enabled ( ) & & attempts + + < 5 ) {
furi_hal_power_enable_otg ( ) ;
furi_delay_ms ( 10 ) ;
}
furi_delay_ms ( 200 ) ;
2022-08-03 00:11:49 +00:00
# endif // ENABLE_MODULE_POWER
# endif // ENABLE_MODULE_DETECTION
2023-03-07 21:18:23 +00:00
app - > mutex = furi_mutex_alloc ( FuriMutexTypeNormal ) ;
if ( ! app - > mutex ) {
2022-08-03 00:11:49 +00:00
WIFI_APP_LOG_E ( " cannot create mutex \r \n " ) ;
free ( app ) ;
return 255 ;
}
WIFI_APP_LOG_I ( " Mutex created " ) ;
2023-03-07 21:18:23 +00:00
app - > m_notification = furi_record_open ( RECORD_NOTIFICATION ) ;
2022-08-03 00:11:49 +00:00
ViewPort * view_port = view_port_alloc ( ) ;
2023-03-07 21:18:23 +00:00
view_port_draw_callback_set ( view_port , wifi_module_render_callback , app ) ;
2022-08-03 00:11:49 +00:00
view_port_input_callback_set ( view_port , wifi_module_input_callback , event_queue ) ;
// Open GUI and register view_port
2023-06-02 14:03:03 +00:00
app - > m_gui = furi_record_open ( RECORD_GUI ) ;
gui_add_view_port ( app - > m_gui , view_port , GuiLayerFullscreen ) ;
2022-08-03 00:11:49 +00:00
//notification_message(app->notification, &sequence_set_only_blue_255);
2022-11-23 23:23:40 +00:00
app - > m_rx_stream = furi_stream_buffer_alloc ( 1 * 1024 , 1 ) ;
2022-08-03 00:11:49 +00:00
app - > m_worker_thread = furi_thread_alloc ( ) ;
furi_thread_set_name ( app - > m_worker_thread , " WiFiModuleUARTWorker " ) ;
furi_thread_set_stack_size ( app - > m_worker_thread , 1024 ) ;
2023-03-07 21:18:23 +00:00
furi_thread_set_context ( app - > m_worker_thread , app ) ;
2022-08-03 00:11:49 +00:00
furi_thread_set_callback ( app - > m_worker_thread , uart_worker ) ;
furi_thread_start ( app - > m_worker_thread ) ;
WIFI_APP_LOG_I ( " UART thread allocated " ) ;
2022-11-23 23:23:40 +00:00
// Enable uart listener
# if DISABLE_CONSOLE
furi_hal_console_disable ( ) ;
# endif
furi_hal_uart_set_br ( FuriHalUartIdUSART1 , FLIPPERZERO_SERIAL_BAUD ) ;
furi_hal_uart_set_irq_cb ( FuriHalUartIdUSART1 , uart_on_irq_cb , app ) ;
WIFI_APP_LOG_I ( " UART Listener created " ) ;
2022-08-03 00:11:49 +00:00
// Because we assume that module was on before we launched the app. We need to ensure that module will be in initial state on app start
send_serial_command ( ESerialCommand_Restart ) ;
SPluginEvent event ;
for ( bool processing = true ; processing ; ) {
FuriStatus event_status = furi_message_queue_get ( event_queue , & event , 100 ) ;
2023-03-07 21:18:23 +00:00
furi_mutex_acquire ( app - > mutex , FuriWaitForever ) ;
2022-08-03 00:11:49 +00:00
# if ENABLE_MODULE_DETECTION
if ( ! app - > m_wifiModuleAttached ) {
if ( furi_hal_gpio_read ( & gpio_ext_pc0 ) = = false ) {
WIFI_APP_LOG_I ( " Module Attached " ) ;
app - > m_wifiModuleAttached = true ;
app - > m_context = Initializing ;
# if ENABLE_MODULE_POWER
2023-03-15 21:07:37 +00:00
uint8_t attempts2 = 0 ;
while ( ! furi_hal_power_is_otg_enabled ( ) & & attempts2 + + < 3 ) {
furi_hal_power_enable_otg ( ) ;
furi_delay_ms ( 10 ) ;
}
2022-08-03 00:11:49 +00:00
# endif
}
}
# endif // ENABLE_MODULE_DETECTION
if ( event_status = = FuriStatusOk ) {
if ( event . m_type = = EventTypeKey ) {
if ( app - > m_wifiModuleInitialized ) {
if ( app - > m_context = = ScanMode ) {
switch ( event . m_input . key ) {
case InputKeyUp :
case InputKeyLeft :
if ( event . m_input . type = = InputTypeShort ) {
WIFI_APP_LOG_I ( " Previous " ) ;
send_serial_command ( ESerialCommand_Previous ) ;
} else if ( event . m_input . type = = InputTypeRepeat ) {
WIFI_APP_LOG_I ( " Previous Repeat " ) ;
send_serial_command ( ESerialCommand_Previous ) ;
}
break ;
case InputKeyDown :
case InputKeyRight :
if ( event . m_input . type = = InputTypeShort ) {
WIFI_APP_LOG_I ( " Next " ) ;
send_serial_command ( ESerialCommand_Next ) ;
} else if ( event . m_input . type = = InputTypeRepeat ) {
WIFI_APP_LOG_I ( " Next Repeat " ) ;
send_serial_command ( ESerialCommand_Next ) ;
}
break ;
default :
break ;
}
}
switch ( event . m_input . key ) {
case InputKeyOk :
if ( event . m_input . type = = InputTypeShort ) {
if ( app - > m_context = = ScanMode ) {
WIFI_APP_LOG_I ( " Monitor Mode " ) ;
send_serial_command ( ESerialCommand_MonitorMode ) ;
}
} else if ( event . m_input . type = = InputTypeLong ) {
WIFI_APP_LOG_I ( " Scan " ) ;
send_serial_command ( ESerialCommand_Scan ) ;
}
break ;
case InputKeyBack :
if ( event . m_input . type = = InputTypeShort ) {
switch ( app - > m_context ) {
case MonitorMode :
send_serial_command ( ESerialCommand_Scan ) ;
break ;
case ScanMode :
processing = false ;
break ;
default :
break ;
}
} else if ( event . m_input . type = = InputTypeLong ) {
processing = false ;
}
break ;
default :
break ;
}
} else {
if ( event . m_input . key = = InputKeyBack ) {
if ( event . m_input . type = = InputTypeShort | |
event . m_input . type = = InputTypeLong ) {
processing = false ;
}
}
}
}
}
# if ENABLE_MODULE_DETECTION
if ( app - > m_wifiModuleAttached & & furi_hal_gpio_read ( & gpio_ext_pc0 ) = = true ) {
WIFI_APP_LOG_D ( " Module Disconnected - Exit " ) ;
processing = false ;
app - > m_wifiModuleAttached = false ;
app - > m_wifiModuleInitialized = false ;
}
# endif
view_port_update ( view_port ) ;
2023-03-07 21:18:23 +00:00
furi_mutex_release ( app - > mutex ) ;
2022-08-03 00:11:49 +00:00
}
WIFI_APP_LOG_I ( " Start exit app " ) ;
furi_thread_flags_set ( furi_thread_get_id ( app - > m_worker_thread ) , WorkerEventStop ) ;
furi_thread_join ( app - > m_worker_thread ) ;
furi_thread_free ( app - > m_worker_thread ) ;
WIFI_APP_LOG_I ( " Thread Deleted " ) ;
2022-10-26 18:54:23 +00:00
// Reset GPIO pins to default state
furi_hal_gpio_init ( & gpio_ext_pc0 , GpioModeAnalog , GpioPullNo , GpioSpeedLow ) ;
2022-08-03 00:11:49 +00:00
# if DISABLE_CONSOLE
furi_hal_console_enable ( ) ;
# endif
view_port_enabled_set ( view_port , false ) ;
2023-06-02 14:03:03 +00:00
gui_remove_view_port ( app - > m_gui , view_port ) ;
2022-08-03 00:11:49 +00:00
// Close gui record
2022-08-13 14:58:46 +00:00
furi_record_close ( RECORD_GUI ) ;
2023-03-07 21:18:23 +00:00
furi_record_close ( RECORD_NOTIFICATION ) ;
2022-08-03 00:11:49 +00:00
app - > m_gui = NULL ;
view_port_free ( view_port ) ;
furi_message_queue_free ( event_queue ) ;
2022-10-07 18:05:16 +00:00
furi_stream_buffer_free ( app - > m_rx_stream ) ;
2022-08-03 00:11:49 +00:00
2023-03-07 21:18:23 +00:00
furi_mutex_free ( app - > mutex ) ;
2022-08-03 00:11:49 +00:00
// Free rest
free ( app ) ;
WIFI_APP_LOG_I ( " App freed " ) ;
# if ENABLE_MODULE_POWER
2023-03-15 21:07:37 +00:00
if ( furi_hal_power_is_otg_enabled ( ) ) {
furi_hal_power_disable_otg ( ) ;
}
2022-08-03 00:11:49 +00:00
# endif
return 0 ;
}